本文整理汇总了PHP中requestVar函数的典型用法代码示例。如果您正苦于以下问题:PHP requestVar函数的具体用法?PHP requestVar怎么用?PHP requestVar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了requestVar函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: requestVar
<div class="clear"></div>
<form name="contentForm" id="contentForm" method="post" action="<?php
echo $_SERVER['PHP_SELF'];
?>
">
<input type="hidden" name="view" value="<?php
echo $view;
?>
"/>
<input type="hidden" name="tab" value="<?php
echo $tab;
?>
"/>
<input type="hidden" name="action" value="controlcap"/>
<input type="hidden" name="cid" value="<?php
echo requestVar('cid');
?>
"/>
<?php
if ($tab != 'main') {
?>
<input type="hidden" name="newControl[Name]" value="<?php
echo validHtmlStr($newControl['Name']);
?>
"/>
<input type="hidden" name="newControl[Type]" value="<?php
echo validHtmlStr($newControl['Type']);
?>
"/>
<input type="hidden" name="newControl[Protocol]" value="<?php
echo validHtmlStr($newControl['Protocol']);
示例2: sb_log
function sb_log()
{
global $oPluginAdmin;
$startpos = requestVar('startpos') ? requestVar('startpos') : 0;
$filter = requestVar('filter') ? requestVar('filter') : 'all';
$filtertype = requestVar('filtertype') ? requestVar('filtertype') : 'all';
$ipp = requestVar('ipp') ? requestVar('ipp') : 10;
$keyword = requestVar('keyword');
$filterform = buildfilterform($filter, $filtertype, $keyword, $ipp);
$total = $oPluginAdmin->plugin->spambayes->nbs->countlogtable($filter, $filtertype, $keyword);
if ($filter == 'all') {
$htotal = $oPluginAdmin->plugin->spambayes->nbs->countlogtable('ham', $filtertype, $keyword);
$stotal = $oPluginAdmin->plugin->spambayes->nbs->countlogtable('spam', $filtertype, $keyword);
echo '<h2>Spam Bayesian: Log [total events: ' . $total . ' (ham: ' . $htotal . ' spam: ' . $stotal . ') ]</h2>';
} else {
echo '<h2>Spam Bayesian: Log [total ' . $filter . ' events: ' . $total . ']</h2>';
}
$res = $oPluginAdmin->plugin->spambayes->nbs->getlogtable($startpos, $filter, $filtertype, $keyword, $ipp);
$pager = buildpager($startpos, $total, $filter, $filtertype, $filterform, 'log', $keyword, $ipp);
if ($total % $ipp == 0) {
$ap = intval(floor($total / $ipp));
} else {
$ap = intval(floor($total / $ipp)) + 1;
}
$cp = intval($startpos + $ipp) / $ipp;
echo '<table>';
echo '<tr><th colspan="2">Page ' . $cp . ' of ' . $ap . '</th><td colspan="2">Browse: <form style="display:inline"><input type="text" size="3" name="ipp" value="' . $ipp . '" /> items per page. <input type="submit" value="Go" /><input type="hidden" name="amount" value="cp" /><input type="hidden" name="filter" value="' . $filter . '" /><input type="hidden" name="filtertype" value="' . $filtertype . '" /><input type="hidden" name="keyword" value="' . $keyword . '" /><input type="hidden" name="page" value="log" /></form>';
echo '<span style="text-align:right" class="batchoperations">';
if ($filter != 'all') {
echo ' type: <b>' . $filter . '</b>';
}
if ($filtertype != 'all') {
echo ' event: <b>' . $filtertype . '</b>';
}
if ($keyword > '') {
echo ' keyword: <b>' . $keyword . '</b>';
}
echo '</span></td></tr>';
echo $pager;
$extraaction = '&filter=' . $filter . '&filtertype=' . urlencode($filtertype) . '&startpos=' . $startpos . '&keyword=' . $keyword . '&ipp=' . $ipp;
echo '<tr><th>Date</th><th>event</th><th>content</th><th>action</th></tr><form>';
$i = 0;
while ($arr = mysql_fetch_array($res)) {
echo '<tr onmouseover="focusRow(this);" onmouseout="blurRow(this);"><td>' . $arr['logtime'] . '<br /><b>' . $arr['catcode'] . '</b></td><td>' . $arr['log'] . '</td><td><input id="batch' . $i . '" name="batch[' . $i . ']" value="' . $arr['id'] . '" type="checkbox"><label for="batch' . $i . '">' . htmlentities(str_replace('^^', ' ', $arr['content'])) . '</label></td>';
echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?page=trainlog&catcode=ham&id=' . $arr['id'] . $extraaction . '"><nobr>train ham</nobr></a>';
echo ' <a href="' . $_SERVER['PHP_SELF'] . '?page=trainlog&catcode=spam&id=' . $arr['id'] . $extraaction . '"><nobr>train spam</nobr></a>';
echo '<br /><a href="' . $_SERVER['PHP_SELF'] . '?page=explain&id=' . $arr['id'] . $extraaction . '"><nobr>explain</nobr></a>';
if (strstr($arr['log'], 'itemid:')) {
echo '<br /><br /><a style="color:red" href="' . $_SERVER['PHP_SELF'] . '?page=promote&id=' . $arr['id'] . $extraaction . '"><nobr>publish</nobr></a>';
}
echo '</td>';
echo '</tr>';
$i++;
}
if (mysql_num_rows($res) == 0) {
echo '<tr><td colspan="4"><b>Eventlog is empty</b></td></tr>';
}
echo '<tr><td colspan="4"><div class="batchoperations">with selected:<select name="batchaction">';
echo '<option value="tspam">Train spam</option>';
echo '<option value="tham">Train ham</option>';
echo '<option value="delete">Delete</option></select><input name="page" value="batch" type="hidden">';
echo '<input type="hidden" name="ipp" value="' . $ipp . '"/><input type="hidden" name="filter" value="' . $filter . '" /><input type="hidden" name="filtertype" value="' . $filtertype . '" /><input type="hidden" name="keyword" value="' . $keyword . '" />';
echo '<input value="Submit" type="submit">(
<a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(1); ">select all</a> -
<a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(0); ">deselect all</a>
)
</div></td></tr></form>';
echo '<tr><td colspan="4"><div class="batchoperations"><form action="" method="get" style="display:inline"><input type="hidden" name="ipp" value="' . $ipp . '"/><input type="hidden" name="page" value="clearlog" /><input type="hidden" name="amount" value="cp" /><input type="hidden" name="filter" value="' . $filter . '" /><input type="hidden" name="filtertype" value="' . $filtertype . '" /><input type="hidden" name="keyword" value="' . $keyword . '" /><input type="submit" value="Clear first ' . $ipp . '" /></form> <form action="" method="get" style="display:inline"><input type="hidden" name="ipp" value="' . $ipp . '"/><input type="hidden" name="page" value="clearlog" /><input type="hidden" name="amount" value="cf" /><input type="hidden" name="filter" value="' . $filter . '" /><input type="hidden" name="filtertype" value="' . $filtertype . '" /><input type="hidden" name="keyword" value="' . $keyword . '" /><input type="submit" value="Clear current filtered logs" /></form> <form action="" method="get" style="display:inline"><input type="hidden" name="page" value="clearlog" /><input type="submit" value="Clear complete log" /></form></div></td></tr>';
echo '<tr><th colspan="2">Page ' . $cp . ' of ' . $ap . '</th><td colspan="2">Browse: <form style="display:inline"><input type="text" size="3" name="ipp" value="' . $ipp . '" /> items per page. <input type="submit" value="Go" /><input type="hidden" name="amount" value="cp" /><input type="hidden" name="filter" value="' . $filter . '" /><input type="hidden" name="filtertype" value="' . $filtertype . '" /><input type="hidden" name="keyword" value="' . $keyword . '" /><input type="hidden" name="page" value="log" /></form></td></tr>';
echo $pager;
echo '</table>';
}
示例3: buildSelect
echo buildSelect($selectName, $filterNames);
?>
<label for="<?php
echo $newSelectName;
?>
"><?php
echo translate('OrEnterNewName');
?>
</label><input type="text" size="32" id="<?php
echo $newSelectName;
?>
" name="<?php
echo $newSelectName;
?>
" value="<?php
echo requestVar('filterName');
?>
"/>
</p>
<?php
} else {
?>
<p>
<label for="<?php
echo $newSelectName;
?>
"><?php
echo translate('EnterNewFilterName');
?>
</label><input type="text" size="32" id="<?php
echo $newSelectName;
示例4: serverVar
}
global $CONF, $manager;
// $manager->checkTicket();
$action_url = $CONF['ActionURL'];
$thispage = $CONF['PluginURL'] . "badbehavior/index.php";
$adminpage = $CONF['AdminURL'];
$thisquerystring = serverVar('QUERY_STRING');
$toplink = '<p class="center"><a href="' . $thispage . '?' . $thisquerystring . '#sitop" alt="Return to Top of Page">-top-</a></p>' . "\n";
$showlist = strtolower(trim(requestVar('showlist')));
if (!in_array($showlist, array('stats', 'admin', 'logs'))) {
$showlist = 'stats';
}
$tname = stringStripTags(trim(requestVar('tname')));
$fname = stringStripTags(trim(requestVar('fname')));
$oname = stringStripTags(trim(requestVar('oname')));
$iname = stringStripTags(trim(requestVar('iname')));
$iname = preg_replace('|[^a-z0-9.,_/-]|i', '_', $iname);
// make sure bad behavior is loaded
if (!defined('BB2_CORE')) {
//echo "loading necessary bad behavior libraries...";
global $DIR_PLUGINS;
$homepath = $DIR_PLUGINS . '/badbehavior/';
require_once $homepath . '/bad-behavior-nucleuscms.php';
//echo " OK. Completed <br />\n";
}
$plugin =& $oPluginAdmin->plugin;
$sipid = $plugin->getID();
$admin = $plugin->siRights();
$minaccess = intval($plugin->minRights);
if (!$minaccess || $minaccess == 0) {
$minaccess = 8;
示例5: convertLocalTrackbackURL
function convertLocalTrackbackURL($data)
{
global $manager, $CONF;
$ping_urls_count = 0;
$ping_urls = array();
$localflag = array();
$ping_url = requestVar('trackback_ping_url');
if (trim($ping_url)) {
$ping_urlsTemp = array();
$ping_urlsTemp = preg_split("/[\\s,]+/", trim($ping_url));
for ($i = 0; $i < count($ping_urlsTemp); $i++) {
$ping_urls[] = trim($ping_urlsTemp[$i]);
$ping_urls_count++;
}
}
$tb_url_amount = intRequestVar('tb_url_amount');
for ($i = 0; $i < $tb_url_amount; $i++) {
$tb_temp_url = requestVar('tb_url_' . $i);
if ($tb_temp_url) {
$ping_urls[$ping_urls_count] = $tb_temp_url;
$localflag[$ping_urls_count] = requestVar('tb_url_' . $i . '_local') == 'on' ? 1 : 0;
$ping_urls_count++;
}
}
if ($ping_urls_count <= 0) {
return;
}
$blog_id = getBlogidFromItemID(intval($data['itemid']));
for ($i = 0; $i < count($ping_urls); $i++) {
if ($localflag[$i]) {
$tmp_url = parse_url($ping_urls[$i]);
$tmp_url['path'] = trim($tmp_url['path'], '/');
$path_arr = explode("/", $tmp_url['path']);
$tail = end($path_arr);
$linkObj = array('linkparam' => 'item', 'bid' => $blog_id);
if (substr($tail, -10) == '.trackback') {
$pathName = substr($tail, 0, -10);
if (substr($pathName, -5) == '.html') {
$linkObj['name'] = $pathName;
} else {
$linkObj['name'] = $pathName . '.html';
}
} else {
$linkObj['name'] = $tail;
}
$item_id = $this->getRequestPathInfo($linkObj);
if ($item_id) {
$ping_urls[$i] = $CONF['ActionURL'] . '?action=plugin&name=TrackBack&tb_id=' . $item_id;
}
}
}
$_REQUEST['trackback_ping_url'] = implode("\n", $ping_urls);
}
示例6: action_banlistnew
/**
* @todo document this
*/
function action_banlistnew($blogid = '')
{
global $member, $manager;
if ($blogid == '') {
$blogid = intRequestVar('blogid');
}
$ip = requestVar('ip');
$member->blogAdminRights($blogid) or $this->disallow();
$blog =& $manager->getBlog($blogid);
$this->pagehead();
?>
<h2><?php
echo _BAN_ADD_TITLE;
?>
</h2>
<form method="post" action="index.php">
<h3><?php
echo _BAN_IPRANGE;
?>
</h3>
<p><?php
echo _BAN_IPRANGE_TEXT;
?>
</p>
<div class="note">
<strong><?php
echo _BAN_EXAMPLE_TITLE;
?>
</strong>
<?php
echo _BAN_EXAMPLE_TEXT;
?>
</div>
<div>
<?php
if ($ip) {
$iprangeVal = htmlspecialchars($ip, ENT_QUOTES);
?>
<input name="iprange" type="radio" value="<?php
echo $iprangeVal;
?>
" checked="checked" id="ip_fixed" />
<label for="ip_fixed"><?php
echo $iprangeVal;
?>
</label>
<br />
<input name="iprange" type="radio" value="custom" id="ip_custom" />
<label for="ip_custom"><?php
echo _BAN_IP_CUSTOM;
?>
</label>
<input name='customiprange' value='<?php
echo $iprangeVal;
?>
' maxlength='15' size='15' />
<?php
} else {
echo "<input name='iprange' value='custom' type='hidden' />";
echo "<input name='customiprange' value='' maxlength='15' size='15' />";
}
?>
</div>
<h3><?php
echo _BAN_BLOGS;
?>
</h3>
<p><?php
echo _BAN_BLOGS_TEXT;
?>
</p>
<div>
<input type="hidden" name="blogid" value="<?php
echo $blogid;
?>
" />
<input name="allblogs" type="radio" value="0" id="allblogs_one" /><label for="allblogs_one">'<?php
echo htmlspecialchars($blog->getName());
?>
'</label>
<br />
<input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php
echo _BAN_ALLBLOGS;
?>
</label>
</div>
<h3><?php
//.........这里部分代码省略.........
示例7: parse_imagetext
/**
* Parse skinvar imagetext
*/
function parse_imagetext()
{
echo htmlspecialchars(requestVar('imagetext'), ENT_QUOTES);
}
示例8: media_loginAndPassThrough
function media_loginAndPassThrough()
{
media_head();
?>
<h1><?php
echo _LOGIN_PLEASE;
?>
</h1>
<form method="post" action="media.php">
<div>
<input name="action" value="login" type="hidden" />
<input name="collection" value="<?php
echo htmlspecialchars(requestVar('collection'));
?>
" type="hidden" />
<?php
echo _LOGINFORM_NAME;
?>
: <input name="login" />
<br /><?php
echo _LOGINFORM_PWD;
?>
: <input name="password" type="password" />
<br /><input type="submit" value="<?php
echo _LOGIN;
?>
" />
</div>
</form>
<p><a href="media.php" onclick="tinyMCEPopup.close();"><?php
echo _POPUP_CLOSE;
?>
</a></p>
<?php
media_foot();
exit;
}
示例9: listplug_table_itemlist
function listplug_table_itemlist($template, $type)
{
$cssclass = null;
switch ($type) {
case 'HEAD':
echo "<th>" . _LIST_ITEM_INFO . "</th><th>" . _LIST_ITEM_CONTENT . "</th><th style=\"white-space:nowrap\" colspan='1'>" . _LISTS_ACTIONS . "</th>";
break;
case 'BODY':
$current = $template['current'];
$current->itime = strtotime($current->itime);
// string -> unix timestamp
if ($current->idraft == 1) {
$cssclass = "class='draft'";
}
// (can't use offset time since offsets might vary between blogs)
if ($current->itime > $template['now']) {
$cssclass = "class='future'";
}
$action = requestVar('action');
echo '<td ' . $cssclass . ' style="white-space:nowrap;">';
if ($action !== 'itemlist') {
echo _LIST_ITEM_BLOG . ' ', htmlspecialchars($current->bshortname) . ' <br />';
}
echo _LIST_ITEM_CAT, ' ', htmlspecialchars($current->cname) . ' <br />';
if ($action !== 'browseownitems') {
echo _LIST_ITEM_AUTHOR, ' ', htmlspecialchars($current->mname) . ' <br />';
}
echo date("Y-m-d", $current->itime), " " . date("H:i", $current->itime);
echo "</td>";
echo "<td {$cssclass}>";
$id = listplug_nextBatchId();
echo '<input type="checkbox" id="batch', $id, '" name="batch[', $id, ']" value="', $current->inumber, '" />';
echo '<label for="batch', $id, '">';
echo "<b>" . htmlspecialchars(strip_tags($current->ititle)) . "</b>";
echo '</label>';
echo "<br />";
$current->ibody = strip_tags($current->ibody);
$current->ibody = htmlspecialchars(shorten($current->ibody, 200, '...'));
$COMMENTS = new COMMENTS($current->inumber);
echo "{$current->ibody}</td>";
echo "<td style=\"white-space:nowrap\" {$cssclass}>";
echo "<a href='index.php?action=itemedit&itemid={$current->inumber}'>" . _LISTS_EDIT . "</a>";
echo " / <a href='index.php?action=itemmove&itemid={$current->inumber}'>" . _LISTS_MOVE . "</a>";
echo " / <a href='index.php?action=itemdelete&itemid={$current->inumber}'>" . _LISTS_DELETE . "</a><br />";
// evaluate amount of comments for the item
$camount = $COMMENTS->amountComments();
if ($camount > 0) {
echo "<a href='index.php?action=itemcommentlist&itemid={$current->inumber}'>";
echo "( " . sprintf(_LIST_ITEM_COMMENTS, $COMMENTS->amountComments()) . " )</a>";
} else {
echo _LIST_ITEM_NOCONTENT;
}
echo "</td>";
break;
}
}
示例10: event_PostAuthentication
function event_PostAuthentication($data)
{
global $CONF;
if ($this->isMobile() && !$CONF['UsingAdminArea']) {
if (requestVar('action') == 'addcomment' || strlen(getVar('query'))) {
// check if valid SJIS
if (!encoding_check(false, false, 'Shift_JIS')) {
foreach (array($_REQUEST, $_SERVER) as $input) {
array_walk($input, 'encoding_check');
}
}
// user/body/query won't be checked anymore.
encoding_check(false, false, false, array('user', 'body', 'query'));
}
}
}
示例11: _skinfiles_uploadfile
function _skinfiles_uploadfile()
{
global $pluginUrl, $manager, $CONF;
$directory = trim(requestVar('dir'));
$directory = sfExpandDirectory($directory);
if (sfValidPath($directory) && is_dir($directory) && is_writable($directory)) {
$file = postFileInfo('name');
if ($file['size'] > $CONF['MaxUploadSize']) {
echo "<p class='error'>" . _SKINFILES_ERR_UPLOAD_FILE1 . "«" . htmlspecialchars($file['name']) . "» " . _SKINFILES_ERR_UPLOAD_FILE2 . _ERROR_FILE_TOO_BIG . "<br />";
echo _SKINFILES_ERR_UPLOAD_FILE3 . $CONF['MaxUploadSize'] . " / ";
echo $file['size'] . " bytes</p>";
sfShowDirectory($directory);
return;
}
if (!is_uploaded_file($file['tmp_name'])) {
echo "<p class='error'>" . _SKINFILES_ERR_UPLOAD_FILE1 . "«" . htmlspecialchars($file['name']) . "» " . _SKINFILES_ERR_UPLOAD_FILE2 . _ERROR_BADREQUEST . _SKINFILES_ERR_UPLOAD_FILE4 . "</p>";
sfShowDirectory($directory);
return;
}
if (sfIllegalFilename($file['name'])) {
echo "<p class='error'>" . _SKINFILES_ERR_UPLOAD_FILE5 . "«" . htmlspecialchars($file['name']) . "» ";
echo _SKINFILES_ERR_UPLOAD_FILE6 . "</p>";
sfShowDirectory($directory);
return;
}
if (file_exists($directory . $file['name'])) {
echo "<p class='error'>" . _SKINFILES_ERR_UPLOAD_FILE1 . "«" . htmlspecialchars($file['name']) . "» " . _SKINFILES_ERR_UPLOAD_FILE2 . _ERROR_UPLOADDUPLICATE . "</p>";
sfShowDirectory($directory);
return;
}
if (!@move_uploaded_file($file['tmp_name'], $directory . $file['name'])) {
echo "<p class='error'>" . _SKINFILES_ERR_UPLOAD_FILE1 . "«" . htmlspecialchars($file['name']) . "» " . _SKINFILES_ERR_UPLOAD_FILE2 . _ERROR_UPLOADMOVEP . _SKINFILES_ERR_UPLOAD_FILE4 . "</p>";
sfShowDirectory($directory);
}
$mask = @umask(00);
@chmod($directory . $file['name'], 0755);
@umask($mask);
echo "<p class='message'>" . _SKINFILES_ERR_UPLOAD_FILE7 . "«" . htmlspecialchars($file['name']) . "» " . _SKINFILES_ERR_UPLOAD_FILE8 . "</p>";
sfShowDirectory($directory);
} else {
echo "<p class='error'>" . _SKINFILES_ERR_UPLOAD_FILE9 . "«" . htmlspecialchars(_skinfiles_basename($directory)) . "» " . _SKINFILES_ERR_UPLOAD_FILE10;
echo _SKINFILES_ERR_UPLOAD_FILE11 . "</p>";
}
}
示例12: callPlugin
/**
* Calls a plugin action
*/
function callPlugin()
{
global $manager;
$pluginName = 'NP_' . requestVar('name');
$actionType = requestVar('type');
// 1: check if plugin is installed
if (!$manager->pluginInstalled($pluginName)) {
doError(_ERROR_NOSUCHPLUGIN);
}
// 2: call plugin
$pluginObject =& $manager->getPlugin($pluginName);
if ($pluginObject) {
$error = $pluginObject->doAction($actionType);
} else {
$error = 'Could not load plugin (see actionlog)';
}
// doAction returns error when:
// - an error occurred (duh)
// - no actions are allowed (doAction is not implemented)
if ($error) {
doError($error);
}
exit;
}
示例13: bm_doShowForm
function bm_doShowForm()
{
global $member;
$blogid = intRequestVar('blogid');
$log_text = trim(requestVar('logtext'));
$log_link = requestVar('loglink');
$log_linktitle = requestVar('loglinktitle');
$log_text = uniDecode($log_text, _CHARSET);
$log_linktitle = uniDecode($log_linktitle, _CHARSET);
if (!BLOG::existsID($blogid)) {
bm_doError(_ERROR_NOSUCHBLOG);
}
if (!$member->isTeamMember($blogid)) {
bm_doError(_ERROR_NOTONTEAM);
}
$logje = '';
if ($log_text) {
$logje .= '<blockquote><div>"' . htmlspecialchars($log_text) . '"</div></blockquote>' . "\n";
}
if (!$log_linktitle) {
$log_linktitle = $log_link;
}
if ($log_link) {
$logje .= '<a href="' . htmlspecialchars($log_link) . '">' . htmlspecialchars($log_linktitle) . '</a>';
}
$item['body'] = $logje;
$item['title'] = htmlspecialchars($log_linktitle);
$factory = new PAGEFACTORY($blogid);
$factory->createAddForm('bookmarklet', $item);
}
示例14: event_PreUpdateItem
function event_PreUpdateItem($data)
{
// Add tags when it add for Item
$itags = trim(requestVar('itags'));
$inum = intval($data['itemid']);
$query = 'SELECT itags as result FROM %s WHERE inum = %d';
$oldTags = quickQuery(sprintf($query, _TAGEX_TABLE, $inum));
if ($itags == $oldTags) {
return false;
}
$query = 'DELETE FROM %s WHERE inum = %d';
sql_query(sprintf($query, _TAGEX_TABLE, $inum));
if (!empty($itags)) {
$query = 'INSERT INTO %s (inum, itags) VALUES (%d, %s)';
$query = sprintf($query, _TAGEX_TABLE, $inum, $this->quote_smart($itags));
sql_query($query);
}
$old_tags_array = $this->getTags($oldTags);
if (!is_array($old_tags_array)) {
$old_tags_array = array($old_tags_array);
}
$new_tags_array = $this->getTags($itags);
$deleteTags = $this->array_minus_array($old_tags_array, $new_tags_array);
for ($i = 0; $i < count($deleteTags); $i++) {
$this->deleteTags($deleteTags[$i], $inum);
}
$addTags = $this->array_minus_array($new_tags_array, $old_tags_array);
for ($i = 0; $i < count($addTags); $i++) {
$this->mergeTags($addTags[$i], $inum);
}
}
示例15: media_upload
/**
* accepts a file for upload
*/
function media_upload()
{
global $DIR_MEDIA, $member, $CONF, $funcNum, $responseType;
$uploadInfo = postFileInfo('upload');
$filename = $uploadInfo['name'];
$filetype = $uploadInfo['type'];
$filesize = $uploadInfo['size'];
$filetempname = $uploadInfo['tmp_name'];
$fileerror = intval($uploadInfo['error']);
// clean filename of characters that may cause trouble in a filename using cleanFileName() function from globalfunctions.php
$filename = cleanFileName($filename);
if ($filename === false) {
upload_doError(_ERROR_BADFILETYPE . $filename);
}
switch ($fileerror) {
case 0:
// = UPLOAD_ERR_OK
break;
case 1:
// = UPLOAD_ERR_INI_SIZE
// = UPLOAD_ERR_INI_SIZE
case 2:
// = UPLOAD_ERR_FORM_SIZE
upload_doError(_ERROR_FILE_TOO_BIG);
case 3:
// = UPLOAD_ERR_PARTIAL
// = UPLOAD_ERR_PARTIAL
case 4:
// = UPLOAD_ERR_NO_FILE
// = UPLOAD_ERR_NO_FILE
case 6:
// = UPLOAD_ERR_NO_TMP_DIR
// = UPLOAD_ERR_NO_TMP_DIR
case 7:
// = UPLOAD_ERR_CANT_WRITE
// = UPLOAD_ERR_CANT_WRITE
default:
// include error code for debugging
// (see http://www.php.net/manual/en/features.file-upload.errors.php)
upload_doError(_ERROR_BADREQUEST . ' (' . $fileerror . ')');
}
if ($filesize > $CONF['MaxUploadSize']) {
upload_doError(_ERROR_FILE_TOO_BIG);
}
// check file type against allowed types
$ok = 0;
$allowedtypes = explode(',', $CONF['AllowedTypes']);
foreach ($allowedtypes as $type) {
if (preg_match("#\\." . $type . "\$#i", $filename)) {
$ok = 1;
}
}
if (!$ok) {
upload_doError(_ERROR_BADFILETYPE . $filename);
}
if (!is_uploaded_file($filetempname)) {
upload_doError(_ERROR_BADREQUEST);
}
// prefix filename with current date (YYYYMMDD-HHMMSS-)
// this to avoid nameclashes
if ($CONF['MediaPrefix']) {
$filename = strftime("%Y%m%d-%H%M%S-", time()) . $filename;
}
// currently selected collection
$collection = requestVar('collection');
if (!$collection || !@is_dir($DIR_MEDIA . $collection)) {
$collection = $member->getID();
}
// avoid directory travarsal and accessing invalid directory
if (!MEDIA::isValidCollection($collection)) {
media_doError(_ERROR_DISALLOWED);
}
$res = MEDIA::addMediaObject($collection, $filetempname, $filename);
if ($res != '') {
upload_doError($res);
}
$url = $CONF['MediaURL'] . $collection . '/' . $filename;
if ($responseType != 'json') {
echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction(" . $funcNum . ", '" . $url . "', '');</script>";
} else {
$arr = array('uploaded' => 1, 'fileName' => $filename, 'url' => $url);
header("Content-Type: application/json; charset=utf-8");
echo json_encode($arr);
}
}