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


PHP functions::utf8encode方法代码示例

本文整理汇总了PHP中functions::utf8encode方法的典型用法代码示例。如果您正苦于以下问题:PHP functions::utf8encode方法的具体用法?PHP functions::utf8encode怎么用?PHP functions::utf8encode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在functions的用法示例。


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

示例1: getUserRecord

 public static function getUserRecord($uid, $checkSU = TRUE)
 {
     // -- If no $uid, return data for authenticated user
     if (!isset($uid) && self::isAuthenticated()) {
         return array("name" => isset($_SESSION["nwAuth"]["username"]) ? $_SESSION["nwAuth"]["username"] : "", "uid" => isset($_SESSION["nwAuth"]["uid"]) ? $_SESSION["nwAuth"]["uid"] : "", "gecos" => isset($_SESSION["nwAuth"]["gecos"]) ? $_SESSION["nwAuth"]["gecos"] : "");
     }
     if (!isset($uid) || empty($uid)) {
         return FALSE;
     }
     // -- Cleanup
     $uid = (int) $uid;
     // -- This UID may have been processed earlier and stored in auth::$userAccounts
     if (isset(self::$userAccounts[$uid]) && ($au = self::$userAccounts[$uid])) {
         return $au;
     }
     // -- Is this the special robot UID?
     if (self::isRobot($uid)) {
         return array("name" => "nobody", "uid" => $uid, "gecos" => "WebRobot");
     }
     // -- Then check if a translation exists in the special accounts DB table (negative UIDs):
     if (preg_match("/^-\\d+/", $uid)) {
         //	if (preg_match("/^-?\d+/",$uid)) {
         // -- Fetch user data for UID from DB
         if (!class_exists("fromdb_accounts", FALSE)) {
             require_once PATH_CLASSES . "/fromdb/accounts.php";
         }
         if (!isset($GLOBALS["accountClass"])) {
             $GLOBALS["accountClass"] = new fromdb_accounts();
         }
         $record = $GLOBALS["accountClass"]->getSpecialUserRecord($uid);
         if (!empty($record)) {
             $au = array("name" => $record["username"], "uid" => $record["id"], "gecos" => functions::utf8encode($record["full_name"]));
             self::$userAccounts[$uid] = $au;
             return $au;
         }
         // -- Negative UIDs are special UIDs
         //	  if (preg_match("/^-\d+/",$uid)) return FALSE;
     }
     // -- Then check if $uid is an account on the local machine
     if ($localAccount = posix_getpwuid((int) $uid)) {
         $localAccount["gecos"] = functions::utf8encode($localAccount["gecos"]);
         return $localAccount;
     }
     // -- Then optionally check SU accounts via locally kept password files
     //    [probably obsolete]
     if ($checkSU) {
         $commonPasswdFile = array("/afs/physto.se/common/uadmin/passwd/su.se/passwd.common", "/afs/kth.se/admin/passwd/passwd.full");
         foreach ($commonPasswdFile as $pwfile) {
             if (file_exists($pwfile) && is_file($pwfile) && ($l = shell_exec("grep '^.*:.*:" . $uid . ":' " . $pwfile))) {
                 $u = split(":", $l);
                 $su = core2posix($u);
                 if (!empty($su["gecos"])) {
                     return $su;
                 }
             }
         }
     }
     // end if ($checkSU)
     // -- Did not find a translation for $uid
     return FALSE;
 }
开发者ID:,项目名称:,代码行数:61,代码来源:

示例2: getSpecialUserRecords

 public function getSpecialUserRecords($where = "", $groupby = "", $sortby = "")
 {
     foreach (array("id", "username", "password", "new_password", "full_name", "status", "superviser") as $field) {
         $outRecord[0][$field] = "";
     }
     // ----------------------
     $sql = "SELECT " . "  `id`," . "  `username`," . "  `password`," . "  `new_password`," . "  `full_name`," . "  `status`," . "  `superviser` " . "FROM " . "  " . $this->dbprefix . "accounts " . (!empty($groupby) ? "GROUP BY " . "  " . $groupby . " " : "") . (!empty($where) ? "WHERE " . "  " . $where . " " : "") . (!empty($sortby) ? "ORDER BY " . "  " . $sortby : "");
     // ----------------------
     $res = $this->query($sql, IS_TESTSERVER);
     // includes a call to connect
     if ($this->num_rows($res)) {
         $outRecord = array();
         while ($row = $this->next_record_assoc($res)) {
             $row["full_name"] = functions::utf8encode($row["full_name"]);
             $outRecord[] = $row;
         }
         // end while
         return $outRecord;
     }
     // end if
     // ----------------------
     return FALSE;
 }
开发者ID:,项目名称:,代码行数:23,代码来源:

