// // ------------------------------------------------------------------------- // // Based on: // // myPHPNUKE Web Portal System - http://myphpnuke.com/ // // PHP-NUKE Web Portal System - http://phpnuke.org/ // // Thatware - http://thatware.org/ // // ------------------------------------------------------------------------- // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // // the Free Software Foundation; either version 2 of the License, or // // (at your option) any later version. // // // // This program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // GNU General Public License for more details. // // // // You should have received a copy of the GNU General Public License // // along with this program; if not, write to the Free Software // // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------- // include '../../../include/cp_header.php'; if ( file_exists("../language/".$xoopsConfig['language']."/main.php") ) { include "../language/".$xoopsConfig['language']."/main.php"; } else { include "../language/english/main.php"; } include '../include/functions.php'; include_once XOOPS_ROOT_PATH.'/class/xoopstree.php'; include_once XOOPS_ROOT_PATH."/class/xoopslists.php"; include_once XOOPS_ROOT_PATH."/include/xoopscodes.php"; include_once XOOPS_ROOT_PATH.'/class/module.errorhandler.php'; $myts =& MyTextSanitizer::getInstance(); $eh = new ErrorHandler; $mytree = new XoopsTree($xoopsDB->prefix("mylinks_cat"),"cid","pid"); function mylinks() { global $xoopsDB, $xoopsModule; xoops_cp_header(); echo "

"._MD_WEBLINKSCONF."

"; echo"" ."
"; // Temporarily 'homeless' links (to be revised in admin.php breakup) $result = $xoopsDB->query("select count(*) from ".$xoopsDB->prefix("mylinks_broken").""); list($totalbrokenlinks) = $xoopsDB->fetchRow($result); if($totalbrokenlinks>0){ $totalbrokenlinks = "$totalbrokenlinks"; } $result2 = $xoopsDB->query("select count(*) from ".$xoopsDB->prefix("mylinks_mod").""); list($totalmodrequests) = $xoopsDB->fetchRow($result2); if($totalmodrequests>0){ $totalmodrequests = "$totalmodrequests"; } $result3 = $xoopsDB->query("select count(*) from ".$xoopsDB->prefix("mylinks_links")." where status=0"); list($totalnewlinks) = $xoopsDB->fetchRow($result3); if($totalnewlinks>0){ $totalnewlinks = "$totalnewlinks"; } echo " - "._MD_GENERALSET.""; echo "

"; echo " - "._MD_ADDMODDELETE.""; echo "

"; echo " - "._MD_LINKSWAITING." ($totalnewlinks)"; echo "

"; echo " - "._MD_BROKENREPORTS." ($totalbrokenlinks)"; echo "

"; echo " - "._MD_MODREQUESTS." ($totalmodrequests)"; $result=$xoopsDB->query("select count(*) from ".$xoopsDB->prefix("mylinks_links")." where status>0"); list($numrows) = $xoopsDB->fetchRow($result); echo "

"; printf(_MD_THEREARE,$numrows); echo "
"; echo"
"; xoops_cp_footer(); } function listNewLinks() { global $xoopsDB, $xoopsConfig, $myts, $eh, $mytree; // List links waiting for validation $linkimg_array = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH."/modules/mylinks/images/shots/"); $result = $xoopsDB->query("select lid, cid, title, url, logourl, submitter from ".$xoopsDB->prefix("mylinks_links")." where status=0 order by date DESC"); $numrows = $xoopsDB->getRowsNum($result); xoops_cp_header(); echo "

"._MD_WEBLINKSCONF."

"; echo"" ."
"; echo "

"._MD_LINKSWAITING." ($numrows)


"; if ( $numrows > 0 ) { while(list($lid, $cid, $title, $url, $logourl, $submitterid) = $xoopsDB->fetchRow($result)) { $result2 = $xoopsDB->query("select description from ".$xoopsDB->prefix("mylinks_text")." where lid=$lid"); list($description) = $xoopsDB->fetchRow($result2); $title = $myts->makeTboxData4Edit($title); $url = $myts->makeTboxData4Edit($url); // $url = urldecode($url); // $logourl = $myts->makeTboxData4Edit($logourl); // $logourl = urldecode($logourl); $description = $myts->makeTareaData4Edit($description); $submitter = XoopsUser::getUnameFromId($submitterid); echo "
\n"; echo ""; echo "\n"; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "
"._MD_SUBMITTER."\n"; echo "$submitter"; echo "
"._MD_SITETITLE.""; echo ""; echo "
"._MD_SITEURL.""; echo ""; echo " [ "._MD_VISIT." ]"; echo "
"._MD_CATEGORYC.""; $mytree->makeMySelBox("title", "title", $cid); echo "
"._MD_DESCRIPTIONC."\n"; echo "\n"; echo "
"._MD_SHOTIMAGE."\n"; //echo "\n"; echo ""; echo "
"; $shotdir = "".XOOPS_URL."/modules/mylinks/images/shots/"; printf(_MD_SHOTMUST,$shotdir); echo "
\n"; echo "
"; echo ""; echo "
\n"; echo myTextForm("index.php?op=delNewLink&lid=$lid",_MD_DELETE); echo "

