/** * 得到帖子信息 * @param $tid - 帖子ID * @param $returnpid - 返回首帖pid * @param $msgleng - 內容截斷的長度 */ function list_threads($tid = 0, $msgleng = 255) { global $_G, $_SC; $tid = intval($tid); $msgleng = intval($msgleng); $ret_thread = array(); if ($tid > 0) { $bbs_dbpre = $_SC['bbs_dbpre']; $db = new db_mysql(array(1 => array('tablepre' => $_SC['bbs_dbpre'], 'dbcharset' => $_SC['bbs_dbcharset'], 'dbhost' => $_SC['bbs_dbhost'], 'dbuser' => $_SC['bbs_dbuser'], 'dbpw' => $_SC['bbs_dbpw'], 'dbname' => $_SC['bbs_dbname']))); $db->connect(); //$db->charset = $_SC['bbs_dbcharset']; //$db->connect($_SC['bbs_dbhost'], $_SC['bbs_dbuser'], $_SC['bbs_dbpw'], $_SC['bbs_dbname'], 0, 1); $query = $db->query("SELECT pid, authorid, author, subject, message FROM {$bbs_dbpre}posts WHERE tid='{$tid}' AND first='1' LIMIT 1"); $ret_thread = $db->fetch_array($query); if (!empty($ret_thread['message'])) { $ret_thread['message'] = messagecutstr($ret_thread['message'], $msgleng); } $db->close(); unset($db); } return $ret_thread; }
*/ require_once "db.class.php"; require_once "XMLParser.php"; require_once "NotificationObject.php"; $config = (require 'config.php'); //Initiate the database connection and the parser $db = new db_mysql($config); $parser = new XMLParser(); //In SpoCoSy, we do not hard delete rows, we set "del" to "yes" //This is probably not what you want, so if del equals yes, this code will delete the element //If you set this to false, it will only set "del" to "yes" and not remove the row $HARD_DELETE = true; //Check if there any files to parse $toParse = $db->query("SELECT * from saved_xml ORDER BY `ut` ASC LIMIT 10") or $db->raise_error(); //Loop over these files while ($fileToParse = $db->fetch_array($toParse)) { $filename = "files/" . $fileToParse["id"] . ".xml"; //Once parse move this file to here $parsedfile = "files/parsed/" . $fileToParse["id"] . ".xml"; echo "Procesing {$filename} \n"; if (file_exists($filename)) { $output = ""; $file = fopen($filename, "r"); if (FALSE === $file) { echo "cannot open {$filesToParse['id']}.xml , exiting..\n"; exit; } while (!feof($file)) { //read file line by line into variable $output = $output . fgets($file, 4096); }