<?php
/**
 * 
 * @file test.php
 * @copyright (c) 2005 - 2011 eifr.com
 * @license http://www.gnu.org/copyleft/gpl.html gnu/gpl
 * eifr is free software
 */
require_once('../../includes/inc_admin.php');
require_once(EIFR_ROOT . 'libraries/adodb_lite/query_debug_console/query_debug_console.php');
//define('EIFR_PATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
//echo EIFR_PATH.",".DIRECTORY_SEPARATOR."<br>";

$url = 'mod_config/config_edit.php';
Common::checkAdminFileAuth($url); //check file authority

function updateArticle() {
    global $db;
    $i = 0;
    $sql = "select id, relation_type, relation_info from eifr_article where relation_type=1 ";
    $rs = $db -> Execute($sql);
    while (!$rs -> EOF) {
        $i++;
        $id = $rs -> fields['id'];
        $relation_info = $rs -> fields['relation_info'];
        $relation_info = str_replace('|',' ',$relation_info);
        
        $sql = "update eifr_article set relation_info = '$relation_info' where id='$id'";
        $rs1 = $db -> Execute($sql);

        $rs -> MoveNext();
    } 
    $rs -> Close();
    echo "updateArticle OK($i) <br>";
} 

//$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
function t_genTable()
{
    echo "<br>[t_genTable]<br>";
    global $db, $ADODB_FETCH_MODE;
    $fields = array();
    $sql = "select * from eifr_article2 limit 1";
    $rs = $db->Execute($sql);
    if($rs) {
        foreach($rs->fields as $key=>$val) {
            $fields[$key] = '';
        }
    }

    if($fields) {
        $cacheHelper = new CCacheHelper('gen_eifr_article2');
        $cacheHelper -> deleteCache();
        $cacheHelper -> writeCache($fields);
    }

}

function tlog() {
    Log_d(__FILE__, __LINE__, 'debug');
    Log_F(__FILE__, __LINE__, 'fatal');
    Log_e(__FILE__, __LINE__, 'err');
    Log_w(__FILE__, __LINE__, 'warn');
    Log_i(__FILE__, __LINE__, 'info');
    Log_v(__FILE__, __LINE__, 'verbose');
} 

echo "eifr_root:" . EIFR_ROOT . "<br>";

echo "<a href='test.php?act=do' >test</a><br>";

$act = kGet('act');
Log_i(__FILE__, __LINE__, $act);
if ($act == 'do') {
    updateArticle();
} 
echo '<hr/>';

/**
 * End of file test.php
 */