function displayCatalog($catalog, &$lnk, $deep = 0, $count)
{
    //
    foreach ($catalog->{u('Группа')} as $group) {
        $d = array('id' => u2w($group->{u('Ид')}), 'name' => u2w($group->{u('Наименование')}));
        ?>
<tr>	
			<td style="padding-left:<?php 
        echo $deep * 20;
        ?>
px;">
					<?php 
        echo $d['name'];
        ?>
					
					<?php 
        //=print_r($count)
        ?>
					<?php 
        if (!empty($count[$d['id']])) {
            ?>
 [<?php 
            echo $count[$d['id']];
            ?>
]<?php 
        }
        ?>
				</td>
				<td>
					<input style="font-size:7pt;width:50px" name="lnk[<?php 
        echo $d['id'];
        ?>
]" value="<?php 
        echo !empty($lnk[$d['id']]) ? $lnk[$d['id']] : '';
        ?>
">
				</td>
				<td style="white-space:nowrap">
					<?php 
        echo $d['id'];
        ?>
				</td>
				<td>
					<?php 
        /*a class="move" rel="<?=$d['id']?>" title="Переместить дочерние узлы" href="#"><img src="/img/pic/move_16.gif"/></a*/
        ?>
					<a class="move_to" rel="<?php 
        echo $d['id'];
        ?>
" title="Переместить дочерние узлы в текущий каталог" href="#"><img src="/img/pic/move_16.gif"/></a>
				</td>
			</tr>
		<?php 
        if (!empty($group->{u('Группы')})) {
            displayCatalog($group->{u('Группы')}, $lnk, $deep + 1, $count);
        }
    }
}
 function fill_ext_catalog($groups)
 {
     $res = array();
     foreach ($groups->{u('Группа')} as $group) {
         $d = array('id' => u2w($group->{u('Ид')}), 'name' => u2w($group->{u('Наименование')}), 'ch' => array());
         if (!empty($group->{u('Группы')})) {
             $d['ch'] = fill_ext_catalog($group->{u('Группы')});
         }
         $res[] = $d;
     }
     return $res;
 }
Exemple #3
0
 function _storeAttachment($mapimessage, $part)
 {
     // attachment
     $attach = mapi_message_createattach($mapimessage);
     // Filename is present in both Content-Type: name=.. and in Content-Disposition: filename=
     if (isset($part->ctype_parameters["name"])) {
         $filename = $part->ctype_parameters["name"];
     } else {
         if (isset($part->d_parameters["name"])) {
             $filename = $part->d_parameters["filename"];
         } else {
             if (isset($part->d_parameters["filename"])) {
                 //sending appointment with nokia only filename is set
                 $filename = $part->d_parameters["filename"];
             } else {
                 $filename = "untitled";
             }
         }
     }
     // Set filename and attachment type
     mapi_setprops($attach, array(PR_ATTACH_LONG_FILENAME => u2w($filename), PR_ATTACH_METHOD => ATTACH_BY_VALUE));
     // Set attachment data
     mapi_setprops($attach, array(PR_ATTACH_DATA_BIN => $part->body));
     // Set MIME type
     mapi_setprops($attach, array(PR_ATTACH_MIME_TAG => $part->ctype_primary . "/" . $part->ctype_secondary));
     mapi_savechanges($attach);
 }
Exemple #4
0
 function getSearchResults($searchquery, $searchrange)
 {
     // only return users from who the displayName or the username starts with $name
     //TODO: use PR_ANR for this restriction instead of PR_DISPLAY_NAME and PR_ACCOUNT
     $addrbook = mapi_openaddressbook($this->_session);
     $ab_entryid = mapi_ab_getdefaultdir($addrbook);
     $ab_dir = mapi_ab_openentry($addrbook, $ab_entryid);
     $table = mapi_folder_getcontentstable($ab_dir);
     $restriction = $this->_getSearchRestriction(u2w($searchquery));
     mapi_table_restrict($table, $restriction);
     mapi_table_sort($table, array(PR_DISPLAY_NAME => TABLE_SORT_ASCEND));
     //range for the search results, default symbian range end is 50, wm 99,
     //so we'll use that of nokia
     $rangestart = 0;
     $rangeend = 50;
     if ($searchrange != '0') {
         $pos = strpos($searchrange, '-');
         $rangestart = substr($searchrange, 0, $pos);
         $rangeend = substr($searchrange, $pos + 1);
     }
     $items = array();
     $querycnt = mapi_table_getrowcount($table);
     //do not return more results as requested in range
     $querylimit = $rangeend + 1 < $querycnt ? $rangeend + 1 : $querycnt;
     $items['range'] = $rangestart . '-' . ($querylimit - 1);
     $abentries = mapi_table_queryrows($table, array(PR_ACCOUNT, PR_DISPLAY_NAME, PR_SMTP_ADDRESS, PR_BUSINESS_TELEPHONE_NUMBER), $rangestart, $querylimit);
     for ($i = 0; $i < $querylimit; $i++) {
         $items[$i]["username"] = w2u($abentries[$i][PR_ACCOUNT]);
         $items[$i]["fullname"] = w2u($abentries[$i][PR_DISPLAY_NAME]);
         if (strlen(trim($items[$i]["fullname"])) == 0) {
             $items[$i]["fullname"] = $items[$i]["username"];
         }
         $items[$i]["emailaddress"] = w2u($abentries[$i][PR_SMTP_ADDRESS]);
         $items[$i]["nameid"] = $searchquery;
         //check if an user has a business phone or it might produce warnings in the log
         $items[$i]["businessphone"] = isset($abentries[$i][PR_BUSINESS_TELEPHONE_NUMBER]) ? w2u($abentries[$i][PR_BUSINESS_TELEPHONE_NUMBER]) : "";
     }
     return $items;
 }
 private function KolabWriteTask($message, $id)
 {
     if (!$id) {
         $uid = strtoupper(md5(uniqid(time())));
     } else {
         $uid = $id;
     }
     $object = array('uid' => $uid, 'start' => $message->utcstartdate, 'due' => $message->utcduedate, 'name' => u2w($message->subject));
     if (isset($message->rtf)) {
         $object['body'] = $this->rtf2text($message->rtf);
     }
     if ($message->reminderset == 1) {
         $object['alarm'] = ($message->remindertime - $message->utcstartdate) / 60;
     }
     //categories
     if (isset($message->categories)) {
         $object['categories'] = u2w(join(',', $message->categories));
     }
     switch ($message->importance) {
         case 0:
             $object["priority"] = 5;
             break;
         case 1:
             $object["priority"] = 3;
             break;
         case 2:
             $object["priority"] = 1;
             break;
     }
     if ($message->complete == 1) {
         $object['completed'] = 100;
         $object['completed_date'] = $message->datecompleted;
     } else {
         $object['completed'] = 0;
     }
     switch ($message->sensitivity) {
         case 1:
         case 2:
             $object["sensitivity"] = "private";
             break;
         case 3:
             $object["sensitivity"] = "confidential";
     }
     //recurence
     if (isset($message->recurrence)) {
         $object["recurrence"] = $this->kolabWriteReccurence($message->reccurence);
     }
     $format = Horde_Kolab_Format::factory('XML', 'task');
     $xml = $format->save($object);
     unset($format);
     // set the mail
     // attach the XML file
     $mail = $this->mail_attach("kolab.xml", 0, $xml, "kolab message", "text/plain", "plain", "application/x-vnd.kolab.task");
     //add header
     $h["from"] = $this->_email;
     $h["to"] = $this->_email;
     $h["X-Mailer"] = "z-push-Kolab Backend";
     $h["subject"] = $object["uid"];
     $h["message-id"] = "<" . strtoupper(md5(uniqid(time()))) . ">";
     $h["date"] = date(DATE_RFC2822);
     foreach (array_keys($h) as $i) {
         $header = $header . $i . ": " . $h[$i] . "\r\n";
     }
     //return the mail formatted
     return array($object['uid'], $h['date'], $header . $mail[0] . "\r\n" . $mail[1]);
 }
