本文整理汇总了PHP中imap_utf7_decode函数的典型用法代码示例。如果您正苦于以下问题:PHP imap_utf7_decode函数的具体用法?PHP imap_utf7_decode怎么用?PHP imap_utf7_decode使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imap_utf7_decode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveGmailDetails
public function saveGmailDetails($parameters)
{
$username = $parameters["gmailusername"];
$password = $parameters["gmailpassword"];
$userid = $_SESSION["userid"];
try {
$inbox = $this->getImapConnection($username, $password, "INBOX");
} catch (Exception $e) {
error_log("Errror Caugt!!!");
return self::$responder->constructErrorResponse("I could not connect to Gmail. Make sure your login details are correct.");
}
try {
self::$gmailDAO->saveGmailDetails($userid, $username, $password);
} catch (Exception $e) {
}
$folderList = array();
$emailFolderList = imap_getmailboxes($inbox, self::INBOX, "*");
error_log("list size: " . sizeof($emailFolderList));
if (is_array($emailFolderList)) {
$count = 0;
foreach ($emailFolderList as $key => $val) {
$temp = imap_utf7_decode($val->name);
$folder = str_replace(self::INBOX, "", $temp);
if (!strstr($folder, "[Gmail]")) {
$folderList["folder" . ++$count] = $folder;
}
}
} else {
return self::$responder->constructErrorResponse("Could not get the list of folder from your account, please try again.");
}
imap_close($inbox);
return self::$responder->constructResponseForKeyValue(array_reverse($folderList));
}
示例2: listMailboxes
function listMailboxes()
{
$mailboxes = imap_list($this->stream, $this->target, "*");
foreach ($mailboxes as &$folder) {
$folder = str_replace($this->target, "", imap_utf7_decode($folder));
}
return $mailboxes;
}
示例3: getListingFolders
public function getListingFolders()
{
$folders = imap_list($this->Stream, $this->_connectionString, "*");
foreach ($folders as $key => $folder) {
$folder = str_replace($this->_connectionString, "", imap_utf7_decode($folder));
$folders[$key] = $folder;
}
return $folders;
}
示例4: getFoldersList
public function getFoldersList()
{
$out = [];
$list = imap_list($this->imapStream, $this->getMailbox(), '*');
if (is_array($list)) {
foreach ($list as $val) {
$out[] = imap_utf7_decode($val);
}
} else {
throw new \Exception('Imap list failed: ' . imap_last_error());
}
return $out;
}
示例5: getFolders
/**
* Vrati pole vsetkych najdenych mailboxov na emailovom konte
*
* @return array
* @throws Exception
*/
public function getFolders()
{
$mbox = $this->openMailServerConnection();
$result = array();
$boxes = imap_getmailboxes($mbox, '{' . IMAP_HOST . '}', '*');
if (is_array($boxes)) {
foreach ($boxes as $key => $val) {
$result[$key]['name'] = str_replace('{' . IMAP_HOST . '}', '', imap_utf7_decode($val->name));
$result[$key]['delimiter'] = $val->delimiter;
$result[$key]['attribs'] = $val->attributes;
$Status = imap_status($mbox, $val->name, SA_ALL);
$result[$key]['msgNum'] = $Status->messages;
$result[$key]['newNum'] = isset($Status->recent) ? $Status->recent : 0;
$result[$key]['unreadNum'] = isset($Status->unseen) ? $Status->unseen : 0;
}
} else {
Logger::error("imap_getmailboxes() failed: " . imap_last_error());
}
// imap_close($mbox);
return $result;
}
示例6: getLabels
function getLabels()
{
$this->load->database();
$this->load->model('grabber');
$inbox = $this->getConnect('INBOX');
$folders = imap_list($inbox, "{imap.gmail.com:993/imap/ssl}", "*");
$i = 0;
$folde = array();
foreach ($folders as $folder) {
$fold = str_replace("{imap.gmail.com:993/imap/ssl}", " ", imap_utf7_decode($folder));
if ($this->grabber->check_label_exist(htmlentities($fold)) == 0) {
$folde[$i]['id'] = uniqid();
$folde[$i]['name'] = htmlentities($fold);
$i++;
}
}
if (count($folde) > 0) {
$this->grabber->insert_labels($folde);
}
//imap_close($inbox);
}
示例7: globalDelete
/**
* Function to delete messages in a mailbox, based on date
* NOTE: this is global ... will affect all mailboxes except any that have 'sent' in the mailbox name
*/
public function globalDelete()
{
$dateArr = split('-', $this->deleteMsgDate);
// date format is yyyy-mm-dd
$delDate = mktime(0, 0, 0, $dateArr[1], $dateArr[2], $dateArr[0]);
$port = $this->port . '/' . $this->service . '/' . $this->serviceOption;
$mboxt = imap_open('{' . $this->mailhost . ":" . $port . '}', $this->mailboxUserName, $this->mailboxPassword, OP_HALFOPEN);
$list = imap_getmailboxes($mboxt, '{' . $this->mailhost . ":" . $port . '}', "*");
$mailboxFound = false;
if (is_array($list)) {
foreach ($list as $key => $val) {
// get the mailbox name only
$nameArr = split('}', imap_utf7_decode($val->name));
$nameRaw = $nameArr[count($nameArr) - 1];
if (!stristr($nameRaw, 'sent')) {
$mboxd = imap_open('{' . $this->mailhost . ":" . $port . '}' . $nameRaw, $this->mailboxUserName, $this->mailboxPassword, CL_EXPUNGE);
$messages = imap_sort($mboxd, SORTDATE, 0);
$i = 0;
$check = imap_mailboxmsginfo($mboxd);
foreach ($messages as $message) {
$header = imap_header($mboxd, $message);
$fdate = date("F j, Y", $header->udate);
// purge if prior to global delete date
if ($header->udate < $delDate) {
imap_delete($mboxd, $message);
}
$i++;
}
imap_expunge($mboxd);
imap_close($mboxd);
}
}
}
}
示例8: decodePart
private function decodePart($part)
{
$bodyStructure = imap_bodystruct($this->imap_stream, $this->message_index, $part);
$att_data = imap_fetchbody($this->imap_stream, $this->message_index, $part);
switch ($bodyStructure->encoding) {
case '1':
//utf7 //php lies, this is 0
$filedata = @imap_utf7_decode($att_data);
break;
// case '1': //utf8 //php lies, this is utf7
// $filedata = imap_utf8($att_data);
// break;
// case '1': //utf8 //php lies, this is utf7
// $filedata = imap_utf8($att_data);
// break;
case '3':
//base64
$filedata = imap_base64($att_data);
break;
case '4':
//quoted printable
$filedata = imap_qprint($att_data);
break;
default:
$filedata = $att_data;
}
return $filedata;
}
示例9: get_folder_caption
function get_folder_caption($realname)
{
$spaces = 0;
$last = $realname;
if (strpos($realname, ".") !== false) {
$last = substr($realname, strrpos($realname, ".") + 1);
$spaces = substr_count($realname, ".");
}
return str_repeat(" ", $spaces) . imap_utf7_decode($last);
}
示例10: printf
printf('<input type="hidden" name="lists[%d]" value="%s">', $key, $val);
}
}
foreach (array("server", "user", "password", "markhtml", "overwrite", "onlyfull", "notify", "nameattributes", "attributeone", "attributetwo") as $item) {
printf('<input type="hidden" name="%s" value="%s">', $item, $_POST[$item]);
}
$done = 0;
$level = 0;
$foldersdone = array();
$tree = array();
while (sizeof($folderdone) < sizeof($folders) && $level < 10) {
reset($folders);
asort($folders);
while (list($key, $val) = each($folders)) {
$delim = $val->delimiter;
$name = str_replace("{" . $server . "}INBOX", "", imap_utf7_decode($val->name));
$parent = mailBoxParent($name, $delim, $level);
$folder = mailBoxName($name, $delim, $level);
if ($folder) {
if (!is_array($tree[$parent])) {
$tree[$parent] = array("node" => $parent, "children" => array());
}
if (!in_array($folder, $tree[$parent]["children"])) {
array_push($tree[$parent]["children"], $folder);
}
# print $parent . " ".$folder."<br/>";
flush();
} else {
array_push($foldersdone, $name);
}
}
示例11: isMailboxExist
/**
* Function to check if a mailbox exists
* - if not found, it will create it
* @param string $mailbox (the mailbox name, must be in 'INBOX.checkmailbox' format)
* @param boolean $create (whether or not to create the checkmailbox if not found, defaults to true)
* @return boolean
*/
function isMailboxExist($mailbox)
{
if (trim($mailbox) == '' || !strstr($mailbox, 'INBOX.')) {
// this is a critical error with either the mailbox name blank or an invalid mailbox name
// need to stop processing and exit at this point
//echo "Invalid mailbox name for move operation. Cannot continue.<br />\n";
//echo "TIP: the mailbox you want to move the message to must include 'INBOX.' at the start.<br />\n";
return false;
}
$port = $this->port . '/' . $this->service . ($this->service_option != 'none' ? '/' . $this->service_option : '');
$mbox = imap_open('{' . $this->mailhost . ":" . $port . '}', $this->mailbox_username, $this->mailbox_password, OP_HALFOPEN);
$list = imap_getmailboxes($mbox, '{' . $this->mailhost . ":" . $port . '}', "*");
$mailboxFound = false;
if (is_array($list)) {
foreach ($list as $key => $val) {
// get the mailbox name only
$nameArr = split('}', imap_utf7_decode($val->name));
$nameRaw = $nameArr[count($nameArr) - 1];
if ($mailbox == $nameRaw) {
$mailboxFound = true;
}
}
// if ( ($mailboxFound === false) && $create ) {
// @imap_createmailbox($mbox, imap_utf7_encode('{'.$this->mailhost.":".$port.'}' . $mailbox));
// imap_close($mbox);
// return true;
// } else {
// imap_close($mbox);
// return false;
// }
} else {
imap_close($mbox);
return false;
}
}
示例12: printf
printf('<input type="hidden" name="lists[%d]" value="%s">', $key, $val);
}
}
foreach (array('server', 'user', 'password', 'markhtml', 'overwrite', 'onlyfull', 'notify', 'nameattributes', 'attributeone', 'attributetwo') as $item) {
printf('<input type="hidden" name="%s" value="%s">', $item, $_POST[$item]);
}
$done = 0;
$level = 0;
$foldersdone = array();
$tree = array();
while (count($folderdone) < count($folders) && $level < 10) {
reset($folders);
asort($folders);
while (list($key, $val) = each($folders)) {
$delim = $val->delimiter;
$name = str_replace('{' . $server . '}INBOX', '', imap_utf7_decode($val->name));
$parent = mailBoxParent($name, $delim, $level);
$folder = mailBoxName($name, $delim, $level);
if ($folder) {
if (!is_array($tree[$parent])) {
$tree[$parent] = array('node' => $parent, 'children' => array());
}
if (!in_array($folder, $tree[$parent]['children'])) {
array_push($tree[$parent]['children'], $folder);
}
# print $parent . " ".$folder."<br/>";
flush();
} else {
array_push($foldersdone, $name);
}
}
示例13: convert_encoding
static function convert_encoding($string, $to, $from = '')
{
// Convert string to ISO_8859-1
if ($from == "UTF-8") {
$iso_string = utf8_decode($string);
} else {
if ($from == "UTF7-IMAP") {
$iso_string = imap_utf7_decode($string);
} else {
$iso_string = $string;
}
}
// Convert ISO_8859-1 string to result coding
if ($to == "UTF-8") {
return utf8_encode($iso_string);
} else {
if ($to == "UTF7-IMAP") {
return imap_utf7_encode($iso_string);
} else {
return $iso_string;
}
}
}
示例14: GetFolder
function GetFolder($id)
{
$folder = new SyncFolder();
$folder->serverid = $id;
// explode hierarchy
$fhir = explode(".", $id);
// compare on lowercase strings
$lid = strtolower($id);
if ($lid == "inbox") {
$folder->parentid = "0";
// Root
$folder->displayname = "Inbox";
$folder->type = SYNC_FOLDER_TYPE_INBOX;
} else {
if ($lid == "drafts") {
$folder->parentid = "0";
$folder->displayname = "Drafts";
$folder->type = SYNC_FOLDER_TYPE_DRAFTS;
} else {
if ($lid == "trash") {
$folder->parentid = "0";
$folder->displayname = "Trash";
$folder->type = SYNC_FOLDER_TYPE_WASTEBASKET;
$this->_wasteID = $id;
} else {
if ($lid == "sent" || $lid == "sent items" || $lid == IMAP_SENTFOLDER) {
$folder->parentid = "0";
$folder->displayname = "Sent";
$folder->type = SYNC_FOLDER_TYPE_SENTMAIL;
$this->_sentID = $id;
} else {
if ($lid == "inbox.drafts") {
$folder->parentid = $fhir[0];
$folder->displayname = "Drafts";
$folder->type = SYNC_FOLDER_TYPE_DRAFTS;
} else {
if ($lid == "inbox.trash") {
$folder->parentid = $fhir[0];
$folder->displayname = "Trash";
$folder->type = SYNC_FOLDER_TYPE_WASTEBASKET;
$this->_wasteID = $id;
} else {
if ($lid == "inbox.sent") {
$folder->parentid = $fhir[0];
$folder->displayname = "Sent";
$folder->type = SYNC_FOLDER_TYPE_SENTMAIL;
$this->_sentID = $id;
} else {
if (count($fhir) > 1) {
$folder->displayname = windows1252_to_utf8(imap_utf7_decode(array_pop($fhir)));
$folder->parentid = implode(".", $fhir);
} else {
$folder->displayname = windows1252_to_utf8(imap_utf7_decode($id));
$folder->parentid = "0";
}
$folder->type = SYNC_FOLDER_TYPE_OTHER;
}
}
}
}
}
}
}
//advanced debugging
//debugLog("IMAP-GetFolder(id: '$id') -> " . print_r($folder, 1));
return $folder;
}
示例15: utf7_decode_string
function utf7_decode_string($data_str)
{
$name = array();
$name['folder_before'] = '';
$name['folder_after'] = '';
$name['translated'] = '';
if (strstr($data_str, '}')) {
// folder name at this stage is {SERVER_NAME:PORT}FOLDERNAME
// get everything to the right of the bracket "}", INCLUDES the bracket itself
$name['folder_before'] = strstr($data_str, '}');
// get rid of that 'needle' "}"
$name['folder_before'] = substr($name['folder_before'], 1);
// translate
if (function_exists('recode_string') == False) {
$name['folder_after'] = imap_utf7_decode($name['folder_before']);
} else {
// Modif UTF-8 by Sam Przyswa so now compatible with MS-Outlook and Netscape accentued folder name
$name_tmp = str_replace("&", "+", $name['folder_before']);
$name['folder_after'] = recode_string("UTF-7..ISO-8859-1", $name_tmp);
}
// "imap_utf7_decode" returns False if no translation occured (supposed to, can return identical string too)
if ($name['folder_after'] == False || $name['folder_before'] == $name['folder_after']) {
// no translation occured
if ($this->debug_utf7 > 0) {
echo ' _ mail_dcom_base: utf7_decode_string (' . __LINE__ . '): returning unmodified name, NO decoding needed, returning feed $data_str: [' . htmlspecialchars(serialize($data_str)) . ']<br>';
}
return $data_str;
} else {
// replace old folder name with new folder name
$name['translated'] = str_replace($name['folder_before'], $name['folder_after'], $data_str);
if ($this->debug_utf7 > 0) {
echo ' _ mail_dcom_base: utf7_decode_string (' . __LINE__ . '): returning decoded name, $name[] DUMP: [' . htmlspecialchars(serialize($name)) . ']<br>';
}
return $name['translated'];
}
} else {
// folder name at this stage is FOLDERNAME
// there is NO {SERVER} part in this name,
// DOES THIS EVER HAPPEN comming *from* the server? I DO NOT THINK SO, but just in case
// translate
$name['translated'] = imap_utf7_decode($data_str);
// "imap_utf7_decode" returns False if no translation occured
if ($name['translated'] == False || $name['folder_before'] == $data_str) {
// no translation occured
if ($this->debug_utf7 > 0) {
echo ' _ mail_dcom_base: utf7_decode_string (' . __LINE__ . '): returning unmodified name, NO decoding needed, returning feed $data_str: [' . htmlspecialchars(serialize($data_str)) . ']<br>';
}
return $data_str;
} else {
if ($this->debug_utf7 > 0) {
echo ' _ mail_dcom_base: utf7_decode_string (' . __LINE__ . '): returning decoded name, $name[] DUMP: [' . htmlspecialchars(serialize($name)) . ']<br>';
}
return $name['translated'];
}
}
}