Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2009-12-17 16:19:27 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2009-12-17 16:19:27 (GMT)
commit64daad1023e6fcc62f0de5cd5650a9c5266f7ba1 (patch)
treec8bc8cd40e7dc44f80dd3e15fbf593c8fd342e53
parent3f968f0b1a7ac4c6f8806084a3ab993fd229fd70 (diff)
Add files-check-missed.php
-rwxr-xr-xaslo/cron/daily-recount2
-rwxr-xr-xaslo/files-check-missed.php71
2 files changed, 73 insertions, 0 deletions
diff --git a/aslo/cron/daily-recount b/aslo/cron/daily-recount
index 72edbc8..d0666d8 100755
--- a/aslo/cron/daily-recount
+++ b/aslo/cron/daily-recount
@@ -26,3 +26,5 @@ php -f maintenance.php addons_collections_total
php -f maintenance.php collections_ratings
php -f maintenance.php share_count_totals
php -f maintenance.php category_totals
+
+php -f ../aslo/files-check-missed.php
diff --git a/aslo/files-check-missed.php b/aslo/files-check-missed.php
new file mode 100755
index 0000000..05fa701
--- /dev/null
+++ b/aslo/files-check-missed.php
@@ -0,0 +1,71 @@
+<?php
+
+// Before doing anything, test to see if we are calling this from the command
+// line. If this is being called from the web, HTTP environment variables will
+// be automatically set by Apache. If these are found, exit immediately.
+if (isset($_SERVER['HTTP_HOST'])) {
+ exit;
+}
+
+require_once('database.class.php');
+
+/**
+ * * Get time as a float.
+ * * @return float
+ * */
+function getmicrotime() {
+ list($usec, $sec) = explode(" ", microtime());
+ return ((float)$usec + (float)$sec);
+}
+
+// Start our timer.
+$start = getmicrotime();
+
+// New database class
+$db = new Database();
+
+$files_sql = "
+ SELECT DISTINCT
+ addons.id as addon_id,
+ files.filename as filename,
+ addons.status as addon_status,
+ files.status as file_status
+ FROM
+ versions
+ INNER JOIN addons ON versions.addon_id = addons.id AND addons.inactive = 0
+ INNER JOIN files ON files.version_id = versions.id
+ ORDER BY
+ addon_status,
+ file_status,
+ addons.id DESC
+";
+
+$files_result = $db->read($files_sql);
+
+while ($row = mysql_fetch_array($files_result)) {
+ $filename = REPO_PATH."/{$row['addon_id']}/{$row['filename']}";
+ if (!file_exists($filename))
+ debug("Missed addon_status={$row['addon_status']} file_status={$row['file_status']} filename={$filename} ", true);
+}
+
+// How long did it take to run?
+$exectime = getmicrotime() - $start;
+
+debug('Time: '.$exectime);
+debug('Exiting ...');
+
+/**
+ * Give this function your output. If the debug flag (in the database) is set or if the error is serious it will get printed
+ *
+ * @param string what to print
+ * @param boolean if the error is fatal or not
+ */
+function debug($msg, $serious=false) {
+ if (CRON_DEBUG || $serious) {
+ $_ts = strftime('%H:%M:%S');
+ echo "{$_ts} {$msg}\n";
+ }
+}
+
+exit;
+?>