These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | // $Id: submit.php 11819 2013-07-09 18:21:40Z 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 'header.php'; |
||
28 | $myts =& MyTextSanitizer::getInstance();// MyTextSanitizer object |
||
29 | include_once XOOPS_ROOT_PATH . '/include/xoopscodes.php'; |
||
30 | |||
31 | include_once './class/utility.php'; |
||
32 | //xoops_load('utility', $xoopsModule->getVar('dirname')); |
||
33 | |||
34 | if (empty($xoopsUser) and !$xoopsModuleConfig['anonpost']) { |
||
35 | redirect_header(XOOPS_URL . '/user.php', 2, _MD_MYLINKS_MUSTREGFIRST); |
||
36 | exit(); |
||
37 | } |
||
38 | |||
39 | if (!empty($_POST['submit'])) { |
||
40 | |||
41 | // include_once XOOPS_ROOT_PATH . '/class/module.errorhandler.php'; |
||
42 | // $eh = new ErrorHandler; //ErrorHandler object |
||
43 | $submitter = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0; |
||
44 | |||
45 | $msg = ''; |
||
46 | switch ( true ) { |
||
47 | case ( empty( $_POST['title'] ) ): |
||
48 | $msg .= _MD_MYLINKS_ERRORTITLE; |
||
49 | case ( empty( $_POST['url'] ) ): |
||
50 | $msg .= _MD_MYLINKS_ERRORURL; |
||
51 | case ( empty( $_POST['message'] ) ): |
||
52 | $msg .= _MD_MYLINKS_ERRORDESC; |
||
53 | } |
||
54 | if ( '' !== $msg ) { |
||
55 | mylinksUtility::show_message($msg); |
||
0 ignored issues
–
show
|
|||
56 | exit(); |
||
57 | } |
||
58 | |||
59 | $title = $myts->addSlashes($_POST['title']); |
||
60 | $url = $myts->addSlashes($_POST['url']); |
||
61 | $notify = !empty($_POST['notify']) ? 1 : 0; |
||
62 | $cid = mylinksUtility::mylinks_cleanVars($_POST, 'cid', 0, 'int', array('min'=>0)); |
||
63 | $description = $myts->addSlashes($_POST['message']); |
||
64 | $date = time(); |
||
65 | $newid = $xoopsDB->genId($xoopsDB->prefix('mylinks_links').'_lid_seq'); |
||
66 | $mylinksAdmin = ( is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid()) ) ? true : false; |
||
67 | $status = ( ( 1 == $xoopsModuleConfig['autoapprove'] ) || $mylinksAdmin ) ? 1 : 0; |
||
68 | |||
69 | $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, ' ', $submitter, $status, $date, 0, 0, 0, 0); |
||
70 | $result = $xoopsDB->query($sql); |
||
71 | if ( !$result ) { |
||
72 | mylinksUtility::show_message(_MD_MYLINKS_DBNOTUPDATED); |
||
0 ignored issues
–
show
|
|||
73 | exit(); |
||
74 | } |
||
75 | if ( 0 == $newid ) { |
||
76 | $newid = $xoopsDB->getInsertId(); |
||
77 | } |
||
78 | $sql = sprintf("INSERT INTO %s (lid, description) VALUES (%u, '%s')", $xoopsDB->prefix('mylinks_text'), $newid, $description); |
||
79 | $result = $xoopsDB->query($sql); |
||
80 | if ( !$result ) { |
||
81 | mylinksUtility::show_message(_MD_MYLINKS_DBNOTUPDATED); |
||
0 ignored issues
–
show
|
|||
82 | exit(); |
||
83 | } |
||
84 | // Notify of new link (anywhere) and new link in category. |
||
85 | $notification_handler =& xoops_getHandler('notification'); |
||
86 | $tags = array(); |
||
87 | $tags['LINK_NAME'] = $title; |
||
88 | $tags['LINK_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/singlelink.php?cid={$cid}&lid={$newid}"; |
||
89 | $sql = 'SELECT title FROM ' . $xoopsDB->prefix('mylinks_cat') . " WHERE cid={$cid}"; |
||
90 | $result = $xoopsDB->query($sql); |
||
91 | $row = $xoopsDB->fetchArray($result); |
||
92 | $tags['CATEGORY_NAME'] = $row['title']; |
||
93 | $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewcat.php?cid={$cid}"; |
||
94 | if ( 1 == $xoopsModuleConfig['autoapprove'] ) { |
||
95 | $notification_handler->triggerEvent('global', 0, 'new_link', $tags); |
||
96 | $notification_handler->triggerEvent('category', $cid, 'new_link', $tags); |
||
97 | redirect_header('index.php', 2, _MD_MYLINKS_RECEIVED . '<br>' . _MD_MYLINKS_ISAPPROVED . ''); |
||
98 | } else { |
||
99 | $tags['WAITINGLINKS_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/index.php?op=listNewLinks'; |
||
100 | $notification_handler->triggerEvent('global', 0, 'link_submit', $tags); |
||
101 | $notification_handler->triggerEvent('category', $cid, 'link_submit', $tags); |
||
102 | if ($notify) { |
||
103 | include_once XOOPS_ROOT_PATH . '/include/notification_constants.php'; |
||
104 | $notification_handler->subscribe('link', $newid, 'approve', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE); |
||
105 | } |
||
106 | redirect_header('index.php', 2, _MD_MYLINKS_RECEIVED); |
||
107 | } |
||
108 | exit(); |
||
109 | } else { |
||
110 | |||
111 | include_once XOOPS_ROOT_PATH . '/class/tree.php'; |
||
112 | $mylinksCatHandler =& xoops_getmodulehandler('category', $xoopsModule->getVar('dirname')); |
||
113 | $catObjs = $mylinksCatHandler->getAll(); |
||
114 | $myCatTree = new XoopsObjectTree($catObjs, 'cid', 'pid'); |
||
115 | |||
116 | $xoopsOption['template_main'] = 'mylinks_submit.html'; |
||
117 | include XOOPS_ROOT_PATH . '/header.php'; |
||
118 | //wanikoo |
||
119 | $xoTheme->addStylesheet('browse.php?' . mylinksGetStylePath('mylinks.css', 'include')); |
||
120 | $xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js'); |
||
121 | $xoTheme->addScript('browse.php?' . mylinksGetStylePath('mylinks.js', 'include')); |
||
122 | // |
||
123 | ob_start(); |
||
124 | xoopsCodeTarea('message',37,8); |
||
125 | $xoopsTpl->assign('xoops_codes', ob_get_contents()); |
||
126 | ob_end_clean(); |
||
127 | ob_start(); |
||
128 | xoopsSmilies('message'); |
||
129 | $xoopsTpl->assign('xoops_smilies', ob_get_contents()); |
||
130 | ob_end_clean(); |
||
131 | $notify_show = (!empty($xoopsUser) && !$xoopsModuleConfig['autoapprove']) ? 1 : 0; |
||
132 | $xoopsTpl->assign('notify_show', $notify_show); |
||
133 | $xoopsTpl->assign('lang_submitonce', _MD_MYLINKS_SUBMITONCE); |
||
134 | $xoopsTpl->assign('lang_submitlinkh', _MD_MYLINKS_SUBMITLINKHEAD); |
||
135 | $xoopsTpl->assign('lang_allpending', _MD_MYLINKS_ALLPENDING); |
||
136 | $xoopsTpl->assign('lang_dontabuse', _MD_MYLINKS_DONTABUSE); |
||
137 | $xoopsTpl->assign('lang_wetakeshot', _MD_MYLINKS_TAKESHOT); |
||
138 | $xoopsTpl->assign('lang_sitetitle', _MD_MYLINKS_SITETITLE); |
||
139 | $xoopsTpl->assign('lang_siteurl', _MD_MYLINKS_SITEURL); |
||
140 | $xoopsTpl->assign('lang_category', _MD_MYLINKS_CATEGORYC); |
||
141 | $xoopsTpl->assign('lang_options', _MD_MYLINKS_OPTIONS); |
||
142 | $xoopsTpl->assign('lang_notify', _MD_MYLINKS_NOTIFYAPPROVE); |
||
143 | $xoopsTpl->assign('lang_description', _MD_MYLINKS_DESCRIPTIONC); |
||
144 | $xoopsTpl->assign('lang_submit', _SUBMIT); |
||
145 | $xoopsTpl->assign('lang_cancel', _CANCEL); |
||
146 | $xoopsTpl->assign('category_selbox', $myCatTree->makeSelBox('cid', 'title', '-', 0, false)); |
||
147 | |||
148 | //wanikoo theme changer |
||
149 | $xoopsTpl->assign('lang_themechanger', _MD_MYLINKS_THEMECHANGER); |
||
150 | $mymylinkstheme_options = ''; |
||
151 | |||
152 | View Code Duplication | foreach ($GLOBALS['mylinks_allowed_theme'] as $mymylinkstheme) { |
|
153 | $mymylinkstheme_options .= "<option value='{$mymylinkstheme}'"; |
||
154 | if ($mymylinkstheme == $GLOBALS['mylinks_theme']) { |
||
155 | $mymylinkstheme_options .= " selected='selected'"; |
||
156 | } |
||
157 | $mymylinkstheme_options .= ">{$mymylinkstheme}</option>"; |
||
158 | } |
||
159 | |||
160 | $mylinkstheme_select = "<select name='mylinks_theme_select' onchange='submit();' size='1'>{$mymylinkstheme_options}</select>"; |
||
161 | |||
162 | $xoopsTpl->assign('mylinksthemeoption', $mylinkstheme_select); |
||
163 | |||
164 | //wanikoo search |
||
165 | View Code Duplication | if (file_exists(XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/search.php')) { |
|
166 | include_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/search.php'; |
||
167 | } else { |
||
168 | include_once XOOPS_ROOT_PATH . '/language/english/search.php'; |
||
169 | } |
||
170 | $xoopsTpl->assign('lang_all', _SR_ALL); |
||
171 | $xoopsTpl->assign('lang_any', _SR_ANY); |
||
172 | $xoopsTpl->assign('lang_exact', _SR_EXACT); |
||
173 | $xoopsTpl->assign('lang_search', _SR_SEARCH); |
||
174 | $xoopsTpl->assign('module_id', $xoopsModule->getVar('mid')); |
||
175 | //category head |
||
176 | $catarray = array(); |
||
177 | if ($mylinks_show_letters) { |
||
178 | $catarray['letters'] = ml_wfd_letters(); |
||
179 | } |
||
180 | if ($mylinks_show_toolbar) { |
||
181 | $catarray['toolbar'] = ml_wfd_toolbar(); |
||
182 | } |
||
183 | $xoopsTpl->assign('catarray', $catarray); |
||
184 | |||
185 | include_once XOOPSMYLINKPATH . '/footer.php'; |
||
186 | } |
||
187 |
This method has been deprecated.