"; } } else { echo ""._MD_NOSUBMITTED.""; } echo"
"; xoops_cp_footer(); } function linksConfigMenu() { global $xoopsDB,$xoopsConfig, $myts, $eh, $mytree; // Add a New Main Category xoops_cp_header(); $linkimg_array = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH."/modules/mylinks/images/shots/"); echo "

"._MD_WEBLINKSCONF."

"; echo "" ."
"; echo "
\n"; echo "

"._MD_ADDMAIN."


"._MD_TITLEC."
"; echo ""._MD_IMGURL."


"; echo "\n"; echo ""; echo "
"; echo"
"; echo "
"; // Add a New Sub-Category $result=$xoopsDB->query("select count(*) from ".$xoopsDB->prefix("mylinks_cat").""); list($numrows)=$xoopsDB->fetchRow($result); if ( $numrows > 0 ) { echo"" ."
"; echo "
"; echo "

"._MD_ADDSUB."


"._MD_TITLEC." "._MD_IN." "; $mytree->makeMySelBox("title", "title"); # echo "
"._MD_IMGURL."
\n"; echo "

"; echo "
"; echo"
"; echo "
"; // If there is a category, add a New Link echo"" ."
"; echo "
\n"; echo "

"._MD_ADDNEWLINK."


\n"; echo "\n"; echo ""; echo "\n"; echo "\n"; $shotdir = "".XOOPS_URL."/modules/mylinks/images/shots/"; echo "\n"; echo "
"._MD_SITETITLE.""; echo ""; echo "
"._MD_SITEURL.""; echo ""; echo "
"._MD_CATEGORYC.""; $mytree->makeMySelBox("title", "title"); echo "
"._MD_DESCRIPTIONC."\n"; xoopsCodeTarea("description",60,8); xoopsSmilies("description"); //echo "\n"; echo "
"._MD_SHOTIMAGE."\n"; //echo ""; echo ""; echo "
"; printf(_MD_SHOTMUST,$shotdir); echo "
\n
"; echo ""; echo "\n"; echo "
"; echo"
"; echo "
"; // Modify Category echo"" ."
"; echo "

"._MD_MODCAT."


"; echo _MD_CATEGORYC; $mytree->makeMySelBox("title", "title"); echo "

\n"; echo "\n"; echo "\n"; echo "
"; echo"
"; echo "
"; } // Modify Link $result2 = $xoopsDB->query("select count(*) from ".$xoopsDB->prefix("mylinks_links").""); list($numrows2) = $xoopsDB->fetchRow($result2); if ( $numrows2 > 0 ) { echo"" ."
"; echo "
\n"; echo "

"._MD_MODLINK."


\n"; echo _MD_LINKID."\n"; echo "\n"; echo "

\n"; echo "
\n"; echo"
"; } xoops_cp_footer(); } function modLink() { global $xoopsDB, $HTTP_GET_VARS, $myts, $eh, $mytree, $xoopsConfig; $linkimg_array = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH."/modules/mylinks/images/shots/"); $lid = $HTTP_GET_VARS['lid']; xoops_cp_header(); echo "

"._MD_WEBLINKSCONF."

"; echo"" ."
"; $result = $xoopsDB->query("select cid, title, url, logourl from ".$xoopsDB->prefix("mylinks_links")." where lid=$lid") or $eh->show("0013"); echo "

"._MD_MODLINK."


"; list($cid, $title, $url, $logourl) = $xoopsDB->fetchRow($result); $title = $myts->makeTboxData4Edit($title); $url = $myts->makeTboxData4Edit($url); // $url = urldecode($url); $logourl = $myts->makeTboxData4Edit($logourl); // $logourl = urldecode($logourl); $result2 = $xoopsDB->query("select description from ".$xoopsDB->prefix("mylinks_text")." where lid=$lid"); list($description)=$xoopsDB->fetchRow($result2); $GLOBALS['description'] = $myts->makeTareaData4Edit($description); echo ""; echo ""; echo ""; echo "\n"; echo "\n"; echo ""; echo "\n"; echo "\n"; $shotdir = "".XOOPS_URL."/modules/mylinks/images/shots/"; echo "\n"; echo "
"._MD_LINKID."$lid
"._MD_SITETITLE."
"._MD_SITEURL."
"._MD_DESCRIPTIONC.""; xoopsCodeTarea("description",60,8); xoopsSmilies("description"); //echo ""; echo "
"._MD_CATEGORYC.""; $mytree->makeMySelBox("title", "title", $cid); echo "
"._MD_SHOTIMAGE.""; //echo " echo ""; echo "
"; printf(_MD_SHOTMUST,$shotdir); echo "
"; echo "

