com web/doc: Removed unused cron scripts and dependencies: include/docweb_dao_common.class.php include/docweb_ dao_metainfo.class.php include/lib_url_entities.i nc.php scripts/checkent.php scripts/gen_function_al iases.php scripts/gen_missing_examples.php scripts/ gen_undocumented_functions.php scripts/grab_livedocs _db.php scripts/notes_stats.php scripts/notes_sta ts_output.php scripts/orphan_notes.php
| Newsgroups | php.doc.web |
|---|---|
| Message-ID | <[email protected]> |
Commit: 27cfbcbc6984301595a5eff12e305b110d0d6059 Author: Sobak <[email protected]> Sat, 22 Mar 2014 13:20:18 +0100 Parents: 94c9e85b648b58db80d766bcfe24116bc94ab5bc Branches: master Link: http://git.php.net/?p=web/doc.git;a=commitdiff;h=27cfbcbc6984301595a5eff12e305b110d0d6059 Log: Removed unused cron scripts and dependencies Changed paths: D include/docweb_dao_common.class.php D include/docweb_dao_metainfo.class.php D include/lib_url_entities.inc.php D scripts/checkent.php D scripts/gen_function_aliases.php D scripts/gen_missing_examples.php D scripts/gen_undocumented_functions.php D scripts/grab_livedocs_db.php D scripts/notes_stats.php D scripts/notes_stats_output.php D scripts/orphan_notes.php
diff_27cfbcbc6984301595a5eff12e305b110d0d6059.txt
(text/plain, 58.2 KB)
diff --git a/include/docweb_dao_common.class.php b/include/docweb_dao_common.class.php deleted file mode 100644 index 7c9de48..0000000 --- a/include/docweb_dao_common.class.php +++ /dev/null @@ -1,216 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: -+----------------------------------------------------------------------+ -| PHP Documentation Site Source Code | -+----------------------------------------------------------------------+ -| Copyright (c) 2005-2011 The PHP Group | -| Copyright (c) 1997-2004 Dave Barr | -+----------------------------------------------------------------------+ -| This source file is subject to version 3.0 of the PHP license, | -| that is bundled with this package in the file LICENSE, and is | -| available through the world-wide-web at the following url: | -| http://www.php.net/license/3_0.txt. | -| If you did not receive a copy of the PHP license and are unable to | -| obtain it through the world-wide-web, please send a note to | -| [email protected] so we can mail you a copy immediately. | -+----------------------------------------------------------------------+ -| Author: Sean Coates <[email protected]> | -+----------------------------------------------------------------------+ -$Id$ -*/ - -define('DOCWEB_DAO_DB_FILE', SQLITE_DIR . 'docweb.sqlite'); - -class DocWeb_DAO_Common -{ - /** - * @var object PEAR::DB object - */ - var $DB; - - /** - * Constructor - Connect to the DocWeb DB - * - * @param bool Check the schema & create missing tables? (set to true - * from generation scripts) - */ - function DocWeb_DAO_Common($checkSchema = FALSE) - { - require_once 'PEAR.php'; - require_once 'DB.php'; // PEAR::DB - $this->dsn = 'sqlite:///' . DOCWEB_DAO_DB_FILE . '?mode=0666'; - if (PEAR::isError($this->DB = DB::connect($this->dsn))) - { - echo "Error connecting to DocWeb database: ". DOCWEB_DAO_DB_FILE ."\n"; - echo " * Error message: ". $this->DB->getMessage() ."\n"; - die(); - } - if ($checkSchema) { - $this->checkSchema(); - } - } - - /** - * Stores a key-value pair in the meta_data table (deletes old pair, if - * exists, and inserts a new pair) - * - * @param string $keyName name of unique key to stor - * @param string $val value to associate with $keyName - */ - function storeMetaData($keyName, $val) - { - $sql = " - DELETE - FROM - meta_data - WHERE - keyname = '" . $this->DB->escapeSimple($keyName) . "' - "; - if (PEAR::isError($this->DB->query($sql))) { - die(" ** Store Meta Data (delete) query failed. (Key: '$keyName')\n"); - } - $sql = " - INSERT - INTO - meta_data (keyname, val) - VALUES - ('" . $this->DB->escapeSimple($keyName) . "', '" . $this->DB->escapeSimple($val) . "') - "; - if (PEAR::isError($this->DB->query($sql))) { - die(" ** Store Meta Data (insert) query failed. (Key: '$keyName', Val: '$val')\n"); - } - return TRUE; - } - - /** - * Logs the current time as meta_data (start time) (Helper method) - * - * @param string $type type to store - */ - function metaLogStartTime($type) - { - $this->storeMetaData("{$type}_start_time", time()); - } - - /** - * Logs the current time as meta_data (end time) (Helper method) - * - * @param string $type type to store - */ - function metaLogEndTime($type) - { - $this->storeMetaData("{$type}_end_time", time()); - } - - /** - * Checks if a given table already exists - * - * @param string $tableName table to check - * @return bool - */ - function tableExists($tableName) - { - $sql = " - SELECT - COUNT(name) - FROM - sqlite_master - WHERE - type = 'table' - AND - name = '". sqlite_escape_string($tableName) ."' - "; - if (PEAR::isError($exists = $this->DB->getOne($sql))) { - echo "Error checking table: $tableName.\n"; - echo " * Error message: ". $r->getMessage() ."\n"; - die(); - } - return $exists ? TRUE : FALSE; - } - - /** - * Creates the database schema - * - * Add any new tables. Tables should be preceeded with a call to the check - * mechanism. Keep these organized. Also, leave them at the end of the file - * (they'll be the most changed) - */ - function checkSchema() - { - // meta_data - if (!$this->tableExists('meta_data')) { - $sql = " - CREATE - TABLE - meta_data - ( - keyname VARCHAR(100) PRIMARY KEY, - val VARCHAR(255) - ); - "; - if (PEAR::isError($create = $this->DB->query($sql))) - { - die("Query Error: ". $create->getMessage() ."\n"); - } - } - - // function_aliases - if (!$this->tableExists('function_aliases')) { - $sql = " - CREATE - TABLE - function_aliases - ( - extension VARCHAR(100), - alias VARCHAR(100), - function VARCHAR(100) - ) - "; - if (PEAR::isError($create = $this->DB->query($sql))) - { - die("Query Error: ". $create->getMessage() ."\n"); - } - } - - // missing_examples - if (!$this->tableExists('missing_examples')) { - $sql = " - CREATE - TABLE - missing_examples - ( - extension VARCHAR(100), - function VARCHAR(100) - ) - "; - if (PEAR::isError($create = $this->DB->query($sql))) - { - die("Query Error: ". $create->getMessage() ."\n"); - } - } - - // undocumented_functions - if (!$this->tableExists('undocumented_functions')) { - $sql = " - CREATE - TABLE - undocumented_functions - ( - extension VARCHAR(100), - function VARCHAR(100) - ) - "; - if (PEAR::isError($create = $this->DB->query($sql))) - { - die("Query Error: ". $create->getMessage() ."\n"); - } - } - - // all complete - return TRUE; - } - - - -} -?> \ No newline at end of file diff --git a/include/docweb_dao_metainfo.class.php b/include/docweb_dao_metainfo.class.php deleted file mode 100644 index 05703d7..0000000 --- a/include/docweb_dao_metainfo.class.php +++ /dev/null @@ -1,204 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: -+----------------------------------------------------------------------+ -| PHP Documentation Site Source Code | -+----------------------------------------------------------------------+ -| Copyright (c) 2005-2011 The PHP Group | -| Copyright (c) 1997-2004 Dave Barr | -+----------------------------------------------------------------------+ -| This source file is subject to version 3.0 of the PHP license, | -| that is bundled with this package in the file LICENSE, and is | -| available through the world-wide-web at the following url: | -| http://www.php.net/license/3_0.txt. | -| If you did not receive a copy of the PHP license and are unable to | -| obtain it through the world-wide-web, please send a note to | -| [email protected] so we can mail you a copy immediately. | -+----------------------------------------------------------------------+ -| Author: Sean Coates <[email protected]> | -+----------------------------------------------------------------------+ -$Id$ -*/ -require_once 'docweb_dao_common.class.php'; - -class DocWeb_DAO_MetaInfo extends DocWeb_DAO_Common -{ - /** - * Constructor - instanciate parent - * - * @param bool Check the schema & create missing tables? (set to true - * from generation scripts) - */ - function DocWeb_DAO_MetaInfo($checkSchema = FALSE) - { - $this->DocWeb_DAO_Common($checkSchema); - } - - /** - * Store function alias data - * - * @param string $ext Extension to which this alias belongs - * @param string $alias Alias function name - * @param string $func Reference function name - * @return bool - */ - function storeFunctionAlias($ext, $alias, $func) - { - $sql = " - INSERT - INTO - function_aliases - ( - extension, - alias, - function - ) - VALUES - ( - '". $this->DB->escapeSimple($ext) ."', - '". $this->DB->escapeSimple($alias) ."', - '". $this->DB->escapeSimple($func) ."' - ) - "; - if (PEAR::isError($this->DB->query($sql))) { - echo " ** Query failed.\n"; - return FALSE; - } - return TRUE; - } - - /** - * Purges function_aliases table - */ - function purgeAliases() - { - $sql = " - DELETE - FROM - function_aliases - "; - if (PEAR::isError($this->DB->query($sql))) { - echo " ** Purge Query failed.\n"; - return FALSE; - } - return TRUE; - } - - /** - * Determines if the passed function name is an alias - * - * @param string $func - * @return bool - */ - function isAlias($func) - { - $sql = " - SELECT - COUNT(function) - FROM - function_aliases - WHERE - alias = '". $this->DB->escapeSimple($func) ."' - "; - if (PEAR::isError($match = $this->DB->getOne($sql))) { - echo " ** Query failed.\n"; - return FALSE; - } - return $match ? TRUE : FALSE; - } - - /** - * Purges missing_examples table - */ - function purgeExamples() - { - $sql = " - DELETE - FROM - missing_examples - "; - if (PEAR::isError($this->DB->query($sql))) { - echo " ** Purge Query failed.\n"; - return FALSE; - } - return TRUE; - } - - /** - * Store missing example data - * - * @param string $ext Extension to which this function belongs - * @param string $func Function name - * @return bool - */ - function storeMissingExample($ext, $func) - { - $sql = " - INSERT - INTO - missing_examples - ( - extension, - function - ) - VALUES - ( - '". $this->DB->escapeSimple($ext) ."', - '". $this->DB->escapeSimple($func) ."' - ) - "; - if (PEAR::isError($this->DB->query($sql))) { - echo " ** Query failed.\n"; - return FALSE; - } - return TRUE; - } - - /** - * Purges undocumented_functions table - */ - function purgeUndocumented() - { - $sql = " - DELETE - FROM - undocumented_functions - "; - if (PEAR::isError($this->DB->query($sql))) { - echo " ** Purge Query failed.\n"; - return FALSE; - } - return TRUE; - } - - /** - * Store missing example data - * - * @param string $ext Extension to which this function belongs - * @param string $func Function name - * @return bool - */ - function storeUndocumentedFunction($ext, $func) - { - $sql = " - INSERT - INTO - undocumented_functions - ( - extension, - function - ) - VALUES - ( - '". $this->DB->escapeSimple($ext) ."', - '". $this->DB->escapeSimple($func) ."' - ) - "; - if (PEAR::isError($this->DB->query($sql))) { - echo " ** Query failed.\n"; - return FALSE; - } - return TRUE; - } - -} -?> diff --git a/include/lib_url_entities.inc.php b/include/lib_url_entities.inc.php deleted file mode 100644 index a440811..0000000 --- a/include/lib_url_entities.inc.php +++ /dev/null @@ -1,409 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: -+----------------------------------------------------------------------+ -| PHP Documentation Tools Site Source Code | -+----------------------------------------------------------------------+ -| Copyright (c) 1997-2011 The PHP Group | -+----------------------------------------------------------------------+ -| This source file is subject to version 3.0 of the PHP license, | -| that is bundled with this package in the file LICENSE, and is | -| available through the world-wide-web at the following url: | -| http://www.php.net/license/3_0.txt. | -| If you did not receive a copy of the PHP license and are unable to | -| obtain it through the world-wide-web, please send a note to | -| [email protected] so we can mail you a copy immediately. | -+----------------------------------------------------------------------+ -| Authors: Georg Richter <[email protected]> | -| Gabor Hojsty <[email protected]> | -| Docweb port: Nuno Lopes <[email protected]> | -| Mehdi Achour <[email protected]> | -| Sean Coates <[email protected]> | -+----------------------------------------------------------------------+ -$Id$ -*/ - -// user agent -define('DOCWEB_CRAWLER_USER_AGENT', 'DocWeb Link Crawler (https://doc.php.net)'); - -// for results -define('SUCCESS', 0); -define('UNKNOWN_HOST', 1); -define('FTP_CONNECT', 2); -define('FTP_LOGIN', 3); -define('FTP_NO_FILE', 4); -define('HTTP_CONNECT', 5); -define('HTTP_MOVED', 6); -define('HTTP_WRONG_HEADER', 7); -define('HTTP_INTERNAL_ERROR', 8); -define('HTTP_NOT_FOUND', 9); - -// lookup -$urlResultLookup = array( // @@@ language-entity these - SUCCESS => '&docweb.checkent.result.success;', - UNKNOWN_HOST => '&docweb.checkent.result.unknown-host;', - FTP_CONNECT => '&docweb.checkent.result.ftp-connect;', - FTP_LOGIN => '&docweb.checkent.result.ftp-login;', - FTP_NO_FILE => '&docweb.checkent.result.ftp-no-file;', - HTTP_CONNECT => '&docweb.checkent.result.http-connect;', - HTTP_MOVED => '&docweb.checkent.result.http-moved;', - HTTP_WRONG_HEADER => '&docweb.checkent.result.http-wrong-header;', - HTTP_INTERNAL_ERROR => '&docweb.checkent.result.http-internal-error;', - HTTP_NOT_FOUND => '&docweb.checkent.result.http-not-found;', -); -// display extra column (return value) -$urlResultExtraCol = array( - SUCCESS => FALSE, - UNKNOWN_HOST => FALSE, - FTP_CONNECT => FALSE, - FTP_LOGIN => FALSE, - FTP_NO_FILE => FALSE, - HTTP_CONNECT => FALSE, - HTTP_MOVED => TRUE, - HTTP_WRONG_HEADER => FALSE, - HTTP_INTERNAL_ERROR => FALSE, - HTTP_NOT_FOUND => FALSE, -); - -// Schemes currently supported -$schemes = array('http'); -if (extension_loaded('openssl')) { - $schemes[] = 'https'; -} -if (function_exists('ftp_connect')) { - $schemes[] = 'ftp'; -} - -// timeout -define('URL_CONNECT_TIMEOUT', 10); - -// allow forking? -define('URL_ALLOW_FORK', function_exists('pcntl_fork') && isset($_ENV['NUMFORKS'])); -define('NUM_ALLOWED_FORKS', URL_ALLOW_FORK ? $_ENV['NUMFORKS'] : 0); - -// SQLite DB files -if (isset($entType)) { // don't bother defining if $entType isn't set - define('URL_ENT_SQLITE_FILE', SQLITE_DIR . "checkent_{$entType}.sqlite"); -} -define('ENTITY_SQLITE_FILE', SQLITE_DIR . 'livedoc-idx.en.sqlite'); -define('REMOTE_ENTITY_SQLITE_FILE', LIVEDOCS . 'livedoc-idx.en.sqlite'); - -/** - * Opens a new SQLite connection for URLs - * - * @return resource SQLite connection - */ -function url_ent_sqlite_open() -{ - return @sqlite_open(URL_ENT_SQLITE_FILE, 0666); -} - -/** - * Opens a new SQLite connection for Entities - * - * @return resource SQLite connection - */ -function ent_sqlite_open() -{ - return @sqlite_open(ENTITY_SQLITE_FILE, 0666); -} - -/** - * Handles relative HTTP URLs (almost RFC 1808 compliant) - * - * @param string $url URL to handle - * @param array $parsed result of parse_url() - * @return string fixed URL - */ -function fix_relative_url ($url, $parsed) -{ - if ($url{0} == '/') { - return "{$parsed['scheme']}://{$parsed['host']}{$url}"; - } - - if (preg_match('@(?:f|ht)tps?://@S', $url)) { - return $url; - } - - /* handle ./ and . */ - if (substr($url, 0, 2) == './') { - $url = substr($url, 2); - } elseif ($url == '.') { - $url = ''; - } - - $path = dirname($parsed['path']) . "/$url"; - $old = ''; - - /* handle ../ */ - do { - $old = $path; - $path = preg_replace('@[^/:?]+/\.\./?@S', '', $path); - } while ($old != $path); - - - return "{$parsed['scheme']}://{$parsed['host']}{$path}"; -} - -/** - * Checks a URL (actually fetches the URL and returns the status) - * - * @param int $num sequence number of URL - * @param string $entity_url URL to check - * @return array - */ -function check_url ($num, $entity_url) -{ - static $old_host = ''; - - // Get the parts of the URL - $url = parse_url($entity_url); - $entity = $GLOBALS['entity_names'][$num]; - - // sleep if accessing the same host more that once in a row - if ($url['host'] == $old_host) { - sleep(5); - } else { - $old_host = $url['host']; - } - - // Try to find host - if (gethostbyname($url['host']) == $url['host']) { - return array(UNKNOWN_HOST, array($num)); - } - - switch($url['scheme']) { - - case 'http': - case 'https': - if (isset($url['path'])) { - $url['path'] = $url['path'] . (isset($url['query']) ? '?' . $url['query'] : ''); - } else { - $url['path'] = '/'; - } - - /* check if using secure http */ - if ($url['scheme'] == 'https') { - $port = 443; - $scheme = 'ssl://'; - } else { - $port = 80; - $scheme = ''; - } - $port = isset($url['port']) ? $url['port'] : $port; - - $junk = ''; - if (!$fp = @fsockopen($scheme . $url['host'], $port, $junk, $junk, URL_CONNECT_TIMEOUT)) { - return array(HTTP_CONNECT, array($num)); - - } else { - $query = "HEAD {$url['path']} HTTP/1.0\r\n" - ."Host: {$url['host']}\r\n" - ."User-agent: ". DOCWEB_CRAWLER_USER_AGENT ."\r\n" - ."Connection: close\r\n" - ."\r\n"; - fputs($fp, $query); - - $str = ''; - while (!feof($fp)) { - $str .= @fgets($fp, 2048); - } - fclose ($fp); - - if (preg_match('@HTTP/1.\d (\d+)(?: .+)?@S', $str, $match)) { - if ($match[1] != '200') { - switch ($match[1]) - { - case '500' : - case '501' : - return array(HTTP_INTERNAL_ERROR, array($num)); - break; - - case '404' : - return array(HTTP_NOT_FOUND, array($num)); - break; - - case '301' : - case '302' : - if (preg_match('/Location: (.+)/', $str, $redir)) { - return array(HTTP_MOVED, array($num, fix_relative_url($redir[1], $url))); - } else { - return array(HTTP_WRONG_HEADER, array($num, $str)); - } - break; - - default : - return array(HTTP_WRONG_HEADER, array($num, $str)); - } - } // error != 200 - } else { - return array(HTTP_WRONG_HEADER, array($num, $str)); - } - } - break; - - case 'ftp': - if ($ftp = @ftp_connect($url['host'])) { - - if (@ftp_login($ftp, 'anonymous', 'IEUser@')) { - $flist = ftp_nlist($ftp, $url['path']); - if (!count($flist)) { - return array(FTP_NO_FILE, array($num)); - } - } else { - return array(FTP_LOGIN, array($num)); - } - @ftp_quit($ftp); - } else { - return array(FTP_CONNECT, array($num)); - } - break; - } - return array(SUCCESS, array($num)); -} - -/** - * Stores the result of the check_url function - * - * @param resource $sqlite sqlite connection resource - * @param int $num entity url number (sequence) - * @param string $name entity name - * @param string $url entity url - * @param array $result result of check_url() - * @return void - */ -function url_store_result($sqlite, $num, $name, $url, $result) -{ - if (!$sqlite) { - if (!$sqlite = url_ent_sqlite_open()) { - echo "Error opening database.\n"; - exit(1); - } - } - $return_val = isset($result[1][1]) ? $result[1][1] : ''; - $sql = " - INSERT - INTO - checked_urls (url_num, entity, url, check_result, return_val) - VALUES - ( - $num, - '". sqlite_escape_string($name) ."', - '". sqlite_escape_string($url) ."', - {$result[0]}, - '". sqlite_escape_string($return_val) ."' - ) - "; - sqlite_query($sqlite, $sql); -} - -/** - * Turns email addresses and URLs into links (for entities) - * - * @param string $eVal Text to (possibly) link - * @return string html-linked text - */ -function ent_link($eVal) -{ - // generic mail match regex - $mailRegex = '!^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$!'; - if (preg_match($mailRegex, $eVal)) { - $eVal = "<a href='mailto:$eVal'>$eVal</a>"; - } else { - $urlRegex = '#(http|https|ftp|news)://([^\s]+)#S'; - $eVal = preg_replace_callback($urlRegex, 'url_callback', $eVal); - } - return $eVal; -} - -/** - * Turns embedded entities into anchor links - * - * @param string $eVal Text to (possibly) alter - * @return string html-linked text - */ -function ent_anchors($eVal) -{ - $entityRegex = '/&([^;]+);/'; - $eVal = preg_replace_callback($entityRegex, 'anchor_callback', $eVal); - return $eVal; -} - -/** - * preg_replace_callback callback for ent_link() - * - * @param array $m results of match - * @return string - */ -function url_callback($m) -{ - $url = $m[1] .'://'. $m[2]; - $link = str_chop($url, 60, true); - - $html = "<a href='$url' title='$url'>$link</a>"; - return $html; -} - -/** - * preg_replace_callback callback for ent_anchors() - * - * @param array $m results of match - * @return string - */ -function anchor_callback($m) -{ - $htmlEntities = get_html_translation_table(HTML_ENTITIES); - $htmlEntities["'"] = '''; // hack; this isn't in the src - - if (in_array("&{$m[1]};", $htmlEntities)) { - return "&{$m[1]};"; - } else { - return "<a href='entities.php#ent-{$m[1]}'>&{$m[1]};</a>"; - } -} - -/** - * Chop a string into a smaller string - * "Public Domain" code from: http://aidan.dotgeek.org/lib/?file=function.str_chop.php - * - * @author Aidan Lister <[email protected]> - * @version 1.1 - * @param mixed $string The string you want to shorten - * @param int $length The length you want to shorten the string to - * @param bool $center If true, chop in the middle of the string - * @param mixed $append String appended if it is shortened - */ -function str_chop($string, $length = 60, $center = false, $append = null) -{ - // Set the default append string - if ($append === null) { - $append = ($center === true) ? ' ... ' : ' ...'; - } - - // Get some measurements - $len_string = strlen($string); - $len_append = strlen($append); - - // If the string is longer than the maximum length, we need to chop it - if ($len_string > $length) { - // Check if we want to chop it in half - if ($center === true) { - // Get the lengths of each segment - $len_start = $length / 2; - $len_end = $len_start - $len_append; - - // Get each segment - $seg_start = substr($string, 0, $len_start); - $seg_end = substr($string, $len_string - $len_end, $len_end); - - // Stick them together - $string = $seg_start . $append . $seg_end; - } else { - // Otherwise, just chop the end off - $string = substr($string, 0, $length - $len_append) . $append; - } - } - - return $string; -} - -?> diff --git a/scripts/checkent.php b/scripts/checkent.php deleted file mode 100755 index 51ac3cc..0000000 --- a/scripts/checkent.php +++ /dev/null @@ -1,173 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: -+----------------------------------------------------------------------+ -| PHP Documentation Site Source Code | -+----------------------------------------------------------------------+ -| Copyright (c) 1997-2011 The PHP Group | -+----------------------------------------------------------------------+ -| This source file is subject to version 3.0 of the PHP license, | -| that is bundled with this package in the file LICENSE, and is | -| available at through the world-wide-web at | -| http://www.php.net/license/3_0.txt. | -| If you did not receive a copy of the PHP license and are unable to | -| obtain it through the world-wide-web, please send a note to | -| [email protected] so we can mail you a copy immediately. | -+----------------------------------------------------------------------+ -| Authors: Georg Richter <[email protected]> | -| Gabor Hojsty <[email protected]> | -| Docweb port: Nuno Lopes <[email protected]> | -| Mehdi Achour <[email protected]> | -| Sean Coates <[email protected]> | -+----------------------------------------------------------------------+ -$Id$ -*/ - -set_time_limit(0); -$scriptBegin = time(); -$inCli = true; -require_once '../include/init.inc.php'; - -// determine type (and display usage on fail) -switch (isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : false) { - case 'phpdoc': - $filename = SVN_DIR . '/' . DOC_DIR. '/doc-base/entities/global.ent'; - $entType = 'php'; - break; - - default: - echo "Usage: {$_SERVER['argv'][0]} phpdoc|peardoc|gtk\n"; - die(); -} - -require_once '../include/lib_url_entities.inc.php'; - -echo "DocWeb URL Entity Checker.\n"; -echo "Using forks? ". (NUM_ALLOWED_FORKS ? 'yes: '. NUM_ALLOWED_FORKS : 'no') . "\n"; -echo "Checking " . $entType . "\n\n"; - -// create a new database (remove old first, if exists) -if (is_file(URL_ENT_SQLITE_FILE) && !unlink(URL_ENT_SQLITE_FILE)) { - echo "Error removing old database.\n"; - die(); -} - -if (!$sqlite = url_ent_sqlite_open()) -{ - echo "Error opening database.\n"; - die(); -} - -// Table creation -$sqlCreateMeta = " - CREATE - TABLE - meta_info - ( - start_time DATETIME, - end_time DATETIME, - schemes VARCHAR(100) - ); -"; -sqlite_query($sqlite, $sqlCreateMeta); -$sqlCreateChecked = " - CREATE - TABLE - checked_urls - ( - url_num INT, - entity VARCHAR(255), - url VARCHAR(255), - check_result INT, - return_val VARCHAR(255) - ); -"; -sqlite_query($sqlite, $sqlCreateChecked); - -// read entities -if (!$file = @file_get_contents($filename)) { - echo "No entities found.\n"; - die(); -} -$array = explode('<!-- Obsoletes -->', $file); - -// Find entity names and URLs -$schemes_preg = '(?:' . join('|', $schemes) . ')'; -preg_match_all("@<!ENTITY\s+(\S+)\s+([\"'])({$schemes_preg}://[^\\2]+)\\2\s*>@U", $array[0], $entities_found); - -// These are the useful parts -$entity_names = $entities_found[1]; -$entity_urls = $entities_found[3]; - -echo "Found: ". count($entity_urls) ." URLs\n"; - -// log start time && schemes in DB -$sql = " - INSERT - INTO - meta_info (start_time, end_time, schemes) - VALUES - (". time() .", NULL, '". sqlite_escape_string(implode(',', $schemes)) ."') -"; -sqlite_query($sqlite, $sql); - -if (URL_ALLOW_FORK) { - // use the forking method ... MUCH faster - declare(ticks=1); - $children = 0; - for ($num=0; $num<count($entity_urls); $num++) { - $url = $entity_urls[$num]; - $name = $entity_names[$num]; - if ($children < NUM_ALLOWED_FORKS) { - $pid = pcntl_fork(); - if ($pid) { - // parent - //echo "Forked: $pid\n"; - ++$children; - } else { - // child - echo "[$num] (". getmypid() .") Checking: $url\n"; - url_store_result(FALSE, $num, $name, $url, check_url($num, $url)); - exit(); - } - } else { - // enough $children - $status = 0; - $child = pcntl_wait($status); - --$children; - echo "Child: $child exited with status $status ($children remain)\n"; - } - } - - while ($children) { - $status = 0; - $child = pcntl_wait($status); - --$children; - echo "Child: $child exited with status $status ($children remain)\n"; - } - -} else { - // no forking - // walk through entities found - foreach ($entity_urls as $num => $entity_url) { - echo "[$num] Checking: $entity_url\n"; - url_store_result($sqlite, $num, $entity_names[$num], $entity_url, check_url($num, $entity_url)); - } - ++$num; // (for the count) -} - -// log end time in DB -$sql = " - UPDATE - meta_info - SET - end_time = ". time() ." -"; -sqlite_query($sqlite, $sql); - -$elapsed = time() - $scriptBegin; - -echo "\n"; -echo "Checked $num URLs.\n"; -echo "Completed in $elapsed seconds.\n"; - -?> diff --git a/scripts/gen_function_aliases.php b/scripts/gen_function_aliases.php deleted file mode 100644 index 674535b..0000000 --- a/scripts/gen_function_aliases.php +++ /dev/null @@ -1,99 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: -+----------------------------------------------------------------------+ -| PHP Documentation Site Source Code | -+----------------------------------------------------------------------+ -| Copyright (c) 2005-2011 The PHP Group | -| Copyright (c) 1997-2004 Dave Barr | -+----------------------------------------------------------------------+ -| This source file is subject to version 3.0 of the PHP license, | -| that is bundled with this package in the file LICENSE, and is | -| available through the world-wide-web at the following url: | -| http://www.php.net/license/3_0.txt. | -| If you did not receive a copy of the PHP license and are unable to | -| obtain it through the world-wide-web, please send a note to | -| [email protected] so we can mail you a copy immediately. | -+----------------------------------------------------------------------+ -| Author: Dave Barr <[email protected]> | -| DocWeb Port: Sean Coates <[email protected]> | -+----------------------------------------------------------------------+ -$Id$ -*/ - -set_time_limit(0); -$scriptBegin = time(); -$inCli = true; -require_once '../include/init.inc.php'; -require_once '../include/lib_meta_info.inc.php'; -require_once '../include/docweb_dao_metainfo.class.php'; - -echo "Generating Function Aliases data...\n"; - -$DAO = new DocWeb_DAO_MetaInfo(TRUE); - -$DAO->metaLogStartTime('aliases'); -$DAO->purgeAliases(); - -// Special places to look for aliases */ -$special = array( - 'info' => 'ZendEngine2/zend_builtin_functions.c', - 'apache' => 'sapi/apache/php_apache.c', -); - -$phpsrc = SRC_DIR; - -// search the extensions -$exts = array(); -$dir = opendir("$phpsrc/ext"); -while ($entry = readdir($dir)) { - if (in_array($entry, array('.','..'))) { - continue; - } - - if (is_dir("$phpsrc/ext/$entry")) { - $exts[] = $entry; - } -} -closedir($dir); - -$aliases = array(); -$total = 0; - -foreach ($exts as $ext) { - $extdir = "$phpsrc/ext/$ext"; - $dir = opendir($extdir); - while ($entry = readdir($dir)) { - if (in_array($entry, array('.','..'))) { - continue; - } - - if (is_file("$extdir/$entry") && - substr("$extdir/$entry", -2) == ".c") { - - // file is a C file, check it for function aliases - find_alias_file("$extdir/$entry", $ext); - } - } - closedir($dir); -} - -foreach ($special as $ext => $filename) { - if (is_file("$phpsrc/$filename")) { - find_alias_file("$phpsrc/$filename", $ext); - } -} - -ksort($aliases, SORT_STRING); - -foreach ($aliases AS $ext => $aliasData) { - foreach ($aliasData AS $alias => $func) { - echo "[$ext] $alias -> $func\n"; - $DAO->storeFunctionAlias($ext, $alias, $func); - } -} - -$DAO->metaLogEndTime('aliases'); - -echo "** Done.\n"; -?> - diff --git a/scripts/gen_missing_examples.php b/scripts/gen_missing_examples.php deleted file mode 100644 index a617614..0000000 --- a/scripts/gen_missing_examples.php +++ /dev/null @@ -1,137 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: -+----------------------------------------------------------------------+ -| PHP Documentation Site Source Code | -+----------------------------------------------------------------------+ -| Copyright (c) 2005-2011 The PHP Group | -| Copyright (c) 1997-2004 Dave Barr | -+----------------------------------------------------------------------+ -| This source file is subject to version 3.0 of the PHP license, | -| that is bundled with this package in the file LICENSE, and is | -| available through the world-wide-web at the following url: | -| http://www.php.net/license/3_0.txt. | -| If you did not receive a copy of the PHP license and are unable to | -| obtain it through the world-wide-web, please send a note to | -| [email protected] so we can mail you a copy immediately. | -+----------------------------------------------------------------------+ -| Author: Dave Barr <[email protected]> | -| DocWeb Port: Sean Coates <[email protected]> | -+----------------------------------------------------------------------+ -$Id$ -*/ - -set_time_limit(0); -$scriptBegin = time(); -$inCli = true; -require_once '../include/init.inc.php'; -require_once '../include/lib_meta_info.inc.php'; -require_once '../include/docweb_dao_metainfo.class.php'; - -echo "Generating Missing Examples data...\n"; - -$DAO = new DocWeb_DAO_MetaInfo(TRUE); - -$reference = SVN_DIR . '/' .DOC_DIR .'/en/reference'; - -$excludefuncs = array( - 'overload' => 'The example is in the introductory section', - 'mysql-db-query' => 'Deprecated function', - 'mysql-change-user' => 'PHP 3', - 'delete' => 'Pseudo function', - 'main' => 'Pseudo function' -); - -$exts = array(); -$dir = opendir($reference); - -while ($entry = readdir($dir)) { - if ($entry == "." || $entry == "..") { - continue; - } - - // entry is a directory, and has a valid functions sub-directory - if (is_dir("$reference/$entry") && is_dir("$reference/$entry/functions")) { - $exts[] = $entry; - } -} - -closedir($dir); - -sort($exts, SORT_STRING); - -$extfuncs = array(); -$functotal = 0; - -foreach ($exts as $ext) { - $extfuncs[$ext] = array(); - - $funcdir = "$reference/$ext/functions"; - $dir = opendir($funcdir); - - while ($entry = readdir($dir)) { - $function = substr($entry, 0, -4); - - // found a file in the functions directory, and it's an .xml file - if ( - is_file("$funcdir/$entry") && - substr($entry, -4) == ".xml" && - strstr(substr($entry, 0, -4), ".") === false && - !isset($excludefuncs[$function]) - ) { - $file = file_get_contents("$funcdir/$entry"); - $ufunction = str_replace('-', '_', $function); - - $alias = $DAO->isAlias($ufunction); - - if ( - strstr($file, "<example") === false && - strstr($file, "<informalexample") === false && - strstr($file, "&info.function.alias;") === false - ) { - // this function doesn't have an example - - // check if this function is an alias - if (!$alias) { - $extfuncs[$ext][] = $ufunction; - } - } - - if (!$alias) { - $functotal++; - } - } - } - - sort($extfuncs[$ext], SORT_STRING); - closedir($dir); -} - -$notmissing = array(); -$extcount = 0; -$total = 0; - - -foreach ($extfuncs as $name => $ext) { - $exttotal = count($ext); - - if ($exttotal == 0) { - $notmissing[] = $name; - } - else { - $extcount++; - $total += $exttotal; - } - -} - -$DAO->purgeExamples(); -foreach (array_diff($extfuncs, $notmissing) AS $ext => $extData) { - foreach ($extData AS $func) { - echo "[$ext] $func\n"; - $DAO->storeMissingExample($ext, $func); - } -} - -echo "** Done.\n"; - -?> diff --git a/scripts/gen_undocumented_functions.php b/scripts/gen_undocumented_functions.php deleted file mode 100644 index dbf7e08..0000000 --- a/scripts/gen_undocumented_functions.php +++ /dev/null @@ -1,113 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: -+----------------------------------------------------------------------+ -| PHP Documentation Site Source Code | -+----------------------------------------------------------------------+ -| Copyright (c) 2005-2011 The PHP Group | -| Copyright (c) 1997-2004 Dave Barr | -+----------------------------------------------------------------------+ -| This source file is subject to version 3.0 of the PHP license, | -| that is bundled with this package in the file LICENSE, and is | -| available through the world-wide-web at the following url: | -| http://www.php.net/license/3_0.txt. | -| If you did not receive a copy of the PHP license and are unable to | -| obtain it through the world-wide-web, please send a note to | -| [email protected] so we can mail you a copy immediately. | -+----------------------------------------------------------------------+ -| Author: Dave Barr <[email protected]> | -| DocWeb Port: Sean Coates <[email protected]> | -+----------------------------------------------------------------------+ -$Id$ -*/ - -set_time_limit(0); -$scriptBegin = time(); -$inCli = true; -require_once '../include/init.inc.php'; -require_once '../include/lib_meta_info.inc.php'; -require_once '../include/docweb_dao_metainfo.class.php'; - -echo "Generating Missing Examples data...\n"; - -$DAO = new DocWeb_DAO_MetaInfo(TRUE); - -$reference = SVN_DIR . '/' . DOC_DIR ."/en/reference"; - -$exts = array(); -$dir = opendir($reference); - -while ($entry = readdir($dir)) { - if ($entry == "." || $entry == "..") - continue; - - // entry is a directory, and has a valid functions sub-directory - if (is_dir("$reference/$entry") && is_dir("$reference/$entry/functions")) { - $exts[] = $entry; - } -} - -closedir($dir); - -sort($exts, SORT_STRING); - -$extfuncs = array(); - -foreach ($exts as $ext) { - $extfuncs[$ext] = array(); - - $funcdir = "$reference/$ext/functions"; - $dir = opendir($funcdir); - - while ($entry = readdir($dir)) { - // found a file in the functions directory, and it's an .xml file - if ( - is_file("$funcdir/$entry") && - substr($entry, -4) == ".xml" && - strstr(substr($entry, 0, -4), ".") === false - ) { - $file = file_get_contents("$funcdir/$entry"); - - if (strstr($file, "&warn.undocumented.func;") !== false) { - // this function isn't documented - $function = str_replace('-', '_', substr($entry, 0, -4)); - - // check if this function is an alias - if (!$DAO->isAlias($function)) { - $extfuncs[$ext][$function] = true; - } - } - } - } - - asort($extfuncs[$ext], SORT_STRING); - closedir($dir); -} - -$notmissing = array(); -$extcount = 0; -$total = 0; - -foreach ($extfuncs as $name => $ext) { - $exttotal = count($ext); - - if ($exttotal == 0) { - $notmissing[] = $name; - } - else { - $extcount++; - $total += $exttotal; - } -} - -$DAO->purgeUndocumented(); - -foreach (array_diff($extfuncs, $notmissing) AS $ext => $extData) { - foreach ($extData AS $func => $junk) { - echo "[$ext] $func\n"; - $DAO->storeUndocumentedFunction($ext, $func); - } -} - -echo "** Done.\n"; - -?> diff --git a/scripts/grab_livedocs_db.php b/scripts/grab_livedocs_db.php deleted file mode 100644 index 9b29b72..0000000 --- a/scripts/grab_livedocs_db.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: -+----------------------------------------------------------------------+ -| PHP Documentation Site Source Code | -+----------------------------------------------------------------------+ -| Copyright (c) 1997-2011 The PHP Group | -+----------------------------------------------------------------------+ -| This source file is subject to version 3.0 of the PHP license, | -| that is bundled with this package in the file LICENSE, and is | -| available at through the world-wide-web at | -| http://www.php.net/license/3_0.txt. | -| If you did not receive a copy of the PHP license and are unable to | -| obtain it through the world-wide-web, please send a note to | -| [email protected] so we can mail you a copy immediately. | -+----------------------------------------------------------------------+ -| Authors: Sean Coates <[email protected]> | -+----------------------------------------------------------------------+ -$Id$ -*/ - -/* Note: If someone has a more efficient way of doing this, - * please fee free to step up. I'm just re-using what livedocs - * already seems to do well... only the `ents` table is required. - * -S - */ - -set_time_limit(0); -$scriptBegin = time(); -$inCli = true; -require_once '../include/init.inc.php'; -require_once '../include/lib_url_entities.inc.php'; - -echo "Grabbing livedocs DB...\n"; - -copy(REMOTE_ENTITY_SQLITE_FILE, ENTITY_SQLITE_FILE); - -$scriptTime = time() - $scriptBegin; -echo "Completed in $scriptTime seconds\n"; - -?> diff --git a/scripts/notes_stats.php b/scripts/notes_stats.php deleted file mode 100644 index 42b21c2..0000000 --- a/scripts/notes_stats.php +++ /dev/null @@ -1,197 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: -+----------------------------------------------------------------------+ -| PHP Documentation Site Source Code | -+----------------------------------------------------------------------+ -| Copyright (c) 1997-2011 The PHP Group | -+----------------------------------------------------------------------+ -| This source file is subject to version 3.0 of the PHP license, | -| that is bundled with this package in the file LICENSE, and is | -| available at through the world-wide-web at | -| http://www.php.net/license/3_0.txt. | -| If you did not receive a copy of the PHP license and are unable to | -| obtain it through the world-wide-web, please send a note to | -| [email protected] so we can mail you a copy immediately. | -+----------------------------------------------------------------------+ -| Authors: Mehdi Achour <[email protected]> (Original Author) | -| Vincent Gevers <[email protected]> | -| Credits: Sean Coates <[email protected]> | -+----------------------------------------------------------------------+ -$Id$ -*/ - -require_once '../build-ops.php'; -require_once '../include/docweb_template.class.php'; - -// Define some globally used vars - -// This setting is used in the output script -$minact = 100; - -$DBFile = SQLITE_DIR . 'notes_stats.sqlite'; - - -if (is_readable($DBFile)) { - $sqlite = sqlite_open($DBFile, 0666); - -// asuming it's not created yet -} else { - $sqlite = create_db($DBFile); -} - -if (!isset($_ENV['SKIP_NNTP'])) { - -$s = nntp_connect("news.php.net") or die("failed to connect to news server\n"); -$res = nntp_cmd($s, 'GROUP php.notes', 211) or die("failed to get infos on news group\n"); - -$first = sqlite_single_query($sqlite, 'SELECT last_article FROM info'); -list($last) = explode(' ', $res); - -if ($first > $last) { - die("Nothing I can do, no new notes available\n"); -} -// process only 10k news in one iteration -elseif ($last > $first+10000) { - $last = $first+10000; -} - -echo "Fetching items: $first-$last\n"; -nntp_cmd($s, "XOVER $first-$last", 224) or die("failed to XOVER the new items\n"); - -$sql = ''; -$last_update = time(); - -for ($i = $first; $i <= $last; ++$i) { - $line = fgets($s, 4096); - $n = $subj = $author = $odate = null; - - $line_parts = explode("\t", $line, 5); - - if(isset($line_parts[0])) $n = $line_parts[0]; - if(isset($line_parts[1])) $subj = $line_parts[1]; - if(isset($line_parts[2])) $author = $line_parts[2]; - if(isset($line_parts[3])) $odate = $line_parts[3]; - - /* check if the server has closed the connection - the program will continue to fetch data later */ - if (feof($s)) { - break; - } - - echo "\r$i"; - - /* - * What should be matched: - * note ID deleted from SECTION by EDITOR - * note ID rejected from SECTION by EDITOR - * note ID modified in SECTION by EDITOR - */ - - if (preg_match('/^note (\d+) (.+) (?:from|in) (.+) by (.+)/S', $subj, $d)) { - if ($d[2] == 'approved') { - continue; - } - - if ($d[2] == 'rejected and deleted') { - $d[2] = 'rejected'; - } - - if (substr($d[3], 0, -4)) { - $d[3] = str_replace('.php', '', $d[3]); - } - - $d[] = strtotime($odate); - $sql .= make_sql($d); - - } // end if(preg_match - -} // end for loop - -@fclose($s); - -// using $i to allow a fetching resume -$sql .= "UPDATE info SET last_article=$i, build_date=$last_update;"; - -sqlite_query($sqlite, 'BEGIN TRANSACTION'); -sqlite_query($sqlite, $sql); -sqlite_query($sqlite, 'COMMIT TRANSACTION'); -sqlite_close($sqlite); - -} // (end SKIP_NNTP block) - -/* write the output to the /www folder */ -include './notes_stats_output.php'; - -$fp = fopen(PATH_ROOT . '/www/notes_stats-data.php', 'w'); -fputs($fp, $out); -fclose($fp); - -/* end of the script */ - - - -/* Open a connection to a NTTP server */ -function nntp_connect($server, $port = 119) { - - if (!$socket = fsockopen($server, $port, $errno, $errstr, 30)) { - echo "error connecting to nntp server: $errstr\n"; - return false; - } - - if (substr(fgets($socket, 1024), 0, 4) != "200 ") { - echo "unexpected greeting: $hello\n"; - return false; - } - - return $socket; -} - - -/* issue a NTTP command */ -function nntp_cmd($conn, $command, $expected) { - if (strlen($command) > 510){ - die("command too long: $command"); - } - - fputs($conn, "$command\r\n"); - list($code,$extra) = explode(' ', fgets($conn, 1024), 2); - - return $code == $expected ? $extra : false; -} - - -/* create a new DB and table schema */ -function create_db($DBFile) { - echo "Creating the database: $DBFile\n"; - - $sqlite = sqlite_open($DBFile, 0666); - - $sql = <<< SQL -CREATE TABLE info ( - last_article INTEGER, - build_date INTEGER -); - -CREATE TABLE notes ( - note INTEGER, - action TEXT, - manpage TEXT, - who TEXT, - time INTEGER -); - -INSERT INTO info VALUES(1, 0); -SQL; - - sqlite_query($sqlite, $sql); - return $sqlite; -} - - -/* makes a sql insert statment from an array */ -function make_sql($array) { - array_shift($array); - return 'INSERT INTO notes VALUES ("' . implode('", "', $array) . '");'; -} - -?> diff --git a/scripts/notes_stats_output.php b/scripts/notes_stats_output.php deleted file mode 100644 index 870a6b8..0000000 --- a/scripts/notes_stats_output.php +++ /dev/null @@ -1,75 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: -+----------------------------------------------------------------------+ -| PHP Documentation Site Source Code | -+----------------------------------------------------------------------+ -| Copyright (c) 1997-2011 The PHP Group | -+----------------------------------------------------------------------+ -| This source file is subject to version 3.0 of the PHP license, | -| that is bundled with this package in the file LICENSE, and is | -| available at through the world-wide-web at | -| http://www.php.net/license/3_0.txt. | -| If you did not receive a copy of the PHP license and are unable to | -| obtain it through the world-wide-web, please send a note to | -| [email protected] so we can mail you a copy immediately. | -+----------------------------------------------------------------------+ -| Authors: Vincent Gevers <[email protected]> | -| Sean Coates <[email protected]> | -+----------------------------------------------------------------------+ -$Id$ -*/ - -// config comes from notes_stats.php - -if (@filesize($DBFile) < 3000000) { // require at least 3 MBs - $out = FALSE; - return; -} - -$sqlite = sqlite_open($DBFile); - -$info = sqlite_fetch_array(sqlite_query($sqlite, 'SELECT * FROM info'), SQLITE_ASSOC); - -// fetch/sort data -$array = sqlite_fetch_all(sqlite_query($sqlite, 'SELECT * FROM notes'), SQLITE_ASSOC); -sqlite_close($sqlite); -$time = time() - 60*60*24*365; - -foreach($array as $row) { - @++$data[$row['who']][$row['action']]; - @++$total[$row['who']]; - @++$manual[$row['manpage']]; - - if ($row['time'] >= $time) { - @++$data_new[$row['who']][$row['action']]; - @++$data_new[$row['who']]['total']; - } - -} -unset($data['']); -ksort($data); -ksort($data_new); -arsort($total); -arsort($manual); - -$build_date = date('j F Y', $info['build_date']); - -$notesData = array( - 'last_article' => $info['last_article'], - 'build_date' => $build_date, - 'data' => $data, - 'data_new' => $data_new, - 'total' => $total, - 'manual' => $manual, - 'minact' => $minact, -); - -$out = "<?php\n"; -$out .= "// This script generated by scripts/notes_stats_output.php -- DO NOT COMMIT\n"; -$out .= "\$notesData = ". var_export($notesData, true) .";\n"; -$out .= "if (isset(\$_GET['raw_data']) && \$_GET['raw_data']) {\n"; -$out .= " var_export(\$notesData);\n"; -$out .= "}\n"; -$out .= "// EOF\n?>"; - -?> diff --git a/scripts/orphan_notes.php b/scripts/orphan_notes.php deleted file mode 100755 index d530673..0000000 --- a/scripts/orphan_notes.php +++ /dev/null @@ -1,145 +0,0 @@ -<?php -/** - * +----------------------------------------------------------------------+ - * | PHP Documentation Site Source Code | - * +----------------------------------------------------------------------+ - * | Copyright (c) 1997-2011 The PHP Group | - * +----------------------------------------------------------------------+ - * | This source file is subject to version 3.0 of the PHP license, | - * | that is bundled with this package in the file LICENSE, and is | - * | available at through the world-wide-web at | - * | http://www.php.net/license/3_0.txt. | - * | If you did not receive a copy of the PHP license and are unable to | - * | obtain it through the world-wide-web, please send a note to | - * | [email protected] so we can mail you a copy immediately. | - * +----------------------------------------------------------------------+ - * | Authors: Nuno Lopes <[email protected]> | - * +----------------------------------------------------------------------+ - * - * $Id$ - */ - -/* - * This script searches for orphan notes in the phpdoc manual - * You need a rsync'ed phpweb dir - */ - - -$inCli = true; -include '../include/init.inc.php'; - -$manual_dir = SVN_DIR .'/phpweb/manual/en'; -$notes_dir = SVN_DIR .'/phpweb/backend/notes'; - - -/* Collect manual IDs */ -function recurse_manual($dir) { - global $files, $len; - - if (!$dh = opendir($dir)) { - exit; - } - - while (($file = readdir($dh)) !== false) { - - if($file == '.' || $file == '..') { - continue; - } - - $path = $dir.'/'.$file; - - if(is_dir($path)) { - recurse_manual($path); - } else { - $files[substr(md5(substr($path, $len, -4)), 0, 16)] = 1; - } - } - - closedir($dh); -} - - -/* Search for bogus notes IDs */ -function recurse_notes($dir) { - global $array, $files, $n_files, $n_notes; - - if (!$dh = opendir($dir)) { - exit; - } - - while (($file = readdir($dh)) !== false) { - - if($file == '.' || $file == '..' || substr($file, -4) == '.bz2' || - $file == 'last-updated' || $file == 'sections') { - continue; - } - - $path = $dir.'/'.$file; - - if(is_dir($path)) { - recurse_notes($path); - } else { - if(isset($files[$file])) { - continue; - } - - $fp = fopen($path, 'r'); - - while (!feof($fp)) { - $line = chop(fgets($fp, 12288)); - if ($line == '') { continue; } - - list($id, $sect) = explode('|', $line); - $array[$sect][] = $id; - - ++$n_notes; - } // file orphan - - ++$n_files; - } // file - } // main while - - closedir($dh); -} - - -/* output HTML */ -function output_html() { - global $array, $n_notes, $n_files; - - echo "<?php include_once '../include/init.inc.php'; echo site_header('docweb.common.header.orphan-notes'); ?><p> </p>"; - - if(count($array) == 0) { - echo '<p>Currently, there are no orphan notes!</p>'; - echo '<p>Last Check: ' . date('r') . '</p>'; - echo '<?php echo site_footer(); ?>'; - return; - } - - echo '<table class="Tc"><tr class="blue"><th>Old ID</th>'. - '<th>Notes IDs</th><th>Move to new ID:</th></tr>'; - - foreach($array as $id => $notes) { - echo '<tr class="old"><td>'.$id.'</td><td>' . - preg_replace('/(\d+)/', '<a href="https://master.php.net/manage/user-notes.php?keyword=$1">$1</a>', implode(', ', $notes)) . - '</td><td><form action="https://master.php.net/manage/user-notes.php?action=mass" method="post">'. - '<input type="hidden" name="step" value="1" /><input type="hidden" name="old_sect" value="' . $id . '" />'. - '<input type="text" name="new_sect" value="" size="30" maxlength="80" /><input type="submit" value=">" /></form></td></tr>'; - - } - - echo "</table><p> </p><p><b>Total Notes</b>: $n_notes<br/><b>Total files</b>: $n_files</p>". - '<p>Last Check: ' . date('r') . '</p><?php echo site_footer(); ?>'; -} - - -/* begin main program */ -$len = strlen("$manual_dir/"); -$n_notes = $n_files = 0; - -recurse_manual($manual_dir); -recurse_notes($notes_dir); - -output_html(); - -?>