3 // URL configuration plugin "NP_CustomURL" ADMIN page
6 // if your 'plugin' directory is not in the default location,
7 // edit this variable to point to your site directory
8 // (where config.php is)
11 include($strRel . 'config.php');
12 include($DIR_LIBS . 'PLUGINADMIN.php');
14 // create the admin area page
15 $oPluginAdmin = new PluginAdmin('CustomURL');
16 $language = ereg_replace( '[\\|/]', '', getLanguageName());
17 if (file_exists($oPluginAdmin->plugin->getDirectory() . 'language/' . $language . '.php')) {
18 include_once($oPluginAdmin->plugin->getDirectory() . 'language/' . $language . '.php');
20 include_once($oPluginAdmin->plugin->getDirectory() . 'language/english.php');
23 if (!($member->isLoggedIn() && $member->isAdmin())) {
24 ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));
25 $myAdmin->error(_ERROR_DISALLOWED);
31 function CustomURL_ADMIN()
33 global $manager, $CONF, $oPluginAdmin;
34 $this->plugin =& $oPluginAdmin->plugin;
35 $this->name = $this->plugin->getName();
36 $this->pluginid = $this->plugin->getID();
37 $this->adminurl = $this->plugin->getAdminURL();
38 $this->editurl = $CONF['adminURL'];
39 $this->pediturl = $CONF['adminURL']
40 . 'index.php?action=pluginoptions&plugid='
42 $this->table = sql_table('plug_customurl');
43 $this->uScat = ($manager->pluginInstalled('NP_MultipleCategories') == TRUE);
44 if ($manager->pluginInstalled('NP_MultipleCategories')) {
45 $mplugin =& $manager->getPlugin('NP_MultipleCategories');
46 if (method_exists($mplugin, 'getRequestName')) {
47 $this->mcadmin = $mplugin->getAdminURL();
54 function action($action)
57 $methodName = 'action_' . $action;
58 $this->actions = strtolower($action);
59 $aActionsNotToCheck = array(
66 if (!in_array($this->actions, $aActionsNotToCheck)) {
67 if (!$manager->checkTicket()) {
68 $this->error(_ERROR_BADTICKET);
72 if (method_exists($this, $methodName)) {
73 call_user_func(array(&$this, $methodName));
75 $this->error(_BADACTION . " ($action)");
82 ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));
83 $msg = array (0, _ERROR_DISALLOWED, '***', _DISALLOWED_MSG);
87 function error($msg = '')
91 $oPluginAdmin->start();
92 $printData = $msg[1] . 'name : ' . $msg[2] . '<br />'
94 . '<a href="' . $this->adminurl . 'index.php" onclick="history.back()">'
102 function action_blogview($msg = '')
104 global $CONF, $oPluginAdmin;
106 $oPluginAdmin->start();
107 $printData = '<h2><a id="pagetop">'._ADMIN_AREA_TITLE.'</a></h2>'
108 . '<ul style="list-style:none;">'
110 . ' <a href="' . $this->pediturl . '">'
115 . ' <a href="' . $this->adminurl . 'index.php?action=memberview">'
116 . _FOR_MEMBER_SETTING
120 . '<p>' . $this->_hsc($msg);
123 $this->print_tablehead(_BLOG_LIST_TITLE, _LISTS_ACTIONS);
124 $query = 'SELECT %s,%s,%s FROM %s';
125 $query = sprintf($query, bname, bnumber, bshortname, sql_table('blog'));
126 $res = sql_query($query);
127 while ($b = mysql_fetch_object($res)) {
128 // $forCatURI = $this->adminurl . 'index.php?action=goCategory&blogid=' . $b->bnumber;
129 $forCatURI = $this->adminurl . 'index.php?action=categoryview&blogid=' . $b->bnumber;
130 // $forItemURI = $this->adminurl . 'index.php?action=goItem&blogid=' . $b->bnumber;
131 $forItemURI = $this->adminurl . 'index.php?action=itemview&blogid=' . $b->bnumber;
132 $bPath = $this->_hsc($this->plugin->getBlogOption($b->bnumber, 'customurl_bname'));
134 'oid' => intval($b->bnumber),
137 'name' => $this->_hsc($b->bname),
139 'ed_URL' => $this->editurl . 'index.php?action=blogsettings'
140 . '&blogid=' . intval($b->bnumber),
141 'desc' => '[<a href="' . $forItemURI . '" style="font-size:x-small;">'
145 . '[<a href="' . $forCatURI . '" style="font-size:x-small;">'
146 . _FOR_CATEGORY_SETTING
149 'setting_text' => _BLOG_SETTING
151 $this->print_tablerow($data);
153 echo '</tbody></table>';
156 $oPluginAdmin->end();
159 function action_categoryview($bid = '', $msg = '')
161 global $CONF, $oPluginAdmin;
163 if (getVar('blogid')) {
164 $bid = intGetVar('blogid');
166 $bid = intval($CONF['DefaultBlog']);
171 $bname = $this->_hsc(getBlognameFromID($bid));
173 $oPluginAdmin->start();
174 $printData = '<h2><a id="pagetop">'._ADMIN_AREA_TITLE.'</a></h2>'
175 . '<ul style="list-style:none;">'
177 . ' <a href="' . $this->pediturl . '">'
182 . ' <a href="' . $this->adminurl . 'index.php?action=blogview">'
187 // . ' <a href="' . $this->adminurl . 'index.php?action=goItem&blogid=' . $bid . '">'
188 . ' <a href="' . $this->adminurl . 'index.php?action=itemview&blogid=' . $bid . '">'
193 . ' <a href="' . $this->adminurl . 'index.php?action=memberview">'
194 . _FOR_MEMBER_SETTING
198 . '<p>' . $this->_hsc($msg)
199 . '<h3 style="padding-left: 0px">' . $bname . '</h3>';
202 $this->print_tablehead(_LISTS_CAT_NAME, _LISTS_DESC);
203 $query = 'SELECT catid, cname, cdesc FROM %s WHERE cblog = %d';
204 $query = sprintf($query, sql_table('category'), $bid);
205 $cnm = sql_query($query);
206 while ($c = mysql_fetch_object($cnm)) {
207 $cPath = $this->_hsc($this->plugin->getCategoryOption($c->catid, 'customurl_cname'));
209 'oid' => intval($c->catid),
212 'name' => $this->_hsc($c->cname),
213 'ret' => 'catoverview',
214 'ed_URL' => $this->editurl
215 . 'index.php?action=categoryedit'
216 . '&blogid=' . $bid
217 . '&catid=' . intval($c->catid),
218 'desc' => $this->_hsc($c->cdesc),
221 $this->print_tablerow($data);
223 $query = 'SELECT scatid, sname, sdesc FROM %s WHERE catid = %d';
224 $query = sprintf($query, sql_table('plug_multiple_categories_sub'), intval($c->catid));
225 $scnm = sql_query($query);
226 while ($sc = mysql_fetch_object($scnm)) {
227 $query = 'SELECT obj_name '
229 . 'WHERE obj_param = "subcategory" '
230 . 'AND obj_bid = %d '
232 $query = sprintf($query, $this->table, intval($c->catid), intval($sc->scatid));
233 $scpt = sql_query($query);
234 $scp = mysql_fetch_object($scpt);
236 'oid' => intval($sc->scatid),
237 'obd' => intval($c->catid),
238 'opr' => 'subcategory',
239 'name' => '»' . $this->_hsc($sc->sname),
240 'ret' => 'catoverview',
241 'ed_URL' => $this->mcadmin
242 . 'index.php?action=scatedit'
243 . '&catid=' . intval($c->catid)
244 . '&scatid=' . intval($sc->scatid),
245 'desc' => $this->_hsc($sc->sdesc),
246 'path' => $this->_hsc($scp->obj_name)
248 $this->print_tablerow($data);
252 echo '</tbody></table>';
253 echo '<a href="' . $this->adminurl . 'index.php" onclick="history.back()">' . _BACK . '</a>';
256 $oPluginAdmin->end();
259 function action_memberview($msg = '')
261 global $CONF, $oPluginAdmin;
263 $oPluginAdmin->start();
264 $printData = '<h2>' . _ADMIN_AREA_TITLE . '</h2>'
265 . '<ul style="list-style:none;">'
267 . ' <a href="' . $this->pediturl . '">'
272 . ' <a href="' . $this->adminurl . 'index.php?action=blogview">'
277 . '<p>' . $this->_hsc($msg);
280 $this->print_tablehead(_LOGIN_NAME, _MEMBERS_REALNAME);
281 $query = 'SELECT %s,%s,%s FROM %s';
282 $query = sprintf($query, mname, mnumber, mrealname, sql_table('member'));
283 $res = sql_query($query);
284 while ($m = mysql_fetch_object($res)) {
285 $mPpath = $this->_hsc($this->plugin->getMemberOption($m->mnumber, 'customurl_mname'));
287 'oid' => intval($m->mnumber),
290 'name' => $this->_hsc($m->mname),
291 'ret' => 'memberview',
292 'ed_URL' => $this->editurl
293 . 'index.php?action=memberedit'
294 . '&memberid=' . intval($m->mnumber),
295 'desc' => $this->_hsc($m->mrealname),
298 $this->print_tablerow($data);
300 echo '</tbody></table></p>';
302 $oPluginAdmin->end();
305 function action_itemview($bid = 0, $msg = '') {
306 global $CONF, $oPluginAdmin;
309 if (getVar('blogid')) {
310 $bid = intGetVar('blogid');
312 $bid = intval($CONF['DefaultBlog']);
317 $oPluginAdmin->start();
318 $printData = '<h2>'._ADMIN_AREA_TITLE.'</h2>'
319 . '<ul style="list-style:none;">'
321 . ' <a href="' . $this->pediturl . '">'
326 . ' <a href="' . $this->adminurl . 'index.php?action=blogview">'
331 // . ' <a href="' . $this->adminurl . 'index.php?action=goCategory&blogid=' . $bid . '">'
332 . ' <a href="' . $this->adminurl . 'index.php?action=categoryview&blogid=' . $bid . '">'
333 . _FOR_CATEGORY_SETTING
337 . ' <a href="' . $this->adminurl . 'index.php?action=memberview">'
338 . _FOR_MEMBER_SETTING
342 . '<p><h3>' . $this->_hsc($msg) . '</h3>';
345 $this->print_tablehead(_LISTS_TITLE, _LISTS_ITEM_DESC);
346 $query = 'SELECT %s,%s,%s FROM %s WHERE iblog = %d ORDER BY itime DESC';
347 $query = sprintf($query, ititle, inumber, ibody, sql_table('item'), $bid);
348 $res = sql_query($query);
349 while ($i = mysql_fetch_object($res)) {
350 $query = 'SELECT obj_name as result FROM %s WHERE obj_param = "item" AND obj_id = %d';
351 $query = sprintf($query, sql_table('plug_customurl'), intval($i->inumber));
352 $temp_res = quickQuery($query);
353 $ipath = $this->_hsc(substr($temp_res, 0, -5));
355 'oid' => intval($i->inumber),
358 'name' => $this->_hsc($i->ititle),
360 'ed_URL' => $this->editurl
361 . 'index.php?action=itemedit'
362 . '&itemid=' . intval($i->inumber),
363 // 'desc' => $this->_hsc(mb_substr(strip_tags($i->ibody), 0, 80)),
366 if (extension_loaded('mbstring')) {
367 $data['desc'] = $this->_hsc(mb_substr(strip_tags($i->ibody), 0, 80));
369 $this->_hsc(substr(strip_tags($i->ibody), 0, 80));
371 $this->print_tablerow($data);
373 echo '</tbody></table></p>';
375 $oPluginAdmin->end();
378 function print_tablehead($o_name, $o_desc)
380 global $oPluginAdmin;
385 $ACTION = _LISTS_ACTIONS;
392 <th style="width:180px;">{$PATH}</th>
393 <th style="width:80px;">{$ACTION}</th>
400 function print_tablerow($data)
402 global $oPluginAdmin, $manager;
404 $updateText = _SETTINGS_UPDATE_BTN;
407 <tr onmouseover="focusRow(this);" onmouseout="blurRow(this);">
408 <form method="post" action="{$this->adminurl}index.php" />
409 <input type="hidden" name="action" value="pathupdate" />
410 <input type="hidden" name="oid" value="{$data['oid']}" />
411 <input type="hidden" name="obd" value="{$data['obd']}" />
412 <input type="hidden" name="opr" value="{$data['opr']}" />
413 <input type="hidden" name="name" value="{$data['name']}" />
414 <input type="hidden" name="ret" value="{$data['ret']}" />
416 $manager->addTicketHidden();
418 <td>{$data['name']}
419 <a href="{$data['ed_URL']}" style="font-size:xx-small;">[{$edit}]</a>
421 <td>{$data['desc']}</td>
422 <td><input type="text" name="path" size="32" value="{$data['path']}"/></td>
423 <td><input type="submit" name="update" value="{$updateText}" /></td>
429 function action_pathupdate() {
430 global $oPluginAdmin;
432 $o_oid = intRequestVar('oid');
433 $o_bid = intRequestVar('obd');
434 $o_param = requestVar('opr');
435 $o_name = requestVar('name');
436 $newPath = requestVar('path');
437 $action = requestVar('ret');
439 $msg = $this->plugin->RegistPath($o_oid, $newPath, $o_bid, $o_param, $o_name);
447 $mesage = _UPDATE_SUCCESS;
450 if ($o_param == 'subcategory') {
451 $bid = getBlogIDFromCatID($o_bid);
455 $this->action_categoryview($bid, _UPDATE_SUCCESS);
458 $this->action_memberview(_UPDATE_SUCCESS);
461 $this->action_blogview(_UPDATE_SUCCESS);
464 $this->action_itemview($o_bid, _UPDATE_SUCCESS);
467 echo _UPDATE_SUCCESS;
473 function action_goItem() {
474 global $oPluginAdmin;
476 $bid = getVar('blogid');
477 $this->action_itemview($bid);
480 function action_goCategory() {
481 global $oPluginAdmin;
483 $bid = getVar('blogid');
484 $this->action_categoryview($bid);
489 return htmlspecialchars($str, ENT_QUOTES, _CHARSET);
494 $myAdmin = new CustomURL_ADMIN();
496 if (requestVar('action')) {
497 $myAdmin->action(requestVar('action'));
499 $myAdmin->action('blogview');