Exemple #6
0
 function _storeAttachment($mapimessage, $part)
 {
     // attachment
     $attach = mapi_message_createattach($mapimessage);
     $filename = "";
     // Filename is present in both Content-Type: name=.. and in Content-Disposition: filename=
     debugLog("_storeAttachment: " . print_r($part, true));
     if (isset($part->ctype_parameters["name"])) {
         $filename = $part->ctype_parameters["name"];
     } else {
         if (isset($part->d_parameters["name"])) {
             $filename = $part->d_parameters["filename"];
         } else {
             if (isset($part->d_parameters["filename"])) {
                 // sending appointment with nokia & android only filename is set
                 $filename = $part->d_parameters["filename"];
             } else {
                 if (isset($part->d_parameters["filename*0"])) {
                     for ($i = 0; $i < count($part->d_parameters); $i++) {
                         if (isset($part->d_parameters["filename*" . $i])) {
                             $filename .= $part->d_parameters["filename*" . $i];
                         }
                     }
                 } else {
                     $filename = "untitled";
                 }
             }
         }
     }
     // Android just doesn't send content-type, so mimeDecode doesn't performs base64 decoding
     // on meeting requests text/calendar somewhere inside content-transfer-encoding
     if (isset($part->headers['content-transfer-encoding']) && strpos($part->headers['content-transfer-encoding'], 'base64')) {
         if (strpos($part->headers['content-transfer-encoding'], 'text/calendar') !== false) {
             $part->ctype_primary = 'text';
             $part->ctype_secondary = 'calendar';
         }
         if (!isset($part->headers['content-type'])) {
             $part->body = base64_decode($part->body);
         }
     }
     if ($part->ctype_primary == 'multipart' && $part->ctype_secondary == 'signed') {
         // Set filename and attachment type
         $filename = "smime.p7m";
         mapi_setprops($attach, array(PR_ATTACH_FILENAME => u2w($filename), PR_ATTACH_METHOD => ATTACH_BY_VALUE, PR_ATTACH_TAG => hex2bin("2A864886F714030A04")));
     } else {
         if ($part->ctype_primary == 'application' && $part->ctype_secondary == 'x-pkcs7-mime') {
             $filename = "smime.p7m";
             mapi_setprops($attach, array(PR_ATTACH_FILENAME => u2w($filename), PR_ATTACH_METHOD => ATTACH_BY_VALUE, PR_ATTACH_TAG => hex2bin("2A864886F714030A04")));
         } else {
             // Set filename and attachment type
             mapi_setprops($attach, array(PR_ATTACH_LONG_FILENAME => u2w($filename), PR_ATTACH_METHOD => ATTACH_BY_VALUE));
         }
     }
     // Set attachment data
     mapi_setprops($attach, array(PR_ATTACH_DATA_BIN => $part->body));
     // Set MIME type
     mapi_setprops($attach, array(PR_ATTACH_MIME_TAG => $part->ctype_primary . "/" . $part->ctype_secondary));
     mapi_savechanges($attach);
 }
Exemple #7
0
 /**
  * Sets the properties for an address string.
  *
  * @param string            $type               which address is being set
  * @param string            $city
  * @param string            $country
  * @param string            $postalcode
  * @param string            $state
  * @param string            $street
  * @param array             &$props
  * @param array             &$properties
  *
  * @access private
  * @return
  */
 private function setAddress($type, &$city, &$country, &$postalcode, &$state, &$street, &$props, &$properties)
 {
     if (isset($city)) {
         $props[$properties[$type . "city"]] = $city = u2w($city);
     }
     if (isset($country)) {
         $props[$properties[$type . "country"]] = $country = u2w($country);
     }
     if (isset($postalcode)) {
         $props[$properties[$type . "postalcode"]] = $postalcode = u2w($postalcode);
     }
     if (isset($state)) {
         $props[$properties[$type . "state"]] = $state = u2w($state);
     }
     if (isset($street)) {
         $props[$properties[$type . "street"]] = $street = u2w($street);
     }
     //set composed address
     $address = Utils::BuildAddressString($street, $postalcode, $city, $state, $country);
     if ($address) {
         $props[$properties[$type . "address"]] = $address;
     }
 }
