- Moving the cloud module to the contributions repository.

4.4.x
Dries Buytaert 2003-11-15 19:53:53 +00:00
parent 7c06438424
commit 4317747eee
4 changed files with 0 additions and 303 deletions

View File

@ -285,19 +285,6 @@ CREATE TABLE [dbo].[sequences] (
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[site] (
[sid] [numeric](10, 0) NULL ,
[name] [varchar] (128) NOT NULL ,
[link] [varchar] (255) NOT NULL ,
[size] [text] NOT NULL ,
[changed] [int] NOT NULL ,
[checked] [int] NOT NULL ,
[feed] [varchar] (255) NOT NULL ,
[refresh] [int] NOT NULL ,
[threshold] [int] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[node_counter] (
[nid] [int] NOT NULL ,
[totalcount] [numeric](20, 0) NOT NULL ,

View File

@ -401,25 +401,6 @@ CREATE TABLE sequences (
PRIMARY KEY (name)
) TYPE=MyISAM;
--
-- Table structure for table 'site'
--
CREATE TABLE site (
sid int(10) unsigned NOT NULL auto_increment,
name varchar(128) NOT NULL default '',
link varchar(255) NOT NULL default '',
size text NOT NULL,
changed int(11) NOT NULL default '0',
checked int(11) NOT NULL default '0',
feed varchar(255) NOT NULL default '',
refresh int(11) NOT NULL default '0',
threshold int(11) NOT NULL default '0',
PRIMARY KEY (sid),
UNIQUE KEY url (link),
UNIQUE KEY title (name)
) TYPE=MyISAM;
--
-- Table structure for table 'node_counter'
--

View File

@ -412,26 +412,6 @@ CREATE TABLE sessions (
-- PRIMARY KEY (name)
-- );
--
-- Table structure for site
--
CREATE TABLE site (
sid SERIAL,
name varchar(128) NOT NULL default '',
link varchar(255) NOT NULL default '',
size text NOT NULL default '',
changed integer NOT NULL default '0',
checked integer NOT NULL default '0',
feed varchar(255) NOT NULL default '',
refresh integer NOT NULL default '0',
threshold integer NOT NULL default '0',
PRIMARY KEY (sid),
UNIQUE (name),
UNIQUE (link)
);
--
-- Table structure for system
--
@ -445,8 +425,6 @@ CREATE TABLE system (
PRIMARY KEY (filename)
);
--
-- Table structure for term_data
--

View File

@ -1,249 +0,0 @@
<?php
// $Id$
function cloud_help($section = "admin/help#cloud") {
$output = "";
switch ($section) {
case 'admin/help#cloud':
$output .= "The cloud monitor tracks or crawls other interesting web sites and displays their last modification dates. Visitors to the host site learn about relevant sites and can easily see if there is new content. Here is how it works:";
$output .= "<ul>";
$output .= "<li>The site administrator enters names and URLs of the relevant pages on the %cloud-add page.</li>";
$output .= "<li>Drupal's cron function, triggers the cloud module to check all the registered web sites for recent changes or updates. (A page is updated when there is an <i>x</i>-byte difference since the last time it checked, where <i>x</i> is a configuration option.)</li>";
$output .= " <li>The module exports both a page and a block that display the registered sites ordered by their last modification date.</li>";
$output .= "</ul>";
$output = t($output, array("%cloud-add" => l(t("content") ." &raquo; ". t("syndication") ." &raquo; ". t("site cloud") ." &raquo; ". t("add new site"), "admin/node/syndication/cloud/add")));
break;
case 'cloud':
$output .= t("<p>The cloud monitor tracks or crawls other interesting web sites and displays their latest modification dates. It acts as a link watcher such that you can keep an eye on the other sites in the cloud.</p>");
break;
case 'admin/system/modules#description':
$output = t("Tracks other sites and displays last date changed.");
break;
case 'admin/node/syndication/cloud':
$output = t("The cloud monitor tracks or crawls other interesting web sites and displays their last modification dates. Visitors to this site learn about other relevant sites and can easily see if there is new content. To get this working you <b>must</b> setup cron support. To get the site cloud block to display you must turn on the <i>site cloud</i> block in %block. To go to a monitored site, click on the site name, to immediately load and/or update the record for a site, click on \"update site\", to delete a site go to \"edit site\". ", array("%block" => l(t("administer") ." &raquo; ". t("configuration") ." &raquo; ". t("blocks"), "admin/block")));
break;
case 'admin/node/syndication/cloud/add':
$output = t("Add a site to the site cloud. Don't forget the \"http://\" for your URLs.");
break;
}
return $output;
}
function cloud_cron() {
$result = db_query("SELECT * FROM {site} WHERE checked = 0 OR checked + refresh < %d", time());
while ($site = db_fetch_array($result)) {
cloud_update($site);
}
}
function cloud_perm() {
return array("access site cloud", "administer site cloud");
}
function cloud_link($type) {
$links = array();
if ($type == "page" && user_access("access site cloud")) {
$links[] = l(t("site cloud"), "cloud", array("title" => t("Monitor other sites in the cloud.")));
}
if ($type == "system") {
if (user_access("administer site cloud")) {
menu("admin/node/syndication/cloud", t("site cloud"), "cloud_admin");
menu("admin/node/syndication/cloud/add", t("add new site"), "cloud_admin");
menu("admin/node/syndication/cloud/help", t("help"), "cloud_help", 9);
}
}
return $links;
}
function cloud_update($site) {
/*
** Check whether the site is properly configured:
*/
if (!ereg("^http://|https://|ftp://", $site["link"])) {
watchdog("warning", "cloud: invalid or missing URL for '". $site["name"] ."'", l(t("edit site"), "admin/node/syndication/cloud/edit/". $site["sid"]));
}
if (!ereg("^http://|https://|ftp://", $site["feed"])) {
watchdog("warning", "cloud: invalid or missing URL to monitor for '". $site["name"] ."'", l(t("edit site"), "admin/node/syndication/cloud/edit/". $site["sid"]));
}
/*
** Grab the page and update the database if required:
*/
if ($fp = @fopen($site["feed"], "r")) {
while (!feof($fp)) {
$data .= fgets($fp, 128);
}
if (abs($site["size"] - strlen($data)) >= $site["threshold"]) {
db_query("UPDATE {site} SET size = %d, changed = %d, checked = %d WHERE link = '%s'", strlen($data), time(), time(), $site["link"]);
}
else {
db_query("UPDATE {site} SET checked = %d WHERE link = '%s'", time(), $site["link"]);
}
fclose($fp);
}
else {
watchdog("warning", "cloud: failed to syndicate from '". $site["name"] ."'". ($errstr ? ": $errstr" : ""));
}
}
function cloud_form($edit = array()) {
$period = array(900 => format_interval(900), 1800 => format_interval(1800), 3600 => format_interval(3600), 7200 => format_interval(7200), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 64800 => format_interval(64800), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200));
$threshold = array(1 => "1 byte", 10 => "10 bytes", 20 => "20 bytes", 40 => "40 bytes", 60 => "60 bytes", 80 => "80 bytes", 100 => "100 bytes", 120 => "120 bytes", 140 => "140 bytes", 160 => "160 bytes", 320 => "320 bytes", 640 => "640 bytes");
$form .= form_textfield("Site name", "name", $edit["name"], 50, 128, "The name of the web site you want to monitor for updates.");
$form .= form_textfield("Site URL", "link", $edit["link"], 50, 255, "The URL of the web site you want to monitor for updates.");
$form .= form_textfield("URL to monitor", "feed", $edit["feed"], 50, 255, "The URL of the page you want to monitor for updates. Likely to be same as the site's URL but useful to monitor framed pages and more accurate when pointed to a XML/RSS/RDF feed.");
$form .= form_select("Update interval", "refresh", ($edit["refresh"] ? $edit["refresh"] : 3600), $period, "The refresh interval indicating how often you want to check this site for updates. Requires crontab.");
$form .= form_select("Change threshold", "threshold", ($edit["threshold"] ? $edit["threshold"] : 40), $threshold, "The number of bytes the site must have been modified before considered changed.");
$form .= form_submit("Submit");
if ($edit["sid"]) {
$form .= form_submit("Delete");
$form .= form_hidden("sid", $edit["sid"]);
}
return form($form);
}
function cloud_get_site($sid) {
return db_fetch_array(db_query("SELECT * FROM {site} WHERE sid = %d", $sid));
}
function cloud_save($edit) {
if ($edit["sid"] && $edit["name"]) {
db_query("UPDATE {site} SET name = '%s', link = '%s', feed = '%s', refresh = %d, threshold = %d WHERE sid = %d", $edit["name"], $edit["link"], $edit["feed"], $edit["refresh"], $edit["threshold"], $edit["sid"]);
}
else if ($edit["sid"]) {
db_query("DELETE FROM {site} WHERE sid = %d", $edit["sid"]);
}
else {
db_query("INSERT INTO {site} (name, link, feed, refresh, threshold) VALUES ('%s', '%s', '%s', %d, %d)", $edit["name"], $edit["link"], $edit["feed"], $edit["refresh"], $edit["threshold"]);
}
}
function cloud_display() {
$result = db_query("SELECT * FROM {site} ORDER BY name");
$header = array(t("site"), t("last update"), array("data" => t("operations"), "colspan" => 2));
while ($site = db_fetch_object($result)) {
$rows[] = array("<a href=\"$site->link\">$site->name</a>", ($site->changed ? format_interval(time() - $site->changed) ." ago" : "never"), l(t("edit site"), "admin/node/syndication/cloud/edit/$site->sid"), l(t("update site"), "admin/node/syndication/cloud/update/$site->sid"));
}
return theme("table", $header, $rows);
}
function cloud_list($limit = 10) {
$result = db_query_range("SELECT * FROM {site} WHERE changed > ". (time() - 604800) ." ORDER BY changed DESC", 0, $limit);
$hour = -1;
$list = -1;
$inlist = false;
$output .= "<div class=\"item-list\">";
while ($site = db_fetch_object($result)) {
if ($hour != floor((time() - $site->changed) / 3600)) {
$hour = floor((time() - $site->changed) / 3600);
if ($hour < 12) {
if ($inlist) {
$output .= "</ul>";
$inlist = false;
}
if ($hour == 0) {
$output .= t("Updated less than one hour ago:");
}
else {
$output .= format_plural($hour, "Updated an hour ago:", "Updated %count hours ago:");
}
}
else if ($list) {
if ($inlist) {
$output .= "</ul>";
$inlist = false;
}
$output .= format_plural($hour, "Updated more than an hour ago:", "Updated more than %count hours ago:");
$list = 0;
}
}
if (!$inlist) {
$output .= "<ul>";
$inlist = true;
}
$output .= "<li><a href=\"$site->link\">$site->name</a></li>";
}
if ($inlist) $output .= "</ul>";
$output .= "</div>";
return $output;
}
function cloud_page() {
if (user_access("access site cloud")) {
print theme("header");
print theme("box", t("Site cloud"), cloud_help("cloud") . cloud_list(100));
print theme("footer");
}
}
function cloud_block($op = "list", $delta = 0) {
if ($op == "list") {
$blocks[0]["info"] = t("Site cloud");
return $blocks;
}
else {
$block["subject"] = t("Site cloud");
$block["content"] = cloud_list(20) ."<div class=\"more-link\">". l(t("more"), "cloud", array("title" => t("Monitor other sites in the cloud."))) ."</div>";
return $block;
}
}
function cloud_admin() {
$op = $_POST["op"];
$edit = $_POST["edit"];
if (empty($op)) {
$op = arg(4);
}
if (user_access("administer site cloud")) {
switch ($op) {
case "add":
$output = cloud_form();
break;
case "edit":
$output = cloud_form(cloud_get_site(arg(5)));
break;
case "update":
$output = status(cloud_update(cloud_get_site(arg(5))));
$output .= cloud_display();
break;
case "Delete":
$edit["name"] = 0;
// fall through:
case "Submit":
$output = status(cloud_save($edit));
// fall through:
default:
$output .= cloud_display();
}
return $output;
}
else {
return message_access();
}
}
?>