Beispiel #1
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 #2
0
     throw new Exception('DB Failure. Can not read entries at the moment. Try later.');
 }
 // 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;
 }
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();
Beispiel #4
0
    }
    public function __toString()
    {
        return json_encode(array('id' => $this->id, 'aid' => $this->aid, 'author' => $this->author, 'added' => $this->added, 'body' => $this->body));
    }
}
$_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 Reply.');
    }
    $_mysql = new KSMySQL();
    if (!$_mysql->connect(KSDBConfig::HOST, KSDBConfig::USER, KSDBConfig::PASS)) {
        throw new Exception('DB Failure. Can not read reply at the moment. Try later.');
    }
    // Select articles DB
    $_mysql->selectdb(KSDBConfig::DB);
    // Get entry meta data
    $_res = $_mysql->query('select t1.id,t1.author as aid,t2.name as author,' . 't1.added,t1.body from reply as t1 join ' . KSAdminDBConfig::DB . ".uinfo as t2 where t1.author=t2.id and t1.id='{$_POST['id']}';");
    if (!$_mysql->numrows()) {
        throw new Exception('Failed to get Reply: inexisting ID.');
    }
    $_row = mysql_fetch_assoc($_res);
    if (!$_row) {
        throw new RuntimeException('Failed to read reply. Try later.');
    }
    KSServiceJson::instance()->chain(new KSJsonReply($_row['id'], $_row['aid'], $_row['author'], $_row['added'], $_row['body']));
} catch (Exception $exception) {
    KSServiceJson::instance()->chain(new KSJsonError($exception->getMessage()));
}
echo KSServiceJson::instance();
Beispiel #5
0
later.');
    }
    $_mysql->selectdb(KSDBConfig::DB);
    // Make input parameters safe for DB
    //
    $_POST['last'] = mysql_real_escape_string($_POST['last'], $_mysql->link());
    $_POST['synch'] = mysql_real_escape_string($_POST['synch'], $_mysql->link());
    // Construct Where condition depending on Log mode
    //
    if ('normal' !== $_POST['mode']) {
        throw new Exception('Update is only available for NORMAL mode.');
    }
    $_entries = array();
    // Get Entries that were added or modified.
    //
    $_res = $_mysql->query('select t1.id from ehead as t1 where ' . "t1.added>='{$_POST['last']}' and " . "t1.edit>'{$_POST['synch']}'" . ';');
    if ($_res && $_mysql->numrows()) {
        while ($_row = mysql_fetch_array($_res, MYSQL_ASSOC)) {
            $_entries[$_row['id']] = array(true, array());
        }
    }
    // Get entries that have replies added
    //
    $_res = $_mysql->query('select t1.id,t2.eid from reply as t1,rhead as t2,' . 'ehead as t3 where t2.eid=t3.id and ' . "t3.added>='{$_POST['last']}' and t2.rid=t1.id and " . "t1.added>'{$_POST['synch']}';");
    if ($_res && $_mysql->numrows()) {
        while ($_row = mysql_fetch_array($_res, MYSQL_ASSOC)) {
            if (array_key_exists($_row['eid'], $_entries)) {
                $_entries[$_row['eid']][1][] = $_row['id'];
            } else {
                $_entries[$_row['eid']] = array(false, array($_row['id']));
            }
Beispiel #6
0
    {
        return json_encode(array('id' => $this->id, 'aid' => $this->aid, 'author' => $this->author, 'title' => $this->title, 'added' => $this->added, 'edit' => $this->edit, 'replies' => $this->replies));
    }
}
// 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);
    // Get entry meta data
    $_res = $_mysql->query("select t1.id,t2.id as aid,t1.added,t1.edit,t1.title,t2.name as author,(select count(*) from rhead as t2 where t2.eid=t1.id) as replies from ehead as t1 join " . KSAdminDBConfig::DB . ".uinfo as t2 where t1.author=t2.id and t1.id='{$_POST['id']}';");
    if (!$_mysql->numrows()) {
        throw new Exception('Failed to get Entry: inexisting ID.');
    }
    $_row = mysql_fetch_assoc($_res);
    if (!$_row) {
        throw new RuntimeException('Failed to read entry. Try later.');
    }
    KSServiceJson::instance()->chain(new KSJsonEntry($_row['id'], $_row['aid'], $_row['author'], $_row['title'], $_row['added'], $_row['edit'], $_row['replies']));
} catch (Exception $exception) {
    KSServiceJson::instance()->chain(new KSJsonError($exception->getMessage()));
}
echo KSServiceJson::instance();