Beispiel #1
0
 public static function save()
 {
     if (!isset($_POST['_zoop_form_id']) || !$_POST['_zoop_form_id']) {
         return;
     }
     $formId = $_POST['_zoop_form_id'];
     $sessionId = session_id();
     //	IMPORTANT SECURITY NOTE:
     //		even though session.id is going to be a unique identifier we still need to check to make sure that it
     //		has the correct session_id to prevent spoofing
     $fieldString = SqlFetchCell("select fields from session_form where session_id = :sessionId and id = :formId", array('sessionId' => $sessionId, 'formId' => $formId));
     if (!$fieldString) {
         trigger_error("session_form row {$formId} not found.  Possible attempt to spoof session data.");
     }
     $objects = array();
     foreach (explode(',', $fieldString) as $thisFieldString) {
         list($class, $id, $field) = explode(':', $thisFieldString);
         if (!isset($_POST['_zoop_form_element'][$class][$id][$field])) {
             continue;
         }
         $objectId = "{$class}:{$id}";
         if (!isset($objects[$objectId])) {
             $objects[$objectId] = new $class($id);
         }
         $objects[$objectId]->{$field} = $_POST['_zoop_form_element'][$class][$id][$field];
     }
     foreach ($objects as $thisObject) {
         $thisObject->save();
     }
 }
Beispiel #2
0
 function getOpenEntry()
 {
     //	there should be a method in DbObject for doing lookups like this
     $entryInfo = SqlFetchCell("select * from entry where person_id = :id and starttime is not null and endtime is null", array('id' => $this->id));
     if (!$entryInfo) {
         return NULL;
     }
     return new Entry($entryInfo);
 }
Beispiel #3
0
 public static function auth($username, $password)
 {
     $id = SqlFetchCell("select id from person where username = :username and password = :password", array('username' => $username, 'password' => $password));
     if (!$id) {
         return false;
     }
     $_SESSION['personId'] = $id;
     session::saveChangesUnsafe();
     return true;
 }
Beispiel #4
0
 public function postSetField($p, $z)
 {
     $id = $_POST['id'];
     $field = $_POST['field'];
     $request = new Request($id);
     if ($field == 'completed') {
         $request->completed = $_POST['update_value'];
     } else {
         if ($field == 'priority') {
             $request->priority_id = SqlFetchCell("select id from priority where name = :name", array('name' => $_POST['update_value']));
         } else {
             trigger_error("undefined field: {$field}");
         }
     }
     $request->save();
     //	this is sent back and thus placed in the table cell
     echo $_POST['update_value'];
 }
Beispiel #5
0
 public function bumpTableSequenceToEnd($tableName)
 {
     $nextVal = SqlFetchCell("SELECT max(id) from :tableName:identifier", array('tableName' => $tableName)) + 1;
     $this->query("ALTER SEQUENCE :sequenceName:identifier RESTART WITH :nextVal:int", array('sequenceName' => "{$tableName}_id_seq", 'nextVal' => $nextVal));
 }
Beispiel #6
0
 public static function getMaxPages()
 {
     return SqlFetchCell("SELECT ceil((max(published_order)-1)/10) FROM entry", array());
 }
Beispiel #7
0
 // print_r($message);
 // echo "$i {$message->from} {$message->to} {$message->subject}\n";
 echo "{$message->from} {$message->to} {$message->subject}\n";
 $res = preg_match('/([\\w ]+)<(\\w+)@([\\w.]+)>/', $message->from, $matches);
 $name = trim($matches[1]);
 $parts = explode(' ', $name);
 $firstname = array_shift($parts);
 $lastname = array_pop($parts);
 $user = trim($matches[2]);
 $domain = trim($matches[3]);
 $username = $email = "{$user}@{$domain}";
 $sender = DbObject::_getOne('Person', array('username' => $username), array('firstname' => $firstname, 'lastname' => $lastname, 'email' => $email));
 // print_r($sender);
 preg_match('/<([^>]+)>/', trim($message->messageId), $matches);
 $messageId = $matches[1];
 if (SqlFetchCell("SELECT count(*) from request where message_id = :messageId", array('messageId' => $messageId))) {
     continue;
 }
 $request = new Request();
 $request->owner_id = $sender->id;
 $request->name = trim($message->subject);
 $request->message_id = $messageId;
 //	deal with the headers
 // foreach ($message->getHeaders() as $name => $value)
 // {
 //     if(is_string($value))
 // 	{
 //         echo "$name: $value\n";
 //         continue;
 //     }
 // 	else
Beispiel #8
0
 public function getWords()
 {
     $words = array();
     for ($row = 1; $row <= self::size; $row++) {
         $word = '';
         for ($col = 1; $col <= self::size; $col++) {
             $letter = $this->cells[$row][$col]->getLetter();
             if ($letter) {
                 $word .= $letter;
             } else {
                 if ($word) {
                     $words[$word] = 1;
                     $word = '';
                 }
             }
         }
         if ($word) {
             $words[$word] = 1;
             $word = '';
         }
     }
     for ($col = 1; $col <= self::size; $col++) {
         $word = '';
         for ($row = 1; $row <= self::size; $row++) {
             $letter = $this->cells[$row][$col]->getLetter();
             if ($letter) {
                 $word .= $letter;
             } else {
                 if ($word) {
                     $words[$word] = 1;
                     $word = '';
                 }
             }
         }
         if ($word) {
             $words[$word] = 1;
             $word = '';
         }
     }
     // SqlEchoOn();
     foreach ($words as $thisWord => $thing) {
         SqlBeginTransaction();
         $word = strtoupper($thisWord);
         $len = strlen($word);
         if ($len < 2) {
             continue;
         }
         $id = SqlFetchCell("select id from word where word = :word", array('word' => $word));
         if (!$id) {
             echo "inserting word: {$word}<br>";
             SqlInsertRow("insert into word (word, len) values (:wordwrap, :len)", array('word' => $word, 'len' => $len));
             Learn::generateWordLetters($word);
         }
         SqlCommitTransaction();
     }
 }