Beispiel #1
0
 }
 // Select articles DB
 $_mysql->selectdb(KSDBConfig::DB);
 $_POST['id'] = mysql_real_escape_string($_POST['id'], $_mysql->link());
 $_POST['author'] = mysql_real_escape_string($_POST['author'], $_mysql->link());
 $_POST['after'] = mysql_real_escape_string($_POST['after'], $_mysql->link());
 $_POST['before'] = mysql_real_escape_string($_POST['before'], $_mysql->link());
 $_POST['last'] = mysql_real_escape_string($_POST['last'], $_mysql->link());
 $_where_condition = '';
 switch ($_POST['mode']) {
     case 'id':
         $_where_condition = " and t1.id in ({$_POST['id']})";
         break;
     case 'author':
         $_res = $_mysql->query("select id from " . KSAdminDBConfig::DB . ".uinfo where name='{$_POST['author']}';");
         if (1 !== $_mysql->numrows()) {
             throw new Exception("Specified Author does not exist.");
         }
         $_row = mysql_fetch_array($_res, MYSQL_ASSOC);
         $_where_condition = " and t1.author='{$_row['id']}'";
         break;
     case 'trange':
         $_where_condition = " and t1.added between '{$_POST['after']}' and '{$_POST['before']}'";
         break;
     default:
         // Assume Normal Mode
         //
         $_where_condition = ($_POST['after'] ? " and t1.added>'{$_POST['after']}'" : '') . ($_POST['before'] ? " and t1.added<'{$_POST['before']}'" : '');
         break;
 }
 $_entries = new KSJsonEntries();
Beispiel #2
0
    {
        return json_encode(array('body' => $this->body));
    }
}
// Entry entry deailes that is identified by:
//   1. ID
$_POST['id'] = trim(strip_tags(urldecode(stripslashes($_POST['id']))));
try {
    if (!preg_match('/^[0-9]{1,5}$/', $_POST['id']) || 65535 < $_POST['id']) {
        throw new RuntimeException('Inexisting Entry.');
    }
    $_mysql = new KSMySQL();
    if (!$_mysql->connect(KSDBConfig::HOST, KSDBConfig::USER, KSDBConfig::PASS)) {
        throw new Exception('DB Failure. Can not read entry at the moment. Try later.');
    }
    // Select articles DB
    $_mysql->selectdb(KSDBConfig::DB);
    // Register article in DB.
    $_res = $_mysql->query("select body from entry where id='{$_POST['id']}';");
    if (!$_mysql->numrows()) {
        throw new Exception('No entries were found.');
    }
    $_row = mysql_fetch_assoc($_res);
    if (!$_row) {
        throw new RuntimeException('Failed to read entry. Try later.');
    }
    KSServiceJson::instance()->chain(new KSJsonEntry($_row['body']));
} catch (Exception $exception) {
    KSServiceJson::instance()->chain(new KSJsonError($exception->getMessage()));
}
echo KSServiceJson::instance();
Beispiel #3
0
}
$_POST['id'] = trim(strip_tags(urldecode(stripslashes($_POST['id']))));
$_POST['last'] = trim(strip_tags(urldecode(stripslashes($_POST['last']))));
try {
    if (!preg_match('/^[0-9]{1,5}$/', $_POST['id']) || 65535 < $_POST['id']) {
        throw new RuntimeException('Inexisting Entry.');
    }
    if ($_POST['last'] && !preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}\\ [0-9]{2}:[0-9]{2}:[0-9]{2}$/', $_POST['last'])) {
        throw new RuntimeException('Inacceptable Last Date sent.');
    }
    $_mysql = new KSMySQL();
    if (!$_mysql->connect(KSDBConfig::HOST, KSDBConfig::USER, KSDBConfig::PASS)) {
        throw new Exception('DB Failure. Can not read replies at the moment. Try later.');
    }
    // Select articles DB
    $_mysql->selectdb(KSDBConfig::DB);
    $_POST['id'] = mysql_real_escape_string($_POST['id'], $_mysql->link());
    $_POST['last'] = mysql_real_escape_string($_POST['last'], $_mysql->link());
    // Get replies associated with current entry from DB.
    $_res = $_mysql->query("select t2.id,t2.author as aid,t3.name as author,t2.body,t2.added from rhead as t1 join reply as t2 join " . KSAdminDBConfig::DB . ".uinfo as t3 where t1.eid='{$_POST['id']}' and t1.rid=t2.id and t3.id=t2.author " . ($_POST['last'] ? " and t2.added>'{$_POST['last']}'" : '') . " order by t2.added asc;");
    $_replies = new KSJsonReplies();
    if ($_mysql->numrows()) {
        while ($_row = mysql_fetch_array($_res, MYSQL_ASSOC)) {
            $_replies->push_back(new KSReply($_row['id'], $_row['aid'], $_row['author'], $_row['body'], $_row['added']));
        }
    }
    KSServiceJson::instance()->chain($_replies);
} catch (Exception $exception) {
    KSServiceJson::instance()->chain(new KSJsonError($exception->getMessage()));
}
echo KSServiceJson::instance();