"Extension","T"=>"Theme"); $typename = $typearray[$_GET["type"]]; ?>

Add New

">
Your File:


\n"; //------------------ // Construct $manifestdata[] array from install.rdf info. // Thanks to Chewie[] with the Perl-Compatable RegExps Help. :-) //------------------- // em:id preg_match("/(.*?)<\/em:id>/", $buf, $matches); $manifestdata["id"]=$matches[1]; // em:version preg_match("/(.*?)<\/em:version>/", $buf, $matches); $manifestdata["version"]=$matches[1]; //em:targetApplication preg_match_all("/(.*?)<\/em:targetApplication>/s", $buf, $matches); //echo"
";
//print_r($buf);
//print_r($matches);
//echo"
"; foreach ($matches[0] as $targetapp ) { //em:targetApplication --> em:id preg_match("/(.*?)<\/em:id>/", $targetapp, $matches); $i = $matches[1]; $manifestdata["targetapplication"][$i]["id"]=$matches[1]; //em:targetApplication --> em:minVersion preg_match("/(.*?)<\/em:minVersion>/", $targetapp, $matches); $manifestdata["targetapplication"][$i]["minversion"]=$matches[1]; //em:targetApplication --> em:maxVersion preg_match("/(.*?)<\/em:maxVersion>/", $targetapp, $matches); $manifestdata["targetapplication"][$i]["maxversion"]=$matches[1]; } //em:name preg_match("/(.*?)<\/em:name>/", $buf, $matches); $manifestdata["name"]=$matches[1]; //em:description preg_match("/(.*?)<\/em:description>/", $buf, $matches); $manifestdata["description"]=$matches[1]; //em:homepageURL preg_match("/(.*?)<\/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"; ?> ">
> New
> Update to:
Your file: "> ">
"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:

"> "> "> "> \n"; } else { echo"\n"; } echo"\n"; echo"\n"; echo"\n"; $sql2 = "SELECT `AppName`,`GUID` FROM `t_applications` GROUP BY `AppName` ORDER BY `AppName` ASC"; $sql_result2 = mysql_query($sql2, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); while ($row2 = mysql_fetch_array($sql_result2)) { $appname = $row2["AppName"]; $guid = $row2["GUID"]; if ($appname == "Mozilla") { $mozguid = $guid; } $minappver = $manifestdata["targetapplication"]["$guid"]['minversion']; $maxappver = $manifestdata["targetapplication"]["$guid"]['maxversion']; echo"\n"; } } } ?> \n"; ?>
Name* " SIZE=45 MAXLENGTH=100> Categories:
    
