Beispiel #1
0
    {
        return $this->body;
    }
    public function __toString()
    {
        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']));
Beispiel #2
0
 if ($_POST['id'] && !preg_match('/^([0-9]{1,5},)*[0-9]{1,5}$/', $_POST['id'])) {
     throw new RuntimeException('Unacceptable Entry(ies). Up to 5 digits only.');
 }
 if ($_POST['author'] && !preg_match('/^(?:\\w{3,}\\ +)*\\w{3,}$/', $_POST['author'])) {
     throw new RuntimeException('Inacceptable Date sent.');
 }
 if ($_POST['after'] && !preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}\\ [0-9]{2}:[0-9]{2}:[0-9]{2}$/', $_POST['after'])) {
     throw new RuntimeException('Inacceptable Date sent.');
 }
 if ($_POST['before'] && !preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}\\ [0-9]{2}:[0-9]{2}:[0-9]{2}$/', $_POST['before'])) {
     throw new RuntimeException('Inacceptable Date sent.');
 }
 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 Date sent.');
 }
 $_mysql = new KSMySQL();
 if (!$_mysql->connect(KSDBConfig::HOST, KSDBConfig::USER, KSDBConfig::PASS)) {
     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;
Beispiel #3
0
    public function __toString()
    {
        array_walk($this->entries, 'toJSON');
        return json_encode($this->entries);
    }
}
$_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']));
        }
    }
Beispiel #4
0
        $this->aid = $_aid;
        $this->author = $_author;
        $this->added = $_added;
        $this->body = $_body;
    }
    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']));
Beispiel #5
0
//
$_POST['mode'] = trim(strip_tags(urldecode(stripslashes($_POST['mode']))));
$_POST['last'] = trim(strip_tags(urldecode(stripslashes($_POST['last']))));
$_POST['synch'] = trim(strip_tags(urldecode(stripslashes($_POST['synch']))));
try {
    // Test Input parameters
    //
    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.');
    }
    if ($_POST['synch'] && !preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}\\ [0-9]{2}:[0-9]{2}:[0-9]{2}$/', $_POST['synch'])) {
        throw new RuntimeException('Inacceptable Synch Date sent.');
    }
    // Connect to DB
    //
    $_mysql = new KSMySQL();
    if (!$_mysql->connect(KSDBConfig::HOST, KSDBConfig::USER, KSDBConfig::PASS)) {
        throw new Exception('DB Failure. Can not read entries at the moment. Try \\
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();
Beispiel #6
0
        $this->edit = $_edit;
        $this->replies = $_replies;
    }
    public function __toString()
    {
        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']));