\n"; echo ""; // echo " "; //echo " "; echo "\n"; echo "
\n"; echo myTextForm("index.php?op=delLink&lid=".$lid , _MD_DELETE); echo "\n"; echo myTextForm("index.php?op=linksConfigMenu", _MD_CANCEL); echo "
\n"; echo "
"; $result5=$xoopsDB->query("SELECT count(*) FROM ".$xoopsDB->prefix("mylinks_votedata")." WHERE lid = $lid"); list($totalvotes) = $xoopsDB->fetchRow($result5); echo "\n"; echo "\n"; // Show Registered Users Votes $result5=$xoopsDB->query("SELECT ratingid, ratinguser, rating, ratinghostname, ratingtimestamp FROM ".$xoopsDB->prefix("mylinks_votedata")." WHERE lid = $lid AND ratinguser >0 ORDER BY ratingtimestamp DESC"); $votes = $xoopsDB->getRowsNum($result5); echo "\n"; echo "\n"; if ($votes == 0){ echo "\n"; } $x=0; $colorswitch="dddddd"; while(list($ratingid, $ratinguser, $rating, $ratinghostname, $ratingtimestamp)=$xoopsDB->fetchRow($result5)) { // $ratingtimestamp = formatTimestamp($ratingtimestamp); //Individual user information $result2=$xoopsDB->query("SELECT rating FROM ".$xoopsDB->prefix("mylinks_votedata")." WHERE ratinguser = '$ratinguser'"); $uservotes = $xoopsDB->getRowsNum($result2); $useravgrating = 0; while ( list($rating2) = $xoopsDB->fetchRow($result2) ) { $useravgrating = $useravgrating + $rating2; } $useravgrating = $useravgrating / $uservotes; $useravgrating = number_format($useravgrating, 1); $ratingusername = XoopsUser::getUnameFromId($ratinguser); echo "\n"; $x++; if ( $colorswitch == "dddddd" ) { $colorswitch="ffffff"; } else { $colorswitch="dddddd"; } } // Show Unregistered Users Votes $result5=$xoopsDB->query("SELECT ratingid, rating, ratinghostname, ratingtimestamp FROM ".$xoopsDB->prefix("mylinks_votedata")." WHERE lid = $lid AND ratinguser = 0 ORDER BY ratingtimestamp DESC"); $votes = $xoopsDB->getRowsNum($result5); echo "\n"; echo "
"; if ( $votes == 0 ) { echo ""; } $x=0; $colorswitch="dddddd"; while ( list($ratingid, $rating, $ratinghostname, $ratingtimestamp)=$xoopsDB->fetchRow($result5) ) { $formatted_date = formatTimestamp($ratingtimestamp); echo ""; $x++; if ( $colorswitch == "dddddd" ) { $colorswitch="ffffff"; } else { $colorswitch="dddddd"; } } echo "\n"; echo "
"; printf(_MD_TOTALVOTES,$totalvotes); echo "



"; printf(_MD_USERTOTALVOTES,$votes); echo "

" ._MD_USER." " ._MD_IP." " ._MD_RATING." " ._MD_USERAVG." " ._MD_TOTALRATE." " ._MD_DATE." " ._MD_DELETE."
" ._MD_NOREGVOTES."
".$ratingusername."".$ratinghostname."$rating".$useravgrating."".$uservotes."".$ratingtimestamp."".myTextForm("index.php?op=delVote&lid=$lid&rid=$ratingid", "X")."


"; printf(_MD_ANONTOTALVOTES,$votes); echo "


" ._MD_IP." " ._MD_RATING." " ._MD_DATE." " ._MD_DELETE."
" ._MD_NOUNREGVOTES."
$ratinghostname$rating$formatted_date".myTextForm("index.php?op=delVote&lid=$lid&rid=$ratingid", "X")."
 
\n"; echo"
"; xoops_cp_footer(); } function delVote() { global $xoopsDB, $HTTP_GET_VARS, $eh; $rid = $HTTP_GET_VARS['rid']; $lid = $HTTP_GET_VARS['lid']; $sql = sprintf("DELETE FROM %s WHERE ratingid = %u", $xoopsDB->prefix("mylinks_votedata"), $rid); $xoopsDB->query($sql) or $eh->show("0013"); updaterating($lid); redirect_header("index.php",1,_MD_VOTEDELETED); exit(); } function listBrokenLinks() { global $xoopsDB, $eh; $result = $xoopsDB->query("select * from ".$xoopsDB->prefix("mylinks_broken")." group by lid order by reportid DESC"); $totalbrokenlinks = $xoopsDB->getRowsNum($result); xoops_cp_header(); echo "

"._MD_WEBLINKSCONF."

"; echo"" ."
"; echo "

"._MD_BROKENREPORTS." ($totalbrokenlinks)


"; if ( $totalbrokenlinks == 0 ) { echo _MD_NOBROKEN; } else { echo "
"._MD_IGNOREDESC."
"._MD_DELETEDESC."