Exemple #8
0
 /**
  * Creates SyncResolveRecipient object for ResolveRecipientsResponse.
  * @param int $type
  * @param string $email
  * @param array $recipientProperties
  * @param int $recipientCount
  *
  * @return SyncResolveRecipient
  */
 private function createResolveRecipient($type, $email, $recipientProperties, $recipientCount = 0)
 {
     $recipient = new SyncResolveRecipient();
     $recipient->type = $type;
     $recipient->displayname = u2w($recipientProperties[PR_DISPLAY_NAME]);
     $recipient->emailaddress = $email;
     if ($type == SYNC_RESOLVERECIPIENTS_TYPE_GAL) {
         $certificateProp = PR_EMS_AB_TAGGED_X509_CERT;
     } elseif ($type == SYNC_RESOLVERECIPIENTS_TYPE_CONTACT) {
         $certificateProp = PR_USER_X509_CERTIFICATE;
     } else {
         $certificateProp = null;
     }
     if (isset($recipientProperties[$certificateProp]) && is_array($recipientProperties[$certificateProp]) && !empty($recipientProperties[$certificateProp])) {
         $certificates = $this->getCertificates($recipientProperties[$certificateProp], $recipientCount);
     } else {
         $certificates = $this->getCertificates(false);
         ZLog::Write(LOGLEVEL_INFO, sprintf("No certificate found for '%s' (requested email address: '%s')", $recipientProperties[PR_DISPLAY_NAME], $email));
     }
     $recipient->certificates = $certificates;
     if (isset($recipientProperties[PR_ENTRYID])) {
         $recipient->id = $recipientProperties[PR_ENTRYID];
     }
     return $recipient;
 }
 static function import1c_old($params = array())
 {
     global $CONFIG, $ST;
     set_time_limit(1000);
     $start_time = time();
     $result = "Не найден контрольный файл";
     //		$PRICE_EXPR=$CONFIG['SHOP_SRV_PRICE_EXPR'];
     //		$PRICE_EXPR_ACT=$CONFIG['SHOP_SRV_PRICE_EXPR_ACT'];
     $dir = CATALOG_DIR;
     $save_dir = $dir . '/save';
     $goods = $dir . '/' . GOODS_FILE_NAME;
     //		$goods_skidki=$dir.'/'.GOODS_SKIDKI_FILE_NAME;
     $goods_price = $dir . '/' . GOODS_PRICE_FILE_NAME;
     $ok_file = $dir . '/' . CATALOG_FILE_CONFIRM;
     $log_file = $dir . '/log.txt';
     if (file_exists($ok_file) || true) {
         //&& extract_files(CATALOG_DIR.'/'.CATALOG_ARCHIV_NAME)
         ///////////////////////////////////////////////////////////////////
         //товары
         if (file_exists($goods) && file_exists($goods_price)) {
             $cnt_imp = 0;
             $lnk = array();
             $rs = $ST->select("SELECT * FROM sc_shop_srv_extcat");
             while ($rs->next()) {
                 $lnk[$rs->get('id')] = $rs->getInt('lnk');
             }
             //				$ST->exec("TRUNCATE TABLE sc_shop_item_tmp");
             $i = 0;
             $j = 0;
             $rows = array();
             $xml = simplexml_load_file($goods);
             $goods_list = $xml->{u('Каталог')}->{u('Товар')};
             foreach ($goods_list as $data) {
                 break;
                 $d = array('id' => u2w($data->{u('Ид')}), 'category' => u2w($data->{u('Группы')}->{u('Ид')}), 'name' => str_replace('.', '. ', u2w($data->{u('Наименование')})), 'description' => str_replace('.', '. ', u2w($data->{u('Наименование')})), 'product' => ($p = u2w($data->{u('Артикул')})) ? $p : '', 'barcode' => u2w($data->{u('Штрихкод')}), 'unit' => intval(1), 'pack_size' => 0, 'pack_only' => 0, 'img' => '');
                 //					if('133a0fa1-4694-11e2-922a-00155d0a010e'==$d['id']){
                 //						file_put_contents(dirname(__FILE__).'/test.txt',$d['id'],FILE_APPEND);
                 //					}
                 if (!empty($data->{u('ЗначенияСвойств')}->{u('ЗначенияСвойства')})) {
                     foreach ($data->{u('ЗначенияСвойств')}->{u('ЗначенияСвойства')} as $data) {
                         if ($data->{u('Ид')} == u('НоменклатураКод')) {
                             //								$d['img']=trim(u2w($data->{u('Значение')}));
                             //								$d['product']=$d['img'];
                             //22.11.2012
                             $d['img'] = trim(u2w($data->{u('Значение')}));
                             //								$d['kod']=$d['img'];
                             //								break;
                         }
                         if ($data->{u('Ид')} == u('НоменклатураКоличествоВУпаковке')) {
                             $d['pack_size'] = u2w($data->{u('Значение')});
                             //								break;
                         }
                         if ($data->{u('Ид')} == u('НоменклатураОтгружаетсяТолькоУпаковками')) {
                             $d['pack_only'] = u2w($data->{u('Значение')}) == 'true' ? 1 : 0;
                             //								break;
                         }
                     }
                 }
                 if (isset($lnk[$d['category']])) {
                     $d['category'] = $lnk[$d['category']];
                 } elseif ($d['category'] == '00000000-0000-0000-0000-000000000000') {
                     $d['category'] = 0;
                     //Нераспределённый товар
                 } else {
                     continue;
                 }
                 $rows[] = $d;
                 //					if('133a0fa1-4694-11e2-922a-00155d0a010e'==$d['id']){
                 //						file_put_contents(dirname(__FILE__).'/test.txt',print_r($d,true),FILE_APPEND);
                 //
                 //						$ST->insert("sc_shop_item_tmp",$d);
                 //					}
                 if (++$i && $i % 200 == 0) {
                     $ST->insertArr("sc_shop_item_tmp", $rows);
                     $rows = array();
                 }
                 $cnt_imp++;
             }
             if ($rows) {
                 $ST->insertArr("sc_shop_item_tmp", $rows);
             }
             //цены
             $xml = simplexml_load_file($goods_price);
             $goods_list = $xml->{u('ПакетПредложений')}->{u('Предложения')}->{u('Предложение')};
             foreach ($goods_list as $data) {
                 break;
                 $id = u2w($data->{u('Ид')});
                 $d = array('price' => u2w($data->{u('Цены')}->{u('Цена')}->{u('ЦенаЗаЕдиницу')}), 'in_stock' => u2w($data->{u('Количество')}));
                 if (floatval($d['price'])) {
                     //только при наличии цены(скорее всего в любом случае)
                     //						if($new_price=floatval(@eval('return '.str_replace('PRICE',$d['price'],$PRICE_EXPR).';'))){
                     //							$d['price']=round($new_price,2);
                     //						}
                     $ST->update("sc_shop_item_tmp", $d, "id='{$id}'");
                 }
             }
             $cnt_upd = 0;
             $cnt_ins = 0;
             //Обнулим что нужно
             $ST->update("sc_shop_item i", array('in_stock' => 0), "EXISTS(SELECT id FROM sc_shop_item_tmp t WHERE t.id=i.ext_id AND (t.in_stock=0))");
             //Сначало обновим то что можно//t.pack_only,
             $res = $ST->select("SELECT i.id,t.category,t.product,t.price,t.in_stock,i.price as old_price\r\n\t\t\t\tFROM sc_shop_item_tmp t,sc_shop_item i \r\n\t\t\t\tWHERE t.price>0 AND  t.id=i.ext_id AND (t.price <> i.price OR t.in_stock<>i.in_stock OR t.category<>i.category)");
             $i = 0;
             while ($res->next()) {
                 //					$r= ++$i.' U '.$res->get('id').'<br>'."\n";
                 //					echo $r;
                 //					ob_flush();
                 $d = $res->getRow();
                 if (floatval($d['price']) != floatval($d['old_price'])) {
                     $ST->insert('sc_shop_srv_diff', array('product' => $d['id'], 'price_old' => floatval($d['old_price']), 'price_new' => floatval($d['price'])));
                 }
                 unset($d['old_price']);
                 unset($d['id']);
                 if ($d['category'] == 0) {
                     unset($d['category']);
                 }
                 $ST->update("sc_shop_item", $d, "id=" . $res->get('id') . ' LIMIT 1');
                 $cnt_upd++;
                 //			file_put_contents('log.txt',$r,FILE_APPEND);
             }
             ///////////////////////////////////////////////////////////////////////////////
             //Потом добавим то чего нет
             //pack_size,pack_only,,unit,weight_flg
             $res = $ST->select("SELECT id,product,category,name,description,price,in_stock \r\n\t\t\t\t\tFROM sc_shop_item_tmp t \r\n\t\t\t\t\tWHERE t.price>0 AND  NOT EXISTS(SELECT id FROM sc_shop_item i WHERE t.id=i.ext_id)");
             $i = 0;
             $rows = array();
             while ($res->next()) {
                 $d = $res->getRow();
                 $d['ext_id'] = $d['id'];
                 unset($d['id']);
                 $cnt_ins++;
                 $rows[] = $d;
                 if (++$i && $i % 200 == 0) {
                     $ST->insertArr("sc_shop_item", $rows);
                     $rows = array();
                 }
             }
             if ($rows) {
                 $ST->insertArr("sc_shop_item", $rows);
             }
             //импорт картинок
             function getImgList($dir)
             {
                 global $ST, $CONFIG;
                 $d = opendir($dir);
                 while ($file = readdir($d)) {
                     if ($file != '.' && $file != '..') {
                         if (is_dir($dir . '/' . $file)) {
                             getImgList($dir . '/' . $file);
                         } else {
                             $ext_id = preg_replace('/\\.[a-z]+$/', '', $file);
                             //								$rs=$ST->select("SELECT id FROM sc_shop_item WHERE ext_id='$ext_id'");
                             $rs = $ST->select("SELECT i.id FROM sc_shop_item i,sc_shop_item_tmp it WHERE i.ext_id=it.id AND it.img='{$ext_id}'");
                             if ($rs->next()) {
                                 copy($dir . '/' . $file, '.' . $CONFIG['CATALOG_PATH'] . '/goods/' . $file);
                                 $ST->update('sc_shop_item', array('img' => $CONFIG['CATALOG_PATH'] . '/goods/' . $file), 'id=' . $rs->get('id'));
                             }
                         }
                     }
                 }
                 closedir($d);
             }
             if (file_exists(CATALOG_DIR . '/' . CATALOG_IMG)) {
                 getImgList(CATALOG_DIR . '/' . CATALOG_IMG);
             }
             //				removeDirectory(CATALOG_DIR.'/'.CATALOG_IMG);
             if (!file_exists($save_dir)) {
                 mkdir($save_dir);
             }
             $stop_time = time();
             $t = $stop_time - $start_time;
             $result = date('Y-m-d H:i:s') . ' - Время загрузки=' . $t . '; Импортировано=' . $cnt_imp . '; Добавлено=' . $cnt_ins . '; Обновлено=' . $cnt_upd . "\r\n";
             file_put_contents($log_file, $result, FILE_APPEND);
         } else {
             $result = date('Y-m-d H:i:s') . " - не найден один из файлов {$goods}, {$goods_price}\r\n";
             file_put_contents($log_file, $result, FILE_APPEND);
         }
     }
     return $result;
 }
 function actTmpImpCartshop()
 {
     set_time_limit(0);
     global $ST;
     echo "test";
     //		exit;
     /*
     1 = (string:121) http://www.farmcosmetica.ru/image/cache/data/avene/AVENE D-Pigment ЛЕЖЕР Средство для осветления темных пятен-228x228.jpg
     */
     $rs = $ST->select("SELECT * FROM sc_shop_item WHERE img='' ");
     //AND id=717
     while ($rs->next()) {
         $c = file_get_contents("http://www.farmcosmetica.ru/index.php?route=product/product&product_id={$rs->getInt('id')}");
         $c = u2w($c);
         if (preg_match('|src="(.+)".*id="image"|Um', $c, $res)) {
             $img_src = str_replace('cache/', '', $res[1]);
             $img_src = str_replace('-228x228', '', $img_src);
             if ($img = @get_url(iconv('cp1251', 'utf-8', $img_src))) {
                 $img_name = preg_replace('|.*data/|', '', $img_src);
                 $img_name = str_replace('/', '_', $img_name);
                 $img_name = "storage/catalog/goods/" . $img_name;
                 if (!file_exists($img_name)) {
                     file_put_contents($img_name, $img);
                 }
                 $field_ext['img'] = "/" . $img_name;
             } else {
                 $field_ext['img'] = "";
             }
             $ST->update('sc_shop_item', array('img' => $field_ext['img']), "id={$rs->getInt('id')}");
         }
     }
 }
 static function import1cV2($params = array())
 {
     global $CONFIG, $ST;
     set_time_limit(1000);
     $start_time = time();
     $dir = CATALOG_DIR;
     $goods_price = $dir . '/' . GOODS_PRICE_FILE_NAME;
     $log_file = $dir . '/log.txt';
     $cnt_upd_price = 0;
     $cnt_ins = 0;
     $cnt_upd = 0;
     ///////////////////////////////////////////////////////////////////
     //остатки
     if (file_exists($goods_price)) {
         $result = date('Y-m-d H:i:s') . "\r\n";
         file_put_contents($log_file, $result, FILE_APPEND);
         //цены
         $xml = simplexml_load_file($goods_price);
         //Склад
         //				$sklad=$xml->{u('ПакетПредложений')}->{u('Владелец')}->{u('Ид')};
         $goods_list = $xml->{u('ПакетПредложений')}->{u('Предложения')}->{u('Предложение')};
         foreach ($goods_list as $data) {
             $id = u2w($data->{u('Ид')});
             $d = array('price' => u2w($data->{u('Цены')}->{u('Цена')}->{u('ЦенаЗаЕдиницу')}), 'in_stock' => u2w($data->{u('Количество')}));
             $rs = $ST->select("SELECT * FROM sc_shop_item WHERE ext_id='" . $id . "' LIMIT 1");
             if ($rs->next()) {
                 $itemid = $rs->getInt('id');
                 if ($d['price'] != $rs->get('price')) {
                     $ST->update('sc_shop_item', array('price' => (double) $d['price']), "ext_id='" . $id . "'");
                     $cnt_upd_price++;
                 }
                 $rs = $ST->select("SELECT * FROM sc_shop_offer WHERE itemid={$itemid} AND region='ekt' LIMIT 1");
                 /* @TODO region*/
                 if ($rs->next()) {
                     if ($d['in_stock'] != $rs->get('in_stock')) {
                         $ST->update('sc_shop_offer', array('in_stock' => (int) $d['in_stock']), "itemid={$itemid} AND region='ekt'");
                         $cnt_upd++;
                     }
                 } else {
                     $ST->insert('sc_shop_offer', array('in_stock' => (int) $d['in_stock'], 'itemid' => $itemid, 'region' => 'ekt'));
                     $cnt_ins++;
                 }
             } else {
                 file_put_contents($log_file, "{$id} не найден\n", FILE_APPEND);
             }
         }
         $stop_time = time();
         $t = $stop_time - $start_time;
         $result = ' - Время загрузки=' . $t . '; Обновлено остатков=' . $cnt_upd . '; Добавлено=' . $cnt_ins . '; Обновлено цен=' . $cnt_upd_price . "\r\n";
         file_put_contents($log_file, $result, FILE_APPEND);
     } else {
         $result = date('Y-m-d H:i:s') . " - не найден один из файлов {$goods_price}\r\n";
         file_put_contents($log_file, $result, FILE_APPEND);
     }
     return $result;
 }
 function getRssData($url, $guid = null)
 {
     $xml = get_url($url);
     $xml = simplexml_load_string($xml);
     $data = array();
     foreach ($xml->channel->item as $item) {
         $i = array('title' => u2w($item->title), 'content' => u2w($item->description), 'img' => (string) @$item->enclosure->attributes()->url, 'date' => date('Y-m-d', strtotime($item->pubDate)), 'guid' => (string) $item->guid);
         if ($guid && $guid == (string) $item->guid) {
             return $i;
         }
         $data[] = $i;
     }
     return $data;
 }
 /**
  * URI компоненты
  *
  * @return string
  */
 function getURI($params = array(), $p = null)
 {
     $uri = u2w(urldecode($this->uri));
     if ($params) {
         foreach ($params as $key => $val) {
             if ($val === null) {
                 $uri = preg_replace('|(' . $key . ')/([^/]+/)?|', '', $uri);
                 continue;
             }
             if ($val === false) {
                 $uri = preg_replace('|' . $key . '/|', '', $uri);
                 continue;
             }
             if (is_int($val)) {
                 $uri = preg_replace('|' . $key . '/\\d*/?|', "{$key}/{$val}/", $uri);
                 continue;
             }
             if (preg_match('|/' . $key . '/([^/]+)/|', $uri)) {
                 $uri = preg_replace('|/(' . $key . ')/([^/]+)/|', '/\\1/' . $val . '/', $uri);
             } else {
                 $uri .= $key . '/' . $val . '/';
             }
         }
     }
     if ($p === true) {
         $uri .= $_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : '';
     } elseif (is_string($p)) {
         $uri .= '?' . $p;
     } elseif (is_array($p)) {
         $uri .= '?' . http_build_query($p);
     }
     return $uri;
 }