示例3: getLogs

 public function getLogs($where = "", $groupby = "", $sortby = "")
 {
     $outRecord = array();
     // ----------------------
     $sql = "SELECT " . "  `id`," . "  `type`," . "  `time`," . "  `uid`," . "  `text`," . "  `ip` " . "FROM " . "  " . $this->dbprefix . PP_LOGTABLE . " " . (!empty($groupby) ? "GROUP BY " . "  " . $groupby . " " : "") . (!empty($where) ? "WHERE " . "  " . $where . " " : "") . (!empty($sortby) ? "ORDER BY " . "  " . $sortby : "");
     // ----------------------
     $res = $this->query($sql);
     // includes a call to connect
     if ($this->num_rows($res)) {
         while ($row = $this->next_record_assoc($res)) {
             $row["text"] = functions::utf8encode($row["text"]);
             $outRecord[] = $row;
         }
         // end while
     }
     // end if
     // ----------------------
     return $outRecord;
 }
开发者ID:,项目名称:,代码行数:19,代码来源:

示例4: OutputMetadataEdit

 static function OutputMetadataEdit($max = 0)
 {
     $stdout = $confirm = $tabletxt = "";
     $year_from = "2007";
     $year_to = date("Y");
     $year_sub = "2009";
     functions::gpc_declare_input("bt", 0, true);
     functions::gpc_declare_input("preprint_category", "", false);
     functions::gpc_declare_input("preprint_year", "", false);
     // --------------------------------------
     // LOAD CLASS
     // --------------------------------------
     self::loadClass(PREPRINT_DATA_SOURCE_DB);
     // --> $GLOBALS["preprintClass"]
     // --------------------------------------
     // COLLECT DATA
     // --------------------------------------
     $ppCategories = $GLOBALS["preprintClass"]->getMetadataCategories();
     // array('label=>'category')
     $ppData = $GLOBALS["preprintClass"]->getAllPreprints("all", "", "all");
     //TODO: $max
     // ------------------------------------------------------------------------
     if ($GLOBALS["bt"]) {
         $record = array();
         foreach ($ppData as $pp) {
             if (isset($pp["serial"]) && isset($pp["publ_year"]) && isset($pp["label"]) && (isset($GLOBALS["preprint_year"][$pp["rowid"]]) && $pp["publ_year"] != $GLOBALS["preprint_year"][$pp["rowid"]] || !empty($GLOBALS["preprint_category"][$pp["rowid"]]) && $pp["label"] != $GLOBALS["preprint_category"][$pp["rowid"]])) {
                 $record[$pp["serial"]]["rowid"] = $pp["rowid"];
                 $record[$pp["serial"]]["publ_year"] = $GLOBALS["preprint_year"][$pp["rowid"]];
                 $record[$pp["serial"]]["label"] = $GLOBALS["preprint_category"][$pp["rowid"]];
             }
         }
         $OK = $GLOBALS["preprintClass"]->updateMetadata($record);
         if (!empty($OK)) {
             $confirm = "<div class='box confirm background padding'>" . "Successfully updated data for preprint number" . (count($OK) > 1 ? "s" : "") . " <strong>\r\n" . implode(", ", $OK) . "</strong></div>\r\n";
         }
         // fetch updated data for table:
         $ppData = $GLOBALS["preprintClass"]->getAllPreprints("all", "", "all");
         //TODO: $max
     }
     // end if bt
     if (empty($ppData)) {
         return $stdout . BLURB_SORRY_NO_PREPRINTS;
     }
     // --------------------------------------
     // OUTPUT LEGEND FOR CATEGORIES
     // --------------------------------------
     $stdout .= "        <div class='col c1of2'>\r\n" . "          <table style='margin-bottom:2em'>\r\n";
     foreach ($ppCategories as $cat => $text) {
         $stdout .= "            <tr><th style='padding-right:2em'>" . $cat . "</th><td>" . $text . "</td></tr>\r\n";
     }
     $stdout .= "          </table>\r\n" . "        </div> <div class='col c2of2'>\r\n" . $confirm . "        </div><div style='clear:both'><br></div>" . "\r\n";
     // --------------------------------------
     // OUTPUT DATA
     // --------------------------------------
     $tabletxt = "        <form action='" . $GLOBALS["documentClass"]->getPagePath() . "/index.php' method='post'>\r\n" . "          <input type='hidden' name='bt' value='1'>\r\n" . "          <table>\r\n";
     $ppC = array_merge(array(""), $ppCategories);
     $i = 0;
     foreach ($ppData as $pp) {
         $pp["authors"] = functions::utf8encode($pp["authors"]);
         $pp["title"] = functions::utf8encode($pp["title"]);
         if ($i % 5 == 0) {
             $tabletxt .= "            <tr><td colspan='12'><input type='submit' value='Submit all changes'></td></tr>\r\n";
         }
         $class = "b_zebra" . ($i % 2 + 1);
         $tabletxt .= "            <tr>\r\n";
         foreach ($ppC as $cat => $text) {
             $tabletxt .= "              <td class='nowrap bold " . (empty($pp["label"]) || $pp["label"] == "S" ? str_replace("zebra", "zebrared", $class) : $class) . "' style='vertical-align:middle;text-align:center;padding:0'>" . "<input type='radio' name='preprint_category[" . $pp["rowid"] . "]' value='" . $cat . "'" . ($pp["label"] == $cat ? "checked" : "") . ">" . "<br>" . (empty($cat) ? "<span class='red'>?</span>" : "<abbr title='" . $ppCategories[$cat] . "'>" . $cat . "</abbr>") . "</td>\r\n";
         }
         $tabletxt .= "              <td class='item " . (empty($pp["publ_year"]) ? str_replace("zebra", "zebrared", $class) : $class) . "' style='vertical-align:middle;padding: 0 1em 0 1em'>" . "[" . $pp["serial"] . "]" . ($pp["status"] != "ok" ? " &nbsp; " . $pp["status"] : "") . "<br>" . "<input type='text' name='preprint_year[" . $pp["rowid"] . "]' value='" . $pp["publ_year"] . "'>" . "</td>\r\n" . "              <td class='item " . $class . "' style='padding: 0 1em 0 1em'>\r\n" . (isset($pp["authors"]) ? "                <p>" . str_replace("&", " and ", $pp["authors"]) . "</p>" : "") . (isset($pp["title"]) ? "\r\n                <p>&quot;<strong>" . str_replace("\"", "'", $pp["title"]) . "</strong>&quot;</p>" : "") . ($pp["label"] != 7 && !empty($pp["journal"]) ? "\r\n                <p>" . ucfirst(str_replace("not to be published", "", $pp["journal"])) . "</p>" : "") . "\r\n" . "              </td>\r\n" . "            </tr>\r\n" . "\r\n";
         $i++;
     }
     $tabletxt .= "            <tr><td colspan='12'><input type='submit' value='Submit all changes'></td></tr>\r\n" . "          </table>\r\n" . "        </form>\r\n";
     if (!empty($tabletxt)) {
         $stdout .= "          <style type='text/css'>\r\n" . "            .item {margin-bottom:2em;}\r\n" . "            .item p {margin-bottom:0em;}\r\n" . "            h4 {margin-bottom: 1em;}\r\n" . "          </style>\r\n" . "          <div>\r\n" . $tabletxt . "          </div>\r\n" . "\r\n";
     }
     // ------------------------------------------------------------------------
     return $stdout;
 }
