diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/calendar.inc | 76 | ||||
-rw-r--r-- | includes/cron.inc | 35 | ||||
-rw-r--r-- | includes/function.inc | 19 | ||||
-rw-r--r-- | includes/hostname.conf (renamed from includes/config.inc) | 37 | ||||
-rw-r--r-- | includes/widget.inc | 10 |
5 files changed, 58 insertions, 119 deletions
diff --git a/includes/calendar.inc b/includes/calendar.inc deleted file mode 100644 index 3748c3699..000000000 --- a/includes/calendar.inc +++ /dev/null @@ -1,76 +0,0 @@ -<? - -class Calendar { - var $date; - - function calendar($date) { - $this->date = $date; - } - - function display() { - global $PHP_SELF; - - ### Extract information from the given date: - $month = date("n", $this->date); - $year = date("Y", $this->date); - $day = date("d", $this->date); - - ### Extract first day of the month: - $first = date("w", mktime(0, 0, 0, $month, 1, $year)); - - ### Extract last day of the month: - $last = date("t", mktime(0, 0, 0, $month, 1, $year)); - - ### Calculate previous and next months dates: - $prev = mktime(0, 0, 0, $month - 1, $day, $year); - $next = mktime(0, 0, 0, $month + 1, $day, $year); - - ### Generate calendar header: - $output .= "\n<!-- calendar -->\n"; - $output .= "<TABLE WIDTH=\"100%\" BORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"1\">\n"; - $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"7\"><SMALL><A HREF=\"$PHP_SELF?date=$prev\"><</A> ". date("F Y", $this->date) ." <A HREF=\"$PHP_SELF?date=$next\">></A></SMALL></TD></TR>\n"; - $output .= " <TR><TD ALIGN=\"center\"><SMALL>S</SMALL></TD><TD ALIGN=\"center\"><SMALL>M</SMALL></TD><TD ALIGN=\"center\"><SMALL>T</SMALL></TD><TD ALIGN=\"center\"><SMALL>W</SMALL></TD><TD ALIGN=\"center\"><SMALL>T</SMALL></TD><TD ALIGN=\"center\"><SMALL>F</SMALL></TD><TD ALIGN=\"center\"><SMALL>S</SMALL></TD></TR>\n"; - - ### Initialize temporary variables: - $nday = 1; - $sday = $first; - - ### Loop through all the days of the month: - while ($nday <= $last) { - ### Set up blank days for first week of the month: - if ($first) { - $output .= " <TR><TD COLSPAN=\"$first\"> </TD>\n"; - $first = 0; - } - - ### Start every week on a new line: - if ($sday == 0) $output .= " <TR>\n"; - - ### Print one cell: - $date = mktime(24, 0, 0, $month, $nday, $year); - if ($nday == $day) $output .= " <TD ALIGN=\"center\"><SMALL><B>$nday</B></SMALL></TD>\n"; - else if ($date > time()) $output .= " <TD ALIGN=\"center\"><SMALL>$nday</SMALL></TD>\n"; - else $output .= " <TD ALIGN=\"center\"><SMALL><A HREF=\"$PHP_SELF?date=$date\" STYLE=\"text-decoration: none;\">$nday</A></SMALL></TD>\n"; - - ### Start every week on a new line: - if ($sday == 6) $output .= " </TR>\n"; - - ### Update temporary variables: - $sday++; - $sday = $sday % 7; - $nday++; - } - - ### Complete the calendar: - if ($sday) { - $end = 7 - $sday; - $output .= " <TD COLSPAN=\"$end\"> </TD>\n </TR>\n"; - } - $output .= "</TABLE>\n\n"; - - ### Return calendar: - return $output; - } -} - -?> diff --git a/includes/cron.inc b/includes/cron.inc index 59ff0a07c..4cfb74fb8 100644 --- a/includes/cron.inc +++ b/includes/cron.inc @@ -1,24 +1,41 @@ <? -function cron_add($name, $help, $code, $scheduled, $message = "") { - if (empty($name) || empty($code) || empty($scheduled)) { +include "includes/theme.inc"; + +function cron_set($module, $scheduled, $message = "") { + if (empty($module) || empty($scheduled)) { $message = "failed: information missing"; } + else if (db_fetch_object(db_query("SELECT * FROM cron WHERE module = '$module'"))) { + db_query("UPDATE cron SET scheduled = $scheduled WHERE module = '$module'"); + } else { - $result = db_query("INSERT INTO cron (name, help, code, scheduled) VALUES ('". check_input($name) ."', '". check_input($help) ."', '". check_code($code) ."', '". check_input($scheduled) ."')"); + db_query("INSERT INTO cron (module, scheduled, timestamp) VALUES ('". check_input($module) ."', '". check_input($scheduled) ."', '42')"); } } -function cron_delete($id) { - $result = db_query("DELETE FROM cron WHERE id = $id"); +function cron_get($module) { + return db_fetch_object(db_query("SELECT * FROM cron WHERE module = '$module'"), 0); +} + +function cron_delete($module) { + $result = db_query("DELETE FROM cron WHERE module = '$module'"); } -function cron_execute($cron) { - eval($cron->code); +function cron_run($cron) { + $time = time(); - db_query("UPDATE cron SET timestamp = '". time() ."' WHERE id = $cron->id"); + $result = db_query("SELECT * FROM cron WHERE $time - timestamp > scheduled"); + + while ($task = db_fetch_object($result)) { + include "modules/". $task->module .".module"; + if ($function = $module["cron"]) { + watchdog("message", "cron: executed '". $task->module ."_cron()'"); + $function(); + } + } - watchdog("message", "cron: executed '$cron->name'"); + db_query("UPDATE cron SET timestamp = $time WHERE $time - timestamp > scheduled"); } ?> diff --git a/includes/function.inc b/includes/function.inc index 7c1afc7ae..87fb0ee37 100644 --- a/includes/function.inc +++ b/includes/function.inc @@ -61,6 +61,25 @@ function format_plural($count, $singular, $plural) { return ($count == 1) ? "$count $singular" : "$count $plural"; } +function format_interval($timestamp) { + if ($timestamp > 86400) { + $output .= format_plural(floor($timestamp / 86400), "day ", "days "); + $timestamp = $timestamp % 86400; + } + if ($timestamp > 3600) { + $output .= format_plural(floor($timestamp / 3600), "hour ", "hours "); + $timestamp = $timestamp % 3600; + } + if ($timestamp > 60) { + $output .= floor($timestamp / 60) ." min "; + $timestamp = $timestamp % 60; + } + if ($timestamp > 0) { + $output .= floor($timestamp / 86400) ." sec"; + } + return $output; +} + function format_date($timestamp, $type = "medium") { global $user; diff --git a/includes/config.inc b/includes/hostname.conf index 87726021f..3afc80517 100644 --- a/includes/config.inc +++ b/includes/hostname.conf @@ -4,23 +4,12 @@ # Database settings: # -### host: "http://www.drop.org/": -$db_host = "zind.net"; -$db_name = "droporg"; -$db_pass = "DropIes"; -$db_name = "droporg"; - -### host: "http://beta.drop.org/": -#$db_host = "zind.net"; -#$db_name = "dries"; -#$db_pass = "Abc123"; -#$db_name = "dries"; - ### host: "http://localhost/": -#$db_host = "localhost"; -#$db_name = "drop"; -#$db_pass = "drop"; -#$db_name = "drop"; +$db_host = "localhost"; +$db_name = "name"; +$db_pass = "pass"; +$db_name = "name"; + # # Administrative information @@ -37,7 +26,6 @@ $site_email = "info@drop.org"; # represent the mathematical calculation to be performed # to update a comment's value. # - $comment_votes = array("none" => "none", "-1" => "- 1", "0" => "+ 0", @@ -78,18 +66,15 @@ $anonymous = "Anonymous Chicken"; # the first theme listed in this associative array will # automatically become the default theme. # -$themes = array("Marvin" => array( +$themes = array("UnConeD" => array( + "themes/unconed/unconed.theme", + "modern theme, gray and blue, high coolness factor"), + "Marvin" => array( "themes/marvin/marvin.theme", "classic theme, white, basic design with a fresh look"), "Zaphod" => array( "themes/zaphod/zaphod.theme", - "classic theme, yellow, structured, advanced navigation"), - "Trillian" => array( - "themes/trillian/trillian.theme", - "simple, easy, black background"), - "UnConeD" => array( - "themes/unconed/unconed.theme", - "modern theme, gray and blue, high coolness factor")); + "classic theme, yellow, structured, advanced navigation")); # # Submission moderation votes: @@ -112,7 +97,7 @@ $submission_votes = array("neutral (+0)" => "+ 0", # story is pushed over the threshold and up it goes on the public # page. On the other hand, when too many people voted to drop a # story, the story will get trashed. -$submission_post_threshold = "3"; +$submission_post_threshold = "5"; $submission_dump_threshold = "-2"; # diff --git a/includes/widget.inc b/includes/widget.inc index b5891a57e..2ea57a246 100644 --- a/includes/widget.inc +++ b/includes/widget.inc @@ -80,9 +80,9 @@ function display_new_diaries($theme, $num = 20) { $content .= "<P><B>". date("l, M jS", $diary->timestamp) ."</B></P>\n"; $time = date("F jS", $diary->timestamp); } - $content .= "<LI><A HREF=\"diary.php?op=view&name=$diary->userid\">$diary->userid</A></LI>\n"; + $content .= "<LI><A HREF=\"module.php?mod=diary&op=view&name=$diary->userid\">$diary->userid</A></LI>\n"; } - $content .= "<P ALIGN=\"right\">[ <A HREF=\"diary.php\"><FONT COLOR=\"$theme->hlcolor2\">more</FONT></A> ]</P>"; + $content .= "<P ALIGN=\"right\">[ <A HREF=\"module.php?mod=diary\"><FONT COLOR=\"$theme->hlcolor2\">more</FONT></A> ]</P>"; $theme->box("Recent diary entries", $content); } @@ -96,12 +96,6 @@ function display_new_headlines($theme, $num = 10) { $theme->box("Latest headlines", $content); } -function display_calendar($theme, $date) { - include "includes/calendar.inc"; - $calendar = new Calendar($date); - $theme->box("Browse archives", $calendar->display()); -} - function display_account($theme) { global $user, $site_name; |