Exemple #14
0
 function getSearchResults($searchquery, $searchrange)
 {
     // only return users from who the displayName or the username starts with $name
     //TODO: use PR_ANR for this restriction instead of PR_DISPLAY_NAME and PR_ACCOUNT
     $addrbook = mapi_openaddressbook($this->_session);
     $ab_entryid = mapi_ab_getdefaultdir($addrbook);
     $ab_dir = mapi_ab_openentry($addrbook, $ab_entryid);
     $table = mapi_folder_getcontentstable($ab_dir);
     $restriction = $this->_getSearchRestriction(u2w($searchquery));
     mapi_table_restrict($table, $restriction);
     mapi_table_sort($table, array(PR_DISPLAY_NAME => TABLE_SORT_ASCEND));
     //range for the search results, default symbian range end is 50, wm 99,
     //so we'll use that of nokia
     $rangestart = 0;
     $rangeend = 50;
     if ($searchrange != '0') {
         $pos = strpos($searchrange, '-');
         $rangestart = substr($searchrange, 0, $pos);
         $rangeend = substr($searchrange, $pos + 1);
     }
     $items = array();
     $querycnt = mapi_table_getrowcount($table);
     //do not return more results as requested in range
     $querylimit = $rangeend + 1 < $querycnt ? $rangeend + 1 : $querycnt;
     $items['range'] = $rangestart . '-' . ($querylimit - 1);
     $items['searchtotal'] = $querycnt;
     if ($querycnt > 0) {
         $abentries = mapi_table_queryrows($table, array(PR_ACCOUNT, PR_DISPLAY_NAME, PR_SMTP_ADDRESS, PR_BUSINESS_TELEPHONE_NUMBER, PR_GIVEN_NAME, PR_SURNAME, PR_MOBILE_TELEPHONE_NUMBER, PR_HOME_TELEPHONE_NUMBER, PR_TITLE, PR_COMPANY_NAME, PR_OFFICE_LOCATION), $rangestart, $querylimit);
     }
     for ($i = 0; $i < $querylimit; $i++) {
         $items[$i][SYNC_GAL_DISPLAYNAME] = w2u($abentries[$i][PR_DISPLAY_NAME]);
         if (strlen(trim($items[$i][SYNC_GAL_DISPLAYNAME])) == 0) {
             $items[$i][SYNC_GAL_DISPLAYNAME] = w2u($abentries[$i][PR_ACCOUNT]);
         }
         $items[$i][SYNC_GAL_ALIAS] = w2u($abentries[$i][PR_ACCOUNT]);
         //it's not possible not get first and last name of an user
         //from the gab and user functions, so we just set lastname
         //to displayname and leave firstname unset
         //this was changed in Zarafa 6.40, so we try to get first and
         //last name and fall back to the old behaviour if these values are not set
         if (isset($abentries[$i][PR_GIVEN_NAME])) {
             $items[$i][SYNC_GAL_FIRSTNAME] = w2u($abentries[$i][PR_GIVEN_NAME]);
         }
         if (isset($abentries[$i][PR_SURNAME])) {
             $items[$i][SYNC_GAL_LASTNAME] = w2u($abentries[$i][PR_SURNAME]);
         }
         if (!isset($items[$i][SYNC_GAL_LASTNAME])) {
             $items[$i][SYNC_GAL_LASTNAME] = $items[$i][SYNC_GAL_DISPLAYNAME];
         }
         $items[$i][SYNC_GAL_EMAILADDRESS] = w2u($abentries[$i][PR_SMTP_ADDRESS]);
         //check if an user has an office number or it might produce warnings in the log
         if (isset($abentries[$i][PR_BUSINESS_TELEPHONE_NUMBER])) {
             $items[$i][SYNC_GAL_PHONE] = w2u($abentries[$i][PR_BUSINESS_TELEPHONE_NUMBER]);
         }
         //check if an user has a mobile number or it might produce warnings in the log
         if (isset($abentries[$i][PR_MOBILE_TELEPHONE_NUMBER])) {
             $items[$i][SYNC_GAL_MOBILEPHONE] = w2u($abentries[$i][PR_MOBILE_TELEPHONE_NUMBER]);
         }
         //check if an user has a home number or it might produce warnings in the log
         if (isset($abentries[$i][PR_HOME_TELEPHONE_NUMBER])) {
             $items[$i][SYNC_GAL_HOMEPHONE] = w2u($abentries[$i][PR_HOME_TELEPHONE_NUMBER]);
         }
         if (isset($abentries[$i][PR_COMPANY_NAME])) {
             $items[$i][SYNC_GAL_COMPANY] = w2u($abentries[$i][PR_COMPANY_NAME]);
         }
         if (isset($abentries[$i][PR_TITLE])) {
             $items[$i][SYNC_GAL_TITLE] = w2u($abentries[$i][PR_TITLE]);
         }
         if (isset($abentries[$i][PR_OFFICE_LOCATION])) {
             $items[$i][SYNC_GAL_OFFICE] = w2u($abentries[$i][PR_OFFICE_LOCATION]);
         }
     }
     return $items;
 }
 /**
  * Resolves recipient from the contact list and gets his certificates.
  *
  * @param string $to
  *
  * @return SyncResolveRecipient|boolean
  */
 private function resolveRecipientContact($to)
 {
     // go through all contact folders of the user and
     // check if there's a contact with the given email address
     $root = mapi_msgstore_openentry($this->defaultstore);
     if (!$root) {
         ZLog::Write(LOGLEVEL_ERROR, sprintf("Unable to open default store: 0x%X", mapi_last_hresult));
     }
     $rootprops = mapi_getprops($root, array(PR_IPM_CONTACT_ENTRYID));
     $contacts = $this->getContactsFromFolder($this->defaultstore, $rootprops[PR_IPM_CONTACT_ENTRYID], $to);
     $recipients = array();
     if ($contacts !== false) {
         // create resolve recipient object
         foreach ($contacts as $contact) {
             $certificates = isset($contact[PR_USER_X509_CERTIFICATE]) && is_array($contact[PR_USER_X509_CERTIFICATE]) && count($contact[PR_USER_X509_CERTIFICATE]) ? $this->getCertificates($contact[PR_USER_X509_CERTIFICATE], 1) : false;
             if ($certificates !== false) {
                 return $this->createResolveRecipient(SYNC_RESOLVERECIPIENTS_TYPE_CONTACT, u2w($contact[PR_DISPLAY_NAME]), $to, $certificates);
             }
         }
     }
     $contactfolder = mapi_msgstore_openentry($this->defaultstore, $rootprops[PR_IPM_CONTACT_ENTRYID]);
     $subfolders = MAPIUtils::GetSubfoldersForType($contactfolder, "IPF.Contact");
     foreach ($subfolders as $folder) {
         $contacts = $this->getContactsFromFolder($this->defaultstore, $folder[PR_ENTRYID], $to);
         if ($contacts !== false) {
             foreach ($contacts as $contact) {
                 $certificates = isset($contact[PR_USER_X509_CERTIFICATE]) && is_array($contact[PR_USER_X509_CERTIFICATE]) && count($contact[PR_USER_X509_CERTIFICATE]) ? $this->getCertificates($contact[PR_USER_X509_CERTIFICATE], 1) : false;
                 if ($certificates !== false) {
                     return $this->createResolveRecipient(SYNC_RESOLVERECIPIENTS_TYPE_CONTACT, u2w($contact[PR_DISPLAY_NAME]), $to, $certificates);
                 }
             }
         }
     }
     // search contacts in public folders
     $storestables = mapi_getmsgstorestable($this->session);
     $result = mapi_last_hresult();
     if ($result == NOERROR) {
         $rows = mapi_table_queryallrows($storestables, array(PR_ENTRYID, PR_DEFAULT_STORE, PR_MDB_PROVIDER));
         foreach ($rows as $row) {
             if (isset($row[PR_MDB_PROVIDER]) && $row[PR_MDB_PROVIDER] == ZARAFA_STORE_PUBLIC_GUID) {
                 // TODO refactor public store
                 $publicstore = mapi_openmsgstore($this->session, $row[PR_ENTRYID]);
                 $publicfolder = mapi_msgstore_openentry($publicstore);
                 $subfolders = MAPIUtils::GetSubfoldersForType($publicfolder, "IPF.Contact");
                 if ($subfolders !== false) {
                     foreach ($subfolders as $folder) {
                         $contacts = $this->getContactsFromFolder($publicstore, $folder[PR_ENTRYID], $to);
                         if ($contacts !== false) {
                             foreach ($contacts as $contact) {
                                 $certificates = isset($contact[PR_USER_X509_CERTIFICATE]) && is_array($contact[PR_USER_X509_CERTIFICATE]) && count($contact[PR_USER_X509_CERTIFICATE]) ? $this->getCertificates($contact[PR_USER_X509_CERTIFICATE], 1) : false;
                                 if ($certificates !== false) {
                                     return $this->createResolveRecipient(SYNC_RESOLVERECIPIENTS_TYPE_CONTACT, u2w($contact[PR_DISPLAY_NAME]), $to, $certificates);
                                 }
                             }
                         }
                     }
                 }
                 break;
             }
         }
     } else {
         ZLog::Write(LOGLEVEL_WARN, sprintf("Unable to open public store: 0x%X", $result));
     }
     $certificates = $this->getCertificates(false);
     return $this->createResolveRecipient(SYNC_RESOLVERECIPIENTS_TYPE_CONTACT, $to, $to, $certificates);
 }
 /**
  * Creates a search restriction
  *
  * @param ContentParameter $cpo
  * @return array
  */
 private function getSearchRestriction($cpo)
 {
     $searchText = $cpo->GetSearchFreeText();
     $searchGreater = strtotime($cpo->GetSearchValueGreater());
     $searchLess = strtotime($cpo->GetSearchValueLess());
     // split the search on whitespache and look for every word
     $searchText = preg_split("/\\W+/", $searchText);
     $searchProps = array(PR_BODY, PR_SUBJECT, PR_DISPLAY_TO, PR_DISPLAY_CC, PR_SENDER_NAME, PR_SENDER_EMAIL_ADDRESS, PR_SENT_REPRESENTING_NAME, PR_SENT_REPRESENTING_EMAIL_ADDRESS);
     $resAnd = array();
     foreach ($searchText as $term) {
         $resOr = array();
         foreach ($searchProps as $property) {
             array_push($resOr, array(RES_CONTENT, array(FUZZYLEVEL => FL_SUBSTRING | FL_IGNORECASE, ULPROPTAG => $property, VALUE => u2w($term))));
         }
         array_push($resAnd, array(RES_OR, $resOr));
     }
     // add time range restrictions
     if ($searchGreater) {
         array_push($resAnd, array(RES_PROPERTY, array(RELOP => RELOP_GE, ULPROPTAG => PR_MESSAGE_DELIVERY_TIME, VALUE => array(PR_MESSAGE_DELIVERY_TIME => $searchGreater))));
         // RES_AND;
     }
     if ($searchLess) {
         array_push($resAnd, array(RES_PROPERTY, array(RELOP => RELOP_LE, ULPROPTAG => PR_MESSAGE_DELIVERY_TIME, VALUE => array(PR_MESSAGE_DELIVERY_TIME => $searchLess))));
     }
     $mapiquery = array(RES_AND, $resAnd);
     return $mapiquery;
 }
