<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
// www.bcoos.net 2006-09 1.0.2 GPL
//v1.3www.bcoos.net 2006-08 GPL
//v1.2 www.exoops.info 2006/03 GPL
// ------------------------------------------------------------------------- //
//                XOOPS - PHP Content Management System                      //
//                       <http://www.xoops.org/>                             //
// ------------------------------------------------------------------------- //
// Modified for EXOOPS by MAALBAK //
// 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("admin_header.php");
include("../cache/config.php");
include("../include/functions.php");
include_once(XOOPS_ROOT_PATH."/class/xoopstree.php");
include_once(XOOPS_ROOT_PATH."/class/module.errorhandler.php");
include_once(XOOPS_ROOT_PATH."/class/xoopscomments.php");
include_once(XOOPS_ROOT_PATH."/class/xoopslists.php");
$old_bigwidth = $mylinks_bigwidth;
$old_shotwidth = $mylinks_shotwidth;
$eh = new ErrorHandler;
$mytree = new XoopsTree($db->prefix("myalbum_cat"),"cid","pid");
function mylinks() {
   	global $db;
	xoops_cp_header();
	OpenTable();
	$result3 = $db->query("select count(*) from ".$db->prefix("myalbum_photos")." where status=0");
    	list($totalnewlinks) = $db->fetchRow($result3);
	if($totalnewlinks>0){
		$totalnewlinks = "<font color=\"#ff0000\"><b>$totalnewlinks</b></font>";
	}
	echo " - <a href=index.php?op=myLinksConfigAdmin>"._GENERALSETTINGS."</a>";
	echo "<br><br>";
	echo " - <a href=index.php?op=linksConfigMenu>"._ADDMODIFYDELETECATEGORIESFILES."</a>";
	echo "<br><br>";
	echo " - <a href=index.php?op=listNewLinks>"._CONTENTWAITING." ($totalnewlinks)</a>";
	echo "<br><br>";
	echo " - <a href=batch.php>"._MD_BATCHUPLOAD."</a>";
	$result=$db->query("select count(*) from ".$db->prefix("myalbum_photos")." where status>0");
        list($numrows) = $db->fetchRow($result);
	echo "<br><br><div align=\"center\">";
	printf(_MD_THEREAREADMIN,$numrows);	echo "</div>";
    	CloseTable();
	xoops_cp_footer();
}
function listNewLinks(){
	global $db, $bcoosConfig, $myts, $eh, $mytree;
	$mytree = new XoopsTree($db->prefix("myalbum_cat"),"cid","pid");
  	$result = $db->query("select lid, cid, title, submitter from ".$db->prefix("myalbum_photos")." where status=0 order by date DESC");
   	$numrows = $db->getRowsNum($result);
	xoops_cp_header();
   	echo "<h4>"._CONTENTWAITING."&nbsp;($numrows)</h4><br>";
   	if ($numrows>0) {
		while(list($lid, $cid, $title, $submitterid) = $db->fetchRow($result)) {
			OpenTable();
			$result2 = $db->query("select description from ".$db->prefix("myalbum_text")." where lid=$lid");
			list($description) = $db->fetchRow($result2);
			$title = $myts->makeTboxData4Edit($title);
			$description = $myts->makeTareaData4Edit($description);
			$submitter = XoopsUser::getUnameFromId($submitterid);
			$cat = $mytree->getNicePathFromId($cid, "title", "../viewcat.php?");
			print "<b>Title:</b> <a href='photo.php?lid=$lid'>$title</a><br />
			<b>Description:</b> $description<br />
			<b>Category:</b> $cat<br />
			<b>Submitter:</b> $submitter";
			CloseTable();
	//		echo myTextForm("index.php?op=delNewLink&lid=$lid",_DELETE);
		}
   	} else {
		echo ""._NONEWSUBMITTED."";
	}
	xoops_cp_footer();
}
function linksConfigMenu(){
	global $db,$bcoosConfig, $myts, $eh, $mytree;
// Add a New Main Category
	xoops_cp_header();
    	OpenTable();
   	echo "<form method=post action=index.php>\n";
    	echo "<h4>"._ADDMAINCATEGORY."</h4><br>"._TITLE.':'."<input type=text class=text name=title size=30 maxlength=50><br /> <br />";
	echo ""._IMGURL."<br><input type=\"text\" class=text name=\"imgurl\" size=\"100\" maxlength=\"150\" value=\"http://\"><br><br>";
	echo "<input type=hidden name=cid value=0>\n";
	echo "<input type=hidden name=op value=addCat>";
	echo "<input type=submit class=button value="._MD_ADD."><br></form>";
    	CloseTable();
    	echo "<br>";
// Add a New Sub-Category
    	$result=$db->query("select count(*) from ".$db->prefix("myalbum_cat")."");
	list($numrows)=$db->fetchRow($result);
    	if ($numrows>0) {
		OpenTable();
    		echo "<form method=post action=index.php>";
    		echo "<h4>"._ADDSUBCATEGORY."</h4><br />"._TITLE.':'."<input type=text class=text name=title size=30 maxlength=50>&nbsp;"._IN."&nbsp;";
		$mytree->makeMySelBox("title", "title");
#		echo "<br>"._IMGURL."<br><input type=\"text\" name=\"imgurl\" size=\"100\" maxlength=\"150\">\n";
    		echo "<input type=hidden name=op value=addCat><br><br>";
		echo "<input type=submit class=button value="._MD_ADD."><br></form>";
		CloseTable();
		echo "<br>";
// Modify Category
    		OpenTable();
    		echo "
    		</center><form method=post action=index.php>
    		<h4>"._MODIFYCATEGORY."</h4><br>";
    		echo _CATEGORY.': ';
    		$mytree->makeMySelBox("title", "title");
    		echo "<br><br>\n";
    		echo "<input type=hidden name=op value=modCat>\n";
    		echo "<input type=submit class=button value="._MODIFY.">\n";
		echo "</form>";
		CloseTable();
		echo "<br>";
    	}
// Modify Link
    	$result2 = $db->query("select count(*) from ".$db->prefix("myalbum_photos")."");
    	list($numrows2) = $db->fetchRow($result2);
    	if ($numrows2>0) {
    		OpenTable();
    		echo "<form method=get action=\"photo.php\">\n";
    		echo "<h4>"._MODIFY."</h4><br>\n";
    		echo _CONTENTID."<input type=text class=text name=lid size=12 maxlength=11>\n";
		echo "<input type=hidden name=fct value=mylinks>\n";
    		echo "<input type=hidden name=op value=modLink><br><br>\n";
		echo "<input type=submit class=button value="._MODIFY."></form>\n";
		CloseTable();
    	}
	xoops_cp_footer();
}
function modLink() {
   	global $db, $_GET, $myts, $eh, $mytree, $bcoosConfig;
    	$lid = $_GET['lid'];
	xoops_cp_header();
    	OpenTable();
    	$result = $db->query("select cid, title, url, email, logourl from ".$db->prefix("mylinks_links")." where lid=$lid") or $eh->show("0013");
    	echo "<h4>"._MODIFY."</h4><br>";
    	list($cid, $title, $url, $email, $logourl) = $db->fetchRow($result);
    	$title = $myts->makeTboxData4Edit($title);
    	$url = $myts->makeTboxData4Edit($url);
//   	$url = urldecode($url);
    	$email = $myts->makeTboxData4Edit($email);
    	$logourl = $myts->makeTboxData4Edit($logourl);
//  	$logourl = urldecode($logourl);
    	$result2 = $db->query("select description from ".$db->prefix("mylinks_text")." where lid=$lid");
    	list($description)=$db->fetchRow($result2);
    	$description = $myts->makeTareaData4Edit($description);
	echo "<table>";
    	echo "<form method=post action=index.php>";
    	echo "<tr><td>"._CONTENTID."</td><td><b>$lid</b></td></tr>";
    	echo "<tr><td>"._SITETITLE."</td><td><input type=text class=text name=title value=\"$title\" size=50 maxlength=100></input></td></tr>\n";
    	echo "<tr><td>"._SITEURL."</td><td><input type=text class=text name=url value=\"$url\" size=50 maxlength=100></input></td></tr>\n";
    	echo "<tr><td>"._EMAIL.':'."</td><td><input type=text class=text name=email value=\"$email\" size=50 maxlength=60></input></td></tr>\n";
    	echo "<tr><td valign=\"top\">"._DESCRIPTION.':'."</td><td><textarea name=description cols=60 rows=5>$description</textarea></td></tr>";
    	echo "<tr><td>"._CATEGORY.': '."</td><td>";
    	$mytree->makeMySelBox("title", "title", $cid);
	echo "</td></tr>\n";
	echo "<tr><td>"._SHOTIMAGE."</td><td><input type=text class=text name=logourl value=\"$logourl\" size=\"50\" maxlength=\"60\"></input></td></tr>\n";
	$shotdir = "<b>".XOOPS_URL."/modules/mylinks/images/shots/</b>";
	echo "<tr><td></td><td>";
	printf(_MD_SHOTMUST,$shotdir);
	echo "</td></tr>\n";
	echo "</table>";
    	echo "<br><BR><input type=hidden name=lid value=$lid></input>\n";
    	echo "<input type=hidden name=op value=modLinkS><input type=submit class=button value="._MODIFY.">";
		// echo "&nbsp;<input type=button value="._DELETE." onclick=\"javascript:location='index.php?op=delLink&lid=".$lid."'\">";
		//echo "&nbsp;<input type=button value="._CANCEL." onclick=\"javascript:history.go(-1)\">";
		echo "</form>\n";
		echo "<table><tr><td>\n";
		echo myTextForm("index.php?op=delLink&lid=".$lid , _DELETE);
		echo "</td><td>\n";
		echo myTextForm("index.php?op=linksConfigMenu", _CANCEL);
		echo "</td></tr></table>\n";
    	echo "<hr>";
    	$result5=$db->query("SELECT count(*) FROM ".$db->prefix("mylinks_votedata")." WHERE lid = $lid");
    	list($totalvotes) = $db->fetchRow($result5);
    	echo "<table valign=top width=100%>\n";
    	echo "<tr><td colspan=7><b>";
	printf(_MD_TOTALVOTES,$totalvotes);
	echo "</b><br><br></td></tr>\n";
        // Show Registered Users Votes
    	$result5=$db->query("SELECT ratingid, ratinguser, rating, ratinghostname, ratingtimestamp FROM ".$db->prefix("mylinks_votedata")." WHERE lid = $lid AND ratinguser >0 ORDER BY ratingtimestamp DESC");
    	$votes = $db->getRowsNum($result5);
    	echo "<tr><td colspan=7><br><br><b>";
	printf(_REGISTEREDUSERSTOTALVOTES,$votes);
	echo "</b><br><br></td></tr>\n";
    	echo "<tr><td><b>" ._USER."  </b></td><td><b>" ._IPADDRESS."  </b></td><td><b>" ._RATING."  </b></td><td><b>" ._USEAVGRATING."  </b></td><td><b>" ._TOTALRATINGS."  </b></td><td><b>" ._DATE."  </b></td><td align=\"center\"><b>" ._DELETE."</b></td></tr>\n";
    	if ($votes == 0){
	 	echo "<tr><td align=\"center\" colspan=\"7\">" ._NOREGISTEREDVOTES."<br></td></tr>\n";
    	}
    	$x=0;
    	$colorswitch="dddddd";
    	while(list($ratingid, $ratinguser, $rating, $ratinghostname, $ratingtimestamp)=$db->fetchRow($result5)) {
    	//	$ratingtimestamp = formatTimestamp($ratingtimestamp);
    	//Individual user information
    		$result2=$db->query("SELECT rating FROM ".$db->prefix("mylinks_votedata")." WHERE ratinguser = '$ratinguser'");
        	$uservotes = $db->getRowsNum($result2);
        	$useravgrating = 0;
        	while(list($rating2) = $db->fetchRow($result2)){
			$useravgrating = $useravgrating + $rating2;
		}
        	$useravgrating = $useravgrating / $uservotes;
        	$useravgrating = number_format($useravgrating, 1);
		$ratingusername = XoopsUser::getUnameFromId($ratinguser);
        	echo "<tr><td bgcolor=\"".$colorswitch."\">".$ratingusername."</td><td bgcolor=\"$colorswitch\">".$ratinghostname."</td><td bgcolor=\"$colorswitch\">$rating</td><td bgcolor=\"$colorswitch\">".$useravgrating."</td><td bgcolor=\"$colorswitch\">".$uservotes."</td><td bgcolor=\"$colorswitch\">".$ratingtimestamp."</td><td bgcolor=\"$colorswitch\" align=\"center\"><b><a href=index.php?op=delVote&lid=$lid&rid=$ratingid>X</a></b></td></tr>\n";
    		$x++;
    		if ($colorswitch=="dddddd"){
			$colorswitch="ffffff";
    		} else {
			$colorswitch="dddddd";
		}
    	}
	// Show Unregistered Users Votes
    	$result5=$db->query("SELECT ratingid, rating, ratinghostname, ratingtimestamp FROM ".$db->prefix("mylinks_votedata")." WHERE lid = $lid AND ratinguser = 0 ORDER BY ratingtimestamp DESC");
    	$votes = $db->getRowsNum($result5);
    	echo "<tr><td colspan=7><b><br><br>";
	printf(_ANONYMOUSUSERTOTALVOTES,$votes);
	echo "</b><br><br></td></tr>\n";
    	echo "<tr><td colspan=2><b>" ._IPADDRESS."  </b></td><td colspan=3><b>" ._RATING."  </b></td><td><b>" ._DATE."  </b></b></td><td align=\"center\"><b>" ._DELETE."</b></td><br></tr>";
    	if ($votes == 0) {
		echo "<tr><td colspan=\"7\" align=\"center\">" ._NOUNREGISTEREDUSERVOTES."<br></td></tr>";
    	}
    	$x=0;
    	$colorswitch="dddddd";
    	while(list($ratingid, $rating, $ratinghostname, $ratingtimestamp)=$db->fetchRow($result5)) {
    		$formatted_date = formatTimestamp($ratingtimestamp);
        	echo "<td colspan=\"2\" bgcolor=\"$colorswitch\">$ratinghostname</td><td colspan=\"3\" bgcolor=\"$colorswitch\">$rating</td><td bgcolor=\"$colorswitch\">$formatted_date</td><td bgcolor=\"$colorswitch\" aling=\"center\"><b><a href=index.php?op=delVote&lid=$lid&rid=$ratingid>X</a></b></td></tr>";
    		$x++;
    		if ($colorswitch=="dddddd") {
			$colorswitch="ffffff";
    		} else {
			$colorswitch="dddddd";
		}
    	}
    	echo "<tr><td colspan=\"6\">&nbsp;<br></td></tr>\n";
    	echo "</table>\n";
    	CloseTable();
    	xoops_cp_footer();
}
function delVote() {
    	global $db, $_GET, $eh;
    	$rid = $_GET['rid'];
    	$lid = $_GET['lid'];
    	$query = "delete from ".$db->prefix("mylinks_votedata")." where ratingid=$rid";
    	$db->query($query) or $eh->show("0013");
    	updaterating($lid);
    	redirect_header("index.php",1,_VOTEDATADELETED);
    	exit();
}
function listBrokenLinks() {
    	global $db, $eh;
    	$result = $db->query("select * from ".$db->prefix("mylinks_broken")." group by lid order by reportid DESC");
    	$totalbrokenlinks = $db->getRowsNum($result);
	xoops_cp_header();
	OpenTable();
	echo "<h4>"._BROKENFILEREPORTS." ($totalbrokenlinks)</h4><br>";
    	if ($totalbrokenlinks==0) {
    		echo _NOBROKENREPORTS;
    	} else {
		echo "<center>
    "._ONLYDELETEREPORT."<br>
    "._DELETEDATAANDREPORT."</center><br><br><br>";
        	$colorswitch="dddddd";
		echo "<table align=\"center\" width=\"90%\">";
        	echo "
        	<tr>
          	<td><b>Link Name</b></td>
          	<td><b>" ._REPORTER."</b></td>
          	<td><b>" ._MD_LINKSUBMITTER."</b></td>
          	<td><b>" ._IGNORE."</b></td>
          	<td><b>" ._DELETE."</b></td>
        	</tr>";
        	while(list($reportid, $lid, $sender, $ip)=$db->fetchRow($result)){
    			$result2 = $db->query("select title, url, submitter from ".$db->prefix("mylinks_links")." where lid=$lid");
			if ($sender != 0) {
				$result3 = $db->query("select uname, email from ".$db->prefix("users")." where uid=$sender");
				list($uname, $email)=$db->fetchRow($result3);
			}
    			list($title, $url, $ownerid)=$db->fetchRow($result2);
//			$url=urldecode($url);
    			$result4 = $db->query("select uname, email from ".$db->prefix("users")." where uid='$ownerid'");
    			list($owner, $owneremail)=$db->fetchRow($result4);
    			echo "<tr><td bgcolor=$colorswitch><a href=$url>$title</a></td>";
    			if ($email=='') { echo "<td bgcolor=\"".$colorswitch."\">".$sender." (".$ip.")";
			} else {
				echo "<td bgcolor=\"".$colorswitch."\"><a href=\"mailto:".$email."\">".$uname."</a> (".$ip.")";
			}
    			echo "</td>";
    			if ($owneremail=='') {
				echo "<td bgcolor=\"".$colorswitch."\">".$owner."";
			} else { echo "<td bgcolor=\"".$colorswitch."\"><a href=\"mailto:".$owneremail."\">".$owner."</a>";
			}
			echo "</td><td bgcolor='$colorswitch' align='center'>\n";
			echo myTextForm("index.php?op=ignoreBrokenLinks&lid=$lid" , "X");
			echo "</td>";
			echo "<td align='center' bgcolor='$colorswitch'>\n";
			echo myTextForm("index.php?op=delBrokenLinks&lid=$lid" , "X");
			echo "</td></tr>\n";
    			if ($colorswitch == "#dddddd") {
				$colorswitch="#ffffff";
			} else {
				$colorswitch="#dddddd";
			}
    		}
		echo "</table>";
    	}
	CloseTable();
	xoops_cp_footer();
}
function delBrokenLinks() {
    	global $db, $_GET, $eh;
    	$lid = $_GET['lid'];
    	$query = "delete from ".$db->prefix("mylinks_broken")." where lid=$lid";
    	$db->query($query) or $eh->show("0013");
    	$query = "delete from ".$db->prefix("mylinks_links")." where lid=$lid";
    	$db->query($query) or $eh->show("0013");
    	redirect_header("index.php",1,_CONTENTDELETED);
	exit();
}
function ignoreBrokenLinks() {
    	global $db, $_GET, $eh;
    	$query = "delete from ".$db->prefix("mylinks_broken")." where lid=".$_GET['lid']."";
    	$db->query($query) or $eh->show("0013");
    	redirect_header("index.php",1,_BROKENFILEREPORTDELETED);
	exit();
}
function listModReq() {
    	global $db, $myts, $eh, $mytree, $mylinks_shotwidth, $mylinks_useshots;
    	$result = $db->query("select * from ".$db->prefix("mylinks_mod")." order by requestid");
    	$totalmodrequests = $db->getRowsNum($result);
	xoops_cp_header();
	OpenTable();
    	echo "<h4>"._USERMODIFICATIONREQUEST." ($totalmodrequests)</h4><br>";
	if($totalmodrequests>0){
    		echo "<table width=95%><tr><td>";
    		while(list($requestid, $lid, $cid, $title, $url, $email, $logourl, $description, $submitterid)=$db->fetchRow($result)) {
			$result2 = $db->query("select cid, title, url, email, logourl, submitter from ".$db->prefix("mylinks_links")." where lid=$lid");
			list($origcid, $origtitle, $origurl, $origemail, $origlogourl, $ownerid)=$db->fetchRow($result2);
			$result2 = $db->query("select description from ".$db->prefix("mylinks_text")." where lid=$lid");
			list($origdescription) = $db->fetchRow($result2);
			$result7 = $db->query("select uname, email from ".$db->prefix("users")." where uid='$submitterid'");
			$result8 = $db->query("select uname, email from ".$db->prefix("users")." where uid='$ownerid'");
			$cidtitle=$mytree->getPathFromId($cid, "title");
			$origcidtitle=$mytree->getPathFromId($origcid, "title");
			list($submitter, $submitteremail)=$db->fetchRow($result7);
			list($owner, $owneremail)=$db->fetchRow($result8);
			$title = $myts->makeTboxData4Show($title);
    			$url = $myts->makeTboxData4Show($url);
//			$url = urldecode($url);
    			$email = $myts->makeTboxData4Show($email);
// 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);
    			$origurl = $myts->makeTboxData4Show($origurl);
//			$origurl = urldecode($origurl);
    			$origemail = $myts->makeTboxData4Show($origemail);
//			$origlogourl = urldecode($origlogourl);
    			$origdescription = $myts->makeTareaData4Show($origdescription);
    			if ($owner=="") {
				$owner="administration";
			}
    			echo "<table border=1 bordercolor=black cellpadding=5 cellspacing=0 align=center width=450><tr><td>
    	   		<table width=100% bgcolor=dddddd>
    	     		<tr>
    	       		<td valign=top width=45%><b>"._ORIGINAL."</b></td>
	       		<td rowspan=14 valign=top align=left><br>"._DESCRIPTION.':'."<br>$origdescription</td>
    	     		</tr>
    	     		<tr><td valign=top width=45%>"._SITETITLE."$origtitle</td></tr>
    	     		<tr><td valign=top width=45%>"._SITEURL."".$origurl."</td></tr>
	     		<tr><td valign=top width=45%>"._CATEGORY.': '."$origcidtitle</td></tr>
	     		<tr><td valign=top width=45%>"._EMAIL.':'."$origemail</td></tr>
	     		<tr><td valign=top width=45%>"._SHOTIMAGE."";
			if ( $mylinks_useshots && !empty($origlogourl) ) {
				echo "<img src=\"".XOOPS_URL."/modules/mylinks/images/shots/".$origlogourl."\" width=\"".$mylinks_shotwidth."\" />";
			} else {
				echo "&nbsp;";
			}
			echo "</td></tr>
    	   		</table></td></tr><tr><td>
    	   		<table width=100%>
    	     		<tr>
    	       		<td valign=top width=45%><b>"._PROPOSED."</b></td>
    	       		<td rowspan=14 valign=top align=left><br>"._DESCRIPTION.':'."<br>$description</td>
    	     		</tr>
    	     		<tr><td valign=top width=45%>"._SITETITLE."$title</td></tr>
    	     		<tr><td valign=top width=45%>"._SITEURL."".$url."</td></tr>
	     		<tr><td valign=top width=45%>"._CATEGORY.': '."$cidtitle</td></tr>
			<tr><td valign=top width=45%>"._EMAIL.':'."$email</td></tr>
	     		<tr><td valign=top width=45%>"._SHOTIMAGE."";
			if ( $mylinks_useshots && !empty($logourl) ) {
				echo "<img src=\"".XOOPS_URL."/modules/mylinks/images/shots/".$logourl."\" width=\"".$mylinks_shotwidth."\" alt=\"/\" />";
			} else {
				echo "&nbsp;";
			}
			echo "</td></tr>
    	   		</table></td></tr></table>
    			<table align=center width=450>
    	  		<tr>";
    			if ($submitteremail=="") {
				echo "<td align=left>"._SUBMITTER."$submitter</td>";
			} else {
				echo "<td align=left>"._SUBMITTER."<a href=mailto:".$submitteremail.">".$submitter."</a></td>";
			}
    			if ($owneremail=="") {
				echo "<td align=center>"._OWNER."".$owner."</td>";
			} else {
				echo "<td align=center>"._OWNER."<a href=mailto:".$owneremail.">".$owner."</a></td>";
			}
			echo "<td align=right>\n";
			echo "<table><tr><td>\n";
			echo myTextForm("index.php?op=changeModReq&requestid=$requestid" , _APPROVE);
			echo "</td><td>\n";
			echo myTextForm("index.php?op=ignoreModReq&requestid=$requestid", _IGNORE);
			echo "</td></tr></table>\n";
			echo "</td></tr>\n";
    			echo "</table><br><br>";
    		}
    		echo "</td></tr></table>";
	}else {
		echo _NOMODIFICATIONREQUEST;
	}
	CloseTable();
	xoops_cp_footer();
}
function changeModReq() {
    	global $db, $_GET, $eh, $myts;
    	$requestid = $_GET['requestid'];
    	$query = "select lid, cid, title, url, email, logourl, description from ".$db->prefix("mylinks_mod")." where requestid=".$requestid."";
    	$result = $db->query($query);
    	while(list($lid, $cid, $title, $url, $email, $logourl, $description)=$db->fetchRow($result)) {
	if (get_magic_quotes_runtime()) {
		$title = stripslashes($title);
    		$url = stripslashes($url);
    		$email = stripslashes($email);
    		$logourl = stripslashes($logourl);
    		$description = stripslashes($description);
	}
	$title = addslashes($title);
    	$url = addslashes($url);
    	$email = addslashes($email);
    	$logourl = addslashes($logourl);
    	$description = addslashes($description);
    	$db->query("UPDATE ".$db->prefix("mylinks_links")." SET cid='$cid',title='$title',url='$url',email='$email',logourl='$logourl', status=2, date=".time()." WHERE lid='$lid'")
      or $eh->show("0013");
	$db->query("UPDATE ".$db->prefix("mylinks_text")." SET description='$description' WHERE lid=".$lid."")
      or $eh->show("0013");
    	$db->query("delete from ".$db->prefix("mylinks_mod")." where requestid='$requestid'") or $eh->show("0013");
    	}
    	redirect_header("index.php",1,_MD_DBUPDATED);
	exit();
}
function ignoreModReq() {
    	global $db, $_GET, $eh;
    	$query= "delete from ".$db->prefix("mylinks_mod")." where requestid=".$_GET['requestid']."";
    	$db->query($query) or $eh->show("0013");
    	redirect_header("index.php",1,_MODIFICATIONREQUESTDELETED);
	exit();
}
function modLinkS() {
    	global $db, $_POST, $myts, $eh;
    	$cid = $_POST["cid"];
    	if (($_POST["url"]) || ($_POST["url"]!="")) {
//		$url = $myts->formatURL($_POST["url"]);
//		$url = urlencode($url);
		$url = $myts->makeTboxData4Save($_POST["url"]);
	}
	$logourl = $myts->makeTboxData4Save($_POST["logourl"]);
    	$title = $myts->makeTboxData4Save($_POST["title"]);
    	$email = $myts->makeTboxData4Save($_POST["email"]);
    	$description = $myts->makeTareaData4Save($_POST["description"]);
    	$db->query("update ".$db->prefix("mylinks_links")." set cid='$cid', title='$title', url='$url', email='$email', logourl='$logourl', status=2, date=".time()." where lid=".$_POST['lid']."")  or $eh->show("0013");
    	$db->query("update ".$db->prefix("mylinks_text")." set description='$description' where lid=".$_POST['lid']."")  or $eh->show("0013");
    	redirect_header("index.php",1,_MD_DBUPDATED);
	exit();
}
function delLink() {
   	global $db, $_GET, $eh;
   	$query = "delete from ".$db->prefix("mylinks_links")." where lid=".$_GET['lid']."";
   	$db->query($query) or $eh->show("0013");
	$query = "delete from ".$db->prefix("mylinks_text")." where lid=".$_GET['lid']."";
	$db->query($query) or $eh->show("0013");
	$query = "delete from ".$db->prefix("mylinks_votedata")." where lid=".$_GET['lid']."";
	$db->query($query) or $eh->show("0013");
    	redirect_header("index.php",1,_CONTENTDELETED);
	exit();
}
function modCat() {
    	global $db, $_POST, $myts, $eh, $mytree;
    	$cid = $_POST["cid"];
	xoops_cp_header();
    	OpenTable();
    	echo "<h4>"._MODIFYCATEGORY."</h4><br>";
	$result=$db->query("select pid, title, imgurl from ".$db->prefix("myalbum_cat")." where cid=$cid");
	list($pid,$title,$imgurl) = $db->fetchRow($result);
	$title = $myts->makeTboxData4Edit($title);
	$imgurl = $myts->makeTboxData4Edit($imgurl);
	echo "<form action=index.php method=post>"._TITLE.':'."<input type=text class=text name=title value=\"$title\" size=51 maxlength=50><br><br>"._MD_IMGURLMAIN."<br><input type=text class=text name=imgurl value=\"$imgurl\" size=100 maxlength=150><br><br>";
	echo _PARENT."&nbsp;";
	$mytree->makeMySelBox("title", "title", $pid, 1, pid);
//	<input type=hidden name=pid value=\"$pid\">
	echo "<br><input type=\"hidden\" name=\"cid\" value=\"".$cid."\">
	<input type=\"hidden\" name=\"op\" value=\"modCatS\"><br>
	<input type=\"submit\" class=button value=\""._MD_SAVE."\">
	<input type=\"button\" class=button value=\""._DELETE."\" onClick=\"location='index.php?pid=$pid&cid=$cid&op=delCat'\">";
	echo "&nbsp;<input type=\"button\" class=button value=\""._CANCEL."\" onclick=\"javascript:history.go(-1)\">";
	echo "</form>";
    	CloseTable();
	xoops_cp_footer();
}
function modCatS() {
    	global $db, $_POST, $myts, $eh;
    	$cid =  $_POST['cid'];
    	$pid =  $_POST['pid'];
    	$title =  $myts->makeTboxData4Save($_POST['title']);
	if (($_POST["imgurl"]) || ($_POST["imgurl"]!="")) {
		$imgurl = $myts->makeTboxData4Save($_POST["imgurl"]);
	}
	$db->query("update ".$db->prefix("myalbum_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 $db, $_GET, $eh, $mytree;
    	$cid =  $_GET['cid'];
    	if($_GET['ok']){
    		$ok =  $_GET['ok'];
    	}
    	if($ok==1) {
		//get all subcategories under the specified category
		$arr=$mytree->getAllChildId($cid);
		for($i=0;$i<sizeof($arr);$i++){
			//get all links in each subcategory
			$result=$db->query("select lid,ext from ".$db->prefix("myalbum_photos")." 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, $ext)=$db->fetchRow($result)){
				$delete = $lid;
				$q = "DELETE FROM ".$db->prefix("myalbum_photos")." WHERE lid = $delete";
				$db->query($q) or $eh->show("0013");
				$q = "DELETE FROM ".$db->prefix("myalbum_text")." WHERE lid = $delete";
				$db->query($q) or $eh->show("0013");
				$q = "DELETE FROM ".$db->prefix("myalbum_votedata")." WHERE lid = $delete";
				$db->query($q) or $eh->show("0013");
				// delete comments for this photo
				$com = new XoopsComments($db->prefix("myalbum_comments"));
				$criteria = array("item_id=$delete", "pid=0");
				$commentsarray = $com->getAllComments($criteria);
				foreach($commentsarray as $comment){
					$comment->delete();
				}
				if(is_numeric($delete)) { // last security check
					unlink(XOOPS_ROOT_PATH."/modules/myalbum/photos/$delete.$ext");
					unlink(XOOPS_ROOT_PATH."/modules/myalbum/photos/thumbs/$delete.$ext");
				}
			}
			//all links for each subcategory is deleted, now delete the subcategory data
    	    $db->query("delete from ".$db->prefix("myalbum_cat")." where cid=".$arr[$i]."") or $eh->show("0013");
		}
		//all subcategory and associated data are deleted, now delete category data and its associated data
		$result=$db->query("select lid, ext from ".$db->prefix("myalbum_photos")." where cid=".$cid."") or $eh->show("0013");
		while(list($lid, $ext)=$db->fetchRow($result)){
			$delete = $lid;
			$q = "DELETE FROM ".$db->prefix("myalbum_photos")." WHERE lid = $delete";
			$db->query($q) or $eh->show("0013");
			$q = "DELETE FROM ".$db->prefix("myalbum_text")." WHERE lid = $delete";
			$db->query($q) or $eh->show("0013");
			$q = "DELETE FROM ".$db->prefix("myalbum_votedata")." WHERE lid = $delete";
			$db->query($q) or $eh->show("0013");
			// delete comments for this photo
			$com = new XoopsComments($db->prefix("myalbum_comments"));
			$criteria = array("item_id=$delete", "pid=0");
			$commentsarray = $com->getAllComments($criteria);
			foreach($commentsarray as $comment){
				$comment->delete();
			}
			if(is_numeric($delete)) { // last security check
				unlink(XOOPS_ROOT_PATH."/modules/myalbum/photos/$delete.$ext");
				unlink(XOOPS_ROOT_PATH."/modules/myalbum/photos/thumbs/$delete.$ext");
			}
		}
	    $db->query("delete from ".$db->prefix("myalbum_cat")." where cid=$cid") or $eh->show("0013");
        redirect_header("index.php",1,_CATEGORYDELETED);
		exit();
    	} else {
		xoops_cp_header();
		OpenTable();
		echo "<center>";
		echo "<h4><font color=\"#ff0000\">";
		echo _DELETECATEGORYANDCONTENT."</font></h4><br>";
		echo "<table><tr><td>\n";
		echo myTextForm("index.php?op=delCat&cid=$cid&ok=1",_YES);
		echo "</td><td>\n";
		echo myTextForm("index.php", _NO);
		echo "</td></tr></table>\n";
    		CloseTable();
		xoops_cp_footer();
    	}
}
function delNewLink() {
    	global $db, $_GET, $eh;
    	$query = "delete from ".$db->prefix("mylinks_links")." where lid=".$_GET['lid']."";
    	$db->query($query) or $eh->show("0013");
    	$query = "delete from ".$db->prefix("mylinks_text")." where lid=".$_GET['lid']."";
    	$db->query($query) or $eh->show("0013");
	redirect_header("index.php",1,_CONTENTDELETED);
}
function addCat() {
    	global $db, $_POST, $myts, $eh;
    	$pid = $_POST["cid"];
    	$title = $_POST["title"];
    	if (($_POST["imgurl"]) || ($_POST["imgurl"]!="")) {
//		$imgurl = $myts->formatURL($_POST["imgurl"]);
//		$imgurl = urlencode($imgurl);
		$imgurl = $myts->makeTboxData4Save($_POST["imgurl"]);
	}
    	$title = $myts->makeTboxData4Save($title);
	$newid = $db->genId($db->prefix("myalbum_cat")."_cid_seq");
    	$db->query("INSERT INTO ".$db->prefix("myalbum_cat")." (cid, pid, title, imgurl) VALUES ($newid, $pid, '$title', '$imgurl')") or $eh->show("0013");
	redirect_header("index.php?op=linksConfigMenu",1,_NEWCATEGORYADDED);
}
function addLink() {
    	global $bcoosConfig, $db, $myts, $xoopsUser, $eh, $_POST;
	if (($_POST["url"]) || ($_POST["url"]!="")) {
	//	$url=$myts->formatURL($_POST["url"]);
//		$url = urlencode($url);
		$url = $myts->makeTboxData4Save($_POST["url"]);
	}
	$logourl = $myts->makeTboxData4Save($_POST["logourl"]);
    	$title = $myts->makeTboxData4Save($_POST["title"]);
    	$email = $myts->makeTboxData4Save($_POST["email"]);
    	$description = $myts->makeTareaData4Save($_POST["description"]);
    	$submitter = $xoopsUser->uid();
    	$result = $db->query("select count(*) from ".$db->prefix("mylinks_links")." where url='$url'");
    	list($numrows) = $db->fetchRow($result);
	$errormsg = "";
	$error = 0;
    	if ($numrows>0) {
		$errormsg .= "<h4><font color=\"#ff0000\">";
		$errormsg .= _MD_ERROREXIST."</font></h4><br>";
		$error = 1;
    	}
// Check if Title exist
    	if ($title=="") {
		$errormsg .= "<h4><font color=\"#ff0000\">";
		$errormsg .= _EMPTYTITLE."</font></h4><br>";
    		$error =1;
    	}
// Check if Description exist
    	if ($description=="") {
		$errormsg .= "<h4><font color=\"#ff0000\">";
		$errormsg .= _EMPTYDESCRIPTION."</font></h4><br>";
    		$error =1;
    	}
    	if($error == 1) {
		xoops_cp_header();
		echo $errormsg;
		xoops_cp_footer();
		exit();
    	}
    	if ( !empty($_POST['cid']) ) {
        	$cid = $_POST['cid'];
	} else {
		$cid = 0;
	}
	$newid = $db->genId($db->prefix("mylinks_links")."_lid_seq");
    	$db->query("INSERT INTO ".$db->prefix("mylinks_links")." (lid, cid, title, url, email, logourl, submitter, status, date, hits, rating, votes, comments) VALUES ($newid, $cid, '$title', '$url', '$email', '$logourl', $submitter, 1, ".time().", 0, 0, 0, 0)") or $eh->show("0013");
	if($newid == 0){
		$newid = $db->insert_id();
	}
    	$db->query("INSERT INTO ".$db->prefix("mylinks_text")." (lid, description) VALUES ($newid, '$description')") or $eh->show("0013");
    	redirect_header("index.php",1,_CONTENTADDED);
}
function approve(){
	global $bcoosConfig, $db, $_POST, $myts, $eh;
	$lid = $_POST['lid'];
	$title = $_POST['title'];
	$cid = $_POST['cid'];
	if ( empty($cid) ) {
		$cid = 0;
	}
	$email = $_POST['email'];
	$description = $_POST['description'];
	if (($_POST["url"]) || ($_POST["url"]!="")) {
//		$url=$myts->formatURL($_POST["url"]);
//		$url = urlencode($url);
		$url = $myts->makeTboxData4Save($_POST["url"]);
	}
	$logourl = $myts->makeTboxData4Save($_POST["logourl"]);
	$title = $myts->makeTboxData4Save($title);
	$email = $myts->makeTboxData4Save($email);
	$description = $myts->makeTareaData4Save($description);
	$query = "update ".$db->prefix("mylinks_links")." set cid='$cid', title='$title', url='$url', email='$email', logourl='$logourl', status=1, date=".time()." where lid=".$lid."";
	$db->query($query) or $eh->show("0013");
	$query = "update ".$db->prefix("mylinks_text")." set description='$description' where lid=".$lid."";
	$db->query($query) or $eh->show("0013");
	$result = $db->query("select submitter from ".$db->prefix("mylinks_links")." where lid=$lid");
	list($submitterid)=$db->fetchRow($result);
	$submitter = XoopsUser::getUnameFromId($submitterid);
	$subject = sprintf(_MD_YOURLINK,$bcoosConfig['title']);
	$message = sprintf(_MD_HELLO,$submitter);
	$message .= "\n\n"._APPROVENOTIFY."\n\n";
	$yourlinkurl = XOOPS_URL."/modules/mylinks/";
	$message .= sprintf(_MD_YOUCANBROWSE,$yourlinkurl);
	$message .= "\n\n"._THANKSSUBMIT."\n\n".$bcoosConfig['title']."\n".XOOPS_URL."\n".$bcoosConfig['adminmail']."";
	$xoopsMailer =& getMailer();
	$xoopsMailer->useMail();
	$xoopsMailer->setToEmails($email);
	$xoopsMailer->setFromEmail($bcoosConfig['adminmail']);
	$xoopsMailer->setFromName($bcoosConfig['title']);
	$xoopsMailer->setSubject($subject);
	$xoopsMailer->setBody($message);
	$xoopsMailer->send();
    	redirect_header("index.php",1,_CONTENTADDED);
}
function myLinksConfigAdmin() {
	global $bcoosConfig;
	global $mylinks_perpage, $mylinks_popular, $mylinks_newlinks, $mylinks_sresults, $mylinks_useshots, $mylinks_shotwidth, $mylinks_bigwidth;
	global $myalbum_width, $myalbum_heigth, $myalbum_fsize, $myalbum_managed;
	xoops_cp_header();
	OpenTable();
	echo "<h4>" . _GENERALSETTINGS . "</h4><br>";
	echo "<form action=\"index.php\" method=\"post\">";
    echo "
    <table width=100% border=0><tr><td nowrap>
    "._MD_LINKSPERPAGE."</td><td width=100%>
        <select class=select name=xmylinks_perpage>
        <option value=$mylinks_perpage selected>$mylinks_perpage</option>
        <option value=10>10</option>
        <option value=15>15</option>
        <option value=20>20</option>
        <option value=25>25</option>
        <option value=30>30</option>
        <option value=50>50</option>
    </select>
    </td></tr><tr><td nowrap>
    "._HITSTOBEPOPULAR."</td><td>
        <select class=select name=xmylinks_popular>
        <option value=$mylinks_popular selected>$mylinks_popular</option>
        <option value=10>10</option>
        <option value=20>20</option>
        <option value=50>50</option>
        <option value=100>100</option>
        <option value=500>500</option>
        <option value=1000>1000</option>
    </select>
    </td></tr><tr><td nowrap>
    "._MD_LINKSNEW."</td><td>
        <select class=select name=xmylinks_newlinks>
        <option value=$mylinks_newlinks selected>$mylinks_newlinks</option>
        <option value=10>10</option>
        <option value=15>15</option>
        <option value=20>20</option>
        <option value=25>25</option>
        <option value=30>30</option>
        <option value=50>50</option>
    </select>";
    echo "</td></tr>";
	echo "<tr><td nowrap>" . _USESHOTS . "</td><td>";
	if ($mylinks_useshots==1) {
		echo "<INPUT TYPE=\"RADIO\" class=radio NAME=\"xmylinks_useshots\" VALUE=\"1\" CHECKED>&nbsp;" ._YES."&nbsp;</INPUT>";
		echo "<INPUT TYPE=\"RADIO\" class=radio NAME=\"xmylinks_useshots\" VALUE=\"0\" >&nbsp;" ._NO."&nbsp;</INPUT>";
	} else {
		echo "<INPUT TYPE=\"RADIO\" class=radio NAME=\"xmylinks_useshots\" VALUE=\"1\">&nbsp;" ._YES."&nbsp;</INPUT>";
		echo "<INPUT TYPE=\"RADIO\" class=radio NAME=\"xmylinks_useshots\" VALUE=\"0\" CHECKED>&nbsp;" ._NO."&nbsp;</INPUT>";
	}
	echo "</td></tr>";
	
	echo "<tr><td nowrap>" . _SHOTIMAGEWIDTH . "</td><td>";
	if($mylinks_shotwidth!=""){
		echo "<INPUT TYPE=\"text\" class=text size=\"10\" NAME=\"xmylinks_shotwidth\" VALUE=\"$mylinks_shotwidth\"></INPUT>";
	}else{
		echo "<INPUT TYPE=\"text\" class=text size=\"10\" NAME=\"xmylinks_shotwidth\" VALUE=\"140\"></INPUT>";
	}
	echo "</td></tr><tr><td nowrap>". _MD_IMGBIGWIDTH . "</td><td>";
	if($mylinks_bigwidth!=""){
		echo "<INPUT TYPE=\"text\" class=text size=\"10\" NAME=\"xmylinks_bigwidth\" VALUE=\"$mylinks_bigwidth\"></INPUT>";
	}else{
		echo "<INPUT TYPE=\"text\" class=text size=\"10\" NAME=\"xmylinks_bigwidth\" VALUE=\"600\"></INPUT>";
	}
	echo "</td></tr><tr><td><br /><h4>" . _MD_MODERATE . "</h4></td></tr>";
	
	echo "<tr><td nowrap>" . _MD_MAXWIDTH . "</td><td>";
	if($myalbum_width!=""){
		echo "<INPUT TYPE=\"text\" class=text size=\"10\" NAME=\"xmyalbum_width\" VALUE=\"$myalbum_width\"></INPUT>";
	}else{
		echo "<INPUT TYPE=\"text\" class=text size=\"10\" NAME=\"xmyalbum_width\" VALUE=\"800\"></INPUT>";
	}
	echo "</td></tr>";
	echo "<tr><td nowrap>" . _MD_MAXHEIGTH . "</td><td>";
	if($myalbum_heigth!=""){
		echo "<INPUT TYPE=\"text\" class=text size=\"10\" NAME=\"xmyalbum_heigth\" VALUE=\"$myalbum_heigth\"></INPUT>";
	}else{
		echo "<INPUT TYPE=\"text\" class=text size=\"10\" NAME=\"xmyalbum_heigth\" VALUE=\"600\"></INPUT>";
	}
	echo "</td></tr>";
	echo "<tr><td nowrap>" . _MD_MAXSIZE . "</td><td>";
	if($myalbum_fsize!=""){
		echo "<INPUT TYPE=\"text\" class=text size=\"10\" NAME=\"xmyalbum_fsize\" VALUE=\"$myalbum_fsize\"></INPUT>";
	}else{
		echo "<INPUT TYPE=\"text\" class=text size=\"10\" NAME=\"xmyalbum_fsize\" VALUE=\"100000\"></INPUT>";
	}
    echo "</td></tr>";
	echo "<tr><td nowrap>" . _MD_MANAGED . "</td><td>";
	if ($myalbum_managed==1) {
		echo "<INPUT TYPE=\"RADIO\" class=radio NAME=\"xmyalbum_managed\" VALUE=\"1\" CHECKED>&nbsp;" ._YES."&nbsp;</INPUT>";
		echo "<INPUT TYPE=\"RADIO\" class=radio NAME=\"xmyalbum_managed\" VALUE=\"0\" >&nbsp;" ._NO."&nbsp;</INPUT>";
	} else {
		echo "<INPUT TYPE=\"RADIO\" class=radio NAME=\"xmyalbum_managed\" VALUE=\"1\">&nbsp;" ._YES."&nbsp;</INPUT>";
		echo "<INPUT TYPE=\"RADIO\" class=radio NAME=\"xmyalbum_managed\" VALUE=\"0\" CHECKED>&nbsp;" ._NO."&nbsp;</INPUT>";
	}
	echo "</td></tr>";
	echo "<tr><td>&nbsp;</td></tr>";
   	echo "</table>";
   	echo "<input type=\"hidden\" name=\"op\" value=\"myLinksConfigChange\">";
   	echo "<input type=\"submit\" class=button value=\""._MD_SAVE."\">";
	echo "&nbsp;<input type=\"button\" class=button value=\""._CANCEL."\" onclick=\"javascript:history.go(-1)\">";
   	echo "</form>";
   	CloseTable();
	xoops_cp_footer();
}
function myLinksConfigChange() {
	global $bcoosConfig, $_POST;
	$xmylinks_popular = $_POST['xmylinks_popular'];
	$xmylinks_newlinks = $_POST['xmylinks_newlinks'];
	$xmylinks_perpage = $_POST['xmylinks_perpage'];
	$xmylinks_useshots = $_POST['xmylinks_useshots'];
	$xmylinks_shotwidth = $_POST['xmylinks_shotwidth'];
	$xmylinks_bigwidth = $_POST['xmylinks_bigwidth'];
	$xmyalbum_width = $_POST['xmyalbum_width'];
	$xmyalbum_heigth = $_POST['xmyalbum_heigth'];
	$xmyalbum_fsize = $_POST['xmyalbum_fsize'];
	$xmyalbum_managed = $_POST['xmyalbum_managed'];
	$filename = XOOPS_ROOT_PATH."/modules/myalbum/cache/config.php";
	$file = fopen($filename, "w");
	$content = "";
	$content .= "<?php\n";
	$content .= "\n";
	$content .= "###############################################################################\n";
	$content .= "# my Album v1.0                                                                #\n";
	$content .= "#                                                                              #\n";
	$content .= "# \$mylinks_popular:	The number of hits required for a link to be a popular site. Default = 20      #\n";
	$content .= "# \$mylinks_newlinks:	The number of links that appear on the front page as latest listings. Default = 10  #\n";
	$content .= "# \$mylinks_perpage:    	The number of links that appear for each page. Default = 10 #\n";
	$content .= "# \$mylinks_useshots:    	Use screenshots? Default = 1 (Yes) #\n";
	$content .= "# \$mylinks_shotwidth:    	Screenshot Image Width (Default = 140) #\n";
	$content .= "###############################################################################\n";
	$content .= "\n";
	$content .= "\$mylinks_popular = $xmylinks_popular;\n";
	$content .= "\$mylinks_newlinks = $xmylinks_newlinks;\n";
	$content .= "\$mylinks_perpage = $xmylinks_perpage;\n";
	$content .= "\$mylinks_useshots = $xmylinks_useshots;\n";
	$content .= "\$mylinks_shotwidth = $xmylinks_shotwidth;\n";
	$content .= "\$mylinks_bigwidth = $xmylinks_bigwidth;\n";
	$content .= "\$myalbum_width = $xmyalbum_width;\n";
	$content .= "\$myalbum_heigth = $xmyalbum_heigth;\n";
	$content .= "\$myalbum_fsize = $xmyalbum_fsize;\n";
	$content .= "\$myalbum_managed = $xmyalbum_managed;\n";
	$content .= "\n";
	$content .= "?>\n";
	fwrite($file, $content);
    	fclose($file);
		
	if ($xmylinks_shotwidth != $old_shotwidth )	{
	
	}
	redirect_header("index.php",1,_MD_CONFUPDATED);
}
switch ($op) {
		default:
			mylinks();
			break;
		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 "delComment":
			delComment($bid, $rid);
			break;
		case "myLinksConfigAdmin":
			myLinksConfigAdmin();
			break;
		case "myLinksConfigChange":
			if (xoopsfwrite()) {
				myLinksConfigChange();
			}
			break;
		case "linksConfigMenu":
			linksConfigMenu();
			break;
		case "listNewLinks":
			listNewLinks();
			break;
}
?>
