本文整理汇总了PHP中convert_to_utf8函数的典型用法代码示例。如果您正苦于以下问题:PHP convert_to_utf8函数的具体用法?PHP convert_to_utf8怎么用?PHP convert_to_utf8使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了convert_to_utf8函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convert_posts
function convert_posts($message)
{
$message = convert_to_utf8($message);
$message = str_replace("\n", '', $message);
$pattern = array('#<!--b--><span class="b">#i', '#</span><!--/b-->#i', '#<!--i--><span class="i">#i', '#</span><!--/i-->#i', '#<!--u--><span class="u">#i', '#</span><!--/u-->#i', '#<!--s--><span class="s">#i', '#</span><!--/u-->#i', '#<!--center--><span class="center">#i', '#</span><!--/center-->#i', '#<!--list(num)?--><(ul|ol)>#i', '#</(ul|ol)><!--/list(num)?-->#i', '#<li><span class="nodisplay">\\[\\*\\]</span>#i', '#</li>#i', '#<!--color=--><span style="color:\\s*(.*?);?">#i', '#</span><!--/color=-->#i', '#<!--img--><img src="#i', '#" alt="Posted Image" />(<!--/img-->)?#i', '#<img src="smileys\\/.*?" alt="(.*?)" class="smiley" />#i', '#<!--url=--><a href="(.*?)">#i', '#(<!--url-->)?<a href="(.*?)">#i', '#<!--email--><a href="mailto:(.*?)">#i', '#</a>(<!--/url=?-->)?#i', '#</a><!--/email-->#i', '#<!--flash--><object type="application/x-shockwave-flash" data="(.*?)" width="560" height="436"><param name="quality" value="high" /><param name="movie" value="(.*?)" /></object><span class="nodisplay">\\[flash\\]\\[/flash\\]</span><!--/flash-->#i', '#<!--youtube--><object width="425" height="350"><param name="movie" value="(.*?)"></param><param name="wmode" value="transparent"></param><embed src="(.*?)" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object><!--/youtube-->#i', '#<!--size=--><span style="font-size:[0-9]{1,2}px;?">#i', '#</span><!--/(size|font)=-->#i', '#<!--font=--><span style="font-family:(.*?)">#i', '#<!--quote=?--><blockquote class="citationb?">(<p><span class="u">(.*?)</span></p>)?<p>#i', '#</p></blockquote><!--/quote=?-->#i', '#<!--(code|php)--><span class="code">(<p>)?<code>#i', '#</code>(</p>)?</span><!--/(code|php)-->#i', '#<!--spoil--><span class="spoil"><span class="spoil_info" onclick="hideAndShow\\(\'spoil[0-9a-f]{32}\'\\);">Spoiler</span><span class="spoil_spoiler" id="spoil[0-9a-f]{32}">#i', '#</span></span><script type="text/javascript">hideAndShow\\(\'spoil[0-9a-f]{32}\'\\);</script><!--/spoil-->#i', '#<br />#i');
$replace = array('[b]', '[/b]', '[i]', '[/i]', '[u]', '[/u]', '[s]', '[/s]', '', '', '[list]', '[/list]', '[*]', '[/*]', '[color=$1]', '[/color]', '[img]', '[/img]', '$1', '[url=$1]', '[url]', '[email=$1]', '[/url]', '[/email]', '[url]$1[/url]', '[url]$1[/url]', '', '', '', '[quote]', '[/quote]', '[code]', '[/code]', '[quote]', '[/quote]', "\n");
$errors = array();
return preparse_bbcode(preg_replace($pattern, $replace, $message), $errors);
}
示例2: categories_name_array_plus
/**
* List up by category
*/
function categories_name_array_plus()
{
global $cfg, $log_table, $row;
$sql = "SELECT `category` FROM `{$log_table}` WHERE `draft` = '0'";
$res = mysql_query($sql);
$rowArray = array();
while ($row = mysql_fetch_array($res)) {
$row = convert_to_utf8($row);
$token = strtok($row['category'], ",");
while ($token) {
array_push($rowArray, trim($token));
$token = strtok(",");
}
}
$rowArray = array_count_values($rowArray);
ksort($rowArray, SORT_STRING);
return $rowArray;
}
示例3: fetch
/**
* Load / fetch a class
* @since Version 3.2
* @param boolean $recurse
*/
public function fetch($recurse)
{
if (!$this->id) {
throw new Exception("Cannot fetch loco class - no class ID given");
return false;
}
if (!filter_var($this->id, FILTER_VALIDATE_INT)) {
$this->id = $this->db->fetchOne("SELECT id FROM loco_class WHERE slug = ?", $this->id);
}
$this->mckey = "railpage:locos.class_id=" . $this->id;
$key = "id";
if ($row = $this->getCache($this->mckey)) {
// Do nothing
} elseif ($this->db instanceof \sql_db) {
$query = "SELECT c.id, c.asset_id, c.slug, c.download_id, c.date_added, c.date_modified, c.model, c.axle_load, c.tractive_effort, c.weight, c.length, c.parent AS parent_class_id, c.source_id AS source, c.id AS class_id, c.flickr_tag, c.flickr_image_id, c.introduced AS class_introduced, c.name AS class_name, c.loco_type_id AS loco_type_id, c.desc AS class_desc, c.manufacturer_id AS class_manufacturer_id, m.manufacturer_name AS class_manufacturer, w.arrangement AS wheel_arrangement, w.id AS wheel_arrangement_id, t.title AS loco_type\r\n\t\t\t\t\t\t\tFROM loco_class AS c\r\n\t\t\t\t\t\t\tLEFT JOIN loco_type AS t ON c.loco_type_id = t.id\r\n\t\t\t\t\t\t\tLEFT JOIN wheel_arrangements AS w ON c.wheel_arrangement_id = w.id\r\n\t\t\t\t\t\t\tLEFT JOIN loco_manufacturer AS m ON m.manufacturer_id = c.manufacturer_id\r\n\t\t\t\t\t\t\tWHERE c." . $key . " = " . $this->db->real_escape_string($this->id);
if ($rs = $this->db->query($query)) {
$row = $rs->fetch_assoc();
$this->setCache($this->mckey, $row, strtotime("+24 hours"));
}
} else {
if (RP_DEBUG) {
global $site_debug;
$debug_timer_start = microtime(true);
}
$query = "SELECT c.id, c.meta, c.asset_id, c.slug, c.download_id, c.date_added, c.date_modified, c.model, c.axle_load, c.tractive_effort, c.weight, c.length, c.parent AS parent_class_id, c.source_id AS source, c.id AS class_id, c.flickr_tag, c.flickr_image_id, c.introduced AS class_introduced, c.name AS class_name, c.loco_type_id AS loco_type_id, c.desc AS class_desc, c.manufacturer_id AS class_manufacturer_id, m.manufacturer_name AS class_manufacturer, w.arrangement AS wheel_arrangement, w.id AS wheel_arrangement_id, t.title AS loco_type\r\n\t\t\t\t\t\t\tFROM loco_class AS c\r\n\t\t\t\t\t\t\tLEFT JOIN loco_type AS t ON c.loco_type_id = t.id\r\n\t\t\t\t\t\t\tLEFT JOIN wheel_arrangements AS w ON c.wheel_arrangement_id = w.id\r\n\t\t\t\t\t\t\tLEFT JOIN loco_manufacturer AS m ON m.manufacturer_id = c.manufacturer_id\r\n\t\t\t\t\t\t\tWHERE c." . $key . " = ?";
$row = $this->db->fetchRow($query, $this->id);
if (RP_DEBUG) {
if ($row === false) {
$site_debug[] = "Zend_DB: FAILED select loco class ID/slug " . $this->id . " in " . round(microtime(true) - $debug_timer_start, 5) . "s";
} else {
$site_debug[] = "Zend_DB: SUCCESS select loco class ID/slug " . $this->id . " in " . round(microtime(true) - $debug_timer_start, 5) . "s";
}
}
foreach ($row as $key => $val) {
$row[$key] = convert_to_utf8($val);
}
$this->setCache($this->mckey, $row, strtotime("+24 hours"));
}
if (isset($row) && is_array($row)) {
if (!isset($row['id'])) {
deleteMemcacheObject($this->mckey);
} else {
$this->id = $row['id'];
}
// Populate the class objects
$this->slug = $row['slug'];
$this->name = $row['class_name'];
$this->desc = $row['class_desc'];
$this->type = $row['loco_type'];
$this->type_id = $row['loco_type_id'];
$this->introduced = $row['class_introduced'];
$this->manufacturer = $row['class_manufacturer'];
$this->manufacturer_id = $row['class_manufacturer_id'];
$this->wheel_arrangement = $row['wheel_arrangement'];
$this->wheel_arrangement_id = $row['wheel_arrangement_id'];
$this->flickr_tag = $row['flickr_tag'];
$this->flickr_image_id = $row['flickr_image_id'];
$this->axle_load = $row['axle_load'];
$this->tractive_effort = $row['tractive_effort'];
$this->weight = $row['weight'];
$this->length = $row['length'];
$this->model = $row['model'];
$this->date_added = $row['date_added'];
$this->date_modified = $row['date_modified'];
$this->download_id = $row['download_id'];
if (empty($this->slug) || $this->slug === "1") {
$this->createSlug();
if (RP_DEBUG) {
global $site_debug;
$site_debug[] = __CLASS__ . "::" . __FUNCTION__ . "() : Creating url slug for loco class ID " . $this->id;
}
$this->commit();
}
$this->url = new Url($this->makeClassURL($this->slug));
$this->url->view = $this->url->url;
$this->url->edit = sprintf("%s?mode=class.edit&id=%d", $this->Module->url, $this->id);
$this->url->addLoco = sprintf("%s?mode=loco.edit&class_id=%d", $this->Module->url, $this->id);
$this->url->sightings = sprintf("%s/sightings", $this->url->url);
$this->url->bulkadd = sprintf("%s?mode=loco.bulkadd&class_id=%d", $this->Module->url, $this->id);
$this->url->bulkedit = sprintf("%s?mode=class.bulkedit&id=%d", $this->Module->url, $this->id);
$this->url->bulkedit_operators = sprintf("%s?mode=class.bulkedit.operators&id=%d", $this->Module->url, $this->id);
$this->url->bulkedit_buildersnumbers = sprintf("%s?mode=class.bulkedit.buildersnumbers&id=%d", $this->Module->url, $this->id);
$this->url->bulkedit_status = sprintf("%s?mode=class.bulkedit.status&id=%d", $this->Module->url, $this->id);
$this->url->bulkedit_gauge = sprintf("%s?mode=class.bulkedit.gauge&id=%d", $this->Module->url, $this->id);
/**
* Set the meta data
*/
if (isset($row['meta'])) {
$this->meta = json_decode($row['meta'], true);
} else {
$this->meta = array();
}
/**
* If an asset ID exists and is greater than 0, create the asset object
*/
//.........这里部分代码省略.........
示例4: _conv_users
function _conv_users($cur_item, $old_charset)
{
global $lang_update;
echo sprintf($lang_update['Converting item'], $lang_update['user'], $cur_item['id']) . '<br />' . "\n";
convert_to_utf8($cur_item['username'], $old_charset);
convert_to_utf8($cur_item['title'], $old_charset);
convert_to_utf8($cur_item['realname'], $old_charset);
convert_to_utf8($cur_item['location'], $old_charset);
convert_to_utf8($cur_item['signature'], $old_charset);
convert_to_utf8($cur_item['admin_note'], $old_charset);
return $cur_item;
}
示例5: unset
unset($_mime, $_act, $_name, $match);
}
if ($do_content_extraction) {
$html = $response['body'];
//echo "[" . $html . "]";
// remove strange things
$html = str_replace('</[>', '', $html);
$html = convert_to_utf8($html, $response['headers']);
//echo "[" . $html . "]";
if ($auto_extract) {
// check site config for single page URL - fetch it if found
if ($single_page_response = getSinglePage($item, $html, $effective_url)) {
$html = $single_page_response['body'];
// remove strange things
$html = str_replace('</[>', '', $html);
$html = convert_to_utf8($html, $single_page_response['headers']);
$effective_url = $single_page_response['effective_url'];
unset($single_page_response);
}
$extract_result = $extractor->process($html, $effective_url);
$readability = $extractor->readability;
$content_block = $extract_result ? $extractor->getContent() : null;
//echo "content_block: [" . $content_block->innerHTML . "] \n\n";
$title = $extract_result ? $extractor->getTitle() : '';
} else {
$readability = new Readability($html, $effective_url);
// content block is entire document (for now...)
$content_block = $readability->dom;
//echo $content_block->innerHTML;
//TODO: get title
$title = '';
示例6: insertdata
function insertdata($table, $todb, $file = __FILE__, $line = __LINE__)
{
global $db;
// Put together the query
$names = $vars = array();
foreach ($todb as $name => $var) {
if ($var != '') {
$names[] = $name;
$vars[] = $var == 'null' ? $var : '\'' . $db->escape(convert_to_utf8($var)) . '\'';
}
}
$db->query('INSERT INTO ' . $db->prefix . $table . ' (' . implode(',', $names) . ') VALUES(' . implode(',', $vars) . ')') or myerror('Unable to save to database.<br><br><b>Query:</b> ' . $query . '<br>', $file, $line, $db->error());
}
示例7: convert_to_utf8
$rownr++;
$erste_spalte = 0;
}
$d .= '<td valign="top" class="small" nowrap="nowrap">';
$divstart = '<div' . ($tdcompact == 1 ? ' class="tdcompact" ' : ' class="tdnormal"') . '>';
$divend = '</div>';
if ($bb == $spalte) {
$data = convert_to_utf8(simple_bbcode_conversion($rowval));
} else {
if ($showtables == 0) {
if (isset($fdesc[$rowkey]['type'])) {
$data = $fdesc[$rowkey]['type'] == 'string' || $fdesc[$rowkey]['type'] == 'blob' ? convert_to_utf8($rowval) : $rowval;
}
} else {
if (isset($temp[$i][$rowkey])) {
$data = $fdesc[$rowkey]['type'] == 'string' || $fdesc[$rowkey]['type'] == 'blob' ? convert_to_utf8($temp[$i][$rowkey]) : $temp[$i][$rowkey];
} else {
$data = '';
}
if (in_array($rowkey, $byte_output)) {
$data = byte_output($data);
}
}
}
//v($fdesc[$rowkey]);
if ($showtables == 0) {
if (is_null($rowval)) {
$data = '<i>NULL</i>';
} else {
$data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8');
}
示例8: next_step
<?php
// Check if AutoPoll is installed
if ($start == 0 && !$db->table_exists('polls')) {
next_step();
}
$result = $fdb->query('SELECT vote_id,topic_id,vote_text,vote_start FROM ' . $fdb->prefix . $_SESSION['phpnuke'] . 'vote_desc WHERE vote_id>' . $start . ' ORDER BY vote_id LIMIT ' . $_SESSION['limit']) or myerror('Unable to fetch poll info', __FILE__, __LINE__, $fdb->error());
$last_id = -1;
while ($ob = $fdb->fetch_assoc($result)) {
$last_id = $ob['vote_id'];
echo htmlspecialchars($ob['vote_text']) . ' (' . $ob['vote_id'] . ")<br>\n";
flush();
$answers = null;
$results = null;
$vote_results = $fdb->query('SELECT vote_option_text,vote_result FROM ' . $fdb->prefix . $_SESSION['phpnuke'] . 'vote_results WHERE vote_id=' . $ob['vote_id'] . ' ORDER BY vote_option_id') or myerror("Unable to get poll answers.", __FILE__, __LINE__, $fdb->error());
while (list($vote_option_text, $vote_result) = $fdb->fetch_row($vote_results)) {
$answers[] = htmlspecialchars($vote_option_text, ENT_QUOTES);
$results[] = $vote_result;
}
$voter_ids = null;
$vote_results = $fdb->query('SELECT vote_user_id FROM ' . $fdb->prefix . $_SESSION['phpnuke'] . 'vote_voters WHERE vote_id=' . $ob['vote_id']) or myerror("PhpBB: Unable to get poll voters.", __FILE__, __LINE__, $fdb->error());
while (list($voters) = $fdb->fetch_row($vote_results)) {
$voter_ids[] = $voters;
}
$db->query('UPDATE ' . $db->prefix . 'topics SET question=\'' . $db->escape(convert_to_utf8($ob['vote_text'])) . '\' WHERE id=' . $ob['topic_id']) or myerror("PhpBB: Unable to get poll voters.", __FILE__, __LINE__, $fdb->error());
// Dataarray
$todb = array('id' => $ob['vote_id'], 'pollid' => $ob['topic_id'], 'ptype' => 1, 'options' => serialize($answers), 'voters' => serialize($voter_ids), 'votes' => serialize($results), 'created' => $ob['vote_start']);
// Save data
insertdata('polls', $todb, __FILE__, __LINE__);
}
convredirect('vote_id', $_SESSION['phpnuke'] . 'vote_desc', $last_id);
示例9: display_forum_log_box
/**
* Article Box
*/
function display_forum_log_box($row)
{
global $cfg, $keys, $lang, $log_table, $comment_class, $forum_table, $cd, $row, $tid, $session_status, $rrow, $case, $i, $keys, $request_uri, $p, $pn;
$row['title'] = sanitize($row['title']);
$row['comment'] = sanitize($row['comment']);
$row['user_name'] = sanitize($row['user_name']);
$row['user_uri'] = sanitize($row['user_uri']);
$row['date'] = sanitize($row['date']);
$row['parent_key'] = sanitize(intval($row['parent_key']));
hit_key_highlight();
// Check the ID of the latest post
$check_latest_sql = "SELECT `id` FROM `{$forum_table}` WHERE `tid` = '{$row['tid']}' AND `parent_key` = '0' AND `trash` = '0' ORDER BY `mod` DESC LIMIT 1";
$check_latest_res = mysql_query($check_latest_sql);
$check_latest_row = mysql_fetch_array($check_latest_res);
if ($check_latest_row[0] == $row['id']) {
$check_latest = ' id="latest"';
} else {
$check_latest = '';
}
if ($row['parent_key'] == 1) {
if (isset($row['refer_id']) && $row['refer_id'] != 0) {
$rsql = "SELECT `name` FROM `{$log_table}` WHERE `id` = '{$row['refer_id']}'";
$rres = mysql_query($rsql);
$rrow = mysql_fetch_array($rres);
$rrow = convert_to_utf8($rrow);
$anchor = '<h2>' . '» ' . '<a href="../article.php?id=' . $row['refer_id'] . '"> ' . $rrow['name'] . " </a></h2>\n";
$top_title = '<div class="comments">' . "\n" . '<h3>' . $row['title'] . "</h3>\n";
} else {
$anchor = '';
$top_title = '<div class="comments"' . $check_latest . '>' . "\n" . '<h2 id="topic-title">' . $row['title'] . "</h2>\n";
// Parent post title
}
$comment = $anchor . $top_title;
} else {
$comment = '<div class="comments"' . $check_latest . '>' . "\n" . '<h3>' . $row['title'] . "</h3>\n";
}
// in case ">" is posted...convert ">" to ">"
//$row['comment'] = htmlspecialchars($row['comment']);
// auto line-breaks
$row['comment'] = nl2p($row['comment']);
// generate URI
if (isset($row['user_uri']) && preg_match('/([^=^\\"]|^)(http\\:[\\w\\.\\~\\-\\/\\?\\&\\+\\=\\:\\@\\%\\;\\#\\%]+)/', $row['user_uri'])) {
$author = '<a href="' . $row['user_uri'] . '">' . $row['user_name'] . '</a>';
} else {
$author = $row['user_name'];
}
$comment .= '<p class="author">' . 'From : ' . $author . ' @ ' . $row['date'] . ' ' . '<span class="edit"><a href="./modify.php?tid=' . $row['tid'] . '&id=' . $row['id'] . '">' . $lang['edit'] . "</a></span>\n" . '<span class="quote"><a href="./topic.php?tid=' . $row['tid'] . '&p=' . $p . '&pn=' . $pn . '&pm=' . $cfg['pagemax'] . '&qid=' . $row['id'] . '#addform">' . $lang['quote'] . "</a></span></p>\n";
$class_order = array_keys($comment_class);
$color_class = $class_order[$row['color']];
$comment .= '<div class="' . $color_class . '">' . "\n" . $row['comment'] . "</div>\n";
if (preg_match('/forum\\/search.php/', $request_uri)) {
$comment .= '<div class="a-footer"><a href="./topic.php?tid=' . $row['tid'] . '">' . $lang['topic'] . '</a></div>';
}
// Display "Update" and "Delete" button while admin is logged-in.
if ($session_status == 'on') {
$comment .= '<form action="./admin/modify.php" method="post">' . "\n" . '<div class="submit-button">' . "\n" . '<input type="hidden" name="id" value="' . $row['id'] . '" />' . "\n" . '<input type="hidden" name="tid" value="' . $row['tid'] . '" />' . "\n" . '<input type="submit" value="' . $lang['mod'] . '" />' . "\n" . "</div>\n" . "</form>\n" . '<form method="post" action="./admin/delete.php">' . "\n" . '<div class="submit-button">' . "\n" . '<input type="hidden" name="id" value="' . $row['id'] . '" />' . "\n" . '<input type="hidden" name="tid" value="' . $row['tid'] . '" />' . "\n" . '<input type="submit" value="' . $lang['delete'] . '" />' . "\n" . "</div>\n" . '</form>' . "\n";
} else {
$comment .= '';
}
$comment .= "</div>\n";
$comment = smiley($comment);
return $comment;
}
示例10: convert_to_utf8
function convert_to_utf8($arr)
{
if (is_array($arr)) {
$temp = array();
foreach ($arr as $i => $rs) {
if (is_array($rs)) {
$temp[$i] = convert_to_utf8($rs);
} else {
$temp[$i] = utf8_decode($rs);
}
}
return $temp;
} else {
return utf8_decode($arr);
}
}
示例11: fetch
/**
* Load / fetch a class
* @since Version 3.2
* @param boolean $recurse
*/
private function fetch($recurse)
{
if (!filter_var($this->id, FILTER_VALIDATE_INT)) {
$this->id = Utility\LocomotiveUtility::getClassId($this->id);
}
$this->mckey = sprintf("railpage:locos.class_id=%d", $this->id);
$key = "id";
if (!($row = $this->Memcached->fetch($this->mckey))) {
$timer = Debug::getTimer();
$query = "SELECT c.id, c.meta, c.asset_id, c.slug, c.download_id, c.date_added, c.date_modified, c.model, c.axle_load, c.tractive_effort, c.weight, c.length, c.parent AS parent_class_id, c.source_id AS source, c.id AS class_id, c.flickr_tag, c.flickr_image_id, c.introduced AS class_introduced, c.name AS class_name, c.loco_type_id AS loco_type_id, c.desc AS class_desc, c.manufacturer_id AS class_manufacturer_id, m.manufacturer_name AS class_manufacturer, w.arrangement AS wheel_arrangement, w.id AS wheel_arrangement_id, t.title AS loco_type\r\n FROM loco_class AS c\r\n LEFT JOIN loco_type AS t ON c.loco_type_id = t.id\r\n LEFT JOIN wheel_arrangements AS w ON c.wheel_arrangement_id = w.id\r\n LEFT JOIN loco_manufacturer AS m ON m.manufacturer_id = c.manufacturer_id\r\n WHERE c." . $key . " = ?";
$row = $this->db->fetchRow($query, $this->id);
Debug::logEvent(__METHOD__, $timer);
/**
* Normalise some items
*/
if (function_exists("convert_to_utf8")) {
foreach ($row as $key => $val) {
$row[$key] = convert_to_utf8($val);
}
}
$this->Memcached->save($this->mckey, $row, strtotime("+1 year"));
}
// Get out early if we don't have a valid data source
if (!isset($row) || !is_array($row)) {
return;
}
$timer = Debug::getTimer();
if (isset($row['id'])) {
$this->id = $row['id'];
}
if (!isset($row['id'])) {
deleteMemcacheObject($this->mckey);
}
// Populate the class objects
$this->slug = $row['slug'];
$this->name = $row['class_name'];
$this->desc = $row['class_desc'];
$this->type = $row['loco_type'];
$this->type_id = $row['loco_type_id'];
$this->introduced = $row['class_introduced'];
$this->manufacturer = $row['class_manufacturer'];
$this->manufacturer_id = $row['class_manufacturer_id'];
$this->wheel_arrangement = $row['wheel_arrangement'];
$this->wheel_arrangement_id = $row['wheel_arrangement_id'];
$this->flickr_tag = $row['flickr_tag'];
$this->flickr_image_id = $row['flickr_image_id'];
$this->axle_load = $row['axle_load'];
$this->tractive_effort = $row['tractive_effort'];
$this->weight = $row['weight'];
$this->length = $row['length'];
$this->model = $row['model'];
$this->date_added = $row['date_added'];
$this->date_modified = $row['date_modified'];
$this->download_id = $row['download_id'];
if (empty($this->slug) || $this->slug === "1") {
$this->createSlug();
$this->commit();
}
$this->url = Utility\LocoClassUtility::buildUrls($this);
/**
* Set the meta data
*/
$this->meta = array();
if (isset($row['meta'])) {
$this->meta = json_decode($row['meta'], true);
}
/**
* If an asset ID exists and is greater than 0, create the asset object
*/
if (isset($row['asset_id']) && $row['asset_id'] > 0) {
try {
$this->Asset = new Asset($row['asset_id']);
} catch (Exception $e) {
global $Error;
$Error->save($e);
}
}
/**
* Create the fwlink object
*/
try {
$this->fwlink = new fwlink($this->url);
if (empty($this->fwlink->url) && !empty(trim($this->name))) {
$this->fwlink->url = $this->url;
$this->fwlink->title = $this->name;
$this->fwlink->commit();
}
} catch (Exception $e) {
// Do nothing
}
/*
// Parent object
if ($row['parent_class_id'] > 0) {
try {
$this->parent = new LocoClass($row['parent_class_id'], false);
//.........这里部分代码省略.........
示例12: save_review
function save_review($req, $rrow, $prow, $contact, &$tf = null)
{
global $Conf, $Opt;
$newsubmit = @$req["ready"] && !@$req["unready"] && (!$rrow || !$rrow->reviewSubmitted);
$submit = $newsubmit || $rrow && $rrow->reviewSubmitted;
$admin = $contact->allow_administer($prow);
if (!$contact->timeReview($prow, $rrow) && (!isset($req['override']) || !$admin)) {
return Conf::msg_error("The <a href='" . hoturl("deadlines") . "'>deadline</a> for entering this review has passed." . ($admin ? " Select the “Override deadlines” checkbox and try again if you really want to override the deadline." : ""));
}
$q = array();
$diff_view_score = VIEWSCORE_FALSE;
$wc = 0;
foreach ($this->forder as $field => $f) {
if (isset($req[$field]) && (!$f->round_mask || $f->is_round_visible($rrow))) {
$fval = $req[$field];
if ($f->has_options) {
if ($f->parse_is_empty($fval)) {
$fval = 0;
} else {
if (!($fval = $f->parse_value($fval, false))) {
continue;
}
}
} else {
$fval = rtrim($fval);
if ($fval != "") {
$fval .= "\n";
}
// Check for valid UTF-8; re-encode from Windows-1252 or Mac OS
$fval = convert_to_utf8($fval);
if ($f->include_word_count()) {
$wc += count_words($fval);
}
}
if ($rrow && strcmp($rrow->{$field}, $fval) != 0 && strcmp(cleannl($rrow->{$field}), cleannl($fval)) != 0) {
$diff_view_score = max($diff_view_score, $f->view_score);
}
$q[] = "{$field}='" . sqlq($fval) . "'";
}
}
// get the current time
$now = time();
if ($rrow && $rrow->reviewModified && $rrow->reviewModified > $now) {
$now = $rrow->reviewModified + 1;
}
// potentially assign review ordinal (requires table locking since
// mySQL is stupid)
$locked = false;
if ($newsubmit) {
$diff_view_score = max($diff_view_score, VIEWSCORE_AUTHOR);
$q[] = "reviewSubmitted={$now}, reviewNeedsSubmit=0";
if (!$rrow || !$rrow->reviewOrdinal) {
$result = $Conf->qe("lock tables PaperReview write");
if (!$result) {
return $result;
}
$locked = true;
$result = $Conf->qe("select coalesce(max(reviewOrdinal), 0) from PaperReview where paperId={$prow->paperId} group by paperId");
if ($result) {
$crow = edb_row($result);
$q[] = "reviewOrdinal=coalesce(reviewOrdinal, " . ($crow[0] + 1) . ")";
}
Dbl::free($result);
$q[] = "timeDisplayed={$now}";
}
}
// check whether used a review token
$usedReviewToken = $contact->review_token_cid($prow, $rrow);
// blind? reviewer type? edit version?
$reviewBlind = $Conf->is_review_blind(!!@$req["blind"]);
if ($rrow && $reviewBlind != $rrow->reviewBlind) {
$diff_view_score = max($diff_view_score, VIEWSCORE_ADMINONLY);
}
$q[] = "reviewBlind=" . ($reviewBlind ? 1 : 0);
if ($rrow && $rrow->reviewType == REVIEW_EXTERNAL && $contact->contactId == $rrow->contactId && $contact->isPC && !$usedReviewToken) {
$q[] = "reviewType=" . REVIEW_PC;
}
if ($rrow && $diff_view_score > VIEWSCORE_FALSE && isset($req["version"]) && ctype_digit($req["version"]) && $req["version"] > defval($rrow, "reviewEditVersion")) {
$q[] = "reviewEditVersion=" . ($req["version"] + 0);
}
if ($diff_view_score > VIEWSCORE_FALSE && $Conf->sversion >= 98) {
$q[] = "reviewWordCount=" . $wc;
}
if (isset($req["reviewFormat"]) && $Conf->sversion >= 104 && @$Opt["formatInfo"]) {
$fmt = null;
foreach ($Opt["formatInfo"] as $k => $f) {
if (@$f["name"] && strcasecmp($f["name"], $req["reviewFormat"]) == 0) {
$fmt = (int) $k;
}
}
if (!$fmt && $req["reviewFormat"] && preg_match('/\\A(?:plain\\s*)?(?:text)?\\z/i', $f["reviewFormat"])) {
$fmt = 0;
}
$q[] = "reviewFormat=" . ($fmt === null ? "null" : $fmt);
}
// notification
$notification_bound = $now - 10800;
$notify = $notify_author = false;
if (!$rrow || $diff_view_score > VIEWSCORE_FALSE) {
$q[] = "reviewModified=" . $now;
//.........这里部分代码省略.........
示例13: extractContentBlock
public function extractContentBlock($permalink)
{
$extractor = new ContentExtractor(dirname(__FILE__) . '/site_config/custom', dirname(__FILE__) . '/site_config/standard');
//$extractor = $this;
$extractor->next_page_deep_count = $this->next_page_deep_count + 1;
$extractor->next_pages = $this->next_pages;
if (in_array($permalink, $extractor->next_pages)) {
return FALSE;
}
$extractor->next_pages[] = $permalink;
if ($extractor->next_page_deep_count > 3) {
return FALSE;
}
$extractor->fingerprints = $this->options->fingerprints;
$elem = new ContentExtractor($this->path, $this->fallback);
$extractor->fingerprints = $this->fingerprints;
$http = new HumbleHttpAgent();
$response = $http->get($permalink, true);
//echo 'status_code: '. $response['status_code'] . "\n\n";
if ($permalink && ($response = $http->get($permalink, true)) && ($response['status_code'] < 300 || $response['status_code'] > 400)) {
$html = $response['body'];
//echo "html: " .$html;
// remove strange things
$html = str_replace('</[>', '', $html);
$html = convert_to_utf8($html, $response['headers']);
if (function_exists('mb_convert_encoding')) {
$html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8");
}
$extract_result = $extractor->process($html, $permalink);
//$readability = $extractor->readability;
$content_block = $extract_result ? $extractor->getContent() : null;
//echo "content_block->innerHTML: ". $content_block->innerHTML . "\n\n";
//$this->body->appendChild($elem);
}
$doc = new DOMDocument();
if (@$doc->loadHTML($content_block->innerHTML)) {
$doc->saveHTML();
//$content = $this->readability->dom->loadHTML($content_block->innerHTML);
$content = $this->readability->dom->createElement('div', $content_block->innerHTML);
$content = $this->readability->dom->importNode($content_block, true);
return $content;
} else {
return FALSE;
}
return FALSE;
//return $content_block;
}
示例14: convert_to_utf8
/**
* Convert specified data to the UTF-8 charset
*
* @param string $str
*/
function convert_to_utf8($str)
{
return convert_to_utf8($str, $this->db_config['charset']);
}
示例15: getContents
/**
* List the contents of this folder
* @since Version 3.3
* @version 3.3
* @return array
* @param object $User
* @param int $page
* @param int $items_per_page
*/
public function getContents($User = false, $page = 1, $items_per_page = 25)
{
if (empty($this->folder)) {
throw new \Exception("Cannot get folder contents - no folder specified");
}
if (!$User || !is_object($User)) {
throw new \Exception("Cannot get folder contents - User object not provided");
}
if (!$User->id) {
throw new \Exception("No user ID available");
}
if (!$User->enable_privmsg) {
throw new \Exception("Private messages not available to this user");
}
// Store the user object
$this->user = $User;
// Fetch message IDs that have been "deleted" by this user
$deleted = $this->getDeleted($User->id);
if (count($deleted)) {
$exclude_sql = " AND privmsgs_id NOT IN ('" . implode("', '", $deleted) . "') ";
} else {
$exclude_sql = "";
}
if ($this->folder == PM_INBOX) {
$pm_folder_sql = "pm.privmsgs_to_userid = " . $this->user->id . " AND (pm.privmsgs_type = " . PRIVMSGS_READ_MAIL . " OR pm.privmsgs_type = " . PRIVMSGS_NEW_MAIL . " OR pm.privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " )";
} elseif ($this->folder == PM_OUTBOX) {
$pm_folder_sql = "pm.privmsgs_from_userid = " . $this->user->id . " AND (pm.privmsgs_type = " . PRIVMSGS_NEW_MAIL . " OR pm.privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . ")";
} elseif ($this->folder == PM_SENTBOX) {
$pm_folder_sql = "pm.privmsgs_from_userid = " . $this->user->id . " AND (pm.privmsgs_type = " . PRIVMSGS_READ_MAIL . " OR pm.privmsgs_type = " . PRIVMSGS_SENT_MAIL . ")";
} elseif ($this->folder == PM_SAVEBOX) {
$pm_folder_sql = "((pm.privmsgs_to_userid = " . $this->user->id . " AND pm.privmsgs_type = " . PRIVMSGS_SAVED_IN_MAIL . ") OR (pm.privmsgs_from_userid = " . $this->user->id . " AND pm.privmsgs_type = " . PRIVMSGS_SAVED_OUT_MAIL . "))";
}
// Which "page" is this?
if ($page == 1) {
$start = 0;
} else {
$start = $page * $items_per_page;
}
// Done checking - get the PMs - sort by date ASC because the uasort() function will fix them up properly
$query = "SELECT pm.*, pmt.*, ufrom.username AS username_from, ufrom.user_id AS user_id_from, ufrom.user_avatar AS user_avatar_from, uto.username AS username_to, uto.user_id AS user_id_from, uto.user_avatar AS user_avatar_to\r\n\t\t\t\t\t\tFROM nuke_bbprivmsgs AS pm\r\n\t\t\t\t\t\tLEFT JOIN nuke_bbprivmsgs_text AS pmt ON pm.privmsgs_id = pmt.privmsgs_text_id\r\n\t\t\t\t\t\tLEFT JOIN nuke_users AS ufrom ON ufrom.user_id = privmsgs_from_userid\r\n\t\t\t\t\t\tLEFT JOIN nuke_users AS uto ON uto.user_id = privmsgs_to_userid\r\n\t\t\t\t\t\tWHERE " . $pm_folder_sql . "\r\n\t\t\t\t\t\t" . $exclude_sql . "\r\n\t\t\t\t\t\tORDER BY pm.privmsgs_date ASC";
#LIMIT ".$start.", ".$this->db->real_escape_string($items_per_page);
#echo $query;
if ($this->db instanceof \sql_db) {
if ($rs = $this->db->query($query)) {
#$total = $this->db->query("SELECT FOUND_ROWS() AS total");
#$total = $total->fetch_assoc();
$return = array();
$return['stat'] = "ok";
#$return['total'] = $total['total'];
$return['page'] = $page;
$return['perpage'] = $items_per_page;
$return['messages'] = array();
while ($row = $rs->fetch_assoc()) {
// Fix up the sodding non-UTF8 characters
$row['privmsgs_text'] = convert_to_utf8($row['privmsgs_text']);
$row['privmsgs_subject'] = str_replace("Re: ", "", $row['privmsgs_subject']);
if ($row['privmsgs_from_userid'] == $this->user->id) {
$pm_from = $row['privmsgs_to_userid'];
} else {
$pm_from = $row['privmsgs_from_userid'];
}
$id = md5($row['privmsgs_subject'] . $pm_from);
if (function_exists("format_avatar")) {
$row['user_avatar_from'] = format_avatar($row['user_avatar_from'], 40, 40);
$row['user_avatar_to'] = format_avatar($row['user_avatar_to'], 40, 40);
}
$return['messages'][$id] = $row;
}
// Sort by loco number
uasort($return['messages'], function ($a, $b) {
return strnatcmp($b['privmsgs_date'], $a['privmsgs_date']);
});
} else {
throw new \Exception($this->db->error);
$return['stat'] = "error";
$return['error'] = $this->db->error;
}
$return['total'] = count($return['messages']);
$return['messages'] = array_slice($return['messages'], $start, $items_per_page);
return $return;
} else {
$return = array();
$return['stat'] = "ok";
$return['page'] = $page;
$return['perpage'] = $items_per_page;
$return['messages'] = array();
foreach ($this->db->fetchAll($query) as $row) {
$row['privmsgs_text'] = convert_to_utf8($row['privmsgs_text']);
$row['privmsgs_subject'] = str_replace("Re: ", "", $row['privmsgs_subject']);
if ($row['privmsgs_from_userid'] == $this->user->id) {
$pm_from = $row['privmsgs_to_userid'];
//.........这里部分代码省略.........