Exemple #17
0
 function SendMail($rfc822, $forward = false, $reply = false, $parent = false)
 {
     $message = Mail_mimeDecode::decode(array('decode_headers' => true, 'decode_bodies' => true, 'include_bodies' => true, 'input' => $rfc822, 'crlf' => "\r\n", 'charset' => 'utf-8'));
     // Open the outbox and create the message there
     $storeprops = mapi_getprops($this->_defaultstore, array(PR_IPM_OUTBOX_ENTRYID, PR_IPM_SENTMAIL_ENTRYID));
     if (!isset($storeprops[PR_IPM_OUTBOX_ENTRYID])) {
         debugLog("Outbox not found to create message");
         return false;
     }
     $outbox = mapi_msgstore_openentry($this->_defaultstore, $storeprops[PR_IPM_OUTBOX_ENTRYID]);
     if (!$outbox) {
         debugLog("Unable to open outbox");
         return false;
     }
     $mapimessage = mapi_folder_createmessage($outbox);
     mapi_setprops($mapimessage, array(PR_SUBJECT => u2w($message->headers["subject"]), PR_SENTMAIL_ENTRYID => $storeprops[PR_IPM_SENTMAIL_ENTRYID], PR_MESSAGE_CLASS => "IPM.Note", PR_MESSAGE_DELIVERY_TIME => time()));
     if (isset($message->headers["x-priority"])) {
         switch ($message->headers["x-priority"]) {
             case 1:
             case 2:
                 $priority = PRIO_URGENT;
                 $importance = IMPORTANCE_HIGH;
                 break;
             case 4:
             case 5:
                 $priority = PRIO_NONURGENT;
                 $importance = IMPORTANCE_LOW;
                 break;
             case 3:
             default:
                 $priority = PRIO_NORMAL;
                 $importance = IMPORTANCE_NORMAL;
                 break;
         }
         mapi_setprops($mapimessage, array(PR_IMPORTANCE => $importance, PR_PRIORITY => $priority));
     }
     $addresses = array();
     $toaddr = $ccaddr = $bccaddr = array();
     if (isset($message->headers["to"])) {
         $toaddr = Mail_RFC822::parseAddressList($message->headers["to"]);
     }
     if (isset($message->headers["cc"])) {
         $ccaddr = Mail_RFC822::parseAddressList($message->headers["cc"]);
     }
     if (isset($message->headers["bcc"])) {
         $bccaddr = Mail_RFC822::parseAddressList($message->headers["bcc"]);
     }
     // Add recipients
     $recips = array();
     if (isset($toaddr)) {
         foreach (array(MAPI_TO => $toaddr, MAPI_CC => $ccaddr, MAPI_BCC => $bccaddr) as $type => $addrlist) {
             foreach ($addrlist as $addr) {
                 $mapirecip[PR_ADDRTYPE] = "SMTP";
                 $mapirecip[PR_EMAIL_ADDRESS] = $addr->mailbox . "@" . $addr->host;
                 if (isset($addr->personal) && strlen($addr->personal) > 0) {
                     $mapirecip[PR_DISPLAY_NAME] = u2w($addr->personal);
                 } else {
                     $mapirecip[PR_DISPLAY_NAME] = $mapirecip[PR_EMAIL_ADDRESS];
                 }
                 $mapirecip[PR_RECIPIENT_TYPE] = $type;
                 $mapirecip[PR_ENTRYID] = mapi_createoneoff($mapirecip[PR_DISPLAY_NAME], $mapirecip[PR_ADDRTYPE], $mapirecip[PR_EMAIL_ADDRESS]);
                 array_push($recips, $mapirecip);
             }
         }
     }
     mapi_message_modifyrecipients($mapimessage, 0, $recips);
     // Loop through subparts. We currently only support single-level
     // multiparts. The PDA currently only does this because you are adding
     // an attachment and the type will be multipart/mixed.
     if ($message->ctype_primary == "multipart" && $message->ctype_secondary == "mixed") {
         foreach ($message->parts as $part) {
             if ($part->ctype_primary == "text") {
                 $body = u2w($part->body);
             } else {
                 // attachment
                 $attach = mapi_message_createattach($mapimessage);
                 // Filename is present in both Content-Type: name=.. and in Content-Disposition: filename=
                 if (isset($part->ctype_parameters["name"])) {
                     $filename = $part->ctype_parameters["name"];
                 } else {
                     if (isset($part->d_parameters["name"])) {
                         $filename = $part->d_parameters["filename"];
                     } else {
                         $filename = "untitled";
                     }
                 }
                 // Set filename and attachment type
                 mapi_setprops($attach, array(PR_ATTACH_LONG_FILENAME => u2w($filename), PR_ATTACH_METHOD => ATTACH_BY_VALUE));
                 // Set attachment data
                 mapi_setprops($attach, array(PR_ATTACH_DATA_BIN => $part->body));
                 // Set MIME type
                 mapi_setprops($attach, array(PR_ATTACH_MIME_TAG => $part->ctype_primary . "/" . $part->ctype_secondary));
                 mapi_savechanges($attach);
             }
         }
     } else {
         $body = u2w($message->body);
     }
     if ($forward) {
         $orig = $forward;
     }
     if ($reply) {
         $orig = $reply;
     }
     if (isset($orig) && $orig) {
         // Append the original text body for reply/forward
         $entryid = mapi_msgstore_entryidfromsourcekey($this->_defaultstore, hex2bin($parent), hex2bin($orig));
         $fwmessage = mapi_msgstore_openentry($this->_defaultstore, $entryid);
         if ($fwmessage) {
             $messageprops = mapi_getprops($fwmessage, array(PR_BODY));
             if (isset($messageprops[PR_BODY])) {
                 if ($forward) {
                     // During a forward, we have to add the forward header ourselves. This is because
                     // normally the forwarded message is added as an attachment. However, we don't want this
                     // because it would be rather complicated to copy over the entire original message due
                     // to the lack of IMessage::CopyTo ..
                     $fwmessageprops = mapi_getprops($fwmessage, array(PR_SENT_REPRESENTING_NAME, PR_DISPLAY_TO, PR_DISPLAY_CC, PR_SUBJECT, PR_CLIENT_SUBMIT_TIME));
                     $body .= "\r\n\r\n";
                     $body .= "-----Original Message-----\r\n";
                     if (isset($fwmessageprops[PR_SENT_REPRESENTING_NAME])) {
                         $body .= "From: " . $fwmessageprops[PR_SENT_REPRESENTING_NAME] . "\r\n";
                     }
                     if (isset($fwmessageprops[PR_DISPLAY_TO]) && strlen($fwmessageprops[PR_DISPLAY_TO]) > 0) {
                         $body .= "To: " . $fwmessageprops[PR_DISPLAY_TO] . "\r\n";
                     }
                     if (isset($fwmessageprops[PR_DISPLAY_CC]) && strlen($fwmessageprops[PR_DISPLAY_CC]) > 0) {
                         $body .= "Cc: " . $fwmessageprops[PR_DISPLAY_CC] . "\r\n";
                     }
                     if (isset($fwmessageprops[PR_CLIENT_SUBMIT_TIME])) {
                         $body .= "Sent: " . strftime("%x %X", $fwmessageprops[PR_CLIENT_SUBMIT_TIME]) . "\r\n";
                     }
                     if (isset($fwmessageprops[PR_SUBJECT])) {
                         $body .= "Subject: " . $fwmessageprops[PR_SUBJECT] . "\r\n";
                     }
                     $body .= "\r\n";
                 }
                 $body .= $messageprops[PR_BODY];
             }
         } else {
             debugLog("Unable to open item with id {$orig} for forward/reply");
         }
     }
     if ($forward) {
         // Add attachments from the original message in a forward
         $entryid = mapi_msgstore_entryidfromsourcekey($this->_defaultstore, hex2bin($parent), hex2bin($orig));
         $fwmessage = mapi_msgstore_openentry($this->_defaultstore, $entryid);
         $attachtable = mapi_message_getattachmenttable($fwmessage);
         $rows = mapi_table_queryallrows($attachtable, array(PR_ATTACH_NUM));
         foreach ($rows as $row) {
             if (isset($row[PR_ATTACH_NUM])) {
                 $attach = mapi_message_openattach($fwmessage, $row[PR_ATTACH_NUM]);
                 $newattach = mapi_message_createattach($mapimessage);
                 // Copy all attachments from old to new attachment
                 $attachprops = mapi_getprops($attach);
                 mapi_setprops($newattach, $attachprops);
                 if (isset($attachprops[mapi_prop_tag(PT_ERROR, mapi_prop_id(PR_ATTACH_DATA_BIN))])) {
                     // Data is in a stream
                     $srcstream = mapi_openpropertytostream($attach, PR_ATTACH_DATA_BIN);
                     $dststream = mapi_openpropertytostream($newattach, PR_ATTACH_DATA_BIN, MAPI_MODIFY | MAPI_CREATE);
                     while (1) {
                         $data = mapi_stream_read($srcstream, 4096);
                         if (strlen($data) == 0) {
                             break;
                         }
                         mapi_stream_write($dststream, $data);
                     }
                     mapi_stream_commit($dststream);
                 }
                 mapi_savechanges($newattach);
             }
         }
     }
     mapi_setprops($mapimessage, array(PR_BODY => $body));
     mapi_savechanges($mapimessage);
     mapi_message_submitmessage($mapimessage);
     return true;
 }
 /**
  * Sets information from SyncBaseBody type for a MAPI message.
  *
  * @param SyncBaseBody $asbody
  * @param array $props
  * @param array $appointmentprops
  *
  * @access private
  * @return void
  */
 private function setASbody($asbody, &$props, $appointmentprops)
 {
     if (isset($asbody->type) && isset($asbody->data) && strlen($asbody->data) > 0) {
         switch ($asbody->type) {
             case SYNC_BODYPREFERENCE_PLAIN:
             default:
                 //set plain body if the type is not in valid range
                 $props[$appointmentprops["body"]] = u2w($asbody->data);
                 break;
             case SYNC_BODYPREFERENCE_HTML:
                 $props[$appointmentprops["html"]] = u2w($asbody->data);
                 break;
             case SYNC_BODYPREFERENCE_RTF:
                 break;
             case SYNC_BODYPREFERENCE_MIME:
                 break;
         }
     } else {
         ZLog::Write(LOGLEVEL_DEBUG, "MAPIProvider->setASbody either type or data are not set. Setting to empty body");
         $props[$appointmentprops["body"]] = "";
     }
 }
