(.*?)<\/em:homepageURL>/", $buf, $matches);
$manifestdata["homepageurl"]=$matches[1];
//echo"Adding Extension... Checking file...
\n";
//echo""; print_r($manifestdata); echo"
\n";
//Populate Form Variables from manifestdata.
$id = $manifestdata[id];
$name = $manifestdata[name];
$version = $manifestdata[version];
$homepage = $manifestdata[homepageurl];
$description = $manifestdata[description];
//Check GUID for validity/existance, if it exists, check the logged in author for permission
$sql = "SELECT ID, GUID from `t_main` WHERE `GUID` = '$manifestdata[id]' LIMIT 1";
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
if (mysql_num_rows($sql_result)=="1") {
// echo"This is a updated extension... Checking author data...
\n";
$mode = "update";
$row = mysql_fetch_array($sql_result);
$item_id = $row["ID"];
if ($_POST["legacy"]=="TRUE") {$item_id = $_POST["existingitems"]; }
$sql = "SELECT `UserID` from `t_authorxref` WHERE `ID`='$item_id' AND `UserID` = '$_SESSION[uid]' LIMIT 1";
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
if (mysql_num_rows($sql_result)=="1" or ($_SESSION["level"]="admin" or $_SESSION["level"]="editor")) {
// echo"This extension belongs to the author logged in
\n";
} else {
echo"ERROR!! This extension does NOT belong to the author logged in.
\n";
die("Terminating...");
}
} else {
$mode = "new";
// echo"This is a new extension...
\n";
}
//Verify MinAppVer and MaxAppVer per app for validity, if they're invalid, reject the file.
if ($_POST["legacy"]=="TRUE" AND !$manifestdata[targetapplication]) {$manifestdata[targetapplication]=array(); }
foreach ($manifestdata[targetapplication] as $key=>$val) {
//echo"$key -- $val[minversion] $val[maxversion]
\n";
$i=0;
$sql = "SELECT `AppName`, `major`, `minor`, `release`, `SubVer` FROM `t_applications` WHERE `GUID`='$key' ORDER BY `major` DESC, `minor` DESC, `release` DESC, `SubVer` DESC";
$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)) {
$i++;
$appname = $row["AppName"];
$subver = $row["SubVer"];
$release = "$row[major].$row[minor]";
if ($row["release"]) {$release = "$release.$row[release]";}
if ($subver !=="final") {$release="$release$subver";}
if ($release == $val[minversion]) { $versioncheck[$key][minversion_valid] = "true"; }
if ($release == $val[maxversion]) { $versioncheck[$key][maxversion_valid] = "true"; }
}
if (!$versioncheck[$key][minversion_valid]) {
$versioncheck[$key][minversion_valid]="false";
echo"Error! The MinAppVer for $appname of $val[minversion] in install.rdf is invalid.
\n";
$versioncheck[errors]="true";
}
if (!$versioncheck[$key][maxversion_valid]) {
$versioncheck[$key][maxversion_valid]="false";
echo"Error! The MaxAppVer for $appname of $val[maxversion] in install.rdf is invalid.
\n";
$versioncheck[errors]="true";
}
}
//echo""; print_r($versioncheck); echo"
\n";
if ($versioncheck[errors]=="true") {
echo"Errors were encountered during install.rdf checking...
\n";
die("Aborting...");
} else {
// echo"install.rdf minAppVer and maxAppVer valid...
\n";
}
} else {
//echo"install.rdf is not present, use legacy mode...
\n";
//header("Location: http://$_SERVER[HTTP_HOST]/developers/additem.php?function=step1b&filename=$filename");
echo"Add Step 1b: Legacy Item Data Entry: ($filename)
\n";
?>
"Extension","T"=>"Theme");
$type = $_POST["type"];
$typename = $typearray[$type];
if ($mode=="update") {
$sql = "SELECT `Name`, `Homepage`, `Description` FROM `t_main` WHERE `ID` = '$item_id' LIMIT 1";
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
$row = mysql_fetch_array($sql_result);
if (!$name) { $name=$row["Name"]; }
$homepage = $row["Homepage"];
$description = $row["Description"];
$authors = ""; $i="";
$sql = "SELECT TU.UserEmail FROM `t_authorxref` TAX INNER JOIN t_userprofiles TU ON TAX.UserID = TU.UserID WHERE `ID` = '$item_id'";
$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)) {
$i++;
$email = $row["UserEmail"];
$authors .= "$email";
if ($i < $numresults) { $authors .=", "; }
}
//Get Currently Set Categories for this Object...
$sql = "SELECT TCX.CategoryID, TC.CatName FROM `t_categoryxref` TCX
INNER JOIN t_categories TC ON TCX.CategoryID = TC.CategoryID
WHERE TCX.ID = '$item_id'
ORDER BY `CatName` 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)) {
$n++;
$catid = $row["CategoryID"];
$categories[$n] = $catid;
}
unset($n);
}
if (!$categories) {$categories = array(); }
?>
Add New »» Step 2:
1) {
//Too many e-mails match, store individual data for error block.
$r++;
$emailerrors[$a]["foundemails"][$r] = $useremail;
}
$authorids[] = $userid;
$authoremails[] = $useremail;
}
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);
if ($_POST["name"] AND $_POST["type"] AND $_POST["authors"] AND $updateauthors !="false" AND $_POST["version"] AND $_POST["osid"] AND $_POST["filename"] AND $_POST["filesize"] AND $_POST["description"] AND $minappver AND $maxappver) {
//All Needed Info is in the arrays, procceed with inserting...
//Create DIV for Box around the output...
echo"Adding Item... Please Wait...
\n";
echo"\n";
//Phase One, Main Data
$name = $_POST["name"];
$homepage = $_POST["homepage"];
$description = $_POST["description"];
$item_id = $_POST["item_id"];
$guid = $_POST["guid"];
$type = $_POST["type"];
//Check to ensure tha the name isn't already taken, if it is, throw an error and halt.
$sql = "SELECT `Name` from `t_main` WHERE `Name`='$name'";
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
if (mysql_num_rows($sql_result)=="0") {
if ($_POST["mode"]=="update") {
$sql = "UPDATE `t_main` SET `Name`='$name', `Homepage`='$homepage', `Description`='$description', `DateUpdated`=NOW(NULL) WHERE `ID`='$item_id' LIMIT 1";
} else {
$sql = "INSERT INTO `t_main` (`GUID`, `Name`, `Type`, `Homepage`,`Description`,`DateAdded`,`DateUpdated`) VALUES ('$guid', '$name', '$type', '$homepage', '$description', NOW(NULL), NOW(NULL));";
}
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
if ($sql_result) {echo"Updating/Adding record for $name...
\n";
} else {
//Handle Error Case and Abort
$failure = "true";
echo"Failure to successfully add/update main record. Unrecoverable Error, aborting.
\n";
include"$page_footer";
echo"