"; $colorswitch="dddddd"; echo ""; echo " "; while ( list($reportid, $lid, $sender, $ip)=$xoopsDB->fetchRow($result) ) { $result2 = $xoopsDB->query("select title, url, submitter from ".$xoopsDB->prefix("mylinks_links")." where lid=$lid"); if ( $sender != 0 ) { $result3 = $xoopsDB->query("select uname, email from ".$xoopsDB->prefix("users")." where uid=$sender"); list($uname, $email)=$xoopsDB->fetchRow($result3); } list($title, $url, $ownerid)=$xoopsDB->fetchRow($result2); // $url=urldecode($url); $result4 = $xoopsDB->query("select uname, email from ".$xoopsDB->prefix("users")." where uid='$ownerid'"); list($owner, $owneremail)=$xoopsDB->fetchRow($result4); echo ""; if ( $email=='' ) { echo ""; if ( $owneremail == '' ) { echo "\n"; if ( $colorswitch == "#dddddd" ) { $colorswitch="#ffffff"; } else { $colorswitch="#dddddd"; } } echo "
Link Name " ._MD_REPORTER." " ._MD_LINKSUBMITTER." " ._MD_IGNORE." " ._EDIT." " ._MD_DELETE."
$title".$sender." (".$ip.")"; } else { echo "".$uname." (".$ip.")"; } echo "".$owner.""; } else { echo "".$owner.""; } echo "\n"; echo myTextForm("index.php?op=ignoreBrokenLinks&lid=$lid" , "X"); echo "\n"; echo myTextForm("index.php?op=modLink&lid=$lid" , "X"); echo "\n"; echo myTextForm("index.php?op=delBrokenLinks&lid=$lid" , "X"); echo "
"; } echo"
"; xoops_cp_footer(); } function delBrokenLinks() { global $xoopsDB, $HTTP_GET_VARS, $eh; $lid = $HTTP_GET_VARS['lid']; $sql = sprintf("DELETE FROM %s WHERE lid = %u", $xoopsDB->prefix("mylinks_broken"), $lid); $xoopsDB->query($sql) or $eh->show("0013"); $sql = sprintf("DELETE FROM %s WHERE lid = %u", $xoopsDB->prefix("mylinks_links"), $lid); $xoopsDB->query($sql) or $eh->show("0013"); redirect_header("index.php",1,_MD_LINKDELETED); exit(); } function ignoreBrokenLinks() { global $xoopsDB, $HTTP_GET_VARS, $eh; $sql = sprintf("DELETE FROM %s WHERE lid = %u", $xoopsDB->prefix("mylinks_broken"), $HTTP_GET_VARS['lid']); $xoopsDB->query($sql) or $eh->show("0013"); redirect_header("index.php",1,_MD_BROKENDELETED); exit(); } function listModReq() { global $xoopsDB, $myts, $eh, $mytree, $xoopsModuleConfig; $result = $xoopsDB->query("select requestid,lid,cid,title,url,logourl,description,modifysubmitter from ".$xoopsDB->prefix("mylinks_mod")." order by requestid"); $totalmodrequests = $xoopsDB->getRowsNum($result); xoops_cp_header(); echo "

"._MD_WEBLINKSCONF."

"; echo"" ."
"; echo "

"._MD_USERMODREQ." ($totalmodrequests)


