1
|
|
|
<?php |
2
|
|
|
// $Id: brokenlink.php 11158 2013-03-05 14:10:36Z zyspec $ |
3
|
|
|
// ------------------------------------------------------------------------ // |
4
|
|
|
// XOOPS - PHP Content Management System // |
5
|
|
|
// Copyright (c) 2000 XOOPS.org // |
6
|
|
|
// <http://www.xoops.org/> // |
7
|
|
|
// ------------------------------------------------------------------------- // |
8
|
|
|
// This program is free software; you can redistribute it and/or modify // |
9
|
|
|
// it under the terms of the GNU General Public License as published by // |
10
|
|
|
// the Free Software Foundation; either version 2 of the License, or // |
11
|
|
|
// (at your option) any later version. // |
12
|
|
|
// // |
13
|
|
|
// You may not change or alter any portion of this comment or credits // |
14
|
|
|
// of supporting developers from this source code or any supporting // |
15
|
|
|
// source code which is considered copyrighted (c) material of the // |
16
|
|
|
// original comment or credit authors. // |
17
|
|
|
// // |
18
|
|
|
// This program is distributed in the hope that it will be useful, // |
19
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
20
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
21
|
|
|
// GNU General Public License for more details. // |
22
|
|
|
// // |
23
|
|
|
// You should have received a copy of the GNU General Public License // |
24
|
|
|
// along with this program; if not, write to the Free Software // |
25
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
26
|
|
|
// ------------------------------------------------------------------------ // |
27
|
|
|
include __DIR__ . '/header.php'; |
28
|
|
|
$myts = MyTextSanitizer::getInstance(); // MyTextSanitizer object |
29
|
|
|
|
30
|
|
|
include_once __DIR__ . '/class/utility.php'; |
31
|
|
|
//xoops_load('utility', $xoopsModule->getVar('dirname')); |
32
|
|
|
$lid = MylinksUtility::mylinks_cleanVars($_REQUEST, 'lid', 0, 'int', array('min' => 0)); |
33
|
|
|
if (!empty($_POST['submit'])) { |
34
|
|
|
$sender = empty($xoopsUser) ? 0 : $xoopsUser->getVar('uid'); |
35
|
|
|
$ip = getenv('REMOTE_ADDR'); |
36
|
|
|
if ($sender != 0) { |
37
|
|
|
// Check if REG user is trying to report twice. |
38
|
|
|
$result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mylinks_broken') . " WHERE lid='{$lid}' AND sender='{$sender}'"); |
39
|
|
|
list($count) = $xoopsDB->fetchRow($result); |
40
|
|
|
if ($count > 0) { |
41
|
|
|
redirect_header('index.php', 2, _MD_MYLINKS_ALREADYREPORTED); |
42
|
|
|
exit(); |
43
|
|
|
} |
44
|
|
|
} else { |
45
|
|
|
// Check if the sender is trying to report it more than once. |
46
|
|
|
$result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mylinks_broken') . " WHERE lid='{$lid}' AND ip='{$ip}'"); |
47
|
|
|
list($count) = $xoopsDB->fetchRow($result); |
48
|
|
|
if ($count > 0) { |
49
|
|
|
redirect_header('index.php', 2, _MD_MYLINKS_ALREADYREPORTED); |
50
|
|
|
exit(); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
$newid = $xoopsDB->genId($xoopsDB->prefix('mylinks_broken') . '_reportid_seq'); |
54
|
|
|
$sql = sprintf("INSERT INTO %s (reportid, lid, sender, ip) VALUES (%u, %u, %u, '%s')", $xoopsDB->prefix('mylinks_broken'), $newid, $lid, $sender, $ip); |
55
|
|
|
$xoopsDB->query($sql) or exit(); |
56
|
|
|
$tags = array(); |
57
|
|
|
$tags['BROKENREPORTS_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/index.php?op=listBrokenLinks'; |
58
|
|
|
$notificationHandler = xoops_getHandler('notification'); |
59
|
|
|
$notificationHandler->triggerEvent('global', 0, 'link_broken', $tags); |
60
|
|
|
redirect_header('index.php', 2, _MD_MYLINKS_THANKSFORINFO); |
61
|
|
|
exit(); |
62
|
|
|
} else { |
63
|
|
|
$xoopsOption['template_main'] = 'mylinks_brokenlink.tpl'; |
64
|
|
|
include XOOPS_ROOT_PATH . '/header.php'; |
65
|
|
|
//wanikoo |
66
|
|
|
$xoTheme->addStylesheet('browse.php?' . mylinksGetStylePath('mylinks.css', 'include')); |
67
|
|
|
$xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js'); |
68
|
|
|
$xoTheme->addScript('browse.php?' . mylinksGetStylePath('mylinks.js', 'include')); |
69
|
|
|
// |
70
|
|
|
$xoopsTpl->assign('lang_reportbroken', _MD_MYLINKS_REPORTBROKEN); |
71
|
|
|
$xoopsTpl->assign('link_id', $lid); |
72
|
|
|
$xoopsTpl->assign('lang_thanksforhelp', _MD_MYLINKS_THANKSFORHELP); |
73
|
|
|
$xoopsTpl->assign('lang_forsecurity', _MD_MYLINKS_FORSECURITY); |
74
|
|
|
$xoopsTpl->assign('lang_cancel', _CANCEL); |
75
|
|
|
|
76
|
|
|
//wanikoo theme changer |
77
|
|
|
$xoopsTpl->assign('lang_themechanger', _MD_MYLINKS_THEMECHANGER); |
78
|
|
|
|
79
|
|
|
$mymylinkstheme_options = ''; |
80
|
|
View Code Duplication |
foreach ($GLOBALS['mylinks_allowed_theme'] as $mymylinkstheme) { |
|
|
|
|
81
|
|
|
$thisSelected = ($mymylinkstheme == $GLOBALS['mylinks_theme']) ? " selected='selected'" : ''; |
82
|
|
|
$mymylinkstheme_options .= "<option value='{$mymylinkstheme}'{$thisSelected}>{$mymylinkstheme}</option>"; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
$mylinkstheme_select = "<select name='mylinks_theme_select' onchange='submit();' size='1'>{$mymylinkstheme_options}</select>"; |
86
|
|
|
$xoopsTpl->assign('mylinksthemeoption', $mylinkstheme_select); |
87
|
|
|
|
88
|
|
|
//wanikoo search |
89
|
|
View Code Duplication |
if (file_exists(XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/search.php')) { |
|
|
|
|
90
|
|
|
include_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/search.php'; |
91
|
|
|
} else { |
92
|
|
|
include_once XOOPS_ROOT_PATH . '/language/english/search.php'; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
$xoopsTpl->assign('lang_all', _SR_ALL); |
96
|
|
|
$xoopsTpl->assign('lang_any', _SR_ANY); |
97
|
|
|
$xoopsTpl->assign('lang_exact', _SR_EXACT); |
98
|
|
|
$xoopsTpl->assign('lang_search', _SR_SEARCH); |
99
|
|
|
$xoopsTpl->assign('module_id', $xoopsModule->getVar('mid')); |
100
|
|
|
//category head |
101
|
|
|
$catarray = array(); |
102
|
|
|
if ($mylinks_show_letters) { |
103
|
|
|
$catarray['letters'] = ml_wfd_letters(); |
104
|
|
|
} |
105
|
|
|
if ($mylinks_show_toolbar) { |
106
|
|
|
$catarray['toolbar'] = ml_wfd_toolbar(); |
107
|
|
|
} |
108
|
|
|
$xoopsTpl->assign('catarray', $catarray); |
109
|
|
|
|
110
|
|
|
include_once XOOPSMYLINKPATH . '/footer.php'; |
111
|
|
|
} |
112
|
|
|
|
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.