"Extensions","T"=>"Themes");
if (!$_GET["type"]) {$_GET["type"]="E";}
?>
Manage :
" style="font-weight: bold;">Add New Item | Show: $typename) {
$i++;
echo"$typename";
if ($i !== $count) {echo" / "; }
}
unset($i);
?>
|
Name |
Description |
Last Updated |
\n";
echo"$i | \n";
echo"$name | \n";
echo"$description | \n";
echo"$dateupdated | \n";
echo"\n";
}
?>
";
echo"Updating $name, please wait...
";
if ($_POST["name"] && $_POST["authors"] && $_POST["categories"] && $_POST["description"]) {
//Everything We *must* have is present... Begin....
//Phase One, update t_main values...
$sql = "UPDATE `t_main` SET `Name`= '$_POST[name]', `Homepage`='$_POST[homepage]', `Description`='$_POST[description]', `DateUpdated`=NOW(NULL) WHERE `ID`='$_POST[id]' LIMIT 1";
//echo"$sql
\n"; //Debug
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
if ($sql_result) {
echo"Your update to $_POST[name] has been submitted successfully...
\n";
}
echo"";
//Phase Two, Author List -- Autocomplete and Verify
$authors = $_POST["authors"];
$authors = explode(", ","$authors");
foreach ($authors as $author) {
if (strlen($author)<2) {continue;} //Kills all values that're too short..
$a++;
$sql = "SELECT `UserID`,`UserEmail` FROM `t_userprofiles` WHERE `UserEmail` LIKE '$author%' ORDER BY `UserMode`, `UserName` ASC";
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
$numresults = mysql_num_rows($sql_result);
while ($row = mysql_fetch_array($sql_result)) {
$userid = $row["UserID"];
$useremail = $row["UserEmail"];
if ($numresults>1) {
//Too many e-mails match, store individual data for error block.
$r++;
$emailerrors[$a]["foundemails"][$r] = $useremail;
}
$authorids[] = $userid;
}
if ($numresults !="1") {
//No Valid Entry Found for this E-Mail or too many, kill and store data for error block.
$emailerrors[$a]["author"] = "$author";
$updateauthors = "false"; // Just takes one of these to kill the author update.
}
}
unset($a,$r);
//Commit Updates to AuthorXref tables.. with the ID and UserID.
if ($updateauthors != "false") {
//Remove Current Authors
$sql = "DELETE FROM `t_authorxref` WHERE `ID` = '$_POST[id]'";
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
//Add New Authors based on $authorids
sort($authorids);
foreach ($authorids as $authorid) {
$sql = "INSERT INTO `t_authorxref` (`ID`, `UserID`) VALUES ('$_POST[id]', '$authorid');";
$result = mysql_query($sql) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
}
echo"Authors for $_POST[name]'s updated...
\n";
} else {
echo"ERROR: Could not update Authors list, please fix the errors printed below and try again...
\n";
}
unset($authors); //Clear from Post..
//Phase Three, Category List, update linkages.
//print_r($_POST["categories"]);
//Delete Current Category Linkages...
$sql = "DELETE FROM `t_categoryxref` WHERE `ID` = '$_POST[id]'";
//echo"$sql
\n"; //Debug
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
//Add New Categories from $_POST["categories"]
foreach ($_POST["categories"] as $categoryid) {
$sql = "INSERT INTO `t_categoryxref` (`ID`, `CategoryID`) VALUES ('$_POST[id]', '$categoryid');";
//echo"$sql
\n"; //Debug
$result = mysql_query($sql) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
}
echo"Categories for $_POST[name]'s updated...
\n";
//End _POST if.
} else {
//Something Isnt Present.. Throw the main error and details...
echo"You're missing one or more required fields, please return to the previous page and correct the errors and try again...
\n";
if (!$_POST["name"]) {echo"Name is required
\n";}
if (!$_POST["authors"]) {echo"Authors is required
\n";}
if (!$_POST["categories"]) {echo"Categories is required
\n";}
if (!$_POST["description"]) {echo"Description is required
\n";}
}
echo"";
} else if ($_POST["submit"]=="Delete") {
$name = $_POST["name"];
$id = $_POST["id"];
echo"Deleting $name, please wait...
\n";
$sql = "SELECT `Version`, `URI` FROM `t_version` WHERE `ID`='$id' GROUP BY `URI` ORDER BY `Version` ASC";
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
while ($row = mysql_fetch_array($sql_result)) {
$version = $row["Version"];
$uri = $row["URI"];
//Delete File(s) from server
if (strpos("$uri","approvalfile.php/")) {
$file = str_replace("http://$sitehostname/developers/approvalfile.php/","$repositorypath/approval/",$uri);
} else if (strpos("$uri","ftp.mozilla.org")) {
$ftppath = $uri;
$file = str_replace("http://ftp.mozilla.org/pub/mozilla.org/","$repositorypath/ftp/",$uri);
}
if (file_exists($file)) {
$unlink = unlink($file);
} else {
$file_exists = "false";
}
if ($file_exists == "false" or !$unlink) {
echo"Error! Encountered a problem when trying to delete associated files, files were not deleted successfully
\n";
} else {
echo"Deleted $name $version (".basename($uri).") successfully...
\n";
}
}
if ($ftppath) {
$basename = basename($ftppath);
$ftppath = str_replace("/$basename","",$ftppath);
$ftppath = str_replace("http://ftp.mozilla.org/pub/mozilla.org","$repositorypath/ftp",$ftppath);
if (@rmdir($ftppath)) {
echo"Removed Directory for $name...
\n";
} else {
echo"Warning! Unable to remove directory for $name. Directory may not be empty.
\n";
}
}
$sql = "DELETE FROM `t_main` WHERE `ID`='$id'";
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
if ($sql_result) {
echo"$name has been deleted...
\n";
echo"«« Back to Main Page...
\n";
include"$page_footer";
echo"