These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * TDMDownload |
||
4 | * |
||
5 | * You may not change or alter any portion of this comment or credits |
||
6 | * of supporting developers from this source code or any supporting source code |
||
7 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
8 | * This program is distributed in the hope that it will be useful, |
||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
11 | * |
||
12 | * @copyright Gregory Mage (Aka Mage) |
||
13 | * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||
14 | * @author Gregory Mage (Aka Mage) |
||
15 | */ |
||
16 | |||
17 | include_once 'header.php'; |
||
18 | // template d'affichage |
||
19 | $xoopsOption['template_main'] = 'tdmdownloads_brokenfile.html'; |
||
20 | include_once XOOPS_ROOT_PATH.'/header.php'; |
||
21 | $xoTheme->addStylesheet( XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/css/styles.css', null ); |
||
22 | //On recupere la valeur de l'argument op dans l'URL$ |
||
23 | $op = TDMDownloads_CleanVars($_REQUEST, 'op', 'liste', 'string'); |
||
24 | $lid = TDMDownloads_CleanVars($_REQUEST, 'lid', 0, 'int'); |
||
25 | |||
26 | //redirection si pas de permission de vote |
||
27 | if ($perm_vote == false) { |
||
28 | redirect_header('index.php', 2, _NOPERM); |
||
29 | exit(); |
||
30 | } |
||
31 | |||
32 | $view_downloads = $downloads_Handler->get($lid); |
||
33 | // redirection si le t�l�chargement n'existe pas ou n'est pas activ� |
||
34 | View Code Duplication | if (count($view_downloads) == 0 || $view_downloads->getVar('status') == 0) { |
|
0 ignored issues
–
show
|
|||
35 | redirect_header('index.php', 3, _MD_TDMDOWNLOADS_SINGLEFILE_NONEXISTENT); |
||
36 | exit(); |
||
37 | } |
||
38 | |||
39 | //redirection si pas de permission (cat) |
||
40 | $categories = TDMDownloads_MygetItemIds('tdmdownloads_view', 'TDMDownloads'); |
||
41 | View Code Duplication | if (!in_array($view_downloads->getVar('cid'), $categories)) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
42 | redirect_header(XOOPS_URL, 2, _NOPERM); |
||
43 | exit(); |
||
44 | } |
||
45 | |||
46 | //Les valeurs de op qui vont permettre d'aller dans les differentes parties de la page |
||
47 | switch ($op) { |
||
48 | // Vue liste |
||
49 | View Code Duplication | case "liste": |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
50 | //tableau des cat�gories |
||
51 | $criteria = new CriteriaCompo(); |
||
52 | $criteria->setSort('cat_weight ASC, cat_title'); |
||
53 | $criteria->setOrder('ASC'); |
||
54 | $criteria->add(new Criteria('cat_cid', '(' . implode(',', $categories) . ')','IN')); |
||
55 | $downloadscat_arr = $downloadscat_Handler->getall($criteria); |
||
56 | $mytree = new XoopsObjectTree($downloadscat_arr, 'cat_cid', 'cat_pid'); |
||
57 | //navigation |
||
58 | $navigation = TDMDownloads_PathTreeUrl($mytree, $view_downloads->getVar('cid'), $downloadscat_arr, 'cat_title', $prefix = ' <img src="images/deco/arrow.gif" alt="arrow" /> ', true, 'ASC', true); |
||
59 | $navigation .= ' <img src="images/deco/arrow.gif" alt="arrow" /> <a title="' . $view_downloads->getVar('title') . '" href="singlefile.php?lid=' . $view_downloads->getVar('lid') . '">' . $view_downloads->getVar('title') . '</a>'; |
||
60 | $navigation .= ' <img src="images/deco/arrow.gif" alt="arrow" /> ' . _MD_TDMDOWNLOADS_SINGLEFILE_REPORTBROKEN; |
||
61 | $xoopsTpl->assign('navigation', $navigation); |
||
62 | // r�f�rencement |
||
63 | // titre de la page |
||
64 | $pagetitle = _MD_TDMDOWNLOADS_SINGLEFILE_REPORTBROKEN . ' - ' . $view_downloads->getVar('title') . ' - '; |
||
65 | $pagetitle .= TDMDownloads_PathTreeUrl($mytree, $view_downloads->getVar('cid'), $downloadscat_arr, 'cat_title', $prefix = ' - ', false, 'DESC', true); |
||
66 | $xoopsTpl->assign('xoops_pagetitle', $pagetitle); |
||
67 | //description |
||
68 | $xoTheme->addMeta( 'meta', 'description', strip_tags(_MD_TDMDOWNLOADS_SINGLEFILE_REPORTBROKEN . ' (' . $view_downloads->getVar('title') . ')')); |
||
69 | //Affichage du formulaire de fichier bris�*/ |
||
70 | $obj =& $downloadsbroken_Handler->create(); |
||
71 | $form = $obj->getForm($lid); |
||
72 | $xoopsTpl->assign('themeForm', $form->render()); |
||
73 | break; |
||
74 | // save |
||
75 | case "save": |
||
76 | $obj =& $downloadsbroken_Handler->create(); |
||
77 | if (empty($xoopsUser)) { |
||
78 | $ratinguser = 0; |
||
79 | } else { |
||
80 | $ratinguser = $xoopsUser->getVar('uid'); |
||
81 | } |
||
82 | if ($ratinguser != 0) { |
||
83 | // si c'est un membre on v�rifie qu'il n'envoie pas 2 fois un rapport |
||
84 | $criteria = new CriteriaCompo(); |
||
85 | $criteria->add(new Criteria('lid', $lid)); |
||
86 | $downloadsbroken_arr = $downloadsbroken_Handler->getall($criteria); |
||
87 | View Code Duplication | foreach (array_keys($downloadsbroken_arr) as $i) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
88 | if ($downloadsbroken_arr[$i]->getVar('sender') == $ratinguser) { |
||
89 | redirect_header('singlefile.php?lid=' . $lid, 2, _MD_TDMDOWNLOADS_BROKENFILE_ALREADYREPORTED); |
||
90 | exit(); |
||
91 | } |
||
92 | } |
||
93 | } else { |
||
94 | // si c'est un utilisateur anonyme on v�rifie qu'il n'envoie pas 2 fois un rapport |
||
95 | $criteria = new CriteriaCompo(); |
||
96 | $criteria->add(new Criteria('lid', $lid)); |
||
97 | $criteria->add(new Criteria('sender', 0)); |
||
98 | $criteria->add(new Criteria('ip', getenv("REMOTE_ADDR"))); |
||
99 | if ($downloadsbroken_Handler->getCount($criteria) >= 1) { |
||
100 | redirect_header('singlefile.php?lid=' . $lid, 2, _MD_TDMDOWNLOADS_BROKENFILE_ALREADYREPORTED); |
||
101 | exit(); |
||
102 | } |
||
103 | } |
||
104 | $erreur = false; |
||
105 | $message_erreur = ''; |
||
106 | // Test avant la validation |
||
107 | xoops_load("captcha"); |
||
108 | $xoopsCaptcha = XoopsCaptcha::getInstance(); |
||
109 | if ( !$xoopsCaptcha->verify() ) { |
||
110 | $message_erreur.=$xoopsCaptcha->getMessage().'<br>'; |
||
111 | $erreur=true; |
||
112 | } |
||
113 | $obj->setVar('lid', $lid); |
||
114 | $obj->setVar('sender', $ratinguser); |
||
115 | $obj->setVar('ip', getenv("REMOTE_ADDR")); |
||
116 | if ($erreur==true) { |
||
0 ignored issues
–
show
|
|||
117 | $xoopsTpl->assign('message_erreur', $message_erreur); |
||
118 | } else { |
||
119 | if ($downloadsbroken_Handler->insert($obj)) { |
||
120 | $tags = array(); |
||
121 | $tags['BROKENREPORTS_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/broken.php'; |
||
122 | $notification_handler =& xoops_gethandler('notification'); |
||
123 | $notification_handler->triggerEvent('global', 0, 'file_broken', $tags); |
||
124 | redirect_header('singlefile.php?lid=' . $lid, 2, _MD_TDMDOWNLOADS_BROKENFILE_THANKSFORINFO); |
||
125 | } |
||
126 | echo $obj->getHtmlErrors(); |
||
127 | } |
||
128 | //Affichage du formulaire de notation des t�l�chargements |
||
129 | $form =& $obj->getForm($lid); |
||
130 | $xoopsTpl->assign('themeForm', $form->render()); |
||
131 | |||
132 | break; |
||
133 | } |
||
134 | include XOOPS_ROOT_PATH.'/footer.php'; |
||
135 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.