Beispiel #1
0
 public function store()
 {
     $page_name = $this->name;
     // cleanups to make directory transversal impossible
     // TODO proper cleanup of name!
     $page_name = str_replace('.', '_', $page_name);
     $page_name = str_replace('/', '_', $page_name);
     $page_name = str_replace('\\', '_', $page_name);
     $page_name = str_replace(' ', '_', $page_name);
     $dst_file = WikiConfig::getDiskPath() . '/' . $page_name;
     file_put_contents($dst_file, $this->text);
     return SqlObject::store($this, self::$tbl_name, 'name');
 }
Beispiel #2
0
 function __construct($id)
 {
     parent::__construct("ticketTypes", "ticketTypeID", $id);
 }
Beispiel #3
0
 public function store()
 {
     return SqlObject::storeUnique($this, self::$tbl_name);
 }
Beispiel #4
0
 function __construct()
 {
     parent::__construct("wannabeCrewResponse", null, -1);
 }
Beispiel #5
0
 public static function getNewUsers($limit = 10)
 {
     $q = 'SELECT * FROM ' . self::$tbl_name . ' ORDER BY time_created DESC LIMIT ' . intval($limit);
     $list = Sql::pSelect($q);
     return SqlObject::loadObjects($list, 'User');
 }
Beispiel #6
0
 function __construct($ID)
 {
     parent::__construct("wannabeResponse", "ID", $ID);
 }
Beispiel #7
0
 public static function delete($id)
 {
     return SqlObject::deleteById($id, self::$tbl_name, 'id');
 }
Beispiel #8
0
 function __construct($articleID = -1)
 {
     parent::__construct("news", "ID", $articleID);
 }
Beispiel #9
0
 public static function remove($id)
 {
     return SqlObject::deleteById($id, self::$tbl_name);
 }
Beispiel #10
0
 /**
  * Question constructor.
  * 
  * @param int $questionID
  */
 public function __construct($questionID)
 {
     parent::__construct("wannabeQuestions", "ID", $questionID);
     $this->_responses = null;
 }
Beispiel #11
0
 public static function getAllByOwner($id)
 {
     $q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE owner = ?';
     $list = Sql::pSelect($q, 'i', $id);
     return SqlObject::loadObjects($list, __CLASS__);
 }
Beispiel #12
0
 static function getActivePolls($type, $owner = 0)
 {
     $q = 'SELECT * FROM tblPolls' . ' WHERE type = ? AND owner = ? AND deleted_by = ? AND NOW() BETWEEN time_start AND time_end' . ' ORDER BY time_start ASC,text ASC';
     $list = Sql::pSelect($q, 'iii', $type, $owner, 0);
     return SqlObject::loadObjects($list, __CLASS__);
 }
Beispiel #13
0
 function __construct($id)
 {
     $this->_seat = -1;
     // Initial value, used to determine if there is a runtime cached seat object.
     parent::__construct("tickets", "ticketID", $id);
 }
<?php

namespace cd;

set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/../core/');
require_once 'SqlObject.php';
if (SqlObject::stringForm(123) != 'i') {
    echo "FAIL 1\n";
}
if (SqlObject::stringForm("abc") != 's') {
    echo "FAIL 2\n";
}
if (SqlObject::stringForm("0123") != 's') {
    echo "FAIL 3\n";
}
if (SqlObject::stringForm(12.34) != 'd') {
    echo "FAIL 4\n";
}
Beispiel #15
0
 public function __construct($id)
 {
     parent::__construct("kiosk_wares", "ID", $id);
 }
Beispiel #16
0
 /**
  * Fetches all items where $field_name = $value
  * @param $field_name
  * @param $value
  * @param $tblname
  * @param $classname
  * @param $order_field
  * @param $order 'desc', 'asc' or empty
  */
 public static function getAllByField($field_name, $value, $tblname, $classname, $order_field = '', $order = 'asc')
 {
     if (!is_alphanumeric($tblname)) {
         throw new \Exception('tblname should be alphanumeric, isnt: ' . $tblname);
     }
     if (!is_alphanumeric($field_name)) {
         throw new \Exception('field_name should be alphanumeric, isnt: ' . $field_name);
     }
     if (!is_alphanumeric($order_field)) {
         throw new \Exception('order_field should be alphanumeric, isnt: ' . $order_field);
     }
     if (!Sql::isValidOrder($order)) {
         throw new \Exception('odd order ' . $order);
     }
     $form = self::stringForm($value);
     $q = 'SELECT * FROM ' . $tblname . ' WHERE ' . $field_name . ' = ?' . ($order_field ? ' ORDER BY ' . $order_field . ' ' . strtoupper($order) : '');
     $list = Sql::pSelect($q, $form, $value);
     return SqlObject::ListToObjects($list, $classname);
 }
Beispiel #17
0
d($x);
$q = 'REPLACE tblSessionData (session_id,session_data,expires) VALUES(?, ?, ?)';
$xxx = Sql::pUpdate($q, 'sss', 666, "hejhej", sql_datetime( time() ) );
d($xxx);
$q = 'INSERT INTO tblLikes (owner,type) VALUES (?, ?)';
$id = Sql::pInsert($q, 'ii', 4,9);
if ($id < 2)    echo "FAIL 5\n";
$w = new Word();
$w->id = 8;
$w->value = "sten";
if (SqlObject::exists($w, 'oWord') != true)   echo "FAIL 10\n";
$w = new Word();
$w->id = 8;
$w->value = "st2en";
if (SqlObject::exists($w, 'oWord') == true)   echo "FAIL 11\n";
*/
// TODO more reliable test of ListToObjects
$q = 'SELECT * FROM tblBookmarks' . ' WHERE owner = ? AND type = ?';
$list = Sql::pSelect($q, 'ii', 2, 100);
$objs = SqlObject::ListToObjects($list, 'Bookmark');
if (count($objs) < 5) {
    echo "FAIL 20\n";
}
$q = 'SELECT * FROM tblBookmarks' . ' WHERE id = ?';
$row = Sql::pSelectRow($q, 'i', 66);
$obj = SqlObject::RowToObject($row, 'Bookmark');
if ($obj->id != 66) {
    echo "FAIL 30\n";
}
$bb = Bookmark::get(66);
d($bb);
Beispiel #18
0
 function __construct($ID)
 {
     parent::__construct("wannabeComment", "ID", $ID);
 }
Beispiel #19
0
 /**
  * Create new group instance.
  */
 function __construct($id)
 {
     parent::__construct("groups", "ID", $id);
 }
Beispiel #20
0
 /** permanently deletes the file from disk */
 public static function unlink($id)
 {
     SqlObject::deleteById($id, self::$tbl_name, 'id');
     $path = self::getUploadPath($id);
     unlink($path);
 }
Beispiel #21
0
 function __construct($id)
 {
     $this->_tickets = null;
     parent::__construct("users", "ID", $id);
 }
Beispiel #22
0
 public static function get($id)
 {
     return SqlObject::getById($id, self::$tbl_name, __CLASS__);
 }
Beispiel #23
0
 public function store()
 {
     $obj->time_saved = sql_datetime(time());
     return SqlObject::store($this, self::$tbl_name, 'id');
 }
Beispiel #24
0
 public function store()
 {
     return SqlObject::store($this, self::$tbl_name, 'id');
 }
Beispiel #25
0
 function __construct($id)
 {
     parent::__construct("seatReg_seatings", "seatID", $id);
 }