[Aminet-commit] r128 - in trunk: bin phpinclude/include
aminet-discuss at aminet.net
aminet-discuss at aminet.net
Sat Feb 2 20:26:32 CET 2008
Author: mendoza
Date: 2008-02-02 11:26:25 -0800 (Sat, 02 Feb 2008)
New Revision: 128
Modified:
trunk/bin/admin.php
trunk/phpinclude/include/main.php
Log:
Return new id when adding package, automatically add_listing when updating package, and be a bit more robust, plus output sql errors
Modified: trunk/bin/admin.php
===================================================================
--- trunk/bin/admin.php 2007-12-29 18:49:27 UTC (rev 127)
+++ trunk/bin/admin.php 2008-02-02 19:26:25 UTC (rev 128)
@@ -127,7 +127,9 @@
}
}
$pkg_size = size_to_human($tmp[7]);
- add_package($matches[1],$matches[2],$pkg_size,$force,$debug);
+ $pkg_id = add_package($matches[1],$matches[2],$pkg_size,$force,$debug);
+ if (!$pkg_id) { report("Some error happened adding package: $matches[1], $matches[2]"); }
+ report(add_listing($pkg_id, $matches[1], $matches[2]));
} else {
report("File \"$amirepo_root/$subdir$matches[1]/$matches[2]\" not found");
}
@@ -158,7 +160,9 @@
report("FAILURE: Unable to delete: $matches[1]/$matches[2]");
}
break;
-
+ case "add_listing":
+ add_listing();
+ break;
case "update_packages_meta":
update_packages_meta();
break;
Modified: trunk/phpinclude/include/main.php
===================================================================
--- trunk/phpinclude/include/main.php 2007-12-29 18:49:27 UTC (rev 127)
+++ trunk/phpinclude/include/main.php 2008-02-02 19:26:25 UTC (rev 128)
@@ -67,6 +67,16 @@
$oldtime = time();
$res = mysql_query($query);
if (isset($_GET['debug'])) {
+ sql_log($query);
+ }
+ if (!$res) {
+ sql_log("$query\n\n".mysql_error());
+ }
+ return $res;
+}
+
+function sql_log($query) {
+ global $amirepo_root;
$newtime = time();
$fmode = "a";
if (!file_exists("$amirepo_root/log/sqlphp.log")) {
@@ -80,8 +90,6 @@
} else {
report("Unable to open $amirepo_root/log/sqlphp.log");
}
- }
- return $res;
}
function aminet_log($text) {
@@ -244,6 +252,7 @@
} else {
$listing_content = "Unsupported format for listing";
}
+ $listing_content = addslashes($listing_content);
sql_query("REPLACE INTO listing (listing_id, listing_content) VALUES ($pkg_id, '$listing_content') ");
return $listing_content;
}
@@ -1010,6 +1019,7 @@
} else {
report("$pkg_path/$pkg_name is not a regular file");
}
+ return $pkg_insert_id;
}
function move_package($source,$dest) {
More information about the Aminet-commit
mailing list