本文整理汇总了PHP中_urlencode函数的典型用法代码示例。如果您正苦于以下问题:PHP _urlencode函数的具体用法?PHP _urlencode怎么用?PHP _urlencode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_urlencode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: html_no_comment
function html_no_comment($url)
{
$url = _urlencode($url);
// create HTML DOM
$check_curl = _isCurl();
if (!($html = file_get_html($url))) {
if (!($html = str_get_html(file_get_contents_curl($url))) or !$check_curl) {
return false;
}
}
// remove all comment elements
foreach ($html->find('comment') as $e) {
$e->outertext = '';
}
$ret = $html->save();
// clean up memory
$html->clear();
unset($html);
return $ret;
}
示例2: _getParametersAsString
function _getParametersAsString(array $parameters)
{
$queryParameters = array();
foreach ($parameters as $key => $value) {
$queryParameters[] = $key . '=' . _urlencode($value);
}
return implode('&', $queryParameters);
}
示例3: _urlencode
function _urlencode($elem)
{
if (is_array($elem)) {
foreach ($elem as $k => $v) {
$na[_urlencode($k)] = _urlencode($v);
}
return $na;
}
return urlencode($elem);
}
示例4: do_Clip
function do_Clip($formatter, $options)
{
global $DBInfo;
$enable_replace = 1;
$keyname = $DBInfo->_getPageKey($options['page']);
$_dir = str_replace("./", '', $DBInfo->upload_dir . '/' . $keyname);
// support hashed upload dir
if (!is_dir($_dir) and !empty($DBInfo->use_hashed_upload_dir)) {
$prefix = get_hashed_prefix($keyname);
$_dir = str_replace('./', '', $DBInfo->upload_dir . '/' . $prefix . $keyname);
}
$pagename = _urlencode($options['page']);
$name = $options['value'];
if (!$name) {
$title = _("Fatal error !");
$formatter->send_header("Status: 406 Not Acceptable", $options);
$formatter->send_title($title, "", $options);
print "<h2>" . _("No filename given") . "</h2>";
$formatter->send_footer("", $options);
return;
}
$pngname = _rawurlencode($name);
//$imgpath="$_dir/$pngname";
$imgpath = "{$pngname}";
$imgparam = '';
if (file_exists($_dir . '/' . $imgpath . '.png')) {
$url = qualifiedUrl($DBInfo->url_prefix . '/' . $_dir . '/' . $imgpath . '.png');
$imgparam = "<param name='image' value='{$url}' />";
}
$png_url = "{$imgpath}.png";
$formatter->send_header("", $options);
$formatter->send_title(_("Clipboard"), "", $options);
$prefix = $formatter->prefix;
$now = time();
$url_exit = $formatter->link_url($pagename, "?ts={$now}");
$url_save = $formatter->link_url($pagename, "?action=draw");
$url_help = $formatter->link_url("ClipMacro");
$pubpath = $DBInfo->url_prefix . "/applets/ClipPlugin";
print "<h2>" . _("Cut & Paste a Clipboard Image") . "</h2>\n";
print <<<APPLET
<applet code="clip"
archive="clip.jar" codebase="{$pubpath}"
width='200' height='200' align="center">
<param name="pngpath" value="{$png_url}" />
<param name="savepath" value="{$url_save}" />
<param name="viewpath" value="{$url_exit}" />
<param name="compress" value="5" />
{$imgparam}
<b>NOTE:</b> You need a Java enabled browser to edit the drawing example.
</applet><br />
APPLET;
$formatter->send_footer("", $options);
return;
}
示例5: do_qr
function do_qr($formatter, $params = array())
{
global $Config;
if (isset($params['value']) && isset($params['value'][0])) {
$value = $params['value'];
} else {
$encoded = _urlencode(strtr($formatter->page->name, ' ', '_'));
$value = qualifiedUrl($formatter->link_url($encoded));
}
if (!empty($Config['cache_public_dir']) and !empty($Config['cache_public_url'])) {
$fc = new Cache_text('qr', array('ext' => 'png', 'dir' => $Config['cache_public_dir']));
$pngname = $fc->getKey($value);
$pngfile = $Config['cache_public_dir'] . '/' . $pngname;
$png_url = !empty($Config['cache_public_url']) ? $Config['cache_public_url'] . '/' . $pngname : $Config['url_prefix'] . '/' . $pngfile;
} else {
$uniq = md5($value);
$pngfile = $cache_dir . '/' . $uniq . '.png';
$png_url = $cache_url . '/' . $uniq . '.png';
}
$img_exists = file_exists($pngfile);
if (!$img_exists || $formatter->refresh) {
require_once dirname(__FILE__) . '/../lib/phpqrcode.php';
QRcode::png($value, $pngfile, 'l', 3, 1);
}
if (!empty($Config['use_cache_url'])) {
header("Pragma: no-cache");
header('Cache-Control: public, max-age=0, s-maxage=0');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate', false);
$formatter->send_header(array('Status: 302', 'Location: ' . $png_url));
return null;
}
$down_mode = 'inline';
header("Content-Type: image/png\r\n");
$mtime = filemtime($pngfile);
$lastmod = gmdate('D, d M Y H:i:s', $mtime) . ' GMT';
$etag = md5($lastmod . $key);
header('Last-Modified: ' . $lastmod);
header('ETag: "' . $etag . '"');
$maxage = 60 * 60 * 24 * 30;
header('Cache-Control: public, max-age=' . $maxage);
$need = http_need_cond_request($mtime, $lastmod, $etag);
if (!$need) {
header('HTTP/1.0 304 Not Modified');
@ob_end_clean();
return null;
}
@ob_clean();
$ret = readfile($pngfile);
return null;
}
示例6: _interwiki_repl
function _interwiki_repl($formatter, $url)
{
global $DBInfo;
if ($url[0] == "w") {
$url = substr($url, 5);
}
$dum = explode(":", $url, 2);
$wiki = $dum[0];
if (isset($dum[1])) {
$page = $dum[1];
} else {
$page = $dum[0];
return array($formatter->link_url($page));
}
$url = $DBInfo->interwiki[$wiki];
# invalid InterWiki name
if (!$url) {
return array();
}
$urlpage = _urlencode(trim($page));
#$urlpage=trim($page);
if (strpos($url, '$PAGE') === false) {
$url .= $urlpage;
} else {
# GtkRef http://developer.gnome.org/doc/API/2.0/gtk/$PAGE.html
# GtkRef:GtkTreeView#GtkTreeView
# is rendered as http://...GtkTreeView.html#GtkTreeView
$page_only = strtok($urlpage, '#?');
$query = substr($urlpage, strlen($page_only));
#if ($query and !$text) $text=strtok($page,'#?');
$url = str_replace('$PAGE', $page_only, $url) . $query;
}
$img = $formatter->imgs_dir_interwiki . strtolower($wiki) . '-16.png';
if (preg_match("/\\.(png|gif|jpeg|jpg)\$/i", $url)) {
$img = $url;
}
return array($url, $img);
}
示例7: macro_Attachments
function macro_Attachments($formatter, $value, $params = array())
{
global $DBInfo;
if ($value and $DBInfo->hasPage($value)) {
$p = $DBInfo->getPage($value);
$body = $p->get_raw_body();
$baseurl = $formatter->link_url(_urlencode($value));
//$formatter->page=&$p;
} else {
if ($params['text']) {
$body = $params['text'];
} else {
$body = $formatter->page->get_raw_body();
}
}
// from wiki.php
$punct = "<\\'}\\]\\|\\.\\!";
# , is omitted for the WikiPedia
$url = 'attachment';
$urlrule = "((?:{$url}):\"[^\"]+\"[^\\s{$punct}]*|(?:{$url}):([^\\s{$punct}]|(\\.?[^\\s{$punct}]))+|\\[\\[Attachment\\([^\\)]+\\)\\]\\])";
// do not include pre block
$body = preg_replace("/\\{\\{\\{.+?\\}\\}\\}/s", '', $body);
$my = array();
$lines = explode("\n", $body);
foreach ($lines as $line) {
preg_match_all("/{$urlrule}/i", $line, $match);
if (!$match) {
continue;
}
$my = array_merge($my, $match[0]);
}
$my = array_unique($my);
if (!empty($params['call'])) {
return $my;
}
return " * " . implode("\n * ", $my);
}
示例8: macro_Fetch
function macro_Fetch($formatter, $url = '', $params = array())
{
global $DBInfo;
if (empty($url)) {
$params['retval']['error'] = _("Empty URL");
return false;
}
// check valid url
if (!preg_match('@^((ftp|https?)://[^/]+)/@', $url, $m)) {
return false;
}
$siteurl = $m[1];
require_once "lib/HTTPClient.php";
$sz = 0;
$allowed = 'png|jpeg|jpg|gif';
if (!empty($DBInfo->fetch_exts)) {
$allowed = $DBInfo->fetch_exts;
}
// urlencode()
$url = _urlencode($url);
// set default params
$maxage = !empty($DBInfo->fetch_maxage) ? (int) $DBInfo->fetch_maxage : 60 * 60 * 24 * 7;
$timeout = !empty($DBInfo->fetch_timeout) ? (int) $DBInfo->fetch_timeout : 15;
$vartmp_dir = $DBInfo->vartmp_dir;
$buffer_size = 2048 * 1024;
// default buffer size
if (!empty($DBInfo->fetch_buffer_size) and $DBInfo->fetch_buffer_size > 2048 * 1024) {
$buffer_size = $DBInfo->fetch_buffer_size;
}
// set referrer
$referer = '';
if (!empty($DBInfo->fetch_referer_re)) {
foreach ($DBInfo->fetch_referer_re as $re => $ref) {
if (preg_match($re, $url)) {
$referer = $ref;
break;
}
}
}
// default referrer
if (empty($referer) and !empty($DBInfo->fetch_referer)) {
$referer = $DBInfo->fetch_referer;
}
// check site available
$si = new Cache_text('siteinfo');
if ($si->exists($siteurl)) {
if (!empty($params['refresh'])) {
$si->remove($siteurl);
} else {
if (empty($params['refresh']) && ($check = $si->fetch($siteurl)) !== false) {
$params['retval']['status'] = $check['status'];
$params['retval']['error'] = $check['error'];
return false;
}
}
}
$sc = new Cache_text('fetchinfo');
$error = null;
if (empty($params['refresh']) and $sc->exists($url) and $sc->mtime($url) < time() + $maxage) {
$info = $sc->fetch($url);
$sz = $info['size'];
$mimetype = $info['mimetype'];
$error = !empty($info['error']) ? $info['error'] : null;
// already retrived and found some error
if (empty($params['refresh']) and !empty($error)) {
$params['retval']['status'] = $info['status'];
$params['retval']['error'] = $error;
$params['retval']['mimetype'] = $mimetype;
$params['retval']['size'] = $sz;
return false;
}
} else {
// check connection
$http = new HTTPClient();
// get file header
$http->nobody = true;
$http->referer = $referer;
$http->sendRequest($url, array(), 'GET');
//if ($http->status == 301 || $http->status == 302 ) {
//
//}
if ($http->status != 200) {
if ($http->status == 404) {
$params['retval']['error'] = '404 File Not Found';
} else {
$params['retval']['error'] = !empty($http->error) ? $http->error : sprintf(_("Invalid Status %d"), $http->status);
}
$params['retval']['status'] = $http->status;
// check alive site
if ($http->status == -210) {
$si->update($siteurl, array('status' => $http->status, 'error' => $params['retval']['error']), 60 * 60 * 24);
return false;
}
$sc->update($url, array('size' => -1, 'mimetype' => '', 'error' => $params['retval']['error'], 'status' => $params['retval']['status']), 60 * 60 * 24 * 3);
return false;
}
if (isset($http->resp_headers['content-length'])) {
$sz = $http->resp_headers['content-length'];
}
if (isset($http->resp_headers['content-type'])) {
//.........这里部分代码省略.........
示例9: interwiki_repl
function interwiki_repl($url, $text = "")
{
global $DBInfo;
if ($url[0] == "w") {
$url = substr($url, 5);
}
$dum = explode(":", $url, 2);
$wiki = $dum[0];
$page = $dum[1];
# if (!$page) { # wiki:Wiki/FrontPage
# $dum1=explode("/",$url,2);
# $wiki=$dum1[0]; $page=$dum1[1];
# }
if (!$page) {
# wiki:FrontPage(not supported in the MoinMoin
# or [wiki:FrontPage Home Page]
$page = $dum[0];
if (!$text) {
return $this->word_repl($page, '', '', 1);
}
return $this->word_repl($page, $text, '', 1);
}
$url = $DBInfo->interwiki[$wiki];
# invalid InterWiki name
if (!$url) {
return $dum[0] . ":" . $this->word_repl($dum[1], $text);
}
$urlpage = _urlencode(trim($page));
#$urlpage=trim($page);
if (strpos($url, '$PAGE') === false) {
$url .= $urlpage;
} else {
# GtkRef http://developer.gnome.org/doc/API/2.0/gtk/$PAGE.html
# GtkRef:GtkTreeView#GtkTreeView
# is rendered as http://...GtkTreeView.html#GtkTreeView
$page_only = strtok($urlpage, '#?');
$query = substr($urlpage, strlen($page_only));
#if ($query and !$text) $text=strtok($page,'#?');
$url = str_replace('$PAGE', $page_only, $url) . $query;
}
$img = $this->_img($DBInfo->imgs_dir . "/" . strtolower($wiki) . "-16.png");
#"<a href='$url' target='wiki'><img border='0' src='$DBInfo->imgs_dir/".
# strtolower($wiki)."-16.png' align='middle' height='16' width='16' ".
# "alt='$wiki:' title='$wiki:' /></a>";
if (!$text) {
$text = str_replace("%20", " ", $page);
} else {
if (preg_match("/^(http|ftp).*\\.(png|gif|jpeg|jpg)\$/i", $text)) {
$text = $this->_a($text);
$img = '';
}
}
if (preg_match("/\\.(png|gif|jpeg|jpg)\$/i", $url)) {
#return "<img border='0' alt='$text' src='$url' />";
return $this->_a($url);
}
return $img . $this->_a($url, $text);
}
示例10: macro_Scrap
function macro_Scrap($formatter, $value = '', $options = array())
{
global $DBInfo;
$user =& $DBInfo->user;
# get cookie
if ($user->id == 'Anonymous') {
return '';
}
$userinfo = $DBInfo->udb->getUser($user->id);
$pages = array();
if (!empty($userinfo->info['scrapped_pages'])) {
$pages = explode("\t", $userinfo->info['scrapped_pages']);
}
if (!empty($options['page']) and !in_array($options['page'], $pages)) {
$pages[] = $options['page'];
}
$out = '';
if ($value == 'js') {
// get the scrapped pages dynamically
$script = get_scriptname() . $DBInfo->query_prefix;
$js = <<<JS
<script type="text/javascript">
/*<![CDATA[*/
(function() {
var script_name = "{$script}";
function get_scrap()
{
var scrap = document.getElementById('scrap');
if (scrap == null) {
// silently ignore
return;
}
// get the scrapped pages
var qp = '?'; // query_prefix
var loc = location.protocol + '//' + location.host;
if (location.port) loc+= ':' + location.port;
loc+= location.pathname + qp + 'action=scrap/ajax';
var ret = HTTPGet(loc);
if (ret) {
var list = JSON.parse(ret);
var html = '';
for (i = 0; i < list.length; i++) {
html+= '<li><a href="' + script_name + list[i] + '">' + list[i] + "</a></li>\\n";
}
scrap.innerHTML = "<ul>" + html + "</ul>";
}
}
// onload
var oldOnload = window.onload;
window.onload = function(ev) {
try { oldOnload(); } catch(e) {};
get_scrap();
}
})();
/*]]>*/
</script>
JS;
#$formatter->register_javascripts('local/scrap.js');
$formatter->register_javascripts($js);
return '<i></i>';
// dummy
}
foreach ($pages as $p) {
if ($DBInfo->hasPage($p)) {
$out .= '<li>' . $formatter->link_tag(_urlencode($p), '', $p) . '</li>';
} else {
if (!empty($p)) {
$list = $formatter->macro_repl('PageList', $p, array('rawre' => 1));
if (empty($list)) {
$out .= substr($list, 4, -6);
}
}
}
}
if (!empty($out)) {
return '<ul>' . $out . '</ul>';
}
return '';
}
示例11: macro_trackback
function macro_trackback($formatter, $value)
{
preg_match('/(\\d+)?(\\s*,?\\s*.*)?$/', $value, $match);
$opts = explode(",", $match[2]);
if ($match[1]) {
$limit = $match[1];
} else {
$limit = 10;
}
# if (in_array('all',$opts))
$lines = TrackBack_text::get_all();
$date_fmt = "m-d [h:i a]";
$template_bra = '';
$template = '$out.= "<a href=\\"$link\\">$title</a> <span class=\\"blog-user\\">by <a href=\\"$url\\">$site</a> @ $date</span><br />\\n";';
$template_ket = '';
if (in_array('simple', $opts)) {
$template_bra = '<ul>';
$template = '$out.= "<li><span class=\\"blog-user\\"><a href=\\"$link\\">$title</a></span><br/><span class=\\"blog-user\\">by <a href=\\"$url\\">$site</a> @ $date</span></li>\\n";';
$template_bra = '</ul>';
$date_fmt = "m-d";
}
$logs = array();
foreach ($lines as $line) {
$logs[] = explode("\t", $line, 8);
}
usort($logs, 'TrackBackCompare');
$out = '';
foreach ($logs as $log) {
if ($limit <= 0) {
break;
}
list($page, $dum, $entry, $url, $date, $site, $title, $dum2) = $log;
if (!$title) {
continue;
}
if ($entry) {
$entry = '&value=' . $entry;
}
$link = $formatter->link_url(_urlencode($page), '?action=trackback' . $entry);
$date[10] = ' ';
$time = strtotime($date . " GMT");
$date = date($date_fmt, $time);
$tmp = explode(':', $site);
$wiki = $tmp[0];
if (!empty($tmp[1])) {
$user = $tmp[1];
$site = $tmp[1];
}
#$out.=$page."<a href='$url'>$title</a> @ $date from $site<br />\n";
#$out.="<a href='$url'>$title</a> @ $date from $site<br />\n";
eval($template);
$limit--;
}
return $template_bra . $out . $template_ket;
}
示例12: macro_Scrap
function macro_Scrap($formatter, $value = '', $options = array())
{
global $DBInfo;
$user =& $DBInfo->user;
# get cookie
if ($user->id == 'Anonymous') {
return '';
}
$userinfo = $DBInfo->udb->getUser($user->id);
$pages = array();
if (!empty($userinfo->info['scrapped_pages'])) {
$pages = explode("\t", $userinfo->info['scrapped_pages']);
}
$scrapped = 0;
$pgname = '';
if (!empty($formatter->page->name)) {
$pgname = $formatter->page->name;
if (!in_array($formatter->page->name, $pages)) {
$pages[] = $options['page'];
} else {
$scrapped = 1;
}
}
$out = '';
if ($value == 'js') {
// get the scrapped pages dynamically
$script = get_scriptname() . $DBInfo->query_prefix;
$pgname = _rawurlencode($pgname);
$js = <<<JS
<script type="text/javascript">
/*<![CDATA[*/
(function() {
var script_name = "{$script}";
var page_name = "{$pgname}";
function get_scrap()
{
var scrap = document.getElementById('scrap');
if (scrap == null) {
// silently ignore
return;
}
var pgname = decodeURIComponent(page_name);
var scrapped = false;
// get the scrapped pages
var qp = '?'; // query_prefix
var loc = '//' + location.host;
if (location.port) loc+= ':' + location.port;
loc+= location.pathname + qp + 'action=scrap/ajax';
var ret = HTTPGet(loc);
if (ret) {
var list = JSON.parse(ret);
var html = '';
for (i = 0; i < list.length; i++) {
if (list[i] == pgname) scrapped = true;
html+= '<li><a href="' + script_name + list[i] + '">' + list[i] + "</a></li>\\n";
}
if (html != '')
scrap.innerHTML = "<ul>" + html + "</ul>";
if (scrapped) {
// change scrap icon
var iconmenu = document.getElementById("wikiIcon");
var icons = iconmenu.getElementsByTagName("A");
for (i = 0; i < icons.length; i++) {
if (icons[i].href.match(/action=scrap/)) {
icons[i].href = icons[i].href.replace(/=scrap/, '=scrap&unscrap=1');
icons[i].firstChild.firstChild.src =
icons[i].firstChild.firstChild.src.replace('scrap', 'unscrap');
break;
}
}
}
}
}
// onload
var oldOnload = window.onload;
window.onload = function(ev) {
try { oldOnload(); } catch(e) {};
get_scrap();
}
})();
/*]]>*/
</script>
JS;
#$formatter->register_javascripts('local/scrap.js');
$formatter->register_javascripts($js);
return '<i></i>';
// dummy
}
foreach ($pages as $p) {
if ($DBInfo->hasPage($p)) {
$out .= '<li>' . $formatter->link_tag(_urlencode($p), '', $p) . '</li>';
} else {
if (!empty($p)) {
$list = $formatter->macro_repl('PageList', $p, array('rawre' => 1));
if (empty($list)) {
//.........这里部分代码省略.........
示例13: macro_WordIndex
//.........这里部分代码省略.........
sort($keys);
foreach ($keys as $k) {
#ksort($dict[$k]);
#ksort($dict[$k], SORT_STRING);
#uksort($dict[$k], "strnatcasecmp");
uksort($dict[$k], "strcasecmp");
}
if ($formatter->group) {
$wc->update('key.' . $formatter->group, $keys);
$wc->update('wordindex.' . $formatter->group, $dict);
} else {
$wc->update('key', $keys);
$wc->update('wordindex', $dict);
}
_fake_lock($lock_file, LOCK_UN);
}
if (isset($sel[0]) and isset($dict[$sel])) {
$selected = array($sel);
} else {
$selected =& $keys;
}
$out = '';
$key = -1;
$count = 0;
$idx = 0;
foreach ($selected as $k) {
$words = array_keys($dict[$k]);
$sz = count($words);
for ($idx = $start; $idx < $sz; $idx++) {
$word = $words[$idx];
$pages =& $dict[$k][$word];
$pkey = $k;
if ($key != $pkey) {
$key = $pkey;
if (!empty($sel) and !preg_match('/^' . $sel . '/i', $pkey)) {
continue;
}
if (!empty($out)) {
$out .= "</ul>";
}
$ukey = urlencode($key);
$out .= "<a name='{$ukey}'></a><h3><a href='#top'>{$key}</a></h3>\n";
}
if (!empty($sel) and !preg_match('/^' . $sel . '/i', $pkey)) {
continue;
}
$out .= "<h4>{$word}</h4>\n";
$out .= "<ul>\n";
foreach ($pages as $page) {
$out .= '<li>' . $formatter->word_repl('"' . $page . '"') . "</li>\n";
}
$out .= "</ul>\n";
$count++;
if ($count >= $word_limit) {
break;
}
}
}
if (isset($sel[0])) {
$last = count($dict[$sel]);
$offset = $idx + 1;
$pager = array();
if ($start > 0) {
// get previous start offset.
$count = 0;
$idx -= $word_limit - 1;
if ($idx < 0) {
$idx = 0;
}
$link = $formatter->link_url($formatter->page->name, '?action=wordindex&sec=' . $sel . '&start=' . $idx);
$pager[] = "<a href='{$link}'>" . _("« Prev") . '</a>';
}
if ($offset < $last) {
$link = $formatter->link_url($formatter->page->name, '?action=wordindex&sec=' . $sel . '&start=' . $offset);
$pager[] = "<a href='{$link}'>" . _("Next »") . '</a>';
}
if (!empty($pager)) {
$out .= implode(' | ', $pager) . "<br />\n";
}
}
$index = array();
$tlink = '';
if (isset($sel[0])) {
$tlink = $formatter->link_url($formatter->page->name, '?action=wordindex&sec=');
}
foreach ($keys as $key) {
$name = strval($key);
if ($key == 'Others') {
$name = _("Others");
}
$ukey = urlencode($key);
$link = !empty($tlink) ? preg_replace('/sec=/', 'sec=' . _urlencode($key), $tlink) : '';
$index[] = "<a href='{$link}#{$ukey}'>{$name}</a>";
}
$str = implode(' | ', $index);
$formatter->pagelinks = $pagelinks;
// restore
$formatter->sister_on = $save;
return "<center><a name='top'></a>{$str}</center>\n{$out}";
}
示例14: macro_Play
function macro_Play($formatter, $value)
{
global $DBInfo;
static $autoplay = 1;
$max_width = 600;
$max_height = 400;
$default_width = 320;
$default_height = 240;
#
$media = array();
#
preg_match("/^(([^,]+\\s*,?\\s*)+)\$/", $value, $match);
if (!$match) {
return '[[Play(error!! ' . $value . ')]]';
}
if (($p = strpos($match[1], ',')) !== false) {
$my = explode(',', $match[1]);
for ($i = 0, $sz = count($my); $i < $sz; $i++) {
if (strpos($my[$i], '=')) {
list($key, $val) = explode('=', $my[$i]);
$val = trim($val, '"\'');
if ($key == 'width' and $val > 1) {
$width = $val;
} else {
if ($key == 'height' and $val > 1) {
$height = $val;
}
}
} else {
// multiple files
$media[] = $my[$i];
}
}
} else {
$media[] = $match[1];
}
# set embeded object size
$mywidth = !empty($width) ? min($width, $max_width) : null;
$myheight = !empty($height) ? min($height, $max_height) : null;
$width = !empty($width) ? min($width, $max_width) : $default_width;
$height = !empty($height) ? min($height, $max_height) : $default_height;
$url = array();
$my_check = 1;
for ($i = 0, $sz = count($media); $i < $sz; $i++) {
if (!preg_match("/^(http|ftp|mms|rtsp):\\/\\//", $media[$i])) {
$fname = $formatter->macro_repl('Attachment', $media[$i], array('link' => 1));
if ($my_check and !file_exists($fname)) {
return $formatter->macro_repl('Attachment', $value);
}
$my_check = 1;
// check only first file.
$fname = str_replace($DBInfo->upload_dir, $DBInfo->upload_dir_url, $fname);
$url[] = qualifiedUrl(_urlencode($fname));
} else {
$url[] = $media[$i];
}
}
if ($autoplay == 1) {
$play = "true";
} else {
$play = "false";
}
#
$use_flashplayer_ok = 0;
if ($DBInfo->use_jwmediaplayer) {
$use_flashplayer_ok = 1;
for ($i = 0, $sz = count($media); $i < $sz; $i++) {
// check type of all files
if (!preg_match("/(flv|mp3|mp4|swf)\$/i", $media[$i])) {
$use_flashplayer_ok = 0;
break;
}
}
}
if ($use_flashplayer_ok) {
# set embed flash size
if (($sz = count($media)) == 1 and preg_match("/(ogg|wav|mp3)\$/i", $media[0])) {
// only one and a sound file
$height = 20;
// override the hegiht of the JW MediaPlayer
}
$swfobject_num = !empty($GLOBALS['swfobject_num']) ? $GLOBALS['swfobject_num'] : 0;
$swfobject_script = '';
if (!$swfobject_num) {
$swfobject_script = "<script type=\"text/javascript\" src=\"{$DBInfo->url_prefix}/local/js/swfobject.js\"></script>\n";
$num = 1;
} else {
$num = ++$swfobject_num;
}
$GLOBALS['swfobject_num'] = $num;
if (!$DBInfo->jwmediaplayer_prefix) {
$_swf_prefix = qualifiedUrl("{$DBInfo->url_prefix}/local/JWPlayers");
// FIXME
} else {
$_swf_prefix = $DBInfo->jwmediaplayer_prefix;
}
$addparam = '';
if ($sz > 1) {
$md5sum = md5(implode(':', $media));
if ($DBInfo->cache_public_dir) {
//.........这里部分代码省略.........
示例15: _urlencode
/**
* _urlencode
* urlencode 字符串或数组
*
* 注意:
* 本函数其实只是用于json_encode2,如果php版本>=5.3的话,
* 建议用闭包实现,这样就不用将此函数暴露在全局中
*
* @param string|array $value
* @return string|array
*/
function _urlencode($value)
{
if (is_array($value)) {
foreach ($value as $k => $v) {
$value[$k] = _urlencode($v);
}
} else {
if (is_string($value)) {
$value = urlencode(str_replace(array("\\", "\r\n", "\r", "\n", "\"", "\\/", "\t"), array('\\\\', '\\n', '\\n', '\\n', '\\"', '\\/', '\\t'), $value));
}
}
return $value;
}