"; if ( $totalmodrequests > 0 ) { echo "
"; $lookup_lid = array(); while ( list($requestid, $lid, $cid, $title, $url, $logourl, $description, $submitterid)=$xoopsDB->fetchRow($result) ) { $lookup_lid[$requestid] = $lid; $result2 = $xoopsDB->query("select cid, title, url, logourl, submitter from ".$xoopsDB->prefix("mylinks_links")." where lid=$lid"); list($origcid, $origtitle, $origurl, $origlogourl, $ownerid)=$xoopsDB->fetchRow($result2); $result2 = $xoopsDB->query("select description from ".$xoopsDB->prefix("mylinks_text")." where lid=$lid"); list($origdescription) = $xoopsDB->fetchRow($result2); $result7 = $xoopsDB->query("select uname, email from ".$xoopsDB->prefix("users")." where uid='$submitterid'"); $result8 = $xoopsDB->query("select uname, email from ".$xoopsDB->prefix("users")." where uid='$ownerid'"); $cidtitle=$mytree->getPathFromId($cid, "title"); $origcidtitle=$mytree->getPathFromId($origcid, "title"); list($submitter, $submitteremail)=$xoopsDB->fetchRow($result7); list($owner, $owneremail)=$xoopsDB->fetchRow($result8); $title = $myts->makeTboxData4Show($title); $url = $myts->makeTboxData4Show($url); // $url = urldecode($url); // use original image file to prevent users from changing screen shots file $origlogourl = $myts->makeTboxData4Show($origlogourl); $logourl = $origlogourl; // $logourl = urldecode($logourl); $description = $myts->makeTareaData4Show($description, 0); $origurl = $myts->makeTboxData4Show($origurl); // $origurl = urldecode($origurl); // $origlogourl = urldecode($origlogourl); $origdescription = $myts->makeTareaData4Show($origdescription, 0); if ( $owner == "" ) { $owner="administration"; } echo "
"._MD_ORIGINAL."
"._MD_DESCRIPTIONC."
$origdescription
"._MD_SITETITLE."$origtitle
"._MD_SITEURL."".$origurl."
"._MD_CATEGORYC."$origcidtitle
"._MD_SHOTIMAGE.""; if ( $xoopsModuleConfig['useshots'] && !empty($origlogourl) ) { echo ""; } else { echo " "; } echo "
"._MD_PROPOSED."
"._MD_DESCRIPTIONC."
$description
"._MD_SITETITLE."$title
"._MD_SITEURL."".$url."
"._MD_CATEGORYC."$cidtitle
"._MD_SHOTIMAGE.""; if ( $xoopsModuleConfig['useshots'] == 1 && !empty($logourl) ) { echo "\"/\""; } else { echo " "; } echo "
"; if ( $submitteremail == "" ) { echo ""; } else { echo ""; } if ( $owneremail == "" ) { echo ""; } else { echo ""; } echo "\n"; echo "
"._MD_SUBMITTER."$submitter"._MD_SUBMITTER."".$submitter.""._MD_OWNER."".$owner.""._MD_OWNER."".$owner."\n"; echo "
\n"; echo myTextForm("index.php?op=changeModReq&requestid=$requestid" , _MD_APPROVE); echo "\n"; echo myTextForm("index.php?op=modLink&lid=$lookup_lid[$requestid]", _EDIT); echo "\n"; echo myTextForm("index.php?op=ignoreModReq&requestid=$requestid", _MD_IGNORE); echo "
\n"; echo "


"; } echo "
"; } else { echo _MD_NOMODREQ; } echo"
"; xoops_cp_footer(); } function changeModReq() { global $xoopsDB, $HTTP_GET_VARS, $eh, $myts; $requestid = $HTTP_GET_VARS['requestid']; $query = "select lid, cid, title, url, logourl, description from ".$xoopsDB->prefix("mylinks_mod")." where requestid=".$requestid.""; $result = $xoopsDB->query($query); while ( list($lid, $cid, $title, $url, $logourl, $description)=$xoopsDB->fetchRow($result) ) { if ( get_magic_quotes_runtime() ) { $title = stripslashes($title); $url = stripslashes($url); $logourl = stripslashes($logourl); $description = stripslashes($description); } $title = addslashes($title); $url = addslashes($url); $logourl = addslashes($logourl); $description = addslashes($description); $sql= sprintf("UPDATE %s SET cid = %u, title = '%s', url = '%s', logourl = '%s', status = 2, date = %u WHERE lid = %u", $xoopsDB->prefix("mylinks_links"), $cid, $title, $url, $logourl, time(), $lid); $xoopsDB->query($sql) or $eh->show("0013"); $sql = sprintf("UPDATE %s SET description = '%s' WHERE lid = %u", $xoopsDB->prefix("mylinks_text"), $description, $lid); $xoopsDB->query($sql) or $eh->show("0013"); $sql = sprintf("DELETE FROM %s WHERE requestid = %u", $xoopsDB->prefix("mylinks_mod"), $requestid); $xoopsDB->query($sql) or $eh->show("0013"); } redirect_header("index.php",1,_MD_DBUPDATED); exit(); } function ignoreModReq() { global $xoopsDB, $HTTP_GET_VARS, $eh; $sql = sprintf("DELETE FROM %s WHERE requestid = %u", $xoopsDB->prefix("mylinks_mod"), $HTTP_GET_VARS['requestid']); $xoopsDB->query($sql) or $eh->show("0013"); redirect_header("index.php",1,_MD_MODREQDELETED); exit(); } function modLinkS() { global $xoopsDB, $HTTP_POST_VARS, $myts, $eh; $cid = $HTTP_POST_VARS["cid"]; if ( ($HTTP_POST_VARS["url"]) || ($HTTP_POST_VARS["url"]!="") ) { // $url = $myts->formatURL($HTTP_POST_VARS["url"]); // $url = urlencode($url); $url = $myts->makeTboxData4Save($HTTP_POST_VARS["url"]); } $logourl = $myts->makeTboxData4Save($HTTP_POST_VARS["logourl"]); $title = $myts->makeTboxData4Save($HTTP_POST_VARS["title"]); $description = $myts->makeTareaData4Save($HTTP_POST_VARS["description"]); $xoopsDB->query("update ".$xoopsDB->prefix("mylinks_links")." set cid='$cid', title='$title', url='$url', logourl='$logourl', status=2, date=".time()." where lid=".$HTTP_POST_VARS['lid']."") or $eh->show("0013"); $xoopsDB->query("update ".$xoopsDB->prefix("mylinks_text")." set description='$description' where lid=".$HTTP_POST_VARS['lid']."") or $eh->show("0013"); redirect_header("index.php",1,_MD_DBUPDATED); exit(); } function delLink() { global $xoopsDB, $HTTP_GET_VARS, $eh, $xoopsModule; $sql = sprintf("DELETE FROM %s WHERE lid = %u", $xoopsDB->prefix("mylinks_links"), $HTTP_GET_VARS['lid']); $xoopsDB->query($sql) or $eh->show("0013"); $sql = sprintf("DELETE FROM %s WHERE lid = %u", $xoopsDB->prefix("mylinks_text"), $HTTP_GET_VARS['lid']); $xoopsDB->query($sql) or $eh->show("0013"); $sql = sprintf("DELETE FROM %s WHERE lid = %u", $xoopsDB->prefix("mylinks_votedata"), $HTTP_GET_VARS['lid']); $xoopsDB->query($sql) or $eh->show("0013"); // delete comments xoops_comment_delete($xoopsModule->getVar('mid'), $HTTP_GET_VARS['lid']); // delete notifications xoops_notification_deletebyitem ($xoopsModule->getVar('mid'), 'link', $HTTP_GET_VARS['lid']); redirect_header("index.php",1,_MD_LINKDELETED); exit(); } function modCat() { global $xoopsDB, $HTTP_POST_VARS, $myts, $eh, $mytree; $cid = $HTTP_POST_VARS["cid"]; xoops_cp_header(); echo "