开发者ID:,项目名称:,代码行数:78,代码来源:

示例5: getBookingsFromMrbs

 function getBookingsFromMrbs($timestampFrom, $timestampTo, $roomid)
 {
     $booking = array();
     // ----------------------
     // One search per week inside given time period
     // ----------------------
     $weekFrom = date("W", $timestampFrom);
     $weekTo = date("W", $timestampTo);
     for ($i = 0; $i <= $weekTo - $weekFrom; $i++) {
         $timestamp = $timestampFrom + $i * 7 * 24 * 60 * 60;
         // ----------------------
         // -- Fetch webpage from Mrbs site and parse code for booking codes
         //    NB: Must use "&" and not "&amp;"
         // ----------------------
         $url1 = "http://rooms.albanova.se/view_week.php?" . "date=" . $timestamp . "&area=-1" . "&selectroom=" . $roomid . "";
         $raw1 = functions::acurl($url1);
         $bkg = array();
         if ($raw1 && preg_match_all("#view_entry.php\\?id=([\\d]*)#ms", $raw1, $res1)) {
             $bkg = array_flip($res1[1]);
         }
         // ----------------------
         // -- Fetch webpage from Mrbs site and parse code for booking information
         // ----------------------
         foreach ($bkg as $bid => $slask) {
             $url2 = "http://rooms.albanova.se/view_entry.php?" . "id=" . $bid;
             $raw2 = functions::acurl($url2);
             if ($raw2 && preg_match("#</H3>[\\s]*<table border=0>(.*)[\\s]*</table>#ms", $raw2, $res2)) {
                 $raw2 = $res2[1];
             }
             if (preg_match("#Start Time[^<]*</td><td>([^<]*)</td></tr>#ms", $raw2, $res)) {
                 $id = isset($this->rbsToId[$roomid]) ? $this->rbsToId[$roomid] : "";
                 $startstamp = strtotime($res[1]);
                 $endtime = preg_match("#End Time[^<]*</td><td>([^<]*)</td></tr>#ms", $raw2, $res) ? $res[1] : "";
                 $endstamp = strtotime(date("Y-m-d", $startstamp) . " " . $endtime . ":00");
                 $duration = preg_match("#Duration[^<]*</td><td>([^<]*)</td></tr>#ms", $raw2, $res) ? $res[1] : "";
                 $area = !empty($id) && preg_match("/^1[23][23]:/", $id) ? "25" : "1";
                 $name = functions::utf8encode(preg_match("#Booked by[^<]*</td><td>([^<]*)</td></tr>#ms", $raw2, $res) ? $res[1] : "");
                 $type = preg_match("#Type[^<]*</td><td>([^<]).*</td></tr>#ms", $raw2, $res) ? strtolower($res[1]) : "";
                 $description = functions::utf8encode(preg_match("#Description[^<]*</td><td>([^<]*)</td></tr>#ms", $raw2, $res) ? $res[1] : "");
                 $title = functions::utf8encode(preg_match("#Event title[^<]*</td><td>([^<]*)</td></tr>#ms", $raw2, $res) ? $res[1] : "");
                 if ($duration == "1 days") {
                     $startstamp = strtotime(date("Y-m-d", $startstamp) . " 08:00");
                     $endstamp = strtotime(date("Y-m-d", $startstamp) . " 19:00");
                 }
                 $booking[] = array("id" => $id, "start_time" => $startstamp, "end_time" => $endstamp, "entry_type" => "", "repeat_id" => "0", "rbs_id" => $roomid, "rbs_area" => $area, "timestamp" => DATETIME_NULL, "create_by" => "", "name" => $name, "roomtype_id" => $type, "description" => $description, "title" => !empty($description) ? $description : $title);
             }
             // end if
         }
         // end foreach
     }
     // end for
     // ----------------------
     return $booking;
 }
