コード例 #1
0
         echo Xml::XmlHeader() . Xml::element('operation', array('status' => 'success'), 'Articles marked as processed');
     } else {
         ReturnError('Request missing essential data', 'request');
     }
     break;
 case 'displayarticles':
     header("Content-type: text/xml; charset=utf-8");
     $wiki = @$_GET['wiki'];
     if (empty($wiki)) {
         ReturnError('No project defined', 'project');
     }
     $count = isset($_GET['count']) ? $_GET['count'] : 100;
     if (!is_numeric($count)) {
         ReturnError('Count is not a number', 'count');
     }
     $siteid = GetOrAddSite($wiki);
     $query = 'SELECT articleid, title FROM articles, site WHERE (site.siteid = articles.siteid) AND (site.address = "' . $wiki . '") AND (checkedout < DATE_SUB(NOW(), INTERVAL 3 HOUR)) AND (userid = 0) LIMIT ' . $count;
     $result = mysql_query($query) or ReturnError('Error: ' . mysql_error(), 'query');
     $xml_output = Xml::XmlHeader() . "\n";
     $xml_output .= Xml::openElement('typoscan');
     $xml_output .= Xml::element('site', array('siteid' => $siteid, 'address' => $wiki));
     $array = array();
     $xml_output .= Xml::openElement('articles');
     while ($row = mysql_fetch_assoc($result)) {
         $array[] = $row['articleid'];
         $therow = $row['title'];
         $xml_output .= "\t" . Xml::element('article', array('id' => $row['articleid']), $therow);
     }
     $xml_output .= Xml::closeElement('articles');
     $xml_output .= Xml::closeElement('typoscan');
     if (mysql_num_rows($result) > 0) {
コード例 #2
0
<?php

if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
    // require_once('common.php');
    die("This is a command-line script\n");
}
if (!isset($argv[1]) && !isset($argv[2])) {
    die("Parameters: <filename> <wiki>\n");
}
echo "Connecting to MySQL...\n";
require_once 'typo-db.php';
require_once 'common.php';
// TODO:Need better parameter handling
$filename = $argv[1];
$siteid = GetOrAddSite($argv[2]);
echo "Site ID: " . $siteid . "\n";
echo "Reading file {$filename}...\n";
$f = fopen($filename, 'r') or die;
echo "Init complete, importing...\n";
$i = 0;
while (!feof($f)) {
    $name = trim(fgets($f));
    if (empty($name)) {
        continue;
    }
    $i++;
    $q = "INSERT INTO articles (title, siteid) VALUES ('" . mysql_escape_string($name) . "', '" . $siteid . "')";
    mysql_query($q) or die;
    // echo $name . "\n";
    if ($i % 100 == 0) {
        echo $i . "\n";