Exemple #19
0
 function _storeAttachment($mapimessage, $part)
 {
     // attachment
     $attach = mapi_message_createattach($mapimessage);
     // Filename is present in both Content-Type: name=.. and in Content-Disposition: filename=
     if (isset($part->ctype_parameters["name"])) {
         $filename = $part->ctype_parameters["name"];
     } else {
         if (isset($part->d_parameters["name"])) {
             $filename = $part->d_parameters["filename"];
         } else {
             if (isset($part->d_parameters["filename"])) {
                 // sending appointment with nokia & android only filename is set
                 $filename = $part->d_parameters["filename"];
             } else {
                 $filename = "untitled";
             }
         }
     }
     // Android just doesn't send content-type, so mimeDecode doesn't performs base64 decoding
     // on meeting requests text/calendar somewhere inside content-transfer-encoding
     if (isset($part->headers['content-transfer-encoding']) && strpos($part->headers['content-transfer-encoding'], 'base64')) {
         if (strpos($part->headers['content-transfer-encoding'], 'text/calendar') !== false) {
             $part->ctype_primary = 'text';
             $part->ctype_secondary = 'calendar';
         }
         if (!isset($part->headers['content-type'])) {
             $part->body = base64_decode($part->body);
         }
     }
     // Set filename and attachment type
     mapi_setprops($attach, array(PR_ATTACH_LONG_FILENAME => u2w($filename), PR_ATTACH_METHOD => ATTACH_BY_VALUE));
     // Set attachment data
     mapi_setprops($attach, array(PR_ATTACH_DATA_BIN => $part->body));
     // Set MIME type
     mapi_setprops($attach, array(PR_ATTACH_MIME_TAG => $part->ctype_primary . "/" . $part->ctype_secondary));
     mapi_savechanges($attach);
 }