"._MD_WEBLINKSCONF."

"; echo"" ."
"; echo "

"._MD_MODCAT."


"; $result=$xoopsDB->query("select pid, title, imgurl from ".$xoopsDB->prefix("mylinks_cat")." where cid=$cid"); list($pid,$title,$imgurl) = $xoopsDB->fetchRow($result); $title = $myts->makeTboxData4Edit($title); $imgurl = $myts->makeTboxData4Edit($imgurl); echo "
"._MD_TITLEC."

"._MD_IMGURLMAIN."


"; echo _MD_PARENT." "; $mytree->makeMySelBox("title", "title", $pid, 1, "pid"); // echo "

"; echo " "; echo "
"; echo"
"; xoops_cp_footer(); } function modCatS() { global $xoopsDB, $HTTP_POST_VARS, $myts, $eh; $cid = $HTTP_POST_VARS['cid']; $pid = $HTTP_POST_VARS['pid']; $title = $myts->makeTboxData4Save($HTTP_POST_VARS['title']); if (empty($title)) { redirect_header("index.php", 2, _MD_ERRORTITLE); } if ( ($HTTP_POST_VARS["imgurl"]) || ($HTTP_POST_VARS["imgurl"]!="") ) { $imgurl = $myts->makeTboxData4Save($HTTP_POST_VARS["imgurl"]); } $xoopsDB->query("update ".$xoopsDB->prefix("mylinks_cat")." set pid=$pid, title='$title', imgurl='$imgurl' where cid=$cid") or $eh->show("0013"); redirect_header("index.php",1,_MD_DBUPDATED); } function delCat() { global $xoopsDB, $HTTP_GET_VARS, $HTTP_POST_VARS, $eh, $mytree, $xoopsModule; $cid = isset($HTTP_POST_VARS['cid']) ? intval($HTTP_POST_VARS['cid']) : intval($HTTP_GET_VARS['cid']); $ok = isset($HTTP_POST_VARS['ok']) ? intval($HTTP_POST_VARS['ok']) : 0; if ( $ok == 1 ) { //get all subcategories under the specified category $arr=$mytree->getAllChildId($cid); $dcount=count($arr); for ( $i=0;$i<$dcount;$i++ ) { //get all links in each subcategory $result=$xoopsDB->query("select lid from ".$xoopsDB->prefix("mylinks_links")." where cid=".$arr[$i]."") or $eh->show("0013"); //now for each link, delete the text data and vote ata associated with the link while ( list($lid)=$xoopsDB->fetchRow($result) ) { $sql = sprintf("DELETE FROM %s WHERE lid = %u", $xoopsDB->prefix("mylinks_text"), $lid); $xoopsDB->query($sql) or $eh->show("0013"); $sql = sprintf("DELETE FROM %s WHERE lid = %u", $xoopsDB->prefix("mylinks_votedata"), $lid); $xoopsDB->query($sql) or $eh->show("0013"); $sql = sprintf("DELETE FROM %s WHERE lid = %u", $xoopsDB->prefix("mylinks_links"), $lid); $xoopsDB->query($sql) or $eh->show("0013"); xoops_comment_delete($xoopsModule->getVar('mid'), $lid); xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'link', $lid); } xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'category', $arr[$i]); //all links for each subcategory is deleted, now delete the subcategory data $sql = sprintf("DELETE FROM %s WHERE cid = %u", $xoopsDB->prefix("mylinks_cat"), $arr[$i]); $xoopsDB->query($sql) or $eh->show("0013"); } //all subcategory and associated data are deleted, now delete category data and its associated data $result=$xoopsDB->query("select lid from ".$xoopsDB->prefix("mylinks_links")." where cid=".$cid."") or $eh->show("0013"); while ( list($lid)=$xoopsDB->fetchRow($result) ) { $sql = sprintf("DELETE FROM %s WHERE lid = %u", $xoopsDB->prefix("mylinks_links"), $lid); $xoopsDB->query($sql) or $eh->show("0013"); $sql = sprintf("DELETE FROM %s WHERE lid = %u", $xoopsDB->prefix("mylinks_text"), $lid); $xoopsDB->query($sql) or $eh->show("0013"); $sql = sprintf("DELETE FROM %s WHERE lid = %u", $xoopsDB->prefix("mylinks_votedata"), $lid); $xoopsDB->query($sql) or $eh->show("0013"); // delete comments xoops_comment_delete($xoopsModule->getVar('mid'), $lid); // delete notifications xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'link', $lid); } $sql = sprintf("DELETE FROM %s WHERE cid = %u", $xoopsDB->prefix("mylinks_cat"), $cid); $xoopsDB->query($sql) or $eh->show("0013"); xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'category', $cid); redirect_header("index.php",1,_MD_CATDELETED); exit(); } else { xoops_cp_header(); xoops_confirm(array('op' => 'delCat', 'cid' => $cid, 'ok' => 1), 'index.php', _MD_WARNING); xoops_cp_footer(); } } function delNewLink() { global $xoopsDB, $HTTP_GET_VARS, $eh, $xoopsModule; $sql = sprintf("DELETE FROM %s WHERE lid = %u", $xoopsDB->prefix("mylinks_links"), $HTTP_GET_VARS['lid']); $xoopsDB->query($sql) or $eh->show("0013"); $sql = sprintf("DELETE FROM %s WHERE lid = %u", $xoopsDB->prefix("mylinks_text"), $HTTP_GET_VARS['lid']); $xoopsDB->query($sql) or $eh->show("0013"); // delete comments xoops_comment_delete($xoopsModule->getVar('mid'), $HTTP_GET_VARS['lid']); // delete notifications xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'link', $HTTP_GET_VARS['lid']); redirect_header("index.php",1,_MD_LINKDELETED); } function addCat() { global $xoopsDB, $HTTP_POST_VARS, $myts, $eh; $pid = $HTTP_POST_VARS["cid"]; $title = $myts->makeTboxData4Save($HTTP_POST_VARS["title"]); if (empty($title)) { redirect_header("index.php",2,_MD_ERRORTITLE); exit(); } if ( ($HTTP_POST_VARS["imgurl"]) || ($HTTP_POST_VARS["imgurl"]!="") ) { // $imgurl = $myts->formatURL($HTTP_POST_VARS["imgurl"]); // $imgurl = urlencode($imgurl); $imgurl = $myts->makeTboxData4Save($HTTP_POST_VARS["imgurl"]); } $newid = $xoopsDB->genId($xoopsDB->prefix("mylinks_cat")."_cid_seq"); $sql = sprintf("INSERT INTO %s (cid, pid, title, imgurl) VALUES (%u, %u, '%s', '%s')", $xoopsDB->prefix("mylinks_cat"), $newid, $pid, $title, $imgurl); $xoopsDB->query($sql) or $eh->show("0013"); if ($newid == 0) { $newid = $xoopsDB->getInsertId(); } global $xoopsModule; $tags = array(); $tags['CATEGORY_NAME'] = $title; $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $newid; $notification_handler =& xoops_gethandler('notification'); $notification_handler->triggerEvent('global', 0, 'new_category', $tags); redirect_header("index.php",1,_MD_NEWCATADDED); } function addLink() { global $xoopsConfig, $xoopsDB, $myts, $xoopsUser, $xoopsModule, $eh, $HTTP_POST_VARS; if ( ($HTTP_POST_VARS["url"]) || ($HTTP_POST_VARS["url"]!="") ) { // $url=$myts->formatURL($HTTP_POST_VARS["url"]); // $url = urlencode($url); $url = $myts->makeTboxData4Save($HTTP_POST_VARS["url"]); } $logourl = $myts->makeTboxData4Save($HTTP_POST_VARS["logourl"]); $title = $myts->makeTboxData4Save($HTTP_POST_VARS["title"]); $description = $myts->makeTareaData4Save($HTTP_POST_VARS["description"]); $submitter = $xoopsUser->uid(); $result = $xoopsDB->query("select count(*) from ".$xoopsDB->prefix("mylinks_links")." where url='$url'"); list($numrows) = $xoopsDB->fetchRow($result); $errormsg = ""; $error = 0; if ( $numrows > 0 ) { $errormsg .= "

