当前位置: 首页>>代码示例>>PHP>>正文


PHP Chop函数代码示例

本文整理汇总了PHP中Chop函数的典型用法代码示例。如果您正苦于以下问题:PHP Chop函数的具体用法?PHP Chop怎么用?PHP Chop使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Chop函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 public function init($from = "", $charset = "UTF-8", $log_file = "")
 {
     if (!empty($from)) {
         $this->setFrom($from);
     }
     if (!empty($charset)) {
         $this->charset = $charset;
     }
     if (!empty($log_file)) {
         $this->log_fp = @fopen($log_file, "wb");
     }
     $boundary_str = "mystep_" . Chop("b" . md5(uniqid(time()))) . "_mystep";
     $this->boundary["body"] = "===Body_" . $boundary_str . "===";
     $this->boundary["attach"] = "===Attach_" . $boundary_str . "===";
     $this->boundary["embed"] = "===Embed_" . $boundary_str . "===";
 }
开发者ID:laiello,项目名称:mystep-cms,代码行数:16,代码来源:myemail.class.php

示例2: ReadReplyHeadersResponse

 function ReadReplyHeadersResponse(&$headers)
 {
     $headers = array();
     if (strlen($this->error)) {
         return $this->error;
     }
     switch ($this->state) {
         case "Disconnected":
             return $this->SetError("1 connection was not yet established");
         case "Connected":
             return $this->SetError("2 request was not sent");
         case "ConnectedToProxy":
             return $this->SetError("2 connection from the remote server from the proxy was not yet established");
         case "SendingRequestBody":
             return $this->SetError("4 request body data was not completely sent");
         case "ConnectSent":
             $connect = 1;
             break;
         case "RequestSent":
             $connect = 0;
             break;
         default:
             return $this->SetError("3 can not get request headers in the current connection state");
     }
     $this->content_length = $this->read_length = $this->read_response = $this->remaining_chunk = 0;
     $this->content_length_set = $this->chunked = $this->last_chunk_read = $chunked = 0;
     $this->connection_close = 0;
     for ($this->response_status = "";;) {
         $line = $this->GetLine();
         if (GetType($line) != "string") {
             return $this->SetError("4 could not read request reply: " . $this->error);
         }
         if (strlen($this->response_status) == 0) {
             if (!preg_match($match = "#^http/[0-9]+\\.[0-9]+[ \t]+([0-9]+)[ \t]*(.*)\$#i", $line, $matches)) {
                 return $this->SetError("3 it was received an unexpected HTTP response status");
             }
             $this->response_status = $matches[1];
             $this->response_message = $matches[2];
         }
         if ($line == "") {
             if (strlen($this->response_status) == 0) {
                 return $this->SetError("3 it was not received HTTP response status");
             }
             $this->state = $connect ? "GotConnectHeaders" : "GotReplyHeaders";
             break;
         }
         $header_name = strtolower($this->Tokenize($line, ":"));
         $header_value = Trim(Chop($this->Tokenize("\r\n")));
         if (isset($headers[$header_name])) {
             if (GetType($headers[$header_name]) == "string") {
                 $headers[$header_name] = array($headers[$header_name]);
             }
             $headers[$header_name][] = $header_value;
         } else {
             $headers[$header_name] = $header_value;
         }
         if (!$connect) {
             switch ($header_name) {
                 case "content-length":
                     $this->content_length = intval($headers[$header_name]);
                     $this->content_length_set = 1;
                     break;
                 case "transfer-encoding":
                     $encoding = $this->Tokenize($header_value, "; \t");
                     if (!$this->use_curl && !strcmp($encoding, "chunked")) {
                         $chunked = 1;
                     }
                     break;
                 case "set-cookie":
                     if ($this->support_cookies) {
                         if (GetType($headers[$header_name]) == "array") {
                             $cookie_headers = $headers[$header_name];
                         } else {
                             $cookie_headers = array($headers[$header_name]);
                         }
                         for ($cookie = 0; $cookie < count($cookie_headers); $cookie++) {
                             $cookie_name = trim($this->Tokenize($cookie_headers[$cookie], "="));
                             $cookie_value = $this->Tokenize(";");
                             $domain = $this->request_host;
                             $path = "/";
                             $expires = "";
                             $secure = 0;
                             while (($name = trim(UrlDecode($this->Tokenize("=")))) != "") {
                                 $value = UrlDecode($this->Tokenize(";"));
                                 switch ($name) {
                                     case "domain":
                                         $domain = $value;
                                         break;
                                     case "path":
                                         $path = $value;
                                         break;
                                     case "expires":
                                         if (preg_match("#^((Mon|Monday|Tue|Tuesday|Wed|Wednesday|Thu|Thursday|Fri|Friday|Sat|Saturday|Sun|Sunday), )?([0-9]{2})\\-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\-([0-9]{2,4}) ([0-9]{2})\\:([0-9]{2})\\:([0-9]{2}) GMT\$#", $value, $matches)) {
                                             $year = intval($matches[5]);
                                             if ($year < 1900) {
                                                 $year += $year < 70 ? 2000 : 1900;
                                             }
                                             $expires = "{$year}-" . $this->months[$matches[4]] . "-" . $matches[3] . " " . $matches[6] . ":" . $matches[7] . ":" . $matches[8];
                                         }
                                         break;
//.........这里部分代码省略.........
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:101,代码来源:http.php

示例3: ReadReplyHeaders

 function ReadReplyHeaders(&$headers)
 {
     $headers = array();
     if (strlen($this->error)) {
         return $this->error;
     }
     switch ($this->state) {
         case "Disconnected":
             return $this->SetError("1 connection was not yet established");
         case "Connected":
             return $this->SetError("2 request was not sent");
         case "RequestSent":
             break;
         default:
             return $this->SetError("3 can not get request headers in the current connection state");
     }
     $this->content_length = $this->read_length = $this->read_response = 0;
     $this->content_length_set = 0;
     for ($this->response_status = "";;) {
         $line = $this->GetLine();
         if (GetType($line) != "string") {
             return $this->SetError("4 could not read request reply: " . $this->error);
         }
         if (strlen($this->response_status) == 0) {
             if (!eregi($match = "^http/[0-9]+\\.[0-9]+[ \t]+([0-9]+)", $line, $matches)) {
                 return $this->SetError("3 it was received an unexpected HTTP response status");
             }
             $this->response_status = $matches[1];
         }
         if ($line == "") {
             if (strlen($this->response_status) == 0) {
                 return $this->SetError("3 it was not received HTTP response status");
             }
             $this->state = "GotReplyHeaders";
             break;
         }
         $header_name = strtolower($this->Tokenize($line, ":"));
         $header_value = Trim(Chop($this->Tokenize("\r\n")));
         if (isset($headers[$header_name])) {
             if (GetType($headers[$header_name]) == "string") {
                 $headers[$header_name] = array($headers[$header_name]);
             }
             $headers[$header_name][] = $header_value;
         } else {
             $headers[$header_name] = $header_value;
         }
         switch ($header_name) {
             case "content-length":
                 $this->content_length = intval($headers[$header_name]);
                 $this->content_length_set = 1;
                 break;
             case "set-cookie":
                 if ($this->support_cookies) {
                     if (GetType($headers[$header_name]) == "array") {
                         $cookie_headers = $headers[$header_name];
                     } else {
                         $cookie_headers = array($headers[$header_name]);
                     }
                     for ($cookie = 0; $cookie < count($cookie_headers); $cookie++) {
                         $cookie_name = trim($this->Tokenize($cookie_headers[$cookie], "="));
                         $cookie_value = $this->Tokenize(";");
                         $domain = $this->request_host;
                         $path = "/";
                         $expires = "";
                         $secure = strtolower($this->protocol) == "https";
                         while (($name = strtolower(trim($this->Tokenize("=")))) != "") {
                             $value = UrlDecode($this->Tokenize(";"));
                             switch ($name) {
                                 case "domain":
                                     if ($value == "" || !strpos($value, ".", $value[0] == ".")) {
                                         break;
                                     }
                                     $domain = strtolower($value);
                                     break;
                                 case "path":
                                     if ($value != "" && $value[0] == "/") {
                                         $path = $value;
                                     }
                                     break;
                                 case "expires":
                                     if (ereg("^((Mon|Monday|Tue|Tuesday|Wed|Wednesday|Thu|Thursday|Fri|Friday|Sat|Saturday|Sun|Sunday), )?([0-9]{2})\\-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\-([0-9]{2,4}) ([0-9]{2})\\:([0-9]{2})\\:([0-9]{2}) GMT\$", $value, $matches)) {
                                         $year = intval($matches[5]);
                                         if ($year < 1900) {
                                             $year += $year < 70 ? 2000 : 1900;
                                         }
                                         $expires = "{$year}-" . $this->months[$matches[4]] . "-" . $matches[3] . " " . $matches[6] . ":" . $matches[7] . ":" . $matches[8];
                                     }
                                     break;
                                 case "secure":
                                     $secure = 1;
                                     break;
                             }
                         }
                         $this->cookies[$secure][$domain][$path][$cookie_name] = array("name" => $cookie_name, "value" => $cookie_value, "domain" => $domain, "path" => $path, "expires" => $expires, "secure" => $secure);
                     }
                 }
         }
     }
     switch ($this->response_status) {
         case "301":
//.........这里部分代码省略.........
开发者ID:Git-Host,项目名称:Online-PHP-Proxy-Browser,代码行数:101,代码来源:http.php

示例4: sqimap_parse_RFC822Header


//.........这里部分代码省略.........
                break;
            case 'f':
                /* From */
                if (strtolower(substr($line, 0, 5)) == "from:") {
                    $hdr->from = sqimap_parse_address(trim(substr($line, 5, strlen($line) - 6)), false);
                    if (!isset($hdr->replyto) || $hdr->replyto == "") {
                        $hdr->replyto = $hdr->from;
                    }
                }
                $i++;
                break;
            case 'd':
                $c2 = strtolower($line[1]);
                switch ($c2) {
                    case 'a':
                        /* Date */
                        if (strtolower(substr($line, 0, 5)) == "date:") {
                            $d = substr($read[$i], 5);
                            $d = trim($d);
                            $d = strtr($d, array('  ' => ' '));
                            $d = explode(' ', $d);
                            $hdr->date = getTimeStamp($d);
                        }
                        $i++;
                        break;
                    case 'i':
                        /* Disposition-Notification-To */
                        if (strtolower(substr($line, 0, 28)) == "disposition-notification-to:") {
                            $dnt = trim(substr($read[$i], 28));
                            $hdr->dnt = sqimap_parse_address($dnt, false);
                        }
                        $i++;
                        break;
                    default:
                        $i++;
                        break;
                }
                break;
            case 's':
                /* SUBJECT */
                if (strtolower(substr($line, 0, 8)) == "subject:") {
                    $hdr->subject = trim(substr($line, 8, strlen($line) - 9));
                    if (strlen(Chop($hdr->subject)) == 0) {
                        $hdr->subject = _("(no subject)");
                    }
                }
                $i++;
                break;
            case 'b':
                /* BCC */
                if (strtolower(substr($line, 0, 4)) == "bcc:") {
                    $hdr->bcc = sqimap_parse_address(trim(substr($line, 4, strlen($line) - 5)), true);
                }
                $i++;
                break;
            case 't':
                /* TO */
                if (strtolower(substr($line, 0, 3)) == "to:") {
                    $hdr->to = sqimap_parse_address(trim(substr($line, 3, strlen($line) - 4)), true);
                }
                $i++;
                break;
            case ')':
                /* ERROR CORRECTION */
                if (strlen(trim($hdr->subject)) == 0) {
                    $hdr->subject = _("(no subject)");
                }
                if (!is_object($hdr->from) && strlen(trim($hdr->from)) == 0) {
                    $hdr->from = _("(unknown sender)");
                }
                if (strlen(trim($hdr->date)) == 0) {
                    $hdr->date = time();
                }
                $i++;
                break;
            case 'x':
                /* X-PRIORITY */
                if (strtolower(substr($line, 0, 11)) == 'x-priority:') {
                    $hdr->priority = trim(substr($line, 11));
                } else {
                    if (strtolower(substr($line, 0, 9)) == 'x-mailer:') {
                        $hdr->xmailer = trim(substr($line, 9));
                    }
                }
                $i++;
                break;
            case 'u':
                /* User-Agent */
                if (strtolower(substr($line, 0, 10)) == 'user-agent') {
                    $hdr->xmailer = trim(substr($line, 10));
                }
                $i++;
                break;
            default:
                $i++;
                break;
        }
    }
    return $hdr;
}
开发者ID:innomatic-libs,项目名称:squirrelmaillib,代码行数:101,代码来源:imap_parse.php

示例5: getline

function getline($file)
{
    $data = Chop(fgets($file, 5000));
    return $data;
}
开发者ID:nldfr219,项目名称:zhi,代码行数:5,代码来源:index.php

示例6: ReadReplyHeaders

 function ReadReplyHeaders(&$headers)
 {
     switch ($this->state) {
         case 'Disconnected':
             return '1 connection was not yet established';
         case 'Connected':
             return '2 request was not sent';
         case 'RequestSent':
             break;
         default:
             return '3 can not get request headers in the current connection state';
     }
     $headers = array();
     $this->content_length = $this->read_length = 0;
     $this->content_length_set = 0;
     for (;;) {
         $line = $this->GetLine();
         if (GetType($line) != 'string') {
             return '4 could not read request reply';
         }
         if ($line == '') {
             $this->state = 'GotReplyHeaders';
             return '';
         }
         $header_name = strtolower(strtok($line, ':'));
         $header_value = Trim(Chop(strtok("\r\n")));
         if (isset($headers[$header_name])) {
             if (GetType($headers[$header_name]) == 'string') {
                 $headers[$header_name] = array($headers[$header_name]);
             }
             $headers[$header_name][] = $header_value;
         } else {
             $headers[$header_name] = $header_value;
         }
         switch ($header_name) {
             case 'content-length':
                 $this->content_length = intval($headers[$header_name]);
                 $this->content_length_set = 1;
                 break;
             case 'set-cookie':
                 if ($this->support_cookies) {
                     $cookie_name = trim(strtok($headers[$header_name], '='));
                     $cookie_value = strtok(';');
                     $domain = $this->request_host;
                     $path = '/';
                     $expires = '';
                     $secure = 0;
                     while (($name = strtolower(trim(strtok('=')))) != '') {
                         $value = UrlDecode(strtok(';'));
                         switch ($name) {
                             case 'domain':
                                 if ($value == '' || !strpos($value, '.', $value[0] == '.')) {
                                     break;
                                 }
                                 $domain = strtolower($value);
                                 break;
                             case 'path':
                                 if ($value != '' && $value[0] == '/') {
                                     $path = $value;
                                 }
                                 break;
                             case 'expires':
                                 if (preg_match("/^((Mon|Monday|Tue|Tuesday|Wed|Wednesday|Thu|Thursday|Fri|Friday|Sat|Saturday|Sun|Sunday), )?([0-9]{2})\\-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\-([0-9]{2,4}) ([0-9]{2})\\:([0-9]{2})\\:([0-9]{2}) GMT\$/i", $value, $matches)) {
                                     $year = intval($matches[5]);
                                     if ($year < 1900) {
                                         $year += $year < 70 ? 2000 : 1900;
                                     }
                                     $expires = "{$year}-" . $this->months[$matches[4]] . '-' . $matches[3] . ' ' . $matches[6] . ':' . $matches[7] . ':' . $matches[8];
                                 }
                                 break;
                             case 'secure':
                                 $secure = 1;
                                 break;
                         }
                     }
                     $this->cookies[$secure][$domain][$path][$cookie_name] = array('name' => $cookie_name, 'value' => $cookie_value, 'domain' => $domain, 'path' => $path, 'expires' => $expires, 'secure' => $secure);
                 }
         }
     }
 }
开发者ID:HaakonME,项目名称:porticoestate,代码行数:80,代码来源:class.http.inc.php

示例7: headlines

function headlines($hid = "", $block = true)
{
    global $NPDS_Prefix;
    global $Version_Num, $Version_Id, $system, $rss_host_verif, $long_chain;
    if (file_exists("proxy.conf.php")) {
        include "proxy.conf.php";
    }
    if ($hid == "") {
        $result = sql_query("SELECT sitename, url, headlinesurl, hid from " . $NPDS_Prefix . "headlines WHERE status=1");
    } else {
        $result = sql_query("SELECT sitename, url, headlinesurl, hid from " . $NPDS_Prefix . "headlines WHERE hid='{$hid}' AND status=1");
    }
    while (list($sitename, $url, $headlinesurl, $hid) = sql_fetch_row($result)) {
        $boxtitle = "{$sitename}";
        $cache_file = "cache/{$sitename}.cache";
        $cache_time = 3600;
        $items = 0;
        $max_items = 10;
        $rss_timeout = 15;
        $rss_font = "<span style=\"font-size: 10px;\">";
        if (!file_exists($cache_file) or filemtime($cache_file) < time() - $cache_time or !filesize($cache_file)) {
            $rss = parse_url($url);
            if ($rss_host_verif == true) {
                $verif = fsockopen($rss['host'], 80, $errno, $errstr, $rss_timeout);
                if ($verif) {
                    fclose($verif);
                    $verif = true;
                }
            } else {
                $verif = true;
            }
            if (!$verif) {
                $cache_file_sec = $cache_file . ".security";
                if (file_exists($cache_file)) {
                    $ibid = rename($cache_file, $cache_file_sec);
                }
                themesidebox($boxtitle, "Security Error");
                return;
            } else {
                if (isset($proxy_url[$hid])) {
                    $fpread = fsockopen($proxy_url[$hid], $proxy_port[$hid], $errno, $errstr, $rss_timeout);
                    fputs($fpread, "GET {$headlinesurl}/ HTTP/1.0\n\n");
                } else {
                    $fpread = fopen($headlinesurl, 'r');
                }
                if (!$long_chain) {
                    $long_chain = 15;
                }
                if ($fpread) {
                    $fpwrite = fopen($cache_file, 'w');
                    if ($fpwrite) {
                        fputs($fpwrite, "<ul>\n");
                        while (!feof($fpread)) {
                            $buffer = ltrim(Chop(fgets($fpread, 512)));
                            if ($buffer == "<item>" && $items < $max_items) {
                                $title = ltrim(Chop(fgets($fpread, 256)));
                                $link = ltrim(Chop(fgets($fpread, 256)));
                                $title = str_replace("<title>", "", $title);
                                $title = str_replace("</title>", "", $title);
                                $link = str_replace("<link>", "", $link);
                                $link = str_replace("</link>", "", $link);
                                if (function_exists("mb_detect_encoding")) {
                                    $encoding = mb_detect_encoding($title);
                                } else {
                                    $encoding = "UTF-8";
                                }
                                $title = $look_title = iconv($encoding, cur_charset . "//TRANSLIT", $title);
                                if ($block) {
                                    if (strlen($look_title) > $long_chain) {
                                        $title = substr($look_title, 0, $long_chain) . " ...";
                                    }
                                }
                                fputs($fpwrite, "<li><a href=\"{$link}\" alt=\"{$look_title}\" title=\"{$look_title}\" target=\"_blank\">{$title}</a></li>\n");
                                $items++;
                            }
                        }
                        fputs($fpwrite, "</ul>");
                        fclose($fpwrite);
                    }
                    fclose($fpread);
                }
            }
        }
        if (file_exists($cache_file)) {
            ob_start();
            $ibid = readfile($cache_file);
            $boxstuff = $rss_font . ob_get_contents() . "</span>";
            ob_end_clean();
        }
        $boxstuff .= "<br /><div align=\"right\"><a href=\"{$url}\" target=\"_blank\"><b>" . translate("read more...") . "</b></a></div>";
        if ($block) {
            themesidebox($boxtitle, $boxstuff);
            $boxstuff = "";
        } else {
            return $boxstuff;
        }
    }
}
开发者ID:Jireck-npds,项目名称:npds_dune,代码行数:98,代码来源:mainfile.php


注:本文中的Chop函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。