开发者ID:,项目名称:,代码行数:54,代码来源:

示例6: fetchRawUserArray

 function fetchRawUserArray($sql = "", $stopOnError = IS_TESTSERVER)
 {
     if (empty($sql)) {
         return array();
     }
     $userarray = $usertmp = array();
     // ------------------------------------------
     // OBTAIN DATA ACCORDING TO QUERY $sql
     // ------------------------------------------
     $result = $this->query($sql, $stopOnError);
     if ($this->num_rows($result) == 0) {
         return array();
     }
     while ($rec = $this->next_record_assoc($result)) {
         // -- Sanitize bad UTF8 data in DB
         foreach (array("av_birthplace", "av_firstname", "av_von", "av_lastname", "av_institute", "av_position", "av_address", "av_city") as $key) {
             $rec[$key] = functions::utf8encode($rec[$key]);
         }
         // -- The value of field "lm_option" is a serialized set of fields, different for different users
         if (!empty($rec["lm_option"])) {
             $rec = array_merge($rec, unserialize(stripslashes($rec["lm_option"])));
         }
         if (isset($rec["av_firstname"]) && isset($rec["av_lastname"])) {
             $id = functions::dotName($rec["av_firstname"] . " " . $rec["av_lastname"]);
             //$id = "[".$rec["av_firstname"]." ".$rec["av_lastname"]."]";
         } elseif (!empty($rec["av_identity"])) {
             $id = preg_replace("/^,/", "", $rec["av_identity"]);
         } else {
             $id = $rec["av_id"];
         }
         $d = array();
         foreach ($rec as $key => $value) {
             //if (isset($rec["av_identity"])) $d[$key] = $value;
             $d[$key] = $value;
         }
         if (isset($rec["lm_status"])) {
             $usertmp[$id][$rec["lm_status"]] = $d;
         }
     }
     // end while
     foreach ($usertmp as $id => $array) {
         $title = array();
         $userarray[$id] = array_shift($array);
         if (isset($userarray[$id]["lm_value"])) {
             $title[] = $userarray[$id]["lm_value"];
         }
         foreach ($array as $key => $record) {
             if (isset($record["lm_value"])) {
                 $title[] = $record["lm_value"];
             }
         }
         $userarray[$id]["lm_value"] = implode(" / ", array_reverse(array_unique($title)));
         $userarray[$id]["cv"] = array("text" => "", "brief" => "", "plain" => "");
     }
     if (empty($userarray)) {
         return array();
     }
     // ------------------------------------------
     // OBTAIN DATA FOR CV TEXTS FROM TABLE 'zzz_list_members'
     // ------------------------------------------
     $cvarray = $this->getCvArray();
     if (!empty($cvarray)) {
         foreach ($cvarray as $id => $cv) {
             if (isset($userarray[$id])) {
                 $userarray[$id]["cv"] = $cv;
             }
         }
     }
     // ------------------------------------------
     return $userarray;
 }
开发者ID:,项目名称:,代码行数:71,代码来源:


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