"; $errormsg .= _MD_ERROREXIST."

"; $error = 1; } // Check if Title exist if ( $title == "" ) { $errormsg .= "

"; $errormsg .= _MD_ERRORTITLE."

"; $error =1; } // Check if Description exist if ( $description == "" ) { $errormsg .= "

"; $errormsg .= _MD_ERRORDESC."

"; $error =1; } if ( $error == 1 ) { xoops_cp_header(); echo $errormsg; xoops_cp_footer(); exit(); } if ( !empty($HTTP_POST_VARS['cid']) ) { $cid = $HTTP_POST_VARS['cid']; } else { $cid = 0; } $newid = $xoopsDB->genId($xoopsDB->prefix("mylinks_links")."_lid_seq"); $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); $xoopsDB->query($sql) or $eh->show("0013"); if ( $newid == 0 ) { $newid = $xoopsDB->getInsertId(); } $sql = sprintf("INSERT INTO %s (lid, description) VALUES (%u, '%s')", $xoopsDB->prefix("mylinks_text"), $newid, $description); $xoopsDB->query($sql) or $eh->show("0013"); $tags = array(); $tags['LINK_NAME'] = $title; $tags['LINK_URL'] = XOOPS_URL . '/modules/'. $xoopsModule->getVar('dirname') . '/singlelink.php?cid=' . $cid . '&lid=' . $newid; $sql = "SELECT title FROM " . $xoopsDB->prefix("mylinks_cat") . " WHERE cid=" . $cid; $result = $xoopsDB->query($sql); $row = $xoopsDB->fetchArray($result); $tags['CATEGORY_NAME'] = $row['title']; $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $cid; $notification_handler =& xoops_gethandler('notification'); $notification_handler->triggerEvent('global', 0, 'new_link', $tags); $notification_handler->triggerEvent('category', $cid, 'new_link', $tags); redirect_header("index.php?op=linksConfigMenu",1,_MD_NEWLINKADDED); } function approve() { global $xoopsConfig, $xoopsDB, $HTTP_POST_VARS, $myts, $eh; $lid = $HTTP_POST_VARS['lid']; $title = $HTTP_POST_VARS['title']; $cid = $HTTP_POST_VARS['cid']; if ( empty($cid) ) { $cid = 0; } $description = $HTTP_POST_VARS['description']; if (($HTTP_POST_VARS["url"]) || ($HTTP_POST_VARS["url"]!="")) { // $url=$myts->formatURL($HTTP_POST_VARS["url"]); // $url = urlencode($url); $url = $myts->makeTboxData4Save($HTTP_POST_VARS["url"]); } $logourl = $myts->makeTboxData4Save($HTTP_POST_VARS["logourl"]); $title = $myts->makeTboxData4Save($title); $description = $myts->makeTareaData4Save($description); $query = "update ".$xoopsDB->prefix("mylinks_links")." set cid='$cid', title='$title', url='$url', logourl='$logourl', status=1, date=".time()." where lid=".$lid.""; $xoopsDB->query($query) or $eh->show("0013"); $query = "update ".$xoopsDB->prefix("mylinks_text")." set description='$description' where lid=".$lid.""; $xoopsDB->query($query) or $eh->show("0013"); global $xoopsModule; $tags=array(); $tags['LINK_NAME'] = $title; $tags['LINK_URL'] = XOOPS_URL . '/modules/'. $xoopsModule->getVar('dirname') . '/singlelink.php?cid=' . $cid . '&lid=' . $lid; $sql = "SELECT title FROM " . $xoopsDB->prefix("mylinks_cat") . " WHERE cid=" . $cid; $result = $xoopsDB->query($sql); $row = $xoopsDB->fetchArray($result); $tags['CATEGORY_NAME'] = $row['title']; $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $cid; $notification_handler =& xoops_gethandler('notification'); $notification_handler->triggerEvent('global', 0, 'new_link', $tags); $notification_handler->triggerEvent('category', $cid, 'new_link', $tags); $notification_handler->triggerEvent('link', $lid, 'approve', $tags); redirect_header("index.php",1,_MD_NEWLINKADDED); } if(!isset($HTTP_POST_VARS['op'])) { $op = isset($HTTP_GET_VARS['op']) ? $HTTP_GET_VARS['op'] : 'main'; } else { $op = $HTTP_POST_VARS['op']; } switch ($op) { case "delNewLink": delNewLink(); break; case "approve": approve(); break; case "addCat": addCat(); break; case "addLink": addLink(); break; case "listBrokenLinks": listBrokenLinks(); break; case "delBrokenLinks": delBrokenLinks(); break; case "ignoreBrokenLinks": ignoreBrokenLinks(); break; case "listModReq": listModReq(); break; case "changeModReq": changeModReq(); break; case "ignoreModReq": ignoreModReq(); break; case "delCat": delCat(); break; case "modCat": modCat(); break; case "modCatS": modCatS(); break; case "modLink": modLink(); break; case "modLinkS": modLinkS(); break; case "delLink": delLink(); break; case "delVote": delVote(); break; case "linksConfigMenu": linksConfigMenu(); break; case "listNewLinks": listNewLinks(); break; case 'main': default: mylinks(); break; } ?>