Author(s):*" SIZE=45>
Version:*$version
Version:*
OS*
Filename:$filename ($filesize"."kb)
Target Application(s):
$appname "; if (($mode=="new" or $mode=="update") and (strtolower($appname) !="mozilla" or $manifestdata["targetapplication"]["$mozguid"])) { //Based on Extension Manifest (New Mode) if ($minappver and $maxappver) { echo"$minappver - $maxappver\n"; echo"\n"; echo"\n"; } else { echo"N/A"; } } else { //Legacy Mode Code... if ($appname =="Firefox" or $appname == "Thunderbird") { echo"
Incompatable with Legacy Extensions (Requires install.rdf)"; } else { $sql = "SELECT `version`,`major`,`minor`,`release`,`SubVer` FROM `t_applications` WHERE `AppName` = '$appname' ORDER BY `major` ASC, `minor` ASC, `release` ASC, `SubVer` ASC"; $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); echo"\n"; echo" - "; $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); echo"\n"; echo"
Homepage " SIZE=60 MAXLENGTH=200>
Description*
Version Notes:
  
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"\n\n"; exit; } } else { //Name wasn't unique, error time. :-) //Handle Error Case and Abort $failure = "true"; echo"Error!The Name for your extension or theme already exists in the Update database.
\nCannot Continue, aborting.
\n"; include"$page_footer"; echo"\n\n"; exit; } //Get ID for inserted row... if we don't know it already if (!$_POST[item_id] and $_POST["mode"] !=="update") { $sql = "SELECT `ID` FROM `t_main` WHERE `GUID`='$_POST[guid]' AND `Name`='$_POST[name]' 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); $id = $row["ID"]; } else { $id = $_POST["item_id"]; } //Phase 2 -- Commit Updates to AuthorXref tables.. with the ID and UserID. if ($updateauthors != "false") { //Remove Current Authors $sql = "DELETE FROM `t_authorxref` WHERE `ID` = '$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 ('$id', '$authorid');"; $result = mysql_query($sql) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); } if ($result) { echo"Authors added...
\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 3, t_categoryxref if (!$_POST["categories"]) { //No Categories defined, need to grab one to prevent errors... $sql = "SELECT `CategoryID` FROM `t_categories` WHERE `CatType`='$type' AND `CatName`='Miscellaneous' LIMIT 1"; $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)) { $_POST["categories"] = array("$row[CategoryID]"); } } //Delete Current Category Linkages... $sql = "DELETE FROM `t_categoryxref` WHERE `ID` = '$id'"; $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 ('$id', '$categoryid');"; $result = mysql_query($sql) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); } if ($result) {echo"Categories added...
\n"; } //Phase 4, t_version rows //Construct Internal App_Version Arrays $i=0; $sql = "SELECT `AppName`, `int_version`, `major`, `minor`, `release`, `SubVer`, `shortname` FROM `t_applications` ORDER BY `AppName`, `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"]; $int_version = $row["int_version"]; $subver = $row["SubVer"]; $release = "$row[major].$row[minor]"; if ($row["release"]) {$release = "$release.$row[release]";} if ($subver !=="final") {$release="$release$subver";} $app_internal_array[$release] = $int_version; $app_shortname[strtolower($appname)] = $row["shortname"]; } $sql2 = "SELECT `AppName`,`AppID` FROM `t_applications` GROUP BY `AppName` ORDER BY `AppName` ASC"; $sql_result2 = mysql_query($sql2, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); while ($row2 = mysql_fetch_array($sql_result2)) { $appname = $row2["AppName"]; $appid = $row2["AppID"]; $minappver = $_POST["$appname-minappver"]; $maxappver = $_POST["$appname-maxappver"]; if ($minappver and $maxappver) { if ($app_internal_array["$minappver"]) {$minappver_int = $app_internal_array["$minappver"]; } if ($app_internal_array["$maxappver"]) {$maxappver_int = $app_internal_array["$maxappver"]; } if (!$minappver_int) {$minappver_int = $minappver;} if (!$maxappver_int) {$maxappver_int = $maxappver;} $version = $_POST["version"]; $osid = $_POST["osid"]; $filesize = $_POST["filesize"]; $uri = ""; //we don't have all the parts to set a uri, leave blank and fix when we do. $notes = $_POST["notes"]; //If a record for this item's exact version, OS, and app already exists, find it and delete it, before inserting $sql3 = "SELECT `vID` from `t_version` TV INNER JOIN `t_applications` TA ON TA.AppID=TV.AppID WHERE `OSID`='$osid' AND `AppName` = '$appname' AND TV.Version='$version' ORDER BY `vID` ASC"; $sql_result3 = mysql_query($sql3, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); while ($row = mysql_fetch_array($sql_result3)) { $sql = "DELETE FROM `t_version` WHERE `vID`='$row[vID]' LIMIT 1"; $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); if ($sql_result) { echo"Warning! A version Record already exists for this item's Application/OS/Version combination. Deleting.
\n"; } } $sql = "INSERT INTO `t_version` (`ID`, `Version`, `OSID`, `AppID`, `MinAppVer`, `MinAppVer_int`, `MaxAppVer`, `MaxAppVer_int`, `Size`, `URI`, `Notes`, `DateAdded`, `DateUpdated`) VALUES ('$id', '$version', '$osid', '$appid', '$minappver', '$minappver_int', '$maxappver', '$maxappver_int', '$filesize', '$uri', '$notes', 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"Added $name version $version for $appname
\n"; $apps_array[]=$app_shortname[strtolower($appname)];} $sql = "SELECT `vID` from `t_version` WHERE `id` = '$id' ORDER BY `vID` DESC 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); $vid_array[] = $row["vID"]; } } $sql = "SELECT `OSName` FROM `t_os` WHERE `OSID`='$osid' 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); $osname = $row["OSName"]; //Construct the New Filename $filename_array = explode(".",$_POST[filename]); $filename_count = count($filename_array)-1; $fileext = $filename_array[$filename_count]; $itemname = str_replace(" ","_",$name); $j=0; $app=""; $app_count = count($apps_array); foreach ($apps_array as $app_val) { $j++; $apps .="$app_val"; if ($j<$app_count) {$apps .="+"; } } $newfilename = "$itemname-$version-$apps"; if (strtolower($osname) !=="all") {$newfilename .="-".strtolower($osname).""; } $newfilename .=".$fileext"; //Move temp XPI to home for approval queue items... $oldpath = "$repositorypath/temp/$_POST[filename]"; $newpath = "$repositorypath/approval/".strtolower($newfilename); if (file_exists($oldpath)) { rename("$oldpath","$newpath"); echo"File $newfilename saved to disk...
\n"; } $uri = str_replace("$repositorypath/approval/","http://$sitehostname/developers/approvalfile.php/",$newpath); //echo"$newfilename ($oldpath) ($newpath) ($uri)
\n"; foreach ($vid_array as $vid) { $sql = "UPDATE `t_version` SET `URI`='$uri' WHERE `vID`='$vid'"; $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); } //Approval Queue //Check if the item belongs to the user, (special case for where admins are trusted, the trust only applies to their own work.) $sql = "SELECT `UserID` from `t_authorxref` WHERE `ID`='$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" AND $_SESSION["trusted"]=="TRUE") { //User is trusted and the item they're modifying inheirits that trust. include"inc_approval.php"; //Get the resuable process_approval() function. $action = "Approval+"; $file = $uri; $comments = "Auto-Approval for Trusted User"; $approval_result = process_approval($type, $file, "approve"); } else { $action="Approval?"; $comments=""; } //Firstly, log the comments and action taken.. $userid = $_SESSION["uid"]; if (!$vid_array) { $vid_array = array(); } foreach ($vid_array as $vid) { $sql = "INSERT INTO `t_approvallog` (`ID`, `vID`, `UserID`, `action`, `date`, `comments`) VALUES ('$id', '$vid', '$userid', '$action', NOW(NULL), '$comments');"; $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE); } echo"Process Complete...

\n"; echo"$name version $version has been added to the Mozilla Update database"; if ($_SESSION["trusted"]=="FALSE") { echo"and is awaiting review by an editor, you will be notified when an editor reviews it."; } else if ($_SESSION["trusted"]=="TRUE") { echo" and has been auto-approved. It should be up on the website within the next half-hour."; } echo"
\n"; echo"To review or make changes to your submission, visit the Item Details page...
\n"; echo"

\n"; echo"«« Back to Home"; echo"
\n"; } //Author Error Handling/Display Block for Form Post... if ($emailerrors) { echo"

Adding Item... Error Found while processing authors

\n "; foreach ($_POST as $key => $val) { if ($key=="authors" or $key=="submit") {continue; } if ($key=="categories") { foreach ($_POST["categories"] as $val) { echo"\n"; } continue; } echo"\n"; } echo"\n"; $authors = $_POST["authors"]; ?>
\n"; echo"
"; foreach ($emailerrors as $authorerror) { $author = $authorerror["author"]; $count = count($authorerror["foundemails"]); if ($count=="0") { //Error for No Entry Found echo"Error! Entry '$author': No Matches Found. Please check your entry and try again.
\n"; } else { //Error for Too Many Entries Found echo"Error! Entry '$author': Too Many Matches. Please make your entry more specific.
\n"; } if ($count>0 AND $count<6) { echo"    Possible Addresses found: "; foreach ($authorerror["foundemails"] as $foundemails) { $a++; echo"$foundemails"; if ($a != $count) {echo", "; } else {echo"
\n";} } } } echo"
Author(s):*" SIZE=70>