| 1 | <?php |
|---|
| 2 | // $Id: submit.php,v 1.4 2005/09/04 20:46:10 onokazu Exp $ |
|---|
| 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."/class/xoopstree.php"; |
|---|
| 30 | include_once XOOPS_ROOT_PATH."/class/module.errorhandler.php"; |
|---|
| 31 | include_once XOOPS_ROOT_PATH."/include/xoopscodes.php"; |
|---|
| 32 | |
|---|
| 33 | $eh = new ErrorHandler; //ErrorHandler object |
|---|
| 34 | $mytree = new XoopsTree($xoopsDB->prefix("mylinks_cat"),"cid","pid"); |
|---|
| 35 | |
|---|
| 36 | if (empty($xoopsUser) and !$xoopsModuleConfig['anonpost']) { |
|---|
| 37 | redirect_header(XOOPS_URL."/user.php",2,_MD_MUSTREGFIRST); |
|---|
| 38 | exit(); |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | if (!empty($_POST['submit'])) { |
|---|
| 42 | |
|---|
| 43 | $submitter = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0; |
|---|
| 44 | |
|---|
| 45 | // RMV - why store submitter on form?? |
|---|
| 46 | //if (!$_POST['submitter'] and $xoopsUser) { |
|---|
| 47 | // $submitter = $xoopsUser->uid(); |
|---|
| 48 | //}elseif(!$_POST['submitter'] and !$xoopsUser) { |
|---|
| 49 | // $submitter = 0; |
|---|
| 50 | //}else{ |
|---|
| 51 | // $submitter = intval($_POST['submitter']); |
|---|
| 52 | //} |
|---|
| 53 | |
|---|
| 54 | // Check if Title exist |
|---|
| 55 | if ($_POST["title"]=="") { |
|---|
| 56 | $eh->show("1001"); |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | // Check if URL exist |
|---|
| 60 | $url = $_POST["url"]; |
|---|
| 61 | if ($url=="" || !isset($url)) { |
|---|
| 62 | $eh->show("1016"); |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | // Check if Description exist |
|---|
| 66 | if ($_POST['message']=="") { |
|---|
| 67 | $eh->show("1008"); |
|---|
| 68 | } |
|---|
| 69 | /* |
|---|
| 70 | $notify = !empty($_POST['notify']) ? 1 : 0; |
|---|
| 71 | |
|---|
| 72 | if ( !empty($_POST['cid']) ) { |
|---|
| 73 | $cid = intval($_POST['cid']); |
|---|
| 74 | } else { |
|---|
| 75 | $cid = 0; |
|---|
| 76 | } |
|---|
| 77 | */ |
|---|
| 78 | $notify = 0; |
|---|
| 79 | $cid = 0; |
|---|
| 80 | |
|---|
| 81 | // $url = urlencode($url); |
|---|
| 82 | $url = $myts->makeTboxData4Save($url); |
|---|
| 83 | |
|---|
| 84 | $title = $myts->makeTboxData4Save($_POST["title"]); |
|---|
| 85 | $description = $myts->makeTareaData4Save($_POST["message"]); |
|---|
| 86 | $date = time(); |
|---|
| 87 | $newid = $xoopsDB->genId($xoopsDB->prefix("mylinks_links")."_lid_seq"); |
|---|
| 88 | if ( $xoopsModuleConfig['autoapprove'] == 1 ) { |
|---|
| 89 | // RMV-FIXME: shouldn't this be 'APPROVE' or something (also in mydl)? |
|---|
| 90 | $status = $xoopsModuleConfig['autoapprove']; |
|---|
| 91 | } else { |
|---|
| 92 | $status = 0; |
|---|
| 93 | } |
|---|
| 94 | |
|---|
| 95 | $developer = $_POST["developer"]; |
|---|
| 96 | $release_date = $_POST["release_date"]; |
|---|
| 97 | $development_time = $_POST["development_time"]; |
|---|
| 98 | $site_status = $_POST["site_status"]; |
|---|
| 99 | $customize_flag = $_POST["customize_flag"]; |
|---|
| 100 | |
|---|
| 101 | $sql = sprintf("INSERT INTO %s (lid, cid, title, url, logourl, submitter, status, date, hits, rating, votes, comments, developer, release_date, development_time, site_status, customize_flag) VALUES (%u, %u, '%s', '%s', '%s', %u, %u, %u, %u, %u, %u, %u, '%s', '%s', '%s', %u, %u)", $xoopsDB->prefix("mylinks_links"), $newid, $cid, $title, $url, ' ', $submitter, $status, $date, 0, 0, 0, 0, $developer, $release_date, $development_time, $site_status, $customize_flag); |
|---|
| 102 | |
|---|
| 103 | $xoopsDB->query($sql) or $eh->show("0013"); |
|---|
| 104 | if ($newid == 0) { |
|---|
| 105 | $newid = $xoopsDB->getInsertId(); |
|---|
| 106 | } |
|---|
| 107 | $sql = sprintf("INSERT INTO %s (lid, description) VALUES (%u, '%s')", $xoopsDB->prefix("mylinks_text"), $newid, $description); |
|---|
| 108 | $xoopsDB->query($sql) or $eh->show("0013"); |
|---|
| 109 | // RMV-NEW |
|---|
| 110 | // Notify of new link (anywhere) and new link in category. |
|---|
| 111 | $notification_handler =& xoops_gethandler('notification'); |
|---|
| 112 | $tags = array(); |
|---|
| 113 | $tags['LINK_NAME'] = $title; |
|---|
| 114 | $tags['LINK_URL'] = XOOPS_URL . '/modules/'. $xoopsModule->getVar('dirname') . '/singlelink.php?cid=' . $cid . '&lid=' . $newid; |
|---|
| 115 | $sql = "SELECT title FROM " . $xoopsDB->prefix("mylinks_cat") . " WHERE cid=" . $cid; |
|---|
| 116 | $result = $xoopsDB->query($sql); |
|---|
| 117 | $row = $xoopsDB->fetchArray($result); |
|---|
| 118 | $tags['CATEGORY_NAME'] = $row['title']; |
|---|
| 119 | $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $cid; |
|---|
| 120 | if ( $xoopsModuleConfig['autoapprove'] == 1 ) { |
|---|
| 121 | $notification_handler->triggerEvent('global', 0, 'new_link', $tags); |
|---|
| 122 | $notification_handler->triggerEvent('category', $cid, 'new_link', $tags); |
|---|
| 123 | redirect_header("index.php",2,_MD_RECEIVED."<br />"._MD_ISAPPROVED.""); |
|---|
| 124 | }else{ |
|---|
| 125 | $tags['WAITINGLINKS_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/index.php?op=listNewLinks'; |
|---|
| 126 | $notification_handler->triggerEvent('global', 0, 'link_submit', $tags); |
|---|
| 127 | $notification_handler->triggerEvent('category', $cid, 'link_submit', $tags); |
|---|
| 128 | if ($notify) { |
|---|
| 129 | include_once XOOPS_ROOT_PATH . '/include/notification_constants.php'; |
|---|
| 130 | $notification_handler->subscribe('link', $newid, 'approve', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE); |
|---|
| 131 | } |
|---|
| 132 | redirect_header("index.php",2,_MD_RECEIVED); |
|---|
| 133 | } |
|---|
| 134 | exit(); |
|---|
| 135 | |
|---|
| 136 | } else { |
|---|
| 137 | |
|---|
| 138 | $xoopsOption['template_main'] = 'mylinks_submit.html'; |
|---|
| 139 | include XOOPS_ROOT_PATH."/header.php"; |
|---|
| 140 | ob_start(); |
|---|
| 141 | xoopsCodeTarea("message",37,8); |
|---|
| 142 | $xoopsTpl->assign('xoops_codes', ob_get_contents()); |
|---|
| 143 | ob_end_clean(); |
|---|
| 144 | ob_start(); |
|---|
| 145 | xoopsSmilies("message"); |
|---|
| 146 | $xoopsTpl->assign('xoops_smilies', ob_get_contents()); |
|---|
| 147 | ob_end_clean(); |
|---|
| 148 | $xoopsTpl->assign('notify_show', !empty($xoopsUser) && !$xoopsModuleConfig['autoapprove'] ? 1 : 0); |
|---|
| 149 | $xoopsTpl->assign('lang_submitonce', _MD_SUBMITONCE); |
|---|
| 150 | $xoopsTpl->assign('lang_submitlinkh', _MD_SUBMITLINKHEAD); |
|---|
| 151 | $xoopsTpl->assign('lang_allpending', _MD_ALLPENDING); |
|---|
| 152 | $xoopsTpl->assign('lang_dontabuse', _MD_DONTABUSE); |
|---|
| 153 | $xoopsTpl->assign('lang_wetakeshot', _MD_TAKESHOT); |
|---|
| 154 | $xoopsTpl->assign('lang_sitetitle', _MD_SITETITLE); |
|---|
| 155 | $xoopsTpl->assign('lang_siteurl', _MD_SITEURL); |
|---|
| 156 | $xoopsTpl->assign('lang_category', _MD_CATEGORYC); |
|---|
| 157 | $xoopsTpl->assign('lang_options', _MD_OPTIONS); |
|---|
| 158 | $xoopsTpl->assign('lang_notify', _MD_NOTIFYAPPROVE); |
|---|
| 159 | $xoopsTpl->assign('lang_description', _MD_DESCRIPTIONC); |
|---|
| 160 | $xoopsTpl->assign('lang_submit', _SUBMIT); |
|---|
| 161 | $xoopsTpl->assign('lang_cancel', _CANCEL); |
|---|
| 162 | $xoopsTpl->assign('lang_developer', _MD_DEVELOPER); |
|---|
| 163 | $xoopsTpl->assign('lang_release_date', _MD_RELEASE_DATE); |
|---|
| 164 | $xoopsTpl->assign('lang_development_time', _MD_DEVELOPMENT_TIME); |
|---|
| 165 | $xoopsTpl->assign('lang_site_status', _MD_SITE_STATUS); |
|---|
| 166 | $xoopsTpl->assign('lang_customize', _MD_CUSTOMIZE); |
|---|
| 167 | $xoopsTpl->assign('lang_new_open', _MD_NEW_OPEN); |
|---|
| 168 | $xoopsTpl->assign('lang_renewal', _MD_RENEWAL); |
|---|
| 169 | $xoopsTpl->assign('lang_on', _MD_ON); |
|---|
| 170 | $xoopsTpl->assign('lang_off', _MD_OFF); |
|---|
| 171 | $xoopsTpl->assign('lang_caution_title', _POST_CAUTION_TITLE); |
|---|
| 172 | $xoopsTpl->assign('lang_caution_body', _POST_CAUTION_BODY); |
|---|
| 173 | ob_start(); |
|---|
| 174 | $mytree->makeMySelBox("title", "title",0,1); |
|---|
| 175 | $selbox = ob_get_contents(); |
|---|
| 176 | ob_end_clean(); |
|---|
| 177 | $xoopsTpl->assign('category_selbox', $selbox); |
|---|
| 178 | include XOOPS_ROOT_PATH.'/footer.php'; |
|---|
| 179 | } |
|---|
| 180 | ?> |
|---|