Пример #1
0
 static function mqRead($name, $want = 0, $wait = true)
 {
     $mq = msg_get_queue(self::_ftok($name));
     $type = null;
     // Recieved Message Type
     $size = 8192;
     // Max Message Size
     $mess = null;
     // Recieved Message Data
     $unser = true;
     $flags = 0;
     $error = null;
     if ($wait == false) {
         $flags |= MSG_IPC_NOWAIT;
     }
     if (msg_receive($mq, $want, $type, $size, $mess, $unser, $flags, $error)) {
         return $mess;
     }
     Radix::dump($mq);
     Radix::dump($want);
     Radix::dump($type);
     Radix::dump($size);
     Radix::dump($mess);
     Radix::dump($unser);
     Radix::dump($flags);
     Radix::dump($error);
     exit;
 }
Пример #2
0
 /**
 	AppModel Save
 	@todo use the _data interface, check for dirty
 */
 function save()
 {
     // Set Sane Defaults
     // if (empty($this->_data['auth_user_id'])) {
     //	 $this->_data['auth_user_id'] = $_SESSION['uid']; // $cu->id;
     // }
     // if (empty($this->_data['hash'])) $this->_data['hash'] = $this->hash();
     // Set some Fields to Null
     // if (empty($this->_data['link_to'])) $this->_data['link_to'] = null;
     // if (empty($this->_data['link_id'])) $this->_data['link_id'] = null;
     if (isset($this->_data['link_to'])) {
         if (empty($this->_data['link_to'])) {
             $this->_data['link_to'] = null;
         }
     }
     if (isset($this->_data['link_id'])) {
         if (empty($this->_data['link_id'])) {
             $this->_data['link_id'] = null;
         }
     }
     // Convert to Array
     // $rec = array();
     // foreach ($this->_properties as $k) {
     //	 if (empty($this->$k)) {
     //		 $rec[$k] = new Zend_Db_Expr('null');
     //	 } else {
     //		 $rec[$k] = $this->$k;
     //	 }
     // }
     // unset($rec['id']);
     $rec = array();
     foreach ($this->_data as $k => $v) {
         $rec[$k] = $v;
     }
     // @todo implement ts_vector
     // update vendors set fulltext = to_tsvector('english',name || ' ' || coalesce(description,''))
     if (isset($this->_properties['fulltext'])) {
         // Build Full Text
         // foreach ($this->_properties as $k=>$v) {
         //
         // }
     }
     if ($this->_data['id']) {
         // if ($this->_diff) Base_Diff::diff($this);
         SQL::update($this->_table, $rec, "id={$this->_data['id']}");
     } else {
         $this->_data['id'] = SQL::insert($this->_table, $rec);
         if (intval($this->_data['id']) == 0) {
             Radix::dump($this);
             Radix::dump(SQL::lastError());
             Radix::trace('Unexpected error saving: ' . get_class($this));
         }
         // if ($this->_diff) Base_Diff::diff($this);
     }
 }
Пример #3
0
function mail_part_list($stat, $depth = null)
{
    if ($depth === null) {
        $depth = null;
    }
    $count = 1;
    // echo "Depth: $depth\n";
    if (empty($stat['parts'])) {
        return false;
    }
    // print_r($stat['parts']);
    // exit;
    $list = array();
    foreach ($stat['parts'] as $i => $chk) {
        // echo "Type: {$chk->type}\n";
        switch ($chk->type) {
            case TYPETEXT:
                // Text (0)
                switch (strtolower($chk->subtype)) {
                    case 'html':
                        $list["{$depth}{$count}"] = array('mime-type' => 'text/html');
                        break;
                    case 'plain':
                        $list["{$depth}{$count}"] = array('mime-type' => 'text/plain');
                        // Radix::dump($chk,true);
                        break;
                    default:
                        die('Unknonw SubType');
                }
                // Encoding?
                switch ($chk->encoding) {
                    case ENC7BIT:
                        $list["{$depth}{$count}"]['mime-encoding'] = '7bit';
                        break;
                    case ENC8BIT:
                        die("8bit\n");
                    case ENCBINARY:
                        die("Binary\n");
                    case ENCBASE64:
                        die("Base64");
                    case ENCQUOTEDPRINTABLE:
                    case 4:
                        // quoted-printable
                        $list["{$depth}{$count}"]['mime-encoding'] = 'quoted-printable';
                        break;
                    case ENCOTHER:
                        die('Other');
                    default:
                        print_r($stat['head']);
                        print_r($chk);
                        die('Unknown Encoding: ' . $chk->encoding);
                }
                break;
            case TYPEMULTIPART:
                // Multipart?
                switch (strtolower($chk->subtype)) {
                    case 'alternative':
                        // Radix::dump($chk,true);
                        $list["1"] = array('mime-type' => 'multipart/alternative');
                        $list += mail_part_list((array) $chk, "{$count}.");
                        break;
                    default:
                        Radix::dump($chk);
                        die("Unknown Multipart?\n");
                }
                break;
            case TYPEIMAGE:
                // Image, blindly accept
                $list["{$depth}{$count}"] = array('mime-type' => 'image/' . strtolower($chk->subtype));
                break;
            default:
                Radix::dump($chk);
                die("Unknown Type: {$chk->type}\n");
        }
        $count++;
    }
    return $list;
}