1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* MyLinks category.php |
4
|
|
|
* |
5
|
|
|
* Xoops mylinks - a multicategory links module |
6
|
|
|
* |
7
|
|
|
* @copyright :: {@link http://xoops.org/ XOOPS Project} |
8
|
|
|
* @license :: {@link http://www.gnu.org/licenses/gpl-2.0.html GNU Public License} |
9
|
|
|
* @package :: mylinks |
10
|
|
|
* @subpackage:: admin |
11
|
|
|
* @author :: Thatware - http://thatware.org/ |
12
|
|
|
*/ |
13
|
|
|
// ------------------------------------------------------------------------- // |
14
|
|
|
// XOOPS - PHP Content Management System // |
15
|
|
|
// <http://www.xoops.org/> // |
16
|
|
|
// ------------------------------------------------------------------------- // |
17
|
|
|
// Based on: // |
18
|
|
|
// myPHPNUKE Web Portal System - http://myphpnuke.com/ // |
19
|
|
|
// PHP-NUKE Web Portal System - http://phpnuke.org/ // |
20
|
|
|
// Thatware - http://thatware.org/ // |
21
|
|
|
// ------------------------------------------------------------------------- // |
22
|
|
|
// This program is free software; you can redistribute it and/or modify // |
23
|
|
|
// it under the terms of the GNU General Public License as published by // |
24
|
|
|
// the Free Software Foundation; either version 2 of the License, or // |
25
|
|
|
// (at your option) any later version. // |
26
|
|
|
// // |
27
|
|
|
// This program is distributed in the hope that it will be useful, // |
28
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
29
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
30
|
|
|
// GNU General Public License for more details. // |
31
|
|
|
// // |
32
|
|
|
// You should have received a copy of the GNU General Public License // |
33
|
|
|
// along with this program; if not, write to the Free Software // |
34
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
35
|
|
|
// ------------------------------------------------------------------------- // |
36
|
|
|
|
37
|
|
|
include __DIR__ . '/admin_header.php'; |
38
|
|
|
xoops_loadLanguage('main', $xoopsModule->getVar('dirname')); |
39
|
|
|
include_once dirname(__DIR__) . '/class/utility.php'; |
40
|
|
|
//xoops_load('utility', $xoopsModule->getVar('dirname')); |
41
|
|
|
|
42
|
|
|
include dirname(__DIR__) . '/include/functions.php'; |
43
|
|
|
include_once XOOPS_ROOT_PATH . '/class/tree.php'; |
44
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
45
|
|
|
include_once XOOPS_ROOT_PATH . '/include/xoopscodes.php'; |
46
|
|
|
//include_once XOOPS_ROOT_PATH . '/class/module.errorhandler.php'; |
47
|
|
|
|
48
|
|
|
$myts = MyTextSanitizer::getInstance(); |
49
|
|
|
//$eh = new ErrorHandler; |
50
|
|
|
|
51
|
|
|
$mylinksCatHandler = xoops_getModuleHandler('category', $xoopsModule->getVar('dirname')); |
52
|
|
|
$catObjs = $mylinksCatHandler->getAll(); |
53
|
|
|
$myCatTree = new XoopsObjectTree($catObjs, 'cid', 'pid'); |
54
|
|
|
|
55
|
|
|
function listNewLinks() |
56
|
|
|
{ |
57
|
|
|
global $xoopsDB, $myts, $myCatTree, $xoopsModule; |
58
|
|
|
// List links waiting for validation |
59
|
|
|
$linkimg_array = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/images/shots/'); |
60
|
|
|
$result = $xoopsDB->query('SELECT lid, cid, title, url, logourl, submitter FROM ' . $xoopsDB->prefix('mylinks_links') . " WHERE status='0' ORDER BY date DESC"); |
61
|
|
|
$numrows = $xoopsDB->getRowsNum($result); |
62
|
|
|
xoops_cp_header(); |
63
|
|
|
|
64
|
|
|
$indexAdmin = new ModuleAdmin(); |
65
|
|
|
echo $indexAdmin->addNavigation(basename(__FILE__) . '?op=listNewLinks'); |
66
|
|
|
|
67
|
|
|
//@TODO: change to use XoopsForm |
68
|
|
|
echo "<table class='outer' style='width: 100%; border-width: 0px; margin: 1px;'>\n" . " <tr><th colspan='7'>" . sprintf(_MD_MYLINKS_LINKSWAITING, $numrows) . "<br></th></tr>\n"; |
69
|
|
|
if ($numrows > 0) { |
70
|
|
|
while (list($lid, $cid, $title, $url, $logourl, $submitterid) = $xoopsDB->fetchRow($result)) { |
71
|
|
|
$result2 = $xoopsDB->query('SELECT description FROM ' . $xoopsDB->prefix('mylinks_text') . " WHERE lid='{$lid}'"); |
72
|
|
|
list($description) = $xoopsDB->fetchRow($result2); |
73
|
|
|
$title = $myts->htmlSpecialChars($title); |
74
|
|
|
$url = $myts->htmlSpecialChars($url); |
75
|
|
|
// $url = urldecode($url); |
76
|
|
|
// $logourl = $myts->htmlSpecialChars($logourl); |
77
|
|
|
// $logourl = urldecode($logourl); |
78
|
|
|
$description = $myts->htmlSpecialChars($description); |
79
|
|
|
$submitter = XoopsUser::getUnameFromId($submitterid); |
80
|
|
|
echo " <tr><td>\n" . " <form action='main.php' method='post'>\n" . " <table style='width: 80%;'>\n" . " <tr><td style='text-align: right; nowrap='nowrap'>" . _MD_MYLINKS_SUBMITTER . "</td>\n" . " <td><a href=\"" . XOOPS_URL . '/userinfo.php?uid=' |
81
|
|
|
. $submitterid . "\">$submitter</a></td>\n" . " </tr>\n" . " <tr><td style='text-align: right;' nowrap='nowrap'>" . _MD_MYLINKS_SITETITLE . "</td>\n" . " <td><input type='text' name='title' size='50' maxlength='100' value='{$title}'></td>\n" |
82
|
|
|
. " </tr>\n" . " <tr><td style='text-align: right;' nowrap='nowrap'>" . _MD_MYLINKS_SITEURL . "</td>\n" . " <td><input type='text' name='url' size='50' maxlength='250' value='{$url}'> \n" . " [ <a href='" |
83
|
|
|
. preg_replace('/javascript:/si', 'java script:', $url) . "' target='_blank'>" . _MD_MYLINKS_VISIT . "</a> ]\n" . " </td>\n" . " </tr>\n" . " <tr><td style='text-align: right;' nowrap'nowrap'>" . _MD_MYLINKS_CATEGORYC . "</td>\n" |
84
|
|
|
. ' <td>' . $myCatTree->makeSelBox('cid', 'title', '- ', $cid) . "</td>\n" . " </tr>\n" . " <tr><td style='text-align: right; vertical-align: top;' nowrap='nowrap'>" . _MD_MYLINKS_DESCRIPTIONC . "</td>\n" |
85
|
|
|
. " <td><textarea name='description' cols='60' rows='5'>{$description}</textarea></td>\n" . " </tr>\n" . " <tr><td style='text-align: right; nowrap='nowrap'>" . _MD_MYLINKS_SHOTIMAGE . "</td>\n" |
86
|
|
|
. " <td><select size='1' name='logourl'><option value=' '>------</option>"; |
87
|
|
|
foreach ($linkimg_array as $image) { |
88
|
|
|
echo "<option value='{$image}'>{$image}</option>"; |
89
|
|
|
} |
90
|
|
|
$shotdir = '<strong>' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/images/shots/</strong>'; |
91
|
|
|
echo "</select></td>\n" . " </tr>\n" . ' <tr><td></td><td>' . sprintf(_MD_MYLINKS_SHOTMUST, $shotdir) . "</td></tr>\n" . " </table>\n" . " <br><input type='hidden' name='op' value='approve'>\n" . " <input type='hidden' name='lid' value='{$lid}'>\n" |
92
|
|
|
. " <input type='submit' value='" . _MD_MYLINKS_APPROVE . "'>\n" . " </form>\n"; |
93
|
|
|
echo " <form action='main.php?op=delNewLink&lid={$lid}' method='post'><input type='submit' value='" . _DELETE . "'></form>\n" . " <br><br>\n" . " </td></tr>\n"; |
94
|
|
|
} |
95
|
|
|
} else { |
96
|
|
|
echo " <tr><td colspan='7' class='odd bold italic'>" . _MD_MYLINKS_NOSUBMITTED . "</td></tr>\n"; |
97
|
|
|
} |
98
|
|
|
echo "</table>\n"; |
99
|
|
|
|
100
|
|
|
include __DIR__ . '/admin_footer.php'; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
function linksConfigMenu() |
104
|
|
|
{ |
105
|
|
|
global $xoopsDB, $myts, $myCatTree, $xoopsModule; |
106
|
|
|
|
107
|
|
|
$mylinksCatHandler = xoops_getModuleHandler('category', $xoopsModule->getVar('dirname')); |
108
|
|
|
$catCount = $mylinksCatHandler->getCount(); |
109
|
|
|
$linkimg_array = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/images/shots/'); |
110
|
|
|
|
111
|
|
|
xoops_cp_header(); |
112
|
|
|
$indexAdmin = new ModuleAdmin(); |
113
|
|
|
echo $indexAdmin->addNavigation(basename(__FILE__) . '?op=linksConfigMenu'); |
114
|
|
|
|
115
|
|
|
// echo "<h4>" . _MD_MYLINKS_WEBLINKSCONF . "</h4>\n"; |
116
|
|
|
|
117
|
|
|
// If there is a category, display add a New Link table |
118
|
|
|
//@TODO: change to use XoopsForm |
119
|
|
|
if ($catCount) { |
120
|
|
|
echo "<table class='outer' style='width: 100%; border-width: 0px; margin: 1px;'>\n" . " <tr><th style='font-size: larger;'>" . _MD_MYLINKS_ADDNEWLINK . "</th></tr>\n" . " <tr class='odd'><td style='padding: 0 10em;'>\n" . " <form method='post' action='main.php'>\n" |
121
|
|
|
. " <table style='width: 80%;'>\n" . " <tr>\n" . " <td style='text-align: right;'>" . _MD_MYLINKS_SITETITLE . "</td>\n" . " <td><input type='text' name='title' size='50' maxlength='100'></td>\n" . " </tr>\n" . " <tr>\n" |
122
|
|
|
. " <td style='text-align: right;' nowrap='nowrap'>" . _MD_MYLINKS_SITEURL . "</td>\n" . " <td><input type='text' name='url' size='50' maxlength='250' value='http://'></td>\n" . " </tr>\n" . " <tr>\n" |
123
|
|
|
. " <td style='text-align: right;' nowrap='nowrap'>" . _MD_MYLINKS_CATEGORYC . "</td>\n" . " <td>\n" . ' ' . $myCatTree->makeSelBox('cid', 'title') . "\n" . " </td>\n" . " </tr>\n" . " <tr>\n" |
124
|
|
|
. " <td style='text-align: right; vertical-align: top;' nowrap='nowrap'>" . _MD_MYLINKS_DESCRIPTIONC . "</td>\n" . ' <td>'; |
125
|
|
|
xoopsCodeTarea('descarea', 60, 8); |
126
|
|
|
xoopsSmilies('descarea'); |
127
|
|
|
echo " </td>\n" . " </tr>\n" . " <tr>\n" . " <td style='text-align: right; nowrap='nowrap'>" . _MD_MYLINKS_SHOTIMAGE . "</td>\n" . " <td><select size='1' name='logourl'><option value=' '>------</option>"; |
128
|
|
|
foreach ($linkimg_array as $image) { |
129
|
|
|
echo "<option value='{$image}'>{$image}</option>"; |
130
|
|
|
} |
131
|
|
|
echo "</select></td>\n" . " </tr>\n"; |
132
|
|
|
$shotdir = '<strong>' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/images/shots/</strong>'; |
133
|
|
|
echo ' <tr><td></td><td>' . sprintf(_MD_MYLINKS_SHOTMUST, $shotdir) . "</td></tr>\n" . " </table><br>\n" . " <div style='text-align: center;'>\n" . " <input type='hidden' name='op' value='addLink'>\n" . " <input type='submit' class='button' value='" . _ADD |
134
|
|
|
. "'>\n" . " </div>\n" . " </form>\n" . " </td></tr>\n" . "</table>\n" . "<br>\n"; |
135
|
|
|
|
136
|
|
|
// Modify Link |
137
|
|
|
$result2 = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mylinks_links') . ''); |
138
|
|
|
list($numLinks) = $xoopsDB->fetchRow($result2); |
139
|
|
|
if ($numLinks) { |
140
|
|
|
echo "<table class='outer' style='width: 100%; border-width: 0px; margin: 1px;'>\n" . " <tr><th style='font-size: larger;'>" . _MD_MYLINKS_MODLINK . "</th></tr>\n" . " <tr class='odd'><td style='text-align: center;'>\n" . " <form method='get' action='main.php'>\n" . ' ' |
141
|
|
|
. _MD_MYLINKS_LINKID . "\n" . " <input type='text' name='lid' size='12' maxlength='11'>\n" . " <input type='hidden' name='fct' value='mylinks'>\n" . " <input type='hidden' name='op' value='modLink'><br><br>\n" . " <input type='submit' value='" |
142
|
|
|
. _MD_MYLINKS_MODIFY . "'>\n" . " </form>\n" . " </td></tr>\n" . '</table>'; |
143
|
|
|
} |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
// Add a New Main Category |
147
|
|
|
echo "<table class='outer' style='width: 100%; border-width: 0px; margin: 1px;'>\n" . " <tr><th style='font-size: larger;'>" . _MD_MYLINKS_ADDMAIN . "</th></tr>\n" . " <tr class='odd'><td style='text-align: center;'>\n" . " <form method='post' action='main.php'>\n" . ' ' |
148
|
|
|
. _MD_MYLINKS_TITLEC . "\n" . " <input type='text' name='title' size='30' maxlength='50'><br>\n" . ' ' . _MD_MYLINKS_IMGURL . "<br>\n" . " <input type='text' name='imgurl' size='100' maxlength='150' value='http://'><br><br>\n" |
149
|
|
|
. " <input type='hidden' name='cid' value='0'>\n" . " <input type='hidden' name='op' value='addCat'>\n" . " <input type='submit' value='" . _ADD . "'><br>\n" . " </form>\n" . " </td></tr>\n"; |
150
|
|
|
if (!$catCount) { |
151
|
|
|
echo " <tr><th style='font-size: larger;'>" . _MD_MYLINKS_IMPORTCATHDR . "</th></tr>\n" . " <tr class='even'><td style='text-align: center;'>\n" . " <form method='post' action='main.php'>\n" . ' ' . _MD_MYLINKS_IMPORTCATS . "<br>\n" |
152
|
|
|
. " <input type='hidden' name='op' value='importCats'>\n" . " <input type='hidden' name='ok' value='0'>\n" . " <input style='margin: .5em 0em;' type='submit' value='" . _SUBMIT . "'><br>\n" . " </form>\n" . ' </td></tr>' . "</table>\n" . "<br>\n"; |
153
|
|
|
} |
154
|
|
|
// Add a New Sub-Category |
155
|
|
View Code Duplication |
if ($catCount) { |
|
|
|
|
156
|
|
|
echo "<table class='outer' style='width: 100%; border-width: 0px; margin: 1px;'>\n" . " <tr><th style='font-size: larger;'>" . _MD_MYLINKS_ADDSUB . "</th></tr>\n" . " <tr class='odd'><td style='text-align: center;'>\n" . " <form method='post' action='main.php'>\n" . ' ' |
157
|
|
|
. _MD_MYLINKS_TITLEC . "\n" . " <input type='text' name='title' size='30' maxlength='50'> " . _MD_MYLINKS_IN . " \n" . ' ' . $myCatTree->makeSelBox('pid', 'title') . "\n" . " <input type='hidden' name='op' value='addCat'><br><br>\n" |
158
|
|
|
. " <input type='submit' value='" . _ADD . "'><br>\n" . " </form>\n" . " </td></tr>\n" . "</table>\n" . '<br>'; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
// Modify Category Table Display |
162
|
|
View Code Duplication |
if ($catCount) { |
|
|
|
|
163
|
|
|
echo "<table class='outer' style='width: 100%; border-width: 0px; margin: 1px;'>\n" . " <tr><th style='font-size: larger;'>" . _MD_MYLINKS_MODCAT . "</th></tr>\n" . " <tr class='odd'><td style='text-align: center;'>\n" . " <form method='get' action='main.php'>\n" |
164
|
|
|
// ." <h4>" . _MD_MYLINKS_MODCAT . "</h4><br>\n" |
165
|
|
|
. ' ' . _MD_MYLINKS_CATEGORYC . "\n" . ' ' . $myCatTree->makeSelBox('cid', 'title') . "\n" . " <br><br>\n" . " <input type='hidden' name='op' value='modCat'>\n" . " <input type='submit' value='" . _MD_MYLINKS_MODIFY . "'>\n" . " </form>\n" . " </td></tr>\n" |
166
|
|
|
. "</table>\n" . "<br>\n"; |
167
|
|
|
} |
168
|
|
|
include __DIR__ . '/admin_footer.php'; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
function modLink() |
172
|
|
|
{ |
173
|
|
|
global $xoopsDB, $myts, $myCatTree, $xoopsModule; |
174
|
|
|
|
175
|
|
|
$linkimg_array = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/images/shots/'); |
176
|
|
|
$lid = MylinksUtility::mylinks_cleanVars($_GET, 'lid', 0, 'int', array('min' => 0)); |
|
|
|
|
177
|
|
|
$bknrptid = MylinksUtility::mylinks_cleanVars($_GET, 'bknrptid', 0, 'int', array('min' => 0)); |
|
|
|
|
178
|
|
|
|
179
|
|
|
xoops_cp_header(); |
180
|
|
|
|
181
|
|
|
$result = $xoopsDB->query('SELECT cid, title, url, logourl FROM ' . $xoopsDB->prefix('mylinks_links') . " WHERE lid={$lid}"); |
182
|
|
|
if (!$result) { |
183
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_NORECORDFOUND); |
|
|
|
|
184
|
|
|
exit(); |
185
|
|
|
} |
186
|
|
|
list($cid, $title, $url, $logourl) = $xoopsDB->fetchRow($result); |
187
|
|
|
|
188
|
|
|
$title = $myts->htmlSpecialChars($myts->stripSlashesGPC($title)); |
189
|
|
|
$url = $myts->htmlSpecialChars($myts->stripSlashesGPC($url)); |
190
|
|
|
$logourl = $myts->htmlSpecialChars($myts->stripSlashesGPC($logourl)); |
191
|
|
|
//$url = urldecode($url); |
192
|
|
|
//$logourl = urldecode($logourl); |
193
|
|
|
$result2 = $xoopsDB->query('SELECT description FROM ' . $xoopsDB->prefix('mylinks_text') . " WHERE lid={$lid}"); |
194
|
|
|
list($description) = $xoopsDB->fetchRow($result2); |
195
|
|
|
$GLOBALS['description'] = $myts->htmlSpecialChars($myts->stripSlashesGPC($description)); |
196
|
|
|
|
197
|
|
|
echo '<h4>' . _MD_MYLINKS_WEBLINKSCONF . '</h4>' . "<table class='outer' style='width: 100%; border-width: 0px; margin: 1px;'>" . " <tr><th colspan='2'>" . _MD_MYLINKS_MODLINK . "</th></tr>\n" . " <tr class='odd'>\n" . " <td>\n" |
198
|
|
|
. " <form method='post' action='main.php' style='display: inline;'>\n" . " <table>\n" . ' <tr><td>' . _MD_MYLINKS_LINKID . "</td><td style='font-weight: bold;'>{$lid}</td></tr>\n" . ' <tr><td>' . _MD_MYLINKS_SITETITLE |
199
|
|
|
. "</td><td><input type='text' name='title' value='{$title}' size='50' maxlength='100'></td></tr>\n" . ' <tr><td>' . _MD_MYLINKS_SITEURL . "</td><td><input type='text' name='url' value='{$url}' size='50' maxlength='250'></td></tr>\n" |
200
|
|
|
. " <tr><td style='vertical-align: top;'>" . _MD_MYLINKS_DESCRIPTIONC . '</td><td>'; |
201
|
|
|
xoopsCodeTarea('description', 60, 8); |
202
|
|
|
xoopsSmilies('description'); |
203
|
|
|
echo "</td></tr>\n" . ' <tr><td>' . _MD_MYLINKS_CATEGORYC . '</td><td>' . '' . $myCatTree->makeSelBox('cid', 'title', '- ', $cid) . '' . " </td></tr>\n" . ' <tr><td>' . _MD_MYLINKS_SHOTIMAGE . '</td><td>' . "<select size='1' name='logourl'>" |
204
|
|
|
. "<option value=' '>------</option>"; |
205
|
|
|
foreach ($linkimg_array as $image) { |
206
|
|
|
$opt_selected = ($image == $logourl) ? " selected='selected'" : ''; |
207
|
|
|
echo "<option value='{$image}'{$opt_selected}>{$image}</option>"; |
208
|
|
|
} |
209
|
|
|
echo '</select>' . "</td></tr>\n"; |
210
|
|
|
|
211
|
|
|
$shotdir = '<strong>' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/images/shots/</strong>'; |
212
|
|
|
echo ' <tr><td> </td><td>' . sprintf(_MD_MYLINKS_SHOTMUST, $shotdir) . "</td></tr>\n" . ' </table>' . " <br><br><input type='hidden' name='lid' value='{$lid}'>\n" . " <input type='hidden' name='bknrptid' value='{$bknrptid}'>\n" |
213
|
|
|
. " <input type='hidden' name='op' value='modLinkS'>\n" . " <input type='submit' value='" . _MD_MYLINKS_MODIFY . "'>" . " </form>\n" |
214
|
|
|
. " <form action='main.php?op=delLink&lid={$lid}' method='post' style='margin-left: 1em; display: inline;'><input type='submit' value='" . _DELETE . "'></form>\n" |
215
|
|
|
. " <form action='main.php?op=linksConfigMenu' method='post' style='margin-left: 1em; display: inline;'><input type='submit' value='" . _CANCEL . "'></form>\n" . ' <hr>'; |
216
|
|
|
|
217
|
|
|
$result5 = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mylinks_votedata') . " WHERE lid='{$lid}'"); |
218
|
|
|
list($totalvotes) = $xoopsDB->fetchRow($result5); |
219
|
|
|
echo " <table style='width: 100%;'>\n" . " <tr><td colspan='7' style='font-weight: bold;'>" . sprintf(_MD_MYLINKS_TOTALVOTES, $totalvotes) . "<br><br></td></tr>\n"; |
220
|
|
|
// Show Registered Users Votes |
221
|
|
|
$result5 = $xoopsDB->query('SELECT ratingid, ratinguser, rating, ratinghostname, ratingtimestamp FROM ' . $xoopsDB->prefix('mylinks_votedata') . " WHERE lid='{$lid}' AND ratinguser >0 ORDER BY ratingtimestamp DESC"); |
222
|
|
|
$votes = $xoopsDB->getRowsNum($result5); |
223
|
|
|
echo " <tr><td colspan='7' style='font-weight: bold;'><br><br>" . sprintf(_MD_MYLINKS_USERTOTALVOTES, $votes) . "<br><br></td></tr>\n"; |
224
|
|
|
echo " <tr>\n" . ' <th>' . _MD_MYLINKS_USER . " </th>\n" . ' <th>' . _MD_MYLINKS_IP . " </th>\n" . ' <th>' . _MD_MYLINKS_RATING . " </th>\n" . ' <th>' . _MD_MYLINKS_USERAVG . " </th>\n" . ' <th>' . _MD_MYLINKS_TOTALRATE . " </th>\n" |
225
|
|
|
. ' <th>' . _MD_MYLINKS_DATE . " </th>\n" . ' <th>' . _DELETE . "</td>\n" . " </tr>\n"; |
226
|
|
|
if (0 == $votes) { |
227
|
|
|
echo " <tr><td style='text-align: center;' colspan='7'>" . _MD_MYLINKS_NOREGVOTES . "<br></td></tr>\n"; |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
$x = 0; |
231
|
|
|
$colorswitch = '#DDDDDD'; |
232
|
|
|
|
233
|
|
|
while (list($ratingid, $ratinguser, $rating, $ratinghostname, $ratingtimestamp) = $xoopsDB->fetchRow($result5)) { |
234
|
|
|
// $ratingtimestamp = formatTimestamp($ratingtimestamp); |
235
|
|
|
//Individual user information |
236
|
|
|
//v3.11 changed to let SQL do calculations instead of PHP |
237
|
|
|
$result2 = $xoopsDB->query('SELECT COUNT(), FORMAT(AVG(rating),2) FROM ' . $xoopsDB->prefix('mylinks_votedata') . " WHERE ratinguser = '$ratinguser'"); |
238
|
|
|
list($uservotes, $useravgrating) = $xoopsDB->fetchRow($result2); |
239
|
|
|
// $useravgrating = ($rating2) ? sprintf("%01.2f", ($useravgrating / $uservotes)) : 0; |
240
|
|
|
/* |
241
|
|
|
$result2=$xoopsDB->query("SELECT rating FROM ".$xoopsDB->prefix("mylinks_votedata")." WHERE ratinguser = '$ratinguser'"); |
242
|
|
|
$uservotes = $xoopsDB->getRowsNum($result2); |
243
|
|
|
$useravgrating = 0; |
244
|
|
|
while ( list($rating2) = $xoopsDB->fetchRow($result2) ) { |
245
|
|
|
$useravgrating = $useravgrating + $rating2; |
246
|
|
|
} |
247
|
|
|
$useravgrating = sprintf("%01.2f", ($useravgrating / $uservotes)); |
248
|
|
|
*/ |
249
|
|
|
$ratingusername = XoopsUser::getUnameFromId($ratinguser); |
250
|
|
|
echo " <tr>\n" . " <td style='background-color: {$colorswitch};'>{$ratingusername}</td>\n" . " <td style='background-color: {$colorswitch};'>{$ratinghostname}</td>\n" . " <td style='background-color: {$colorswitch};'>{$rating}</td>\n" |
251
|
|
|
. " <td style='background-color: {$colorswitch};'>{$useravgrating}</td>\n" . " <td style='background-color: {$colorswitch};'>{$uservotes}</td>\n" . " <td style='background-color: {$colorswitch};'>{$ratingtimestamp}</td>\n" |
252
|
|
|
. " <td style='background-color: {$colorswitch}; text-align: center; font-weight: bold;'>\n" . " <form action='main.php?op=delVote&lid={$lid}&rid={$ratingid}' method='post'><input type='submit' value='X'></form>\n" . " </td>\n" . " </tr>\n"; |
253
|
|
|
$x++; |
254
|
|
|
$colorswitch = ($colorswitch == '#DDDDDD') ? '#FFFFFF' : '#DDDDDD'; |
255
|
|
|
} |
256
|
|
|
// Show Unregistered Users Votes |
257
|
|
|
$result5 = $xoopsDB->query('SELECT ratingid, rating, ratinghostname, ratingtimestamp FROM ' . $xoopsDB->prefix('mylinks_votedata') . " WHERE lid ='{$lid}' AND ratinguser='0' ORDER BY ratingtimestamp DESC"); |
258
|
|
|
$votes = $xoopsDB->getRowsNum($result5); |
259
|
|
|
echo " <tr><td colspan='7' style='font-weight: bold;'><br><br>" . sprintf(_MD_MYLINKS_ANONTOTALVOTES, $votes) . "<br><br></td></tr>\n" . " <tr>\n" . " <th colspan='2'>" . _MD_MYLINKS_IP . " </th>\n" . " <th colspan='3' style='font-weight: bold;'>" |
260
|
|
|
. _MD_MYLINKS_RATING . " </th>\n" . " <th style='font-weight: bold;'>" . _MD_MYLINKS_DATE . " </th>\n" . " <th style='text-align: center; font-weight: bold;'>" . _DELETE . "<br></th>\n" . " </tr>\n"; |
261
|
|
|
if (0 == $votes) { |
262
|
|
|
echo " <tr><td colspan='7' style='text-align: center;'>" . _MD_MYLINKS_NOUNREGVOTES . "<br></td></tr>\n"; |
263
|
|
|
} |
264
|
|
|
$x = 0; |
265
|
|
|
$colorswitch = '#DDDDDD'; |
266
|
|
|
while (list($ratingid, $rating, $ratinghostname, $ratingtimestamp) = $xoopsDB->fetchRow($result5)) { |
267
|
|
|
$formatted_date = formatTimestamp($ratingtimestamp); |
268
|
|
|
echo " <tr>\n" . " <td colspan='2' style='background-color: {$colorswitch}'>{$ratinghostname}</td>\n" . " <td colspan='3' style='background-color: {$colorswitch}'>{$rating}</td>\n" . " <td style='background-color: {$colorswitch}'>{$formatted_date}</td>\n" |
269
|
|
|
. " <td style='background-color: {$colorswitch} text-align: center; font-weight: bold;'>\n" . " <form action='main.php?op=delVote&lid={$lid}&rid={$ratingid}' method='post'><input type='submit' value='X'></form>\n" . ' </td>' . ' </tr>'; |
270
|
|
|
$x++; |
271
|
|
|
$colorswitch = ($colorswitch == '#DDDDDD') ? '#FFFFFF' : '#DDDDDD'; |
272
|
|
|
} |
273
|
|
|
echo " <tr><td colspan='7'> <br></td></tr>\n" . " </table>\n" . " </td>\n" . " </tr>\n" . "</table>\n"; |
274
|
|
|
include __DIR__ . '/admin_footer.php'; |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
function delVote() |
278
|
|
|
{ |
279
|
|
|
global $xoopsDB; |
280
|
|
|
$lid = MylinksUtility::mylinks_cleanVars($_POST, 'lid', 0, 'int', array('min' => 0)); |
|
|
|
|
281
|
|
|
$rid = MylinksUtility::mylinks_cleanVars($_POST, 'rid', 0, 'int', array('min' => 0)); |
|
|
|
|
282
|
|
|
|
283
|
|
|
$sql = sprintf('DELETE FROM %s WHERE ratingid = %u', $xoopsDB->prefix('mylinks_votedata'), $rid); |
284
|
|
|
$result = $xoopsDB->query($sql); |
|
|
|
|
285
|
|
|
if (!result) { |
286
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_NORECORDFOUND); |
|
|
|
|
287
|
|
|
exit(); |
288
|
|
|
} |
289
|
|
|
updaterating($lid); |
|
|
|
|
290
|
|
|
redirect_header('index.php', 2, _MD_MYLINKS_VOTEDELETED); |
291
|
|
|
exit(); |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
function listBrokenLinks() |
295
|
|
|
{ |
296
|
|
|
global $xoopsDB, $xoopsModule, $pathIcon16, $myts; |
297
|
|
|
|
298
|
|
|
$result = $xoopsDB->query('SELECT * FROM ' . $xoopsDB->prefix('mylinks_broken') . ' GROUP BY lid ORDER BY reportid DESC'); |
299
|
|
|
$totalBrokenLinks = $xoopsDB->getRowsNum($result); |
300
|
|
|
xoops_cp_header(); |
301
|
|
|
|
302
|
|
|
$indexAdmin = new ModuleAdmin(); |
303
|
|
|
echo $indexAdmin->addNavigation(basename(__FILE__) . '?op=listBrokenLinks'); |
304
|
|
|
$GLOBALS['xoTheme']->addStylesheet(mylinksGetStylePath('mylinks.css', 'include')); |
305
|
|
|
// echo "<link rel='stylesheet' href='" . $GLOBALS['xoops']->url('browse.php?modules/mylinks/include/mylinks.css') . "' type='text/css'>"; |
306
|
|
|
|
307
|
|
|
echo "<table class='outer' style='width: 100%; border-width: 0px; margin: 1px;'>\n" . ' <tr><th>' . sprintf(_MD_MYLINKS_BROKENREPORTS, $totalBrokenLinks) . "<br></th></tr>\n" . " <tr class='odd'><td>\n"; |
308
|
|
|
|
309
|
|
|
if (0 == $totalBrokenLinks) { |
310
|
|
|
echo " <span class='italic bold'>" . _MD_MYLINKS_NOBROKEN . '</span>'; |
311
|
|
|
} else { |
312
|
|
|
$colorswitch = '#DDDDDD'; |
313
|
|
|
echo "<img src='{$pathIcon16}/on.png'> = " . _MD_MYLINKS_IGNOREDESC . '<br>' . "<img src='{$pathIcon16}/edit.png'> = " . _MD_MYLINKS_EDITDESC . '<br>' . "<img src='{$pathIcon16}/delete.png'> = " . _MD_MYLINKS_DELETEDESC . '<br>' . " <table class='center width100'>\n" |
314
|
|
|
// ." <tr><th colspan='6'>" . _MD_MYLINKS_DELETEDESC . "</th><tr>" |
315
|
|
|
. " <tr>\n" . ' <th>' . _MD_MYLINKS_LINKNAME . "</th>\n" . ' <th>' . _MD_MYLINKS_REPORTER . "</th>\n" . ' <th>' . _MD_MYLINKS_LINKSUBMITTER . "</th>\n" . ' <th>' . _MD_MYLINKS_ACTIONS . "</th>\n" . " </tr>\n"; |
316
|
|
|
|
317
|
|
|
$formToken = $GLOBALS['xoopsSecurity']->getTokenHTML(); |
318
|
|
|
|
319
|
|
|
while (list($reportid, $lid, $sender, $ip) = $xoopsDB->fetchRow($result)) { |
320
|
|
|
$result2 = $xoopsDB->query('SELECT title, url, submitter FROM ' . $xoopsDB->prefix('mylinks_links') . " WHERE lid={$lid}"); |
321
|
|
|
if (0 != $sender) { |
322
|
|
|
$result3 = $xoopsDB->query('SELECT uname, email FROM ' . $xoopsDB->prefix('users') . " WHERE uid={$sender}"); |
323
|
|
|
list($uname, $email) = $xoopsDB->fetchRow($result3); |
324
|
|
|
} |
325
|
|
|
list($title, $url, $ownerid) = $xoopsDB->fetchRow($result2); |
326
|
|
|
$title = $myts->stripSlashesGPC($title); |
327
|
|
|
// $url=urldecode($url); |
328
|
|
|
$result4 = $xoopsDB->query('SELECT uname, email FROM ' . $xoopsDB->prefix('users') . " WHERE uid='{$ownerid}'"); |
329
|
|
|
list($owner, $owneremail) = $xoopsDB->fetchRow($result4); |
330
|
|
|
echo " <tr>\n" . " <td style='background-color: {$colorswitch}'><a href=$url target='_blank'>{$title}</a></td>\n"; |
331
|
|
|
if ($email == '') { |
332
|
|
|
echo " <td style='background-color: {$colorswitch};'>{$sender} ({$ip})"; |
333
|
|
|
} else { |
334
|
|
|
echo " <td style='background-color: {$colorswitch};'><a href='mailto:{$email}'>{$uname}</a> ({$ip})"; |
|
|
|
|
335
|
|
|
} |
336
|
|
|
echo " </td>\n"; |
337
|
|
|
if ('' == $owneremail) { |
338
|
|
|
echo " <td style='background-color: {$colorswitch};'>{$owner}"; |
339
|
|
|
} else { |
340
|
|
|
echo " <td style='background-color: {$colorswitch};'><a href='mailto:{$owneremail}'>{$owner}</a>\n"; |
341
|
|
|
} |
342
|
|
|
echo " <td style='text-align: center; background-color: {$colorswitch};'>\n" |
343
|
|
|
// ." <a href='main.php?op=ignoreBrokenLinks&lid={$lid}'><img src=". $pathIcon16 ."/on.png alt='" . _AM_MYLINKS_IGNORE . "' title='" . _AM_MYLINKS_IGNORE . "'></a>\n" |
344
|
|
|
// ." <a href='main.php?op=modLink&lid={$lid}&bknrptid={$reportid}'><img src=". $pathIcon16 ."/edit.png alt='" . _EDIT . "' title='" . _EDIT . "'></a>\n" |
345
|
|
|
// ." <a href='main.php?op=delBrokenLinks&lid={$lid}'><img src=". $pathIcon16 ."/delete.png alt='" . _DELETE . "' title='" . _DELETE . "'></a>\n" |
346
|
|
|
. " <form class='inline' action='" . $_SERVER['PHP_SELF'] . "' method='post'>\n" . " <input type='hidden' name='op' value='ignoreBrokenLinks'>\n" . " <input type='hidden' name='bknrptid' value='{$reportid}'>\n" . " {$formToken}\n" |
347
|
|
|
. " <input type='button' title='" . _MD_MYLINKS_IGNOREDESC . "' alt='" . _AM_MYLINKS_IGNORE . "' id='image-button-on' onclick='this.form.submit();'></input>\n" . " </form>\n" . " <form class='inline' action='" . $_SERVER['PHP_SELF'] |
348
|
|
|
. "'?op=modLink&lid={$lid} method='get'>\n" . " <input type='hidden' name='op' value='modLink'>\n" . " <input type='hidden' name='bknrptid' value='{$reportid}'>\n" . " <input type='hidden' name='lid' value={$lid}>\n" |
349
|
|
|
. " <input type='button' title='" . _MD_MYLINKS_EDITDESC . "' alt='" . _EDIT . "' id='image-button-edit' onclick='this.form.submit();'></input>\n" . " </form>\n" . " <form class='inline' action='" . $_SERVER['PHP_SELF'] . "' method='post'>\n" |
350
|
|
|
. " <input type='hidden' name='op' value='delBrokenLinks'>\n" . " <input type='hidden' name='lid' value='{$lid}'>\n" . " {$formToken}\n" . " <input type='button' title='" . _MD_MYLINKS_DELETEDESC . "' alt='" . _DELETE |
351
|
|
|
. "' id='image-button-delete' onclick='this.form.submit();'></input>\n" . " </form>\n" . " </td>\n" . " </tr>\n"; |
352
|
|
|
|
353
|
|
|
$colorswitch = ($colorswitch == '#DDDDDD') ? '#FFFFFF' : '#DDDDDD'; |
354
|
|
|
} |
355
|
|
|
echo " </table>\n"; |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
echo '</td></tr></table>'; |
359
|
|
|
include __DIR__ . '/admin_footer.php'; |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
function delBrokenLinks() |
363
|
|
|
{ |
364
|
|
|
global $xoopsDB; |
365
|
|
|
|
366
|
|
|
$lid = MylinksUtility::mylinks_cleanVars($_GET, 'lid', 0, 'int', array('min' => 0)); |
|
|
|
|
367
|
|
|
|
368
|
|
|
$sql = sprintf('DELETE FROM %s WHERE lid = %u', $xoopsDB->prefix('mylinks_broken'), $lid); |
369
|
|
|
$result = $xoopsDB->queryF($sql); |
|
|
|
|
370
|
|
|
if (!result) { |
371
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_NOBROKEN); |
|
|
|
|
372
|
|
|
exit(); |
373
|
|
|
} |
374
|
|
|
|
375
|
|
|
$sql = sprintf('DELETE FROM %s WHERE lid = %u', $xoopsDB->prefix('mylinks_links'), $lid); |
376
|
|
|
$result = $xoopsDB->queryF($sql); |
|
|
|
|
377
|
|
|
if (!result) { |
378
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_NORECORDFOUND); |
|
|
|
|
379
|
|
|
} else { |
380
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_LINKDELETED); |
|
|
|
|
381
|
|
|
} |
382
|
|
|
exit(); |
383
|
|
|
} |
384
|
|
|
|
385
|
|
View Code Duplication |
function ignoreBrokenLinks() |
|
|
|
|
386
|
|
|
{ |
387
|
|
|
global $xoopsDB; |
388
|
|
|
|
389
|
|
|
$bknrptid = MylinksUtility::mylinks_cleanVars($_POST, 'bknrptid', 0, 'int', array('min' => 0)); |
|
|
|
|
390
|
|
|
$sql = sprintf('DELETE FROM %s WHERE reportid = %u', $xoopsDB->prefix('mylinks_broken'), $bknrptid); |
391
|
|
|
$result = $xoopsDB->queryF($sql); |
|
|
|
|
392
|
|
|
if (!result) { |
393
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_NORECORDFOUND); |
|
|
|
|
394
|
|
|
} else { |
395
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_BROKENDELETED); |
|
|
|
|
396
|
|
|
} |
397
|
|
|
exit(); |
398
|
|
|
} |
399
|
|
|
|
400
|
|
|
function listModReq() |
401
|
|
|
{ |
402
|
|
|
global $xoopsDB, $myts, $xoopsModuleConfig, $xoopsModule; |
403
|
|
|
|
404
|
|
|
$result = $xoopsDB->query('SELECT requestid, lid, cid, title, url, logourl, description, modifysubmitter FROM ' . $xoopsDB->prefix('mylinks_mod') . ' ORDER BY requestid'); |
405
|
|
|
$totalModRequests = $xoopsDB->getRowsNum($result); |
406
|
|
|
xoops_cp_header(); |
407
|
|
|
$indexAdmin = new ModuleAdmin(); |
408
|
|
|
echo $indexAdmin->addNavigation(basename(__FILE__) . '?op=listModReq'); |
409
|
|
|
|
410
|
|
|
$mylinksCatHandler = xoops_getModuleHandler('category', $xoopsModule->getVar('dirname')); |
411
|
|
|
|
412
|
|
|
//echo "<h4>" . _MD_MYLINKS_WEBLINKSCONF . "</h4>\n"; |
413
|
|
|
echo "<table class='outer' style='width: 100%; border-weight: 0px; margin: 1px;'>\n" . " <tr class='even'><th>" . sprintf(_MD_MYLINKS_MODREQUESTS, $totalModRequests) . "</th></tr>\n" . " <tr class='odd'>\n" . " <td>\n"; |
414
|
|
|
if ($totalModRequests > 0) { |
415
|
|
|
echo " <table style='width: 95%;'>\n" . " <tr>\n" . " <td>\n"; |
416
|
|
|
$lookup_lid = array(); |
417
|
|
|
while (list($requestid, $lid, $cid, $title, $url, $logourl, $description, $submitterid) = $xoopsDB->fetchRow($result)) { |
418
|
|
|
$catObj = $mylinksCatHandler->get($cid); |
419
|
|
|
$lookup_lid[$requestid] = $lid; |
420
|
|
|
$result2 = $xoopsDB->query('SELECT cid, title, url, logourl, submitter FROM ' . $xoopsDB->prefix('mylinks_links') . " WHERE lid='{$lid}'"); |
421
|
|
|
list($origcid, $origtitle, $origurl, $origlogourl, $ownerid) = $xoopsDB->fetchRow($result2); |
422
|
|
|
$origCatObj = $mylinksCatHandler->get($origcid); |
423
|
|
|
$result2 = $xoopsDB->query('SELECT description FROM ' . $xoopsDB->prefix('mylinks_text') . " WHERE lid='{$lid}'"); |
424
|
|
|
list($origdescription) = $xoopsDB->fetchRow($result2); |
425
|
|
|
$result7 = $xoopsDB->query('SELECT uname, email FROM ' . $xoopsDB->prefix('users') . " WHERE uid='{$submitterid}'"); |
426
|
|
|
$result8 = $xoopsDB->query('SELECT uname, email FROM ' . $xoopsDB->prefix('users') . " WHERE uid='{$ownerid}'"); |
427
|
|
|
$cidtitle = $catObj->getVar('title'); |
428
|
|
|
$cidtitle = $myts->htmlSpecialChars($cidtitle); |
429
|
|
|
$origcidtitle = $origCatObj->getVar('title'); |
430
|
|
|
$origcidtitle = $myts->htmlSpecialChars($origcidtitle); |
431
|
|
|
/* |
432
|
|
|
$cidtitle = $catObj->getPathFromID(); |
433
|
|
|
$origcidtitle = $origCatObj->getPathFromID(); |
434
|
|
|
*/ |
435
|
|
|
list($submitter, $submitteremail) = $xoopsDB->fetchRow($result7); |
436
|
|
|
list($owner, $owneremail) = $xoopsDB->fetchRow($result8); |
437
|
|
|
$title = $myts->htmlSpecialChars($title); |
438
|
|
|
$url = $myts->htmlSpecialChars($url); |
439
|
|
|
//$url = urldecode($url); |
440
|
|
|
|
441
|
|
|
// use original image file to prevent users from changing screen shots file |
442
|
|
|
$origlogourl = $myts->htmlSpecialChars($origlogourl); |
443
|
|
|
$logourl = $origlogourl; |
444
|
|
|
|
445
|
|
|
//$logourl = urldecode($logourl); |
446
|
|
|
$description = $myts->displayTarea($myts->stripSlashesGPC($description), 0); |
447
|
|
|
$origurl = $myts->htmlSpecialChars($origurl); |
448
|
|
|
//$origurl = urldecode($origurl); |
449
|
|
|
//$origlogourl = urldecode($origlogourl); |
450
|
|
|
$origdescription = $myts->displayTarea($myts->stripSlashesGPC($origdescription), 0); |
451
|
|
|
$owner = ('' == $owner) ? 'administration' : $owner; |
452
|
|
|
echo " <table style='border-width: 1px; border-color: black; padding: 5px; margin: auto; text-align: center; width: 800px;'>\n" . " <tr><td>\n" . " <table style='width: 100%; background-color: #DDDDDD'>\n" . " <tr>\n" |
453
|
|
|
. " <td style='vertical-align: top; width: 45%; font-weight: bold;'>" . _MD_MYLINKS_ORIGINAL . "</td>\n" . " <td rowspan='14' style='vertical-align: top; text-align: left; font-size: small;'><br>" . _MD_MYLINKS_DESCRIPTIONC |
454
|
|
|
. "<br>{$origdescription}</td>\n" . " </tr>\n" . " <tr><td style='vertical-align: top; width: 45%; font-size: small;'>" . _MD_MYLINKS_SITETITLE . "{$myts->stripSlashesGPC($origtitle)}</td></tr>\n" |
455
|
|
|
. " <tr><td style='vertical-align: top; width: 45%; font-size: small;'>" . _MD_MYLINKS_SITEURL . "{$origurl}</td></tr>\n" . " <tr><td style='vertical-align= top; width: 45%; font-size: small;'>" . _MD_MYLINKS_CATEGORYC . "{$origcidtitle}</td></tr>\n" |
456
|
|
|
. " <tr><td style='vertical-align: top; width: 45%; font-size: small;'>" . _MD_MYLINKS_SHOTIMAGE . ''; |
457
|
|
View Code Duplication |
if ($xoopsModuleConfig['useshots'] && !empty($origlogourl)) { |
|
|
|
|
458
|
|
|
echo "<img src='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/images/shots/{$origlogourl}' style='width: " . $xoopsModuleConfig['shotwidth'] . ";'>"; |
459
|
|
|
} else { |
460
|
|
|
echo ' '; |
461
|
|
|
} |
462
|
|
|
echo "</td></tr>\n" . " </table>\n" . " </td></tr>\n" . " <tr><td>\n" . " <table style='width: 100%; background-color: #DDDDDD'>\n" . " <tr>\n" . " <td style='vertical-align: top; width: 45%; font-weight: bold;'>" . _MD_MYLINKS_PROPOSED |
463
|
|
|
. "</td>\n" . " <td rowspan='14' style='vertical-align: top; text-align: left; font-size: small;'><br>" . _MD_MYLINKS_DESCRIPTIONC . "<br>{$description}</td>\n" . " </tr>\n" . " <tr><td style='vertical-align: top; width: 45%; font-size: small;'>" |
464
|
|
|
. _MD_MYLINKS_SITETITLE . "{$title}</td></tr>\n" . " <tr><td style='vertical-align: top; width: 45%; font-size: small;'>" . _MD_MYLINKS_SITEURL . "{$url}</td></tr>\n" . " <tr><td style='vertical-align: top; width: 45%; font-size: small;'>" . _MD_MYLINKS_CATEGORYC |
465
|
|
|
. "{$cidtitle}</td></tr>\n" . " <tr><td style='vertical-align: top; width: 45%; font-size: small;'>" . _MD_MYLINKS_SHOTIMAGE . ''; |
466
|
|
View Code Duplication |
if ($xoopsModuleConfig['useshots'] == 1 && !empty($logourl)) { |
|
|
|
|
467
|
|
|
echo "<img src='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/images/shots/{$logourl}' style='width: " . $xoopsModuleConfig['shotwidth'] . ";' alt=''>"; |
468
|
|
|
} else { |
469
|
|
|
echo ' '; |
470
|
|
|
} |
471
|
|
|
echo "</td></tr>\n" . " </table>\n" . " </td></tr>\n" . " </table>\n" . " <table style='text-align: center; width: 800px; margin: auto;'>\n" . " <tr>\n"; |
472
|
|
|
if ('' == $submitteremail) { |
473
|
|
|
echo " <td style='text-align: center; font-weight: bold;'>" . _MD_MYLINKS_SUBMITTER . "{$submitter}</td>\n"; |
474
|
|
|
} else { |
475
|
|
|
echo " <td style='text-align: center; font-size: small;'>" . _MD_MYLINKS_SUBMITTER . "<a href='mailto:{$submitteremail}'>{$submitter}</a></td>\n"; |
476
|
|
|
} |
477
|
|
|
if ('' == $owneremail) { |
478
|
|
|
echo " <td style='text-align: center; font-size: small;'>" . _MD_MYLINKS_OWNER . "{$owner}</td>\n"; |
479
|
|
|
} else { |
480
|
|
|
echo " <td style='text-align: center; font-size: small;'>" . _MD_MYLINKS_OWNER . "<a href='mailto:{$owneremail}'>{$owner}</a></td>\n"; |
481
|
|
|
} |
482
|
|
|
echo " <td style='text-align: center; font-size: small;'>\n" // ." <form style='display: inline; margin-right: 1.5em;' action='main.php?op=changeModReq&requestid={$requestid}' method='get'>\n" |
483
|
|
|
. " <form style='display: inline; margin-right: 1.5em;' action='main.php' method='post'>\n" . " <input type='hidden' name='op' value='changeModReq'>\n" . " <input type='hidden' name='requestid' value='{$requestid}'>\n" |
484
|
|
|
. " <input type='submit' value='" . _MD_MYLINKS_APPROVE . "'>\n" . " </form>\n" // ." <form style='display: inline; margin-right: 1.5em;' action='main.php?op=modLink&lid={$lid}' method='get'>\n" |
485
|
|
|
. " <form style='display: inline; margin-right: 1.5em;' action='main.php' method='get'>\n" . " <input type='hidden' name='op' value='modLink'>\n" . " <input type='hidden' name='lid' value='{$lid}'>\n" . " <input type='submit' value='" . _EDIT |
486
|
|
|
. "'></form>\n" // ." <form style='display: inline;' action='main.php?op=ignoreModReq&requestid={$requestid}' method='post'><input type='submit' value='" . _MD_MYLINKS_IGNORE . "'></form>\n" |
487
|
|
|
. " <form style='display: inline;' action='main.php' method='post'>\n" . " <input type='hidden' name='op' value='ignoreModReq'>\n" . " <input type='hidden' name='requestid' value='{$requestid}'>\n" . " <input type='submit' value='" |
488
|
|
|
. _MD_MYLINKS_IGNORE . "'>\n" . " </form>\n" . " </td>\n" . " </tr>\n" . " </table><br><br>\n"; |
489
|
|
|
} |
490
|
|
|
echo ' </td></tr></table>'; |
491
|
|
|
} else { |
492
|
|
|
echo ' <em>' . _MD_MYLINKS_NOMODREQ . "</em>\n"; |
493
|
|
|
} |
494
|
|
|
echo " </td>\n" . " </tr>\n" . "</table>\n"; |
495
|
|
|
include __DIR__ . '/admin_footer.php'; |
496
|
|
|
} |
497
|
|
|
|
498
|
|
|
function changeModReq() |
499
|
|
|
{ |
500
|
|
|
global $xoopsDB, $myts; |
501
|
|
|
|
502
|
|
|
$requestid = MylinksUtility::mylinks_cleanVars($_POST, 'requestid', 0, 'int', array('min' => 0)); |
|
|
|
|
503
|
|
|
$query = 'SELECT lid, cid, title, url, logourl, description FROM ' . $xoopsDB->prefix('mylinks_mod') . " WHERE requestid='{$requestid}'"; |
504
|
|
|
$result = $xoopsDB->query($query); |
505
|
|
|
while (list($lid, $cid, $title, $url, $logourl, $description) = $xoopsDB->fetchRow($result)) { |
506
|
|
|
$url = addslashes($url); |
507
|
|
|
$logourl = addslashes($logourl); |
508
|
|
|
$title = addslashes($title); |
509
|
|
|
$description = addslashes($description); |
510
|
|
|
|
511
|
|
|
$sql = sprintf("UPDATE %s SET cid = %u, title = '%s', url = '%s', logourl = '%s', status = 1, date = %u WHERE lid = %u", $xoopsDB->prefix('mylinks_links'), $cid, $title, $url, $logourl, time(), $lid); |
512
|
|
|
$result = $xoopsDB->query($sql); |
|
|
|
|
513
|
|
|
if (!result) { |
514
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_DBNOTUPDATED); |
|
|
|
|
515
|
|
|
exit(); |
516
|
|
|
} else { |
517
|
|
|
$sql = sprintf("UPDATE %s SET description = '%s' WHERE lid = %u", $xoopsDB->prefix('mylinks_text'), $description, $lid); |
518
|
|
|
$result = $xoopsDB->query($sql); |
519
|
|
|
if (!$result) { |
520
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_DBNOTUPDATED); |
|
|
|
|
521
|
|
|
exit(); |
522
|
|
|
} else { |
523
|
|
|
$sql = sprintf('DELETE FROM %s WHERE requestid = %u', $xoopsDB->prefix('mylinks_mod'), $requestid); |
524
|
|
|
$xoopsDB->query($sql); |
525
|
|
|
if (!result) { |
526
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_DBNOTUPDATED); |
|
|
|
|
527
|
|
|
exit(); |
528
|
|
|
} |
529
|
|
|
} |
530
|
|
|
} |
531
|
|
|
} |
532
|
|
|
redirect_header('index.php', 2, _MD_MYLINKS_DBUPDATED); |
533
|
|
|
exit(); |
534
|
|
|
} |
535
|
|
|
|
536
|
|
View Code Duplication |
function ignoreModReq() |
|
|
|
|
537
|
|
|
{ |
538
|
|
|
global $xoopsDB; |
539
|
|
|
|
540
|
|
|
$requestid = MylinksUtility::mylinks_cleanVars($_POST, 'requestid', 0, 'int', array('min' => 0)); |
|
|
|
|
541
|
|
|
$sql = sprintf('DELETE FROM %s WHERE requestid = %u', $xoopsDB->prefix('mylinks_mod'), $requestid); |
542
|
|
|
$result = $xoopsDB->query($sql); |
|
|
|
|
543
|
|
|
if (!result) { |
544
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_DBNOTUPDATED); |
|
|
|
|
545
|
|
|
} else { |
546
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_MODREQDELETED); |
|
|
|
|
547
|
|
|
} |
548
|
|
|
exit(); |
549
|
|
|
} |
550
|
|
|
|
551
|
|
|
function modLinkS() |
552
|
|
|
{ |
553
|
|
|
global $xoopsDB, $myts; |
554
|
|
|
|
555
|
|
|
$cid = MylinksUtility::mylinks_cleanVars($_POST, 'cid', 0, 'int', array('min' => 0)); |
|
|
|
|
556
|
|
|
$lid = MylinksUtility::mylinks_cleanVars($_POST, 'lid', 0, 'int', array('min' => 0)); |
|
|
|
|
557
|
|
|
$bknrptid = MylinksUtility::mylinks_cleanVars($_POST, 'bknrptid', 0, 'int', array('min' => 0)); |
|
|
|
|
558
|
|
|
$url = MylinksUtility::mylinks_cleanVars($_POST, 'url', '', 'string'); |
|
|
|
|
559
|
|
|
$logourl = MylinksUtility::mylinks_cleanVars($_POST, 'logourl', '', 'string'); |
|
|
|
|
560
|
|
|
$title = MylinksUtility::mylinks_cleanVars($_POST, 'title', '', 'string'); |
|
|
|
|
561
|
|
|
$description = MylinksUtility::mylinks_cleanVars($_POST, 'description', '', 'string'); |
|
|
|
|
562
|
|
|
/* |
563
|
|
|
$url = $myts->addSlashes($url); |
564
|
|
|
$logourl = $myts->addSlashes($_POST['logourl']); |
565
|
|
|
$title = $myts->addSlashes($_POST['title']); |
566
|
|
|
$description = $myts->addSlashes($_POST['description']); |
567
|
|
|
*/ |
568
|
|
|
$xoopsDB->query('UPDATE ' . $xoopsDB->prefix('mylinks_links') . " SET cid='{$cid}', title='{$title}', url='{$url}', logourl='{$logourl}', status='2', date=" . time() . " WHERE lid='{$lid}'"); |
569
|
|
|
$result = $xoopsDB->query('UPDATE ' . $xoopsDB->prefix('mylinks_text') . " SET description='{$description}' where lid='{$lid}'"); |
|
|
|
|
570
|
|
|
if (!result) { |
571
|
|
|
redirect_header('main.php', 2, _MD_MYLINKS_DBNOTUPDATED); |
572
|
|
|
exit(); |
573
|
|
|
} |
574
|
|
|
if ($bknrptid) { |
575
|
|
|
// edit came after following link from a broken report, so delete broken report too |
576
|
|
|
$sql = sprintf('DELETE FROM %s WHERE reportid = %u', $xoopsDB->prefix('mylinks_broken'), $bknrptid); |
577
|
|
|
$result = $xoopsDB->query($sql); |
578
|
|
|
if (!$result) { |
579
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_DBNOTUPDATED); |
|
|
|
|
580
|
|
|
exit(); |
581
|
|
|
} |
582
|
|
|
} |
583
|
|
|
redirect_header('index.php', 1, _MD_MYLINKS_DBUPDATED); |
584
|
|
|
exit(); |
585
|
|
|
} |
586
|
|
|
|
587
|
|
|
function delLink() |
588
|
|
|
{ |
589
|
|
|
global $xoopsDB, $xoopsModule; |
590
|
|
|
$lid = MylinksUtility::mylinks_cleanVars($_GET, 'lid', 0, 'int', array('min' => 0)); |
|
|
|
|
591
|
|
|
|
592
|
|
|
$dbTables = array('links', 'text', 'votedata', 'broken', 'mod'); |
593
|
|
View Code Duplication |
foreach ($dbTables as $thisTable) { |
|
|
|
|
594
|
|
|
$sql = sprintf('DELETE FROM %s WHERE lid = %u', $xoopsDB->prefix("mylinks_{$thisTable}"), $lid); |
595
|
|
|
$result = $xoopsDB->query($sql); |
596
|
|
|
if (!$result) { |
597
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_DBNOTUPDATED); |
|
|
|
|
598
|
|
|
exit(); |
599
|
|
|
} |
600
|
|
|
} |
601
|
|
|
// delete comments & notifications |
602
|
|
|
xoops_comment_delete($xoopsModule->getVar('mid'), $lid); |
603
|
|
|
xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'link', $lid); |
604
|
|
|
|
605
|
|
|
redirect_header('index.php', 2, _MD_MYLINKS_LINKDELETED); |
606
|
|
|
exit(); |
607
|
|
|
} |
608
|
|
|
|
609
|
|
|
function modCat() |
610
|
|
|
{ |
611
|
|
|
global $xoopsDB, $myts, $xoopsModule; |
612
|
|
|
|
613
|
|
|
$cid = MylinksUtility::mylinks_cleanVars($_GET, 'cid', 0, 'int', array('min' => 0)); |
|
|
|
|
614
|
|
|
xoops_cp_header(); |
615
|
|
|
|
616
|
|
|
echo '<h4>' . _MD_MYLINKS_WEBLINKSCONF . "</h4>\n" . "<table class='outer' style='width: 100%; border-width: 0px; margin: 1px;'>\n" . ' <tr><th>' . _MD_MYLINKS_MODCAT . "<br></th></tr>\n" . " <tr class='odd'>\n" . " <td>\n"; |
617
|
|
|
$mylinksCatHandler = xoops_getModuleHandler('category', $xoopsModule->getVar('dirname')); |
618
|
|
|
$catObj = $mylinksCatHandler->get($cid); |
619
|
|
|
|
620
|
|
|
if (isset($catObj) && is_object($catObj)) { |
621
|
|
|
$criteria = new CriteriaCompo(); |
622
|
|
|
$criteria->add(new Criteria('cid', $cid, '!=')); |
623
|
|
|
$catListObjs = $mylinksCatHandler->getAll($criteria); |
624
|
|
|
$catListTree = new XoopsObjectTree($catListObjs, 'cid', 'pid'); |
625
|
|
|
|
626
|
|
|
$title = $myts->htmlSpecialChars($catObj->getVar('title')); |
627
|
|
|
$imgurl = $myts->htmlSpecialChars($catObj->getVar('imgurl'), 'n'); |
628
|
|
|
$pid = $catObj->getVar('pid'); |
629
|
|
|
echo " <form action='main.php' method='post'>" . _MD_MYLINKS_TITLEC . "\n" . " <input type='text' name='title' value='{$title}' size='51' maxlength='50'>\n" . " <br><br>\n"; |
630
|
|
|
if (0 == $catObj->getVar('pid')) { |
631
|
|
|
echo ' ' . _MD_MYLINKS_IMGURLMAIN . "<br>\n" . " <input type='text' name='imgurl' value='{$imgurl}' size='100' maxlength='150'>\n" . " <br><br>\n"; |
632
|
|
|
} |
633
|
|
|
echo ' ' . _MD_MYLINKS_PARENT . " \n" . ' ' . $catListTree->makeSelBox('pid', 'title', '- ', $pid, true) . "\n" . " <br>\n" . " <input type='hidden' name='cid' value='{$cid}'>\n" . " <input type='hidden' name='op' value='modCatS'><br>\n" |
634
|
|
|
. " <input type='submit' value='" . _MD_MYLINKS_SAVE . "'>\n" . " <input type='button' value='" . _DELETE . "' onclick=\"location='main.php?pid={$pid}&cid={$cid}&op=delCat'\"> \n" . " <input type='button' value='" . _CANCEL |
635
|
|
|
. "' onclick=\"javascript:history.go(-1)\">\n" . " </form>\n"; |
636
|
|
|
} else { |
637
|
|
|
echo ' <tr><td>' . _MD_MYLINKS_CIDERROR . "</td></tr>\n" . " <tr><td><input type='button' value='" . _BACK . "' onclick=\"history.go(-1)\"></td></tr>\n"; |
638
|
|
|
} |
639
|
|
|
echo " </td>\n" . " </tr>\n" . "</table>\n"; |
640
|
|
|
include __DIR__ . '/admin_footer.php'; |
641
|
|
|
} |
642
|
|
|
|
643
|
|
|
function modCatS() |
644
|
|
|
{ |
645
|
|
|
global $xoopsDB, $myts, $xoopsModule; |
646
|
|
|
$cid = MylinksUtility::mylinks_cleanVars($_POST, 'cid', 0, 'int', array('min' => 0)); |
|
|
|
|
647
|
|
|
$imgurl = MylinksUtility::mylinks_cleanVars($_POST, 'imgurl', '', 'string'); |
|
|
|
|
648
|
|
|
$title = MylinksUtility::mylinks_cleanVars($_POST, 'title', '', 'string'); |
|
|
|
|
649
|
|
|
// $title = $myts->addSlashes($title); |
650
|
|
|
|
651
|
|
|
if (empty($title)) { |
652
|
|
|
redirect_header('index.php', 3, _MD_MYLINKS_ERRORTITLE); |
653
|
|
|
} |
654
|
|
|
|
655
|
|
|
// $imgurl = $myts->addSlashes($imgurl); |
656
|
|
|
$updateInfo = array( |
657
|
|
|
'pid' => (int)$_POST['pid'], |
658
|
|
|
// 'title' => $myts->addSlashes($_POST['title']), |
659
|
|
|
'title' => $title, |
660
|
|
|
'imgurl' => $imgurl |
661
|
|
|
); |
662
|
|
|
|
663
|
|
|
$mylinksCatHandler = xoops_getModuleHandler('category', $xoopsModule->getVar('dirname')); |
664
|
|
|
$catObj = $mylinksCatHandler->get($cid); |
665
|
|
|
|
666
|
|
|
if (isset($catObj) && is_object($catObj)) { |
667
|
|
|
$catObj->setVars($updateInfo); |
668
|
|
|
$result = $mylinksCatHandler->insert($catObj); |
669
|
|
|
} else { |
670
|
|
|
$result = false; |
671
|
|
|
} |
672
|
|
|
|
673
|
|
|
if (!$result) { |
674
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_DBNOTUPDATED); |
|
|
|
|
675
|
|
|
exit(); |
676
|
|
|
} else { |
677
|
|
|
redirect_header('index.php', 2, _MD_MYLINKS_DBUPDATED); |
678
|
|
|
} |
679
|
|
|
} |
680
|
|
|
|
681
|
|
|
function delCat() |
682
|
|
|
{ |
683
|
|
|
global $xoopsDB, $myCatTree, $xoopsModule, $xoopsUser; |
684
|
|
|
|
685
|
|
|
$cid = MylinksUtility::mylinks_cleanVars($_REQUEST, 'cid', 0, 'int', array('min' => 0)); |
|
|
|
|
686
|
|
|
$ok = MylinksUtility::mylinks_cleanVars($_POST, 'ok', 0, 'int', array('min' => 0, 'max' => 1)); |
|
|
|
|
687
|
|
|
|
688
|
|
|
if (1 == $ok) { |
689
|
|
|
/** |
690
|
|
|
* nickname code: |
691
|
|
|
* |
692
|
|
|
* get all subcategories |
693
|
|
|
* get all links in these categories/subcategories |
694
|
|
|
* get all links in category & subcategories |
695
|
|
|
* delete all links in links, text, votedata, broken, & mod db tables that are in any of these categories |
696
|
|
|
* delete all comments and notifications for the links that have been deleted |
697
|
|
|
* delete category and all subcategories from category db table |
698
|
|
|
* delete all notifications for the categories that have been deleted |
699
|
|
|
*/ |
700
|
|
|
$mylinksCatHandler = xoops_getModuleHandler('category', $xoopsModule->getVar('dirname')); |
701
|
|
|
|
702
|
|
|
//get all subcategories under the specified category |
703
|
|
|
$catObjArr = $myCatTree->getAllChild($cid); |
704
|
|
|
$cidArray = array(); |
705
|
|
|
foreach ($catObjArr as $catObj) { |
706
|
|
|
$cidArray[] = $catObj->getVar('cid'); |
707
|
|
|
} |
708
|
|
|
|
709
|
|
|
array_push($cidArray, $cid); //add this category id to the array |
710
|
|
|
$catIDs = implode(',', $cidArray); |
711
|
|
|
$criteria = new CriteriaCompo(); |
712
|
|
|
$criteria->add(new Criteria('cid', '(' . (int)$cid . ',' . $catIDs . ')', 'IN')); |
713
|
|
|
|
714
|
|
|
// get list ids in any of these categories |
715
|
|
|
$sql = sprintf('SELECT lid FROM %s WHERE cid IN %s', $xoopsDB->prefix('mylinks_links'), "({$catIDs})"); |
716
|
|
|
$result = $xoopsDB->query($sql); |
717
|
|
|
if (!$result) { |
718
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_NORECORDFOUND); |
|
|
|
|
719
|
|
|
exit(); |
720
|
|
|
} |
721
|
|
|
$lidArray = $xoopsDB->fetchArray($result); |
722
|
|
|
|
723
|
|
|
// delete any links, link notifications and link comments from the database tables |
724
|
|
|
if ($lidArray) { |
725
|
|
|
$linkIDs = '(' . implode(',', $lidArray) . ')'; |
726
|
|
|
$dbTables = array('links', 'text', 'votedata', 'broken', 'mod'); |
727
|
|
View Code Duplication |
foreach ($dbTables as $thisTable) { |
|
|
|
|
728
|
|
|
$sql = sprintf('DELETE FROM %s WHERE lid IN %s', $xoopsDB->prefix("mylinks_{$thisTable}"), $linkIDs); |
729
|
|
|
$result = $xoopsDB->query($sql); |
|
|
|
|
730
|
|
|
if (!result) { |
731
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_NORECORDFOUND); |
|
|
|
|
732
|
|
|
exit(); |
733
|
|
|
} |
734
|
|
|
} |
735
|
|
|
// remove any notifications and comments for these listings |
736
|
|
|
foreach ($lidArray as $this_lid) { |
737
|
|
|
xoops_comment_delete($xoopsModule->getVar('mid'), $this_lid); |
738
|
|
|
xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'link', $this_lid); |
739
|
|
|
} |
740
|
|
|
} |
741
|
|
|
// delete category and all subcategories from database |
742
|
|
|
if (!$mylinksCatHandler->deleteAll($criteria)) { |
743
|
|
|
redirect_header('main.php', 2, _MD_MYLINKS_NORECORDFOUND); |
744
|
|
|
exit(); |
745
|
|
|
} |
746
|
|
|
|
747
|
|
|
// delete the notification settings for each (sub)category |
748
|
|
|
foreach ($cidArray as $key => $id) { |
749
|
|
|
xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'category', $id); |
750
|
|
|
} |
751
|
|
|
|
752
|
|
|
redirect_header('index.php', 2, _MD_MYLINKS_CATDELETED); |
753
|
|
|
exit(); |
754
|
|
|
} else { |
755
|
|
|
xoops_cp_header(); |
756
|
|
|
xoops_confirm(array('op' => 'delCat', 'cid' => $cid, 'ok' => 1), 'main.php', _MD_MYLINKS_WARNING); |
757
|
|
|
include __DIR__ . '/admin_footer.php'; |
758
|
|
|
} |
759
|
|
|
} |
760
|
|
|
|
761
|
|
|
function delNewLink() |
762
|
|
|
{ |
763
|
|
|
global $xoopsDB, $xoopsModule; |
764
|
|
|
$lid = MylinksUtility::mylinks_cleanVars($_GET, 'lid', 0, 'int', array('min' => 0)); |
|
|
|
|
765
|
|
|
|
766
|
|
|
$sql = sprintf('DELETE FROM %s WHERE lid = %u', $xoopsDB->prefix('mylinks_links'), $lid); |
767
|
|
|
$result = $xoopsDB->query($sql); |
|
|
|
|
768
|
|
|
if (!result) { |
769
|
|
|
redirect_header('main.php', 2, _MD_MYLINKS_NORECORDFOUND); |
770
|
|
|
exit(); |
771
|
|
|
} |
772
|
|
|
$sql = sprintf('DELETE FROM %s WHERE lid = %u', $xoopsDB->prefix('mylinks_text'), $lid); |
773
|
|
|
$result = $xoopsDB->query($sql); |
774
|
|
|
if (!$result) { |
775
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_NORECORDFOUND); |
|
|
|
|
776
|
|
|
exit(); |
777
|
|
|
} |
778
|
|
|
// delete comments |
779
|
|
|
xoops_comment_delete($xoopsModule->getVar('mid'), $lid); |
780
|
|
|
// delete notifications |
781
|
|
|
xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'link', $lid); |
782
|
|
|
redirect_header('index.php', 2, _MD_MYLINKS_LINKDELETED); |
783
|
|
|
} |
784
|
|
|
|
785
|
|
|
function addCat() |
786
|
|
|
{ |
787
|
|
|
global $xoopsDB, $myts, $xoopsModule; |
788
|
|
|
$pid = MylinksUtility::mylinks_cleanVars($_POST, 'pid', 0, 'int', array('min' => 0)); |
|
|
|
|
789
|
|
|
$title = MylinksUtility::mylinks_cleanVars($_POST, 'title', '', 'string'); |
|
|
|
|
790
|
|
|
$imgurl = MylinksUtility::mylinks_cleanVars($_POST, 'imgurl', '', 'string'); |
|
|
|
|
791
|
|
|
/* |
792
|
|
|
$title = $myts->addSlashes($title); |
793
|
|
|
$imgurl = $myts->addSlashes($imgurl); |
794
|
|
|
*/ |
795
|
|
|
if (empty($title)) { |
796
|
|
|
redirect_header('index.php', 2, _MD_MYLINKS_ERRORTITLE); |
797
|
|
|
exit(); |
798
|
|
|
} |
799
|
|
|
|
800
|
|
|
$newCatVars = array( |
801
|
|
|
'pid' => $pid, |
802
|
|
|
'title' => $title, |
803
|
|
|
'imgurl' => $imgurl |
804
|
|
|
); |
805
|
|
|
|
806
|
|
|
$mylinksCatHandler = xoops_getModuleHandler('category', $xoopsModule->getVar('dirname')); |
807
|
|
|
$newCatObj = $mylinksCatHandler->create(); |
808
|
|
|
$newCatObj->setVars($newCatVars); |
809
|
|
|
$newCatId = $mylinksCatHandler->insert($newCatObj); |
810
|
|
|
if ($newCatId) { |
811
|
|
|
//now update notification handler & trigger new cat added event |
812
|
|
|
$tags = array(); |
813
|
|
|
$tags['CATEGORY_NAME'] = $title; |
814
|
|
|
$tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $newCatId; |
815
|
|
|
$notificationHandler = xoops_getHandler('notification'); |
816
|
|
|
$notificationHandler->triggerEvent('global', 0, 'new_category', $tags); |
817
|
|
|
redirect_header('index.php', 2, _MD_MYLINKS_NEWCATADDED); |
818
|
|
|
} else { |
819
|
|
|
redirect_header('index.php', 2, _MD_MYLINKS_DBNOTUPDATED); |
820
|
|
|
} |
821
|
|
|
} |
822
|
|
|
|
823
|
|
|
function importCats() |
824
|
|
|
{ |
825
|
|
|
global $xoopsDB, $xoopsModule, $xoopsConfig, $myts; |
826
|
|
|
|
827
|
|
|
$ok = MylinksUtility::mylinks_cleanVars($_POST, 'ok', 0, 'int', array('min' => 0, 'max' => 1)); |
|
|
|
|
828
|
|
|
if (1 == $ok) { |
829
|
|
|
if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/sql/mylinks_cat.dat')) { |
830
|
|
|
$importFile = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/sql/mylinks_cat.dat'; |
831
|
|
|
} else { |
832
|
|
|
$importFile = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/sql/mylinks_cat.dat'; |
833
|
|
|
} |
834
|
|
|
|
835
|
|
|
if (file_exists($importFile)) { |
836
|
|
|
/* the following will not work on some shared servers even though it's the most efficient |
837
|
|
|
$sql = "LOAD DATA INFILE '{$importFile}' INTO TABLE " . $xoopsDB->prefix('mylinks_cat') . " FIELDS TERMINATED BY ',' IGNORE 1 LINES"; |
838
|
|
|
$result = $xoopsDB->query($sql); |
839
|
|
|
*/ |
840
|
|
|
|
841
|
|
|
if (($handle = fopen($importFile, 'r')) !== false) { |
842
|
|
|
// set 1000 to 0 in the following line if input line is truncated |
843
|
|
|
while (($data = fgetcsv($handle, 1000, ',')) !== false) { |
844
|
|
|
$sql = sprintf("INSERT INTO %s (cid, pid, title, imgurl) VALUES (%u, %u, '%s', '%s')", $xoopsDB->prefix('mylinks_cat'), (int)$data[0], (int)$data[1], $myts->addSlashes($data[2]), $myts->addSlashes($data[3])); |
845
|
|
|
$result = $xoopsDB->query($sql); |
846
|
|
|
if (!$result) { |
847
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_NORECORDFOUND); |
|
|
|
|
848
|
|
|
exit(); |
849
|
|
|
} |
850
|
|
|
} |
851
|
|
|
fclose($handle); |
852
|
|
|
redirect_header('index.php', 2, _MD_MYLINKS_CATSIMPORTED); |
853
|
|
|
} else { |
854
|
|
|
// problem importing categories |
855
|
|
|
$mylinksCatHandler = xoops_getModuleHandler('category', $xoopsModule->getVar('dirname')); |
856
|
|
|
$result = $mylinksCatHandler->getAll(); |
857
|
|
|
if (count($result)) { |
858
|
|
|
$result = $mylinksCatHandler->deleteAll(); // empty the dB table from partial import |
|
|
|
|
859
|
|
|
} |
860
|
|
|
redirect_header('index.php', 2, _MD_MYLINKS_CATSNOTIMPORTED); |
861
|
|
|
} |
862
|
|
|
} else { //exit somewhat gracefully if import file not found |
863
|
|
|
redirect_header('index.php', 2, sprintf(_MD_MYLINKS_IMPORTFILENOTFOUND, $importFile)); |
864
|
|
|
} |
865
|
|
|
exit(); |
866
|
|
|
} else { |
867
|
|
|
xoops_cp_header(); |
868
|
|
|
xoops_confirm(array('op' => 'importCats', 'ok' => 1), 'main.php', _MD_MYLINKS_CATWARNING); |
869
|
|
|
include __DIR__ . '/admin_footer.php'; |
870
|
|
|
} |
871
|
|
|
} |
872
|
|
|
|
873
|
|
|
function addLink() |
874
|
|
|
{ |
875
|
|
|
global $xoopsDB, $myts, $xoopsUser, $xoopsModule; |
876
|
|
|
|
877
|
|
|
$cid = MylinksUtility::mylinks_cleanVars($_POST, 'cid', 0, 'int', array('min' => 0)); |
|
|
|
|
878
|
|
|
$url = MylinksUtility::mylinks_cleanVars($_POST, 'url', '', 'string'); |
|
|
|
|
879
|
|
|
$logourl = MylinksUtility::mylinks_cleanVars($_POST, 'logourl', '', 'string'); |
|
|
|
|
880
|
|
|
$title = MylinksUtility::mylinks_cleanVars($_POST, 'title', '', 'string'); |
|
|
|
|
881
|
|
|
$description = MylinksUtility::mylinks_cleanVars($_POST, 'descarea', '', 'string'); |
|
|
|
|
882
|
|
|
/* |
883
|
|
|
$url = $myts->addSlashes($url); |
884
|
|
|
$logourl = $myts->addSlashes($logourl); |
885
|
|
|
$title = $myts->addSlashes($title); |
886
|
|
|
$description = $myts->addSlashes($description); |
887
|
|
|
*/ |
888
|
|
|
$submitter = $xoopsUser->uid(); |
889
|
|
|
$result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mylinks_links') . " WHERE url='{$url}'"); |
890
|
|
|
list($numrows) = $xoopsDB->fetchRow($result); |
891
|
|
|
$errormsg = array(); |
892
|
|
|
$error = false; |
893
|
|
|
if ($numrows > 0) { |
894
|
|
|
$errormsg[] = "<h4 style='color: #FF0000'>" . _MD_MYLINKS_ERROREXIST . '</h4>'; |
895
|
|
|
$error = true; |
896
|
|
|
} |
897
|
|
|
if ($title == '') { // check if title exists |
898
|
|
|
$errormsg[] = "<h4 style='color: #FF0000'>" . _MD_MYLINKS_ERRORTITLE . '</h4>'; |
899
|
|
|
$error = true; |
900
|
|
|
} |
901
|
|
|
if ($url == '') { // check if url exists |
902
|
|
|
$errormsg[] = "<h4 style='color: #FF0000'>" . _MD_MYLINKS_ERRORURL . '</h4>'; |
903
|
|
|
$error = true; |
904
|
|
|
} |
905
|
|
|
if ($description == '') { // check if description exists |
906
|
|
|
$errormsg[] = "<h4 style='color: #FF0000'>" . _MD_MYLINKS_ERRORDESC . '</h4>'; |
907
|
|
|
$error = true; |
908
|
|
|
} |
909
|
|
|
if ($error) { |
910
|
|
|
xoops_cp_header(); |
911
|
|
|
$displayMsg = implode('<br>', $errormsg); |
912
|
|
|
echo "<div style='text-align: center;'><fieldset>{$displayMsg}</fieldset></div>\n"; |
913
|
|
|
xoops_cp_footer(); |
914
|
|
|
exit(); |
915
|
|
|
} |
916
|
|
|
|
917
|
|
|
$newid = $xoopsDB->genId($xoopsDB->prefix('mylinks_links') . '_lid_seq'); |
918
|
|
|
$sql = sprintf("INSERT INTO %s (lid, cid, title, url, logourl, submitter, status, date, hits, rating, votes, comments) VALUES (%u, %u, '%s', '%s', '%s', %u, %u, %u, %u, %u, %u, %u)", $xoopsDB->prefix('mylinks_links'), $newid, $cid, $title, $url, $logourl, $submitter, 1, time(), 0, 0, 0, 0); |
919
|
|
|
$result = $xoopsDB->query($sql); |
920
|
|
|
if (!$result) { |
921
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_NORECORDFOUND); |
|
|
|
|
922
|
|
|
exit(); |
923
|
|
|
} |
924
|
|
|
if (0 == $newid) { |
925
|
|
|
$newid = $xoopsDB->getInsertId(); |
926
|
|
|
} |
927
|
|
|
$sql = sprintf("INSERT INTO %s (lid, description) VALUES (%u, '%s')", $xoopsDB->prefix('mylinks_text'), $newid, $description); |
928
|
|
|
$result = $xoopsDB->query($sql); |
929
|
|
|
if (!$result) { |
930
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_NORECORDFOUND); |
|
|
|
|
931
|
|
|
exit(); |
932
|
|
|
} |
933
|
|
|
$tags = array(); |
934
|
|
|
$tags['LINK_NAME'] = $title; |
935
|
|
|
$tags['LINK_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/singlelink.php?cid={$cid}&lid={$newid}"; |
936
|
|
|
|
937
|
|
|
$mylinksCatHandler = xoops_getModuleHandler('category', $xoopsModule->getVar('dirname')); |
938
|
|
|
$catObj = $mylinksCatHandler->get($cid); |
939
|
|
|
$tags['CATEGORY_NAME'] = $catObj->getVar('title'); |
940
|
|
|
unset($catObj, $mylinksCatHandler); |
941
|
|
|
|
942
|
|
|
$tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewcat.php?cid={$cid}"; |
943
|
|
|
$notificationHandler = xoops_getHandler('notification'); |
944
|
|
|
$notificationHandler->triggerEvent('global', 0, 'new_link', $tags); |
945
|
|
|
$notificationHandler->triggerEvent('category', $cid, 'new_link', $tags); |
946
|
|
|
redirect_header('main.php?op=linksConfigMenu', 2, _MD_MYLINKS_NEWLINKADDED); |
947
|
|
|
} |
948
|
|
|
|
949
|
|
|
function approve() |
950
|
|
|
{ |
951
|
|
|
global $xoopsDB, $myts, $xoopsModule; |
952
|
|
|
|
953
|
|
|
$lid = MylinksUtility::mylinks_cleanVars($_POST, 'lid', 0, 'int', array('min' => 0)); |
|
|
|
|
954
|
|
|
$cid = MylinksUtility::mylinks_cleanVars($_POST, 'cid', 0, 'int', array('min' => 0)); |
|
|
|
|
955
|
|
|
$title = MylinksUtility::mylinks_cleanVars($_POST, 'title', '', 'string'); |
|
|
|
|
956
|
|
|
$url = MylinksUtility::mylinks_cleanVars($_POST, 'url', '', 'string'); |
|
|
|
|
957
|
|
|
$logourl = MylinksUtility::mylinks_cleanVars($_POST, 'logourl', '', 'string'); |
|
|
|
|
958
|
|
|
$description = MylinksUtility::mylinks_cleanVars($_POST, 'description', '', 'string'); |
|
|
|
|
959
|
|
|
/* |
960
|
|
|
$url = $myts->addSlashes($url); |
961
|
|
|
$logourl = $myts->addSlashes($logourl); |
962
|
|
|
$title = $myts->addSlashes($title); |
963
|
|
|
$description = $myts->addSlashes($description); |
964
|
|
|
*/ |
965
|
|
|
$query = 'UPDATE ' . $xoopsDB->prefix('mylinks_links') . " set cid='{$cid}', title='{$title}', url='{$url}', logourl='{$logourl}', status='1', date=" . time() . " WHERE lid='{$lid}'"; |
966
|
|
|
$result = $xoopsDB->query($query); |
967
|
|
|
if ($result) { |
968
|
|
|
$query = 'UPDATE ' . $xoopsDB->prefix('mylinks_text') . " SET description='{$description}' WHERE lid='{$lid}'"; |
969
|
|
|
$result = $xoopsDB->query($query); |
970
|
|
|
if (!$result) { |
971
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_NORECORDFOUND); |
|
|
|
|
972
|
|
|
exit(); |
973
|
|
|
} |
974
|
|
|
} else { |
975
|
|
|
MylinksUtility::show_message(_MD_MYLINKS_NORECORDFOUND); |
|
|
|
|
976
|
|
|
exit(); |
977
|
|
|
} |
978
|
|
|
$tags = array(); |
979
|
|
|
$tags['LINK_NAME'] = $title; |
980
|
|
|
$tags['LINK_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/singlelink.php?cid={$cid}&lid={$lid}"; |
981
|
|
|
$mylinksCatHandler = xoops_getModuleHandler('category', $xoopsModule->getVar('dirname')); |
982
|
|
|
$catObj = $mylinksCatHandler->get($cid); |
983
|
|
|
/* |
984
|
|
|
$sql = "SELECT title FROM " . $xoopsDB->prefix("mylinks_cat") . " WHERE cid=" . $cid; |
985
|
|
|
$result = $xoopsDB->query($sql); |
986
|
|
|
$row = $xoopsDB->fetchArray($result); |
987
|
|
|
$tags['CATEGORY_NAME'] = $row['title']; |
988
|
|
|
*/ |
989
|
|
|
if ($catObj) { |
990
|
|
|
$tags['CATEGORY_NAME'] = $catObj->getVar('title'); |
991
|
|
|
$tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewcat.php?cid={$cid}"; |
992
|
|
|
$notificationHandler = xoops_getHandler('notification'); |
993
|
|
|
$notificationHandler->triggerEvent('global', 0, 'new_link', $tags); |
994
|
|
|
$notificationHandler->triggerEvent('category', $cid, 'new_link', $tags); |
995
|
|
|
$notificationHandler->triggerEvent('link', $lid, 'approve', $tags); |
996
|
|
|
redirect_header('index.php', 2, _MD_MYLINKS_NEWLINKADDED); |
997
|
|
|
} else { |
998
|
|
|
redirect_header('index.php', 2, _MD_MYLINKS_DBNOTUPDATED); |
999
|
|
|
} |
1000
|
|
|
} |
1001
|
|
|
|
1002
|
|
|
$op = MylinksUtility::mylinks_cleanVars($_REQUEST, 'op', 'main', 'string'); |
|
|
|
|
1003
|
|
|
|
1004
|
|
|
switch ($op) { |
1005
|
|
|
case 'delNewLink': |
1006
|
|
|
delNewLink(); |
1007
|
|
|
break; |
1008
|
|
|
case 'approve': |
1009
|
|
|
approve(); |
1010
|
|
|
break; |
1011
|
|
|
case 'addCat': |
1012
|
|
|
addCat(); |
1013
|
|
|
break; |
1014
|
|
|
case 'importCats': |
1015
|
|
|
importCats(); |
1016
|
|
|
break; |
1017
|
|
|
case 'addLink': |
1018
|
|
|
addLink(); |
1019
|
|
|
break; |
1020
|
|
|
case 'listBrokenLinks': |
1021
|
|
|
listBrokenLinks(); |
1022
|
|
|
break; |
1023
|
|
|
case 'delBrokenLinks': |
1024
|
|
|
delBrokenLinks(); |
1025
|
|
|
break; |
1026
|
|
|
case 'ignoreBrokenLinks': |
1027
|
|
|
ignoreBrokenLinks(); |
1028
|
|
|
break; |
1029
|
|
|
case 'listModReq': |
1030
|
|
|
listModReq(); |
1031
|
|
|
break; |
1032
|
|
|
case 'changeModReq': |
1033
|
|
|
changeModReq(); |
1034
|
|
|
break; |
1035
|
|
|
case 'ignoreModReq': |
1036
|
|
|
ignoreModReq(); |
1037
|
|
|
break; |
1038
|
|
|
case 'delCat': |
1039
|
|
|
delCat(); |
1040
|
|
|
break; |
1041
|
|
|
case 'modCat': |
1042
|
|
|
modCat(); |
1043
|
|
|
break; |
1044
|
|
|
case 'modCatS': |
1045
|
|
|
modCatS(); |
1046
|
|
|
break; |
1047
|
|
|
case 'modLink': |
1048
|
|
|
modLink(); |
1049
|
|
|
break; |
1050
|
|
|
case 'modLinkS': |
1051
|
|
|
modLinkS(); |
1052
|
|
|
break; |
1053
|
|
|
case 'delLink': |
1054
|
|
|
delLink(); |
1055
|
|
|
break; |
1056
|
|
|
case 'delVote': |
1057
|
|
|
delVote(); |
1058
|
|
|
break; |
1059
|
|
|
case 'linksConfigMenu': |
1060
|
|
|
default: |
1061
|
|
|
linksConfigMenu(); |
1062
|
|
|
break; |
1063
|
|
|
case 'listNewLinks': |
1064
|
|
|
listNewLinks(); |
1065
|
|
|
break; |
1066
|
|
|
case 'main': |
1067
|
|
|
break; |
1068
|
|
|
} |
1069
|
|
|
|
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.