本文整理汇总了PHP中gps函数的典型用法代码示例。如果您正苦于以下问题:PHP gps函数的具体用法?PHP gps怎么用?PHP gps使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gps函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pagetop
function pagetop($pagetitle, $message = '', $msgclass = '')
{
global $css_mode, $siteurl, $sitename, $txp_user, $event;
$area = gps('area');
$event = !$event ? 'article' : $event;
$bm = gps('bm');
$privs = safe_field('privs', 'txp_users', "name = '" . doSlash($txp_user) . "'");
$GLOBALS['privs'] = $privs;
$areas = areas();
$area = false;
foreach ($areas as $k => $v) {
if (in_array($event, $v)) {
$area = $k;
break;
}
}
if (gps('logout')) {
$body_id = 'page-logout';
} elseif (!$txp_user) {
$body_id = 'page-login';
} else {
$body_id = 'page-' . $event;
}
$theme = 'default';
include txpath . DS . 'theme' . DS . $theme . DS . 'header.php';
}
示例2: page_edit
/**
* The main Page editor panel.
*
* @param string|array $message The activity message
*/
function page_edit($message = '')
{
global $event, $step;
pagetop(gTxt('edit_pages'), $message);
extract(array_map('assert_string', gpsa(array('copy', 'save_error', 'savenew'))));
$name = sanitizeForPage(assert_string(gps('name')));
$newname = sanitizeForPage(assert_string(gps('newname')));
if ($step == 'page_delete' || empty($name) && $step != 'page_new' && !$savenew) {
$name = safe_field('page', 'txp_section', "name = 'default'");
} elseif ((($copy || $savenew) && $newname || $newname && $newname != $name) && !$save_error) {
$name = $newname;
}
$buttons = n . tag(gTxt('page_name'), 'label', array('for' => 'new_page')) . br . fInput('text', 'newname', $name, 'input-medium', '', '', INPUT_MEDIUM, '', 'new_page', false, true);
if ($name) {
$buttons .= span(href(gTxt('duplicate'), '#', array('id' => 'txp_clone', 'class' => 'clone', 'title' => gTxt('page_clone'))), array('class' => 'txp-actions'));
} else {
$buttons .= hInput('savenew', 'savenew');
}
$html = !$save_error ? fetch('user_html', 'txp_page', 'name', $name) : gps('html');
// Format of each entry is popTagLink -> array ( gTxt() string, class/ID).
$tagbuild_items = array('page_article' => array('page_article_hed', 'article-tags'), 'page_article_nav' => array('page_article_nav_hed', 'article-nav-tags'), 'page_nav' => array('page_nav_hed', 'nav-tags'), 'page_xml' => array('page_xml_hed', 'xml-tags'), 'page_misc' => array('page_misc_hed', 'misc-tags'), 'page_file' => array('page_file_hed', 'file-tags'));
$tagbuild_links = '';
foreach ($tagbuild_items as $tb => $item) {
$tagbuild_links .= wrapRegion($item[1] . '_group', taglinks($tb), $item[1], $item[0], 'page_' . $item[1]);
}
echo hed(gTxt('tab_pages'), 1, array('class' => 'txp-heading'));
echo n . tag(n . tag(hed(gTxt('tagbuilder'), 2) . $tagbuild_links, 'div', array('id' => 'tagbuild_links', 'class' => 'txp-layout-cell txp-layout-1-4')) . n . tag(form(graf($buttons) . graf(tag(gTxt('page_code'), 'label', array('for' => 'html')) . br . '<textarea class="code" id="html" name="html" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_LARGE . '" dir="ltr">' . txpspecialchars($html) . '</textarea>') . graf(fInput('submit', '', gTxt('save'), 'publish') . eInput('page') . sInput('page_save') . hInput('name', $name)), '', '', 'post', 'edit-form', '', 'page_form'), 'div', array('id' => 'main_content', 'class' => 'txp-layout-cell txp-layout-2-4')) . n . tag(graf(sLink('page', 'page_new', gTxt('create_new_page')), ' class="action-create"') . page_list($name) . n, 'div', array('id' => 'content_switcher', 'class' => 'txp-layout-cell txp-layout-1-4')) . n, 'div', array('id' => $event . '_container', 'class' => 'txp-layout-grid'));
}
示例3: view_help
function view_help($message = '')
{
pagetop(gTxt('edit_plugins'), $message);
$filename = gps('filename');
$plugin = array();
if (!empty($filename)) {
$content = file($filename);
$source_lines = count($content);
$format = 'none';
for ($i = 0; $i < $source_lines; $i++) {
$content[$i] = rtrim($content[$i]);
}
$format = 'unknown';
// Check for ZEM plugin...
$plugin['help'] = _zem_extract_section($content, 'HELP');
if ('' != $plugin['help']) {
$format = 'zem_help';
} else {
// check for ied style help section...
$plugin['help'] = _ied_extract_section($content, 'HELP');
if ('' != $plugin['help']) {
$format = 'ied_help';
}
}
echo startTable('edit');
switch ($format) {
case 'zem_help':
echo tr(tda('<p>Plugin is in zem template format.</p>', ' width="600"'));
if (!isset($plugin['allow_html_help']) or 0 === $plugin['allow_html_help']) {
# Textile...
$plugin['css'] = _zem_extract_section($content, 'CSS');
include_once txpath . '/lib/classTextile.php';
if (class_exists('Textile')) {
$textile = new Textile();
$plugin['help'] = $plugin['css'] . n . $textile->TextileThis($plugin['help']);
echo tr(tda('<p>Extracted and Textile processed help section follows…</p><hr>', ' width="600"'));
} else {
echo tr(tda('<p>Extracted help section follows, <strong>Textile Processing Failed</strong>…</p><hr>', ' width="600"'));
}
} else {
# (x)html...
$plugin['css'] = _zem_extract_section($content, 'CSS');
$plugin['help'] = $plugin['css'] . n . $plugin['help_raw'];
}
echo tr(tda($plugin['help'], ' width="600"'));
break;
case 'ied_help':
echo tr(tda('<p>Plugin is in ied template format.</p>', ' width="600"'));
echo tr(tda('<p>Extracted raw help section follows…</p><hr>', ' width="600"'));
echo tr(tda($plugin['help'], ' width="600"'));
break;
default:
echo tr(tda('<p><strong>Unknown plugin file format or empty help section.</strong></p><hr>', ' width="600"'));
break;
}
echo endTable();
} else {
echo 'Help not accessible from that file.';
}
}
示例4: plugin_help
function plugin_help()
{
$name = gps('name');
pagetop(gTxt('plugin_help'));
$help = $name ? safe_field('help', 'txp_plugin', "name = '" . doSlash($name) . "'") : '';
echo startTable('edit') . tr(tda($help, ' width="600"')) . endTable();
}
示例5: doTxpValidate
function doTxpValidate()
{
global $logout, $txpcfg;
$p_userid = ps('p_userid');
$p_password = ps('p_password');
$logout = gps('logout');
$stay = ps('stay');
if ($logout) {
setcookie('txp_login', '', time() - 3600);
}
if (!empty($_COOKIE['txp_login']) and !$logout) {
// cookie exists
@(list($c_userid, $cookie_hash) = split(',', $_COOKIE['txp_login']));
$nonce = safe_field('nonce', 'txp_users', "name='{$c_userid}'");
if (md5($c_userid . $nonce) === $cookie_hash && $nonce) {
// check nonce
$GLOBALS['txp_user'] = $c_userid;
// cookie is good, create $txp_user
return '';
} else {
// something's gone wrong
$GLOBALS['txp_user'] = '';
setcookie('txp_login', '', time() - 3600);
return gTxt('bad_cookie');
}
} elseif ($p_userid and $p_password) {
// no cookie, but incoming login vars
sleep(3);
// should grind dictionary attacks to a halt
if (txp_validate($p_userid, $p_password)) {
$nonce = safe_field('nonce', 'txp_users', "name='{$p_userid}'");
if (!$nonce) {
define('TXP_UPDATE', 1);
include_once txpath . '/update/_update.php';
exit(graf('Please reload'));
}
if ($stay) {
// persistent cookie required
setcookie('txp_login', $p_userid . ',' . md5($p_userid . $nonce), time() + 3600 * 24 * 365);
// expires in 1 year
} else {
// session-only cookie required
setcookie('txp_login', $p_userid . ',' . md5($p_userid . $nonce));
setcookie('txp_nostay', '1', time() + 3600 * 24 * 365);
// remember nostay for 1 year
}
$GLOBALS['txp_user'] = $p_userid;
// login is good, create $txp_user
return '';
} else {
$GLOBALS['txp_user'] = '';
return gTxt('could_not_log_in');
}
} else {
$GLOBALS['txp_user'] = '';
return gTxt('login_to_textpattern');
}
}
示例6: change_email
function change_email()
{
global $txp_user;
$new_email = gps('new_email');
$rs = safe_update("txp_users", "email = '{$new_email}'", "name = '{$txp_user}'");
if ($rs) {
admin('email address changed to ' . $new_email);
}
}
示例7: edit_plugin
function edit_plugin()
{
$name = gps('name');
pagetop(gTxt('edit_plugins'));
echo plugin_edit_form($name);
// echo graf('<a href="?event=plugin'.
// a.'step=view_hilighted'.
// a.'name='.urlencode($name).
// '">View highlighted</a>');
}
示例8: doTxpValidate
function doTxpValidate()
{
global $logout, $txpcfg;
$p_userid = ps('p_userid');
$p_password = ps('p_password');
$logout = gps('logout');
$stay = ps('stay');
if ($logout) {
setcookie('txp_login', ' ', time() - 3600);
}
if (isset($_COOKIE['txp_login']) and !$logout) {
// cookie exists
list($c_userid, $cookie_hash) = split(',', $_COOKIE['txp_login']);
$nonce = safe_field('nonce', 'txp_users', "name='{$c_userid}'");
if (md5($c_userid . $nonce) == $cookie_hash) {
// check secret word
$GLOBALS['txp_user'] = $c_userid;
// cookie is good, create $txp_user
return '';
} else {
// something's gone wrong
$GLOBALS['txp_user'] = '';
setcookie('txp_login', '', time() - 3600);
return gTxt('bad_cookie');
}
} elseif ($p_userid and $p_password) {
// no cookie, but incoming login vars
sleep(3);
// should grind dictionary attacks to a halt
if (txp_validate($p_userid, $p_password)) {
$nonce = safe_field('nonce', 'txp_users', "name='{$p_userid}'");
if (!$nonce) {
exit(graf('Missing authentication information.
Please run _update.php'));
}
if ($stay) {
// persistent cookie required
setcookie('txp_login', $p_userid . ',' . md5($p_userid . $nonce), time() + 3600 * 24 * 365);
// expires in 1 year
} else {
// session-only cookie required
setcookie('txp_login', $p_userid . ',' . md5($p_userid . $nonce));
}
$GLOBALS['txp_user'] = $p_userid;
// login is good, create $txp_user
return '';
} else {
$GLOBALS['txp_user'] = '';
return gTxt('could_not_log_in');
}
} else {
$GLOBALS['txp_user'] = '';
return gTxt('login_to_textpattern');
}
}
示例9: change_email
function change_email()
{
global $txp_user;
$new_email = gps('new_email');
if (!is_valid_email($new_email)) {
author_list(array(gTxt('email_required'), E_ERROR));
return;
}
$rs = safe_update('txp_users', "email = '" . doSlash($new_email) . "'", "name = '" . doSlash($txp_user) . "'");
author_list($rs ? gTxt('email_changed', array('{email}' => $new_email)) : gTxt(array('author_save_failed', E_ERROR)));
}
示例10: doTxpValidate
function doTxpValidate()
{
global $logout, $txpcfg, $txp_user;
$p_userid = ps('p_userid');
$p_password = ps('p_password');
$logout = gps('logout');
$stay = ps('stay');
if ($logout) {
setcookie('txp_login', '', time() - 3600);
}
if (!empty($_COOKIE['txp_login']) and !$logout) {
@(list($c_userid, $cookie_hash) = split(',', cs('txp_login')));
$nonce = safe_field('nonce', 'txp_users', "name='" . doSlash($c_userid) . "'");
if ($nonce && $nonce === md5($c_userid . pack('H*', $cookie_hash))) {
// cookie is good, create $txp_user
$txp_user = $c_userid;
return '';
} else {
// something's gone wrong
$txp_user = '';
setcookie('txp_login', '', time() - 3600);
return gTxt('bad_cookie');
}
} elseif ($p_userid and $p_password) {
sleep(3);
// should grind dictionary attacks to a halt
if (txp_validate($p_userid, $p_password)) {
$cookie_hash = md5(uniqid(rand()));
safe_update('txp_users', "nonce = '" . doSlash(md5($p_userid . pack('H*', $cookie_hash))) . "'", "name = '" . doSlash($p_userid) . "'");
if ($stay) {
setcookie('txp_login', $p_userid . ',' . $cookie_hash, time() + 3600 * 24 * 365);
// expires in 1 year
if (cs('txp_nostay')) {
setcookie('txp_nostay', '', time() - 3600);
}
} else {
setcookie('txp_login', $p_userid . ',' . $cookie_hash);
setcookie('txp_nostay', '1', time() + 3600 * 24 * 365);
// remember nostay for 1 year
}
$txp_user = $p_userid;
// login is good, create $txp_user
return '';
} else {
$txp_user = '';
return gTxt('could_not_log_in');
}
} else {
$txp_user = '';
return gTxt('login_to_textpattern');
}
}
示例11: change_email
function change_email()
{
global $txp_user;
$new_email = gps('new_email');
if (!is_valid_email($new_email)) {
admin(gTxt('email_required'));
return;
}
$rs = safe_update('txp_users', "email = '" . doSlash($new_email) . "'", "name = '" . doSlash($txp_user) . "'");
if ($rs) {
admin(gTxt('email_changed', array('{email}' => $new_email)));
}
}
示例12: jmd_sitemap
function jmd_sitemap($event, $step)
{
global $prefs;
$sitemap = new JMD_Sitemap();
// Generate sitemap
if ($step == ('create' || 'edit' || 'update')) {
$excluded = gps('exclude');
if ($excluded) {
$excluded = serialize($excluded);
$prefs['jmd_sitemap_exclude'] = $excluded;
safe_update("txp_prefs", "val = '{$excluded}'", "name = 'jmd_sitemap_exclude'");
}
$sitemap->writeSitemap();
}
// Extensions tab
if ($event == 'jmd_sitemap') {
pageTop('jmd_sitemap', $step ? _jmd_sitemap_gtxt('sitemap_updated') : '');
echo '<div id="jmd_sitemap" style="width: 350px; margin: 0 auto">';
// File errors
if (file_exists($sitemap->filename)) {
if (!is_writable($sitemap->filename)) {
$fileError = _jmd_sitemap_gtxt('error_not_writable');
}
} else {
$fileError = _jmd_sitemap_gtxt('error_doesnt_exist');
}
if (isset($fileError)) {
echo tag($sitemap->filename . ' ' . $fileError, 'p', ' class="not-ok"');
}
$out = '<label for="exclude">' . _jmd_sitemap_gtxt('exclude_sections') . ':</label><br/>
<select id="exclude" name="exclude[]" multiple="multiple"
size="5" style="width: 150px; margin: 3px 0 10px">';
// Exclude sections
$exclude = $prefs['jmd_sitemap_exclude'];
$exclude = unserialize($exclude);
$sections = safe_column("name", "txp_section", "name != 'default'");
foreach ($sections as $section) {
$out .= '<option name="' . $section . '"';
// Select excluded
if (in_array($section, $exclude)) {
$out .= ' selected="selected"';
}
$out .= ">{$section}</option>";
}
$out .= '</select><br/>';
echo form($out . tag(_jmd_sitemap_gtxt('update_sitemap'), 'button') . eInput('jmd_sitemap') . sInput('update'));
echo '</div><!--//jmd_sitemap-->';
}
}
示例13: page_edit
/**
* The main Page editor panel.
*
* @param string|array $message The activity message
*/
function page_edit($message = '')
{
global $event, $step;
pagetop(gTxt('edit_pages'), $message);
extract(array_map('assert_string', gpsa(array('copy', 'save_error', 'savenew'))));
$name = sanitizeForPage(assert_string(gps('name')));
$newname = sanitizeForPage(assert_string(gps('newname')));
if ($step == 'page_delete' || empty($name) && $step != 'page_new' && !$savenew) {
$name = safe_field("page", 'txp_section', "name = 'default'");
} elseif ((($copy || $savenew) && $newname || $newname && $newname != $name) && !$save_error) {
$name = $newname;
}
$titleblock = inputLabel('new_page', fInput('text', 'newname', $name, 'input-medium', '', '', INPUT_MEDIUM, '', 'new_page', false, true), 'page_name', array('', 'instructions_page_name'), array('class' => 'txp-form-field'));
if ($name === '') {
$titleblock .= hInput('savenew', 'savenew');
} else {
$titleblock .= hInput('name', $name);
}
$titleblock .= eInput('page') . sInput('page_save');
$html = !$save_error ? fetch('user_html', 'txp_page', 'name', $name) : gps('html');
// Format of each entry is popTagLink -> array ( gTxt() string, class/ID).
$tagbuild_items = array('page_article' => array('page_article_hed', 'article-tags'), 'page_article_nav' => array('page_article_nav_hed', 'article-nav-tags'), 'page_nav' => array('page_nav_hed', 'nav-tags'), 'page_xml' => array('page_xml_hed', 'xml-tags'), 'page_misc' => array('page_misc_hed', 'misc-tags'), 'page_file' => array('page_file_hed', 'file-tags'));
$tagbuild_links = '';
foreach ($tagbuild_items as $tb => $item) {
$tagbuild_links .= wrapRegion($item[1] . '_group', taglinks($tb), $item[1], $item[0], 'page_' . $item[1]);
}
// Pages code columm.
echo n . tag(hed(gTxt('tab_pages'), 1, array('class' => 'txp-heading')) . form($titleblock . inputLabel('html', '<textarea class="code" id="html" name="html" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_LARGE . '" dir="ltr">' . txpspecialchars($html) . '</textarea>', 'page_code', array('', 'instructions_page_code'), array('class' => 'txp-form-field')), '', '', 'post', '', '', 'page_form'), 'div', array('class' => 'txp-layout-4col-cell-1-2-3', 'id' => 'main_content', 'role' => 'region'));
// Pages create/switcher column.
$buttonExtras = '';
if ($name) {
$buttonExtras .= href('<span class="ui-icon ui-icon-copy"></span> ' . gTxt('duplicate'), '#', array('class' => 'txp-clone', 'data-form' => 'page_form'));
}
$buttons = graf(tag_void('input', array('class' => 'publish', 'type' => 'submit', 'method' => 'post', 'value' => gTxt('save'), 'form' => 'page_form')), ' class="txp-save"') . graf(sLink('page', 'page_new', '<span class="ui-icon ui-extra-icon-new-document"></span> ' . gTxt('create_new_page'), 'txp-new') . $buttonExtras, array('class' => 'txp-actions'));
echo n . tag($buttons . page_list($name) . n, 'div', array('class' => 'txp-layout-4col-cell-4alt', 'id' => 'content_switcher', 'role' => 'region'));
// Pages tag builder column. TODO: make this a modal?
// echo n.tag(
// hed(gTxt('tagbuilder'), 2).
// $tagbuild_links
// , 'div', array(
// 'class' => '',
// 'id' => 'tagbuild_links',
// ));
}
示例14: log_list
function log_list()
{
pagetop(gTxt('visitor_logs'));
extract(get_prefs());
safe_delete("txp_log", "`time` < date_sub(now(),interval " . $expire_logs_after . " day)");
safe_optimize("txp_log");
safe_repair("txp_log");
$page = gps('page');
$total = getCount('txp_log', "1");
$limit = 50;
$numPages = ceil($total / $limit);
$page = !$page ? 1 : $page;
$offset = ($page - 1) * $limit;
$nav[] = $page > 1 ? PrevNextLink("log", $page - 1, gTxt('prev'), 'prev') : '';
$nav[] = sp . small($page . '/' . $numPages) . sp;
$nav[] = $page != $numPages ? PrevNextLink("log", $page + 1, gTxt('next'), 'next') : '';
$rs = safe_rows_start("*, unix_timestamp(time) as stamp", "txp_log", "1 order by time desc limit {$offset},{$limit}");
if ($rs) {
echo startTable('list'), assHead('time', 'host', 'page', 'referrer');
$stamp = '';
while ($a = nextRow($rs)) {
extract($a);
if ($refer) {
$referprint = preg_replace("/^www\\./", "", chunk(htmlspecialchars($refer), 50));
$referprint = '<a href="http://' . htmlspecialchars($refer) . '">' . $referprint . '</a>';
} else {
$referprint = ' ';
}
$pageprint = preg_replace('/\\/$/', '', htmlspecialchars(substr($page, 1)));
$pageprint = $pageprint == '' ? '' : '<a href="' . htmlspecialchars($page) . '" target="_blank">' . chunk($pageprint, 50) . '</a>';
if ($method == 'POST') {
$pageprint = '<b>' . $pageprint . '</b>';
}
$fstamp = date("n/j g:i a", $stamp + tz_offset());
$hostprint = chunk($host, 40);
echo tr(td($fstamp) . td($hostprint) . td($pageprint) . td($referprint));
unset($refer, $referprint, $page, $pageprint);
}
echo '<tr><td colspan="4" align="right" style="padding:10px">', join('', $nav), "</td></tr>", endTable();
} else {
echo graf(gTxt('no_refers_recorded'), ' align="center"');
}
}
示例15: mdp_calendar_calcDates
function mdp_calendar_calcDates($year = '', $month = '', $static, $calid)
{
global $gmtoffset, $is_dst;
// Since year and date are now attributes, first check to make sure the user
// hasn't set them.
$incoming_calid = gps('calid');
$incoming_year = (gps('y') and is_numeric(gps('y'))) ? (int) gps('y') : '';
$incoming_month = (gps('m') and is_numeric(gps('m'))) ? (int) gps('m') : '';
if ($static) {
// if we're static w/o any supplied var's, use the current
if (!$year) {
$year = safe_strftime('%Y');
}
if (!$month) {
$month = safe_strftime('%m');
}
} else {
// otherwise use current only if we arn't passed something else
if ($calid == $incoming_calid) {
// use incoming
if (!$year) {
$year = $incoming_year ? $incoming_year : safe_strftime('%Y');
}
if (!$month) {
$month = $incoming_month ? $incoming_month : safe_strftime('%m');
}
} else {
// use current
if (!$year) {
$year = safe_strftime('%Y');
}
if (!$month) {
$month = safe_strftime('%m');
}
}
}
// The times in the DB are stored using the servers localtime, so we don't
// want to adjust anything since mktime uses the servers localtime.
$ts_first = mktime(0, 0, 0, $month, 1, $year);
$ts_last = mktime(23, 59, 59, $month, date('t', $ts_first), $year);
return array('year' => $year, 'month' => $month, 'ts_first' => $ts_first, 'ts_last' => $ts_last);
}