本文整理汇总了PHP中fix_id函数的典型用法代码示例。如果您正苦于以下问题:PHP fix_id函数的具体用法?PHP fix_id怎么用?PHP fix_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fix_id函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: start
/**
* Start a new session. This function is called
* once by main initialization script and should not
* be used in other parts of the system.
*
* @note: When session is set to TYPE_NORMAL some
* versions of IE will create new session on each page
* load. This is due to bug in IE which accepts
* cookies in GMT but checks for their validity in
* local time zone. Since our cookies are set to
* expire in 15 minutes, they are expired before they
* are stored. Using TYPE_BROWSER solves this issue.
*/
public static function start()
{
global $session_type;
$type = $session_type;
$normal_duration = null;
// get current session type
if (isset($_COOKIE[Session::COOKIE_TYPE])) {
$type = fix_id($_COOKIE[Session::COOKIE_TYPE]);
}
// configure default duration
switch ($type) {
case Session::TYPE_BROWSER:
session_set_cookie_params(0, Session::get_path());
break;
case Session::TYPE_NORMAL:
default:
$normal_duration = Session::DEFAULT_DURATION * 60;
session_set_cookie_params($normal_duration, Session::get_path());
break;
}
// start session
session_name(Session::COOKIE_ID);
session_start();
// extend expiration for normal type
if ($type == Session::TYPE_NORMAL) {
setcookie(Session::COOKIE_ID, session_id(), time() + $normal_duration, Session::get_path());
setcookie(Session::COOKIE_TYPE, Session::TYPE_NORMAL, time() + $normal_duration, Session::get_path());
}
}
开发者ID:tareqy,项目名称:Caracal,代码行数:42,代码来源:session.php
示例2: transferControl
/**
* Transfers control to module functions
*
* @param array $params
* @param array $children
*/
public function transferControl($params, $children)
{
// global control actions
if (isset($params['action'])) {
switch ($params['action']) {
case 'set_omit_elements':
$this->omit_elements = fix_chars(explode(',', $params['elements']));
break;
case 'set_optimizer_page':
$this->optimizer_page = fix_chars($params['page']);
if (isset($params['show_control'])) {
$this->optimizer_show_control = fix_id($params['show_control']) == 0 ? false : true;
}
break;
case 'set_description':
$this->setDescription($params, $children);
break;
default:
break;
}
}
// backend control actions
if (isset($params['backend_action'])) {
switch ($params['backend_action']) {
case 'show':
$this->showSettings();
break;
case 'save':
$this->saveSettings();
break;
default:
break;
}
}
}
开发者ID:tareqy,项目名称:Caracal,代码行数:41,代码来源:page_info.php
示例3: __construct
/**
* Constructor
*
* @param string $param_name
*/
public function __construct($param_name = null)
{
if (!is_null($param_name)) {
$this->param_name = $param_name;
}
if (isset($_REQUEST[$this->param_name])) {
$this->current_page = fix_id($_REQUEST[$this->param_name]);
}
}
开发者ID:tareqy,项目名称:Caracal,代码行数:14,代码来源:page_switch.php
示例4: tag_ResultList
/**
* Handle printing search results
*
* Modules need to return results in following format:
* array(
* array(
* 'score' => 0..100 // score for this result
* 'title' => '', // title to be shown in list
* 'description' => '', // short description, if exists
* 'id' => 0, // id of containing item
* 'type' => '', // type of item
* 'module' => '' // module name
* ),
* ...
* );
*
* Resulting array doesn't need to be sorted.
*
* @param array $tag_params
* @param array $children
*/
public function tag_ResultList($tag_params, $children)
{
// get search query
$query_string = null;
$threshold = 25;
$limit = 30;
// get query
if (isset($tag_params['query'])) {
$query_string = mb_strtolower(fix_chars($tag_params['query']));
}
if (isset($_REQUEST['query']) && is_null($query_string)) {
$query_string = mb_strtolower(fix_chars($_REQUEST['query']));
}
if (is_null($query_string)) {
return;
}
// get threshold
if (isset($tag_params['threshold'])) {
$threshold = fix_chars($tag_params['threshold']);
}
if (isset($_REQUEST['threshold']) && is_null($threshold)) {
$threshold = fix_chars($_REQUEST['threshold']);
}
// get limit
if (isset($tag_params['limit'])) {
$limit = fix_id($tag_params['limit']);
}
// get list of modules to search on
$module_list = null;
if (isset($tag_params['module_list'])) {
$module_list = fix_chars(split(',', $tag_params['module_list']));
}
if (isset($_REQUEST['module_list']) && is_null($module_list)) {
$module_list = fix_chars(split(',', $_REQUEST['module_list']));
}
if (is_null($module_list)) {
$module_list = array_keys($this->modules);
}
// get intersection of available and specified modules
$available_modules = array_keys($this->modules);
$module_list = array_intersect($available_modules, $module_list);
// get results from modules
$results = array();
if (count($module_list) > 0) {
foreach ($module_list as $name) {
$module = $this->modules[$name];
$results = array_merge($results, $module->getSearchResults($query_string, $threshold));
}
}
// sort results
usort($results, array($this, 'sortResults'));
// apply limit
if ($limit > 0) {
$results = array_slice($results, 0, $limit);
}
// load template
$template = $this->loadTemplate($tag_params, 'result.xml');
// parse results
if (count($results) > 0) {
foreach ($results as $params) {
$template->setLocalParams($params);
$template->restoreXML();
$template->parse();
}
}
}
开发者ID:tareqy,项目名称:Caracal,代码行数:87,代码来源:search.php
示例5: apply_tempcode_escaping_inline
/**
* Apply whatever escaping is requested to the given value.
*
* @param array A list of escaping to do
* @param string The string to apply the escapings to
* @return string Output string
*/
function apply_tempcode_escaping_inline($escaped, $value)
{
global $HTML_ESCAPE_1_STRREP, $HTML_ESCAPE_2;
foreach (array_reverse($escaped) as $escape) {
if ($escape == ENTITY_ESCAPED) {
$value = str_replace($HTML_ESCAPE_1_STRREP, $HTML_ESCAPE_2, $value);
} elseif ($escape == FORCIBLY_ENTITY_ESCAPED) {
$value = str_replace($HTML_ESCAPE_1_STRREP, $HTML_ESCAPE_2, $value);
} elseif ($escape == SQ_ESCAPED) {
$value = str_replace(''', '\\'', str_replace('\'', '\\\'', str_replace('\\', '\\\\', $value)));
} elseif ($escape == DQ_ESCAPED) {
$value = str_replace('"', '\\"', str_replace('"', '\\"', str_replace('\\', '\\\\', $value)));
} elseif ($escape == NL_ESCAPED) {
$value = str_replace(chr(13), '', str_replace(chr(10), '', $value));
} elseif ($escape == NL2_ESCAPED) {
$value = str_replace(chr(13), '', str_replace(chr(10), '\\n', $value));
} elseif ($escape == CC_ESCAPED) {
$value = str_replace('[', '\\[', str_replace('\\', '\\\\', $value));
} elseif ($escape == UL_ESCAPED) {
$value = ocp_url_encode($value);
} elseif ($escape == UL2_ESCAPED) {
$value = rawurlencode($value);
} elseif ($escape == JSHTML_ESCAPED) {
$value = str_replace(']]>', ']]\'+\'>', str_replace('</', '<\\/', $value));
} elseif ($escape == ID_ESCAPED) {
$value = fix_id($value);
} elseif ($escape == CSS_ESCAPED) {
$value = preg_replace('#[^\\w\\#\\.\\-\\%]#', '_', $value);
} elseif ($escape == NAUGHTY_ESCAPED) {
$value = filter_naughty_harsh($value, true);
}
}
if ($GLOBALS['XSS_DETECT'] && $escaped != array()) {
ocp_mark_as_escaped($value);
}
return $value;
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:44,代码来源:tempcode__runtime.php
示例6: actualise_post_comment
/**
* Add comments to the specified resource.
*
* @param boolean Whether this resource allows comments (if not, this function does nothing - but it's nice to move out this common logic into the shared function)
* @param ID_TEXT The type (download, etc) that this commenting is for
* @param ID_TEXT The ID of the type that this commenting is for
* @param mixed The URL to where the commenting will pass back to (to put into the comment topic header) (URLPATH or Tempcode)
* @param ?string The title to where the commenting will pass back to (to put into the comment topic header) (NULL: don't know, but not first post so not important)
* @param ?string The name of the forum to use (NULL: default comment forum)
* @param boolean Whether to not require a captcha
* @param ?BINARY Whether the post is validated (NULL: unknown, find whether it needs to be marked unvalidated initially). This only works with the OCF driver (hence is the last parameter).
* @param boolean Whether to force allowance
* @param boolean Whether to skip a success message
* @param boolean Whether posts made should not be shared
* @return boolean Whether a hidden post has been made
*/
function actualise_post_comment($allow_comments, $content_type, $content_id, $content_url, $content_title, $forum = NULL, $avoid_captcha = false, $validated = NULL, $explicit_allow = false, $no_success_message = false, $private = false)
{
if (!$explicit_allow) {
if (get_option('is_on_comments') == '0' || !$allow_comments) {
return false;
}
if (!has_specific_permission(get_member(), 'comment', get_page_name())) {
return false;
}
}
if (running_script('preview')) {
return false;
}
$forum_tie = get_option('is_on_strong_forum_tie') == '1';
if (addon_installed('captcha')) {
if (array_key_exists('post', $_POST) && $_POST['post'] != '' && !$avoid_captcha) {
require_code('captcha');
enforce_captcha();
}
}
$post_title = post_param('title', NULL);
if (is_null($post_title) && !$forum_tie) {
return false;
}
$post = post_param('post', NULL);
if ($post == do_lang('POST_WARNING')) {
$post = '';
}
if ($post == do_lang('THREADED_REPLY_NOTICE', do_lang('POST_WARNING'))) {
$post = '';
}
if ($post == '' && $post_title !== '') {
$post = $post_title;
$post_title = '';
}
if ($post === '') {
warn_exit(do_lang_tempcode('NO_PARAMETER_SENT', 'post'));
}
if (is_null($post)) {
$post = '';
}
$email = trim(post_param('email', ''));
if ($email != '') {
$body = '> ' . str_replace(chr(10), chr(10) . '> ', $post);
if (substr($body, -2) == '> ') {
$body = substr($body, 0, strlen($body) - 2);
}
if (get_page_name() != 'tickets') {
$post .= '[staff_note]';
}
$post .= "\n\n" . '[email subject="Re: ' . comcode_escape($post_title) . ' [' . get_site_name() . ']" body="' . comcode_escape($body) . '"]' . $email . '[/email]' . "\n\n";
if (get_page_name() != 'tickets') {
$post .= '[/staff_note]';
}
}
$content_title = strip_comcode($content_title);
if (is_null($forum)) {
$forum = get_option('comments_forum_name');
}
$content_url_flat = is_object($content_url) ? $content_url->evaluate() : $content_url;
$_parent_id = post_param('parent_id', '');
$parent_id = $_parent_id == '' ? NULL : intval($_parent_id);
$poster_name_if_guest = post_param('poster_name_if_guest', '');
list($topic_id, $is_hidden) = $GLOBALS['FORUM_DRIVER']->make_post_forum_topic($forum, $content_type . '_' . $content_id, get_member(), $post_title, $post, $content_title, do_lang('COMMENT'), $content_url_flat, NULL, NULL, $validated, $explicit_allow ? 1 : NULL, $explicit_allow, $poster_name_if_guest, $parent_id, false, !$private && $post != '' ? 'comment_posted' : NULL, !$private && $post != '' ? $content_type . '_' . $content_id : NULL);
if (!is_null($topic_id)) {
if (!is_integer($forum)) {
$forum_id = $GLOBALS['FORUM_DRIVER']->forum_id_from_name($forum);
} else {
$forum_id = (int) $forum;
}
if (get_forum_type() == 'ocf' && !is_null($GLOBALS['LAST_POST_ID'])) {
$extra_review_ratings = array();
global $REVIEWS_STRUCTURE;
if (array_key_exists($content_type, $REVIEWS_STRUCTURE)) {
$reviews_rating_criteria = $REVIEWS_STRUCTURE[$content_type];
} else {
$reviews_rating_criteria[] = '';
}
foreach ($reviews_rating_criteria as $rating_type) {
// Has there actually been any rating?
$rating = post_param_integer('review_rating__' . fix_id($rating_type), NULL);
if (!is_null($rating)) {
if ($rating > 10 || $rating < 1) {
log_hack_attack_and_exit('VOTE_CHEAT');
//.........这里部分代码省略.........
开发者ID:erico-deh,项目名称:ocPortal,代码行数:101,代码来源:feedback.php
示例7: tag_ValueList
/**
* Handle item size values tag
*
* @param array $tag_params
* @param array $childen
*/
public function tag_ValueList($tag_params, $children)
{
$manager = ShopItemSizeValuesManager::getInstance();
$conditions = array();
// create conditions
if (isset($tag_params['definition'])) {
$conditions['definition'] = fix_id($tag_params['definition']);
}
// get items from database
$items = $manager->getItems($manager->getFieldNames(), $conditions);
// create template
$template = $this->_parent->loadTemplate($tag_params, 'values_list_item.xml');
$template->setMappedModule($this->name);
// parse template
if (count($items) > 0) {
foreach ($items as $item) {
$params = array('id' => $item->id, 'value' => $item->value, 'item_change' => url_MakeHyperlink($this->_parent->getLanguageConstant('change'), window_Open('shop_item_size_values_change', 370, $this->_parent->getLanguageConstant('title_size_value_change'), true, true, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'sizes'), array('sub_action', 'value_change'), array('id', $item->id)))), 'item_delete' => url_MakeHyperlink($this->_parent->getLanguageConstant('delete'), window_Open('shop_item_size_values_delete', 400, $this->_parent->getLanguageConstant('title_size_value_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'sizes'), array('sub_action', 'value_delete'), array('id', $item->id)))));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
}
}
开发者ID:tareqy,项目名称:Caracal,代码行数:29,代码来源:shop_item_sizes_handler.php
示例8: deleteUser_Commit
/**
* Perform user removal
*/
private function deleteUser_Commit()
{
$id = fix_id($_REQUEST['id']);
$manager = UserManager::getInstance();
// trigger event
$user = $manager->getSingleItem($manager->getFieldNames(), array('id' => $id));
Events::trigger('backend', 'user-delete', $user);
// remove user from database
$manager->deleteData(array('id' => $id));
$template = new TemplateHandler('message.xml', $this->parent->path . 'templates/');
$template->setMappedModule($this->parent->name);
$params = array('message' => $this->parent->getLanguageConstant('message_users_deleted'), 'button' => $this->parent->getLanguageConstant('close'), 'action' => window_Close('system_users_delete') . ';' . window_ReloadContent('system_users'));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
开发者ID:tareqy,项目名称:Caracal,代码行数:19,代码来源:user_manager.php
示例9: tag_Times
/**
* Handle drawing time list.
*
* @param array $tag_params
* @param array $children
*/
public function tag_Times($tag_params, $children)
{
$manager = IntervalTimeManager::getInstance();
$conditions = array();
$order_by = array('start');
if (isset($tag_params['interval'])) {
$conditions['interval'] = fix_id($tag_params['interval']);
} else {
$conditions['interval'] = -1;
}
// get all times
$times = $manager->getItems($manager->getFieldNames(), $conditions, $order_by, True);
// load template
$template = $this->loadTemplate($tag_params, 'time.xml');
if (count($times) > 0) {
foreach ($times as $time) {
$params = array('start' => $time->start, 'end' => $time->end, 'price' => $time->amount);
$template->setLocalParams($params);
$template->restoreXML();
$template->parse();
}
}
}
开发者ID:Way2CU,项目名称:Bali-Shuk-Store,代码行数:29,代码来源:delivery.php
示例10: printCommentData
/**
* Print JSON object containing all the comments
*
* @param boolean $only_visible
*/
private function printCommentData($only_visible = true)
{
$module = isset($_REQUEST['module']) && !empty($_REQUEST['module']) ? fix_chars($_REQUEST['module']) : null;
$comment_section = isset($_REQUEST['comment_section']) && !empty($_REQUEST['comment_section']) ? fix_chars($_REQUEST['comment_section']) : null;
$result = array();
if (!is_null($module) || !is_null($comment_section)) {
$result['error'] = 0;
$result['error_message'] = '';
$starting_with = isset($_REQUEST['starting_with']) ? fix_id($_REQUEST['starting_with']) : null;
$manager = CommentManager::getInstance();
$conditions = array('module' => $module, 'section' => $comment_section);
if (!is_null($starting_with)) {
$conditions['id'] = array('operator' => '>', 'value' => $starting_with);
}
if ($only_visible) {
$conditions['visible'] = 1;
}
$items = $manager->getItems(array('id', 'user', 'message', 'timestamp'), $conditions);
$result['last_id'] = 0;
$result['comments'] = array();
if (count($items) > 0) {
foreach ($items as $item) {
$timestamp = strtotime($item->timestamp);
$date = date($this->getLanguageConstant('format_date_short'), $timestamp);
$time = date($this->getLanguageConstant('format_time_short'), $timestamp);
$result['comments'][] = array('id' => $item->id, 'user' => empty($item->user) ? 'Anonymous' : $item->user, 'content' => $item->message, 'date' => $date, 'time' => $time);
}
$result['last_id'] = end($items)->id;
}
} else {
// no comments_section and/or module specified
$result['error'] = 1;
$result['error_message'] = $this->getLanguageConstant('message_error_data');
}
print json_encode($result);
}
开发者ID:tareqy,项目名称:Caracal,代码行数:41,代码来源:comments.php
示例11: tag_CategoryList
/**
* Tag handler for category list
*
* @param array $tag_params
* @param array $children
*/
public function tag_CategoryList($tag_params, $children)
{
global $language;
$manager = ShopCategoryManager::getInstance();
$conditions = array();
$order_by = array();
$order_asc = true;
$item_category_ids = array();
$item_id = isset($tag_params['item_id']) ? fix_id($tag_params['item_id']) : null;
// create conditions
if (isset($tag_params['parent_id'])) {
// set parent from tag parameter
$conditions['parent'] = fix_id($tag_params['parent_id']);
} else {
if (isset($tag_params['parent'])) {
// get parent id from specified text id
$text_id = fix_chars($tag_params['parent']);
$parent = $manager->getSingleItem(array('id'), array('text_id' => $text_id));
if (is_object($parent)) {
$conditions['parent'] = $parent->id;
} else {
$conditions['parent'] = -1;
}
} else {
if (!isset($tag_params['show_all'])) {
$conditions['parent'] = 0;
}
}
}
if (isset($tag_params['level'])) {
$level = fix_id($tag_params['level']);
} else {
$level = 0;
}
if (isset($tag_params['exclude'])) {
$list = fix_id(explode(',', $tag_params['exclude']));
$conditions['id'] = array('operator' => 'NOT IN', 'value' => $list);
}
if (!is_null($item_id)) {
$membership_manager = ShopItemMembershipManager::getInstance();
$membership_items = $membership_manager->getItems(array('category'), array('item' => $item_id));
if (count($membership_items) > 0) {
foreach ($membership_items as $membership) {
$item_category_ids[] = $membership->category;
}
}
}
// get order list
if (isset($tag_params['order_by'])) {
$order_by = fix_chars(split(',', $tag_params['order_by']));
} else {
$order_by = array('title_' . $language);
}
if (isset($tag_params['order_ascending'])) {
$order_asc = $tag_params['order_asc'] == '1' or $tag_params['order_asc'] == 'yes';
} else {
// get items from database
$items = $manager->getItems($manager->getFieldNames(), $conditions, $order_by, $order_asc);
}
// create template handler
$template = $this->_parent->loadTemplate($tag_params, 'category_list_item.xml');
$template->registerTagHandler('_children', $this, 'tag_CategoryList');
// initialize index
$index = 0;
// parse template
if (count($items) > 0) {
foreach ($items as $item) {
$image_url = '';
$thumbnail_url = '';
if (class_exists('gallery')) {
$gallery = gallery::getInstance();
$gallery_manager = GalleryManager::getInstance();
$image = $gallery_manager->getSingleItem(array('filename'), array('id' => $item->image));
if (!is_null($image)) {
$image_url = $gallery->getImageURL($image);
$thumbnail_url = $gallery->getThumbnailURL($image);
}
}
$params = array('id' => $item->id, 'index' => $index++, 'item_id' => $item_id, 'parent' => $item->parent, 'image_id' => $item->image, 'image' => $image_url, 'thumbnail' => $thumbnail_url, 'text_id' => $item->text_id, 'title' => $item->title, 'description' => $item->description, 'level' => $level, 'in_category' => in_array($item->id, $item_category_ids) ? 1 : 0, 'selected' => isset($tag_params['selected']) ? fix_id($tag_params['selected']) : 0, 'item_change' => url_MakeHyperlink($this->_parent->getLanguageConstant('change'), window_Open('shop_category_change', 400, $this->_parent->getLanguageConstant('title_category_change'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'categories'), array('sub_action', 'change'), array('id', $item->id)))), 'item_delete' => url_MakeHyperlink($this->_parent->getLanguageConstant('delete'), window_Open('shop_category_delete', 270, $this->_parent->getLanguageConstant('title_category_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'categories'), array('sub_action', 'delete'), array('id', $item->id)))), 'item_add' => url_MakeHyperlink($this->_parent->getLanguageConstant('add'), window_Open('shop_category_add', 400, $this->_parent->getLanguageConstant('title_category_add'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'categories'), array('sub_action', 'add'), array('parent', $item->id)))));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
}
}
开发者ID:tareqy,项目名称:Caracal,代码行数:91,代码来源:shop_category_handler.php
示例12: tag_CurrencyList
/**
* Handle displaying list of stored currencies
*
* @param array $tag_params
* @param array $children
*/
public function tag_CurrencyList($tag_params, $children)
{
$manager = ShopCurrenciesManager::getInstance();
$conditions = array();
$items = $manager->getItems($manager->getFieldNames(), $conditions);
// create template
$template = $this->_parent->loadTemplate($tag_params, 'currency_list_item.xml');
$template->setMappedModule($this->name);
$selected = isset($tag_params['selected']) ? fix_id($tag_params['selected']) : -1;
// parse template
if (count($items) > 0) {
foreach ($items as $item) {
$params = $this->getCurrencyForCode($item->currency);
$params['selected'] = $selected;
// add delete link to params
$params['item_delete'] = url_MakeHyperlink($this->_parent->getLanguageConstant('delete'), window_Open('shop_currencies_delete', 270, $this->_parent->getLanguageConstant('title_currencies_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'currencies'), array('sub_action', 'delete'), array('id', $item->id))));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
}
}
开发者ID:tareqy,项目名称:Caracal,代码行数:28,代码来源:shop_currencies_handler.php
示例13: json_GroupList
/**
* Create JSON object containing group items
*/
private function json_GroupList()
{
define('_OMIT_STATS', 1);
$groups = array();
$conditions = array();
$limit = isset($tag_params['limit']) ? fix_id($tag_params['limit']) : null;
$order_by = isset($tag_params['order_by']) ? explode(',', fix_chars($tag_params['order_by'])) : array('id');
$order_asc = isset($tag_params['order_asc']) && $tag_params['order_asc'] == 'yes' ? true : false;
$manager = LinkGroupsManager::getInstance();
$items = $manager->getItems($manager->getFieldNames(), $conditions, $order_by, $order_asc, $limit);
$result = array('error' => false, 'error_message' => '', 'items' => array());
if (count($items) > 0) {
foreach ($items as $item) {
$result['items'][] = array('id' => $item->id, 'name' => $item->name);
}
} else {
}
print json_encode($result);
}
开发者ID:tareqy,项目名称:Caracal,代码行数:22,代码来源:links.php
示例14: json_UpdateTransactionStatus
/**
* Handle updating transaction status through AJAX request
*/
public function json_UpdateTransactionStatus()
{
$manager = ShopTransactionsManager::getInstance();
$id = fix_id($_REQUEST['id']);
$status = fix_id($_REQUEST['status']);
$result = false;
$transaction = null;
if ($_SESSION['logged']) {
// get transaction
$transaction = $manager->getSingleItem(array('id'), array('id' => $id));
// update status
if (is_object($transaction)) {
$manager->updateData(array('status' => $status), array('id' => $id));
$result = true;
}
}
print json_encode($result);
}
开发者ID:tareqy,项目名称:Caracal,代码行数:21,代码来源:shop_transactions_handler.php
示例15: tag_CycleUnit
/**
* Handle drawing recurring payment cycle units.
*
* @param array $tag_params
* @param array $children
*/
public function tag_CycleUnit($tag_params, $children)
{
$units = array(RecurringPayment::DAY => $this->getLanguageConstant('cycle_day'), RecurringPayment::WEEK => $this->getLanguageConstant('cycle_week'), RecurringPayment::MONTH => $this->getLanguageConstant('cycle_month'), RecurringPayment::YEAR => $this->getLanguageConstant('cycle_year'));
$selected = isset($tag_params['selected']) ? fix_id($tag_params['selected']) : null;
$template = $this->loadTemplate($tag_params, 'cycle_unit_option.xml');
foreach ($units as $id => $text) {
$params = array('id' => $id, 'text' => $text, 'selected' => $id == $selected);
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
}
开发者ID:tareqy,项目名称:Caracal,代码行数:18,代码来源:shop.php
示例16: tag_SubmissionFields
/**
* Show submission data.
*
* @param array $tag_params
* @param array $children
*/
public function tag_SubmissionFields($tag_params, $children)
{
global $language;
$conditions = array();
$form_field_manager = ContactForm_FormFieldManager::getInstance();
$submission_manager = ContactForm_SubmissionManager::getInstance();
$submission_field_manager = ContactForm_SubmissionFieldManager::getInstance();
// get conditional parameters
$submission_id = null;
if (isset($tag_params['submission'])) {
$submission_id = fix_id($tag_params['submission']);
}
// we require submission to be specified
if (is_null($submission_id)) {
trigger_error('Submission fields tag: No submission id specified.', E_USER_NOTICE);
return;
}
// get submission for specified id
$submission = $submission_manager->getSingleItem($submission_manager->getFieldNames(), array('id' => $submission_id));
if (!is_object($submission)) {
trigger_error('Submission fields tag: Unknown submission.', E_USER_NOTICE);
return;
}
// get form fields
$raw_fields = $form_field_manager->getItems($form_field_manager->getFieldNames(), array('form' => $submission->form));
$fields = array();
foreach ($raw_fields as $field) {
$fields[$field->id] = $field;
}
// load submission data
$items = $submission_field_manager->getItems($submission_field_manager->getFieldNames(), array('submission' => $submission->id));
// load template
$template = $this->loadTemplate($tag_params, 'submission_field.xml');
if (count($items) > 0) {
foreach ($items as $item) {
$field = $fields[$item->field];
$text = $field->name;
if (!empty($field->placeholder[$language])) {
$text = $field->placeholder[$language];
}
if (!empty($field->label[$language])) {
$text = $field->label[$language];
}
$params = array('submission' => $submission->id, 'form' => $submission->form, 'field' => $item->field, 'value' => $item->value, 'label' => $field->label, 'placeholder' => $field->placeholder, 'text' => $text, 'type' => $field->type, 'name' => $field->name);
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
}
}
开发者ID:tareqy,项目名称:Caracal,代码行数:56,代码来源:contact_form.php
示例17: deleteCode_Commit
/**
* Remove specified `code` object and inform user about operation status
*/
private function deleteCode_Commit()
{
$id = fix_id(fix_chars($_REQUEST['id']));
$manager = CodeManager::getInstance();
$manager->deleteData(array('id' => $id));
$template = new TemplateHandler('message.xml', $this->path . 'templates/');
$template->setMappedModule($this->name);
$params = array('message' => $this->getLanguageConstant("message_code_deleted"), 'button' => $this->getLanguageConstant("close"), 'action' => window_Close('codes_delete') . ";" . window_ReloadContent('codes_manage'));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
开发者ID:tareqy,项目名称:Caracal,代码行数:15,代码来源:code_project.php
示例18: redirectDownload
/**
* Record download count and redirect to existing file
*/
private function redirectDownload()
{
$id = isset($_REQUEST['id']) ? fix_id($_REQUEST['id']) : null;
$manager = DownloadsManager::getInstance();
if (!is_null($id)) {
$item = $manager->getSingleItem(array('count', 'filename'), array('id' => $id));
// update count
$manager->updateData(array('count' => $item->count + 1), array('id' => $id));
// redirect
$url = $this->_getDownloadURL($item);
header("Location: {$url}");
} else {
die('Invalid download ID!');
}
}
开发者ID:tareqy,项目名称:Caracal,代码行数:18,代码来源:downloads.php
示例19: json_TipList
/**
* Return JSON list of tips.
*/
public function json_TipList()
{
global $language;
$conditions = array();
$limit = null;
$order_by = isset($_REQUEST['random']) && $_REQUEST['random'] == 'yes' ? 'RAND()' : 'id';
$order_asc = isset($_REQUEST['order_asc']) && $_REQUEST['order_asc'] == 'yes';
$all_languages = isset($_REQUEST['all_languages']) && $_REQUEST['all_languages'] == 'yes';
if (isset($_REQUEST['id'])) {
$conditions['id'] = fix_id(explode(',', $_REQUEST['id']));
}
if (isset($_REQUEST['only_visible']) && $_REQUEST['only_visible'] == 'yes') {
$conditions['visible'] = 1;
}
if (isset($_REQUEST['limit'])) {
$limit = fix_id($_REQUEST['limit']);
}
$manager = TipManager::getInstance();
$items = $manager->getItems($manager->getFieldNames(), $conditions, array($order_by), $order_asc, $limit);
$result = array('error' => false, 'error_message' => '', 'items' => array());
if (count($items) > 0) {
foreach ($items as $item) {
$result['items'][] = array('id' => $item->id, 'content' => $all_languages ? $item->content : $item->content[$language], 'visible' => $item->visible);
}
}
print json_encode($result);
}
开发者ID:tareqy,项目名称:Caracal,代码行数:30,代码来源:tips.php
示例20: json_Vote
/**
* Function to record vote from AJAX call
*/
private function json_Vote()
{
$id = fix_id($_REQUEST['id']);
$value = $_REQUEST['value'];
$manager = ArticleManager::getInstance();
$vote_manager = ArticleVoteManager::getInstance();
$vote = $vote_manager->getSingleItem(array('id'), array('article' => $id, 'address' => $_SERVER['REMOTE_ADDR']));
$result = array('error' => false, 'error_message' => '');
if (is_object($vote)) {
// that address already voted
$result['error'] = true;
$result['error_message'] = $this->getLanguageConstant('message_vote_already');
} else {
// stupid but we need to make sure article exists
$article = $manager->getSingleItem(array('id', 'votes_up', 'votes_down'), array('id' => $id));
if (is_object($article)) {
$vote_manager->insertData(array('article' => $article->id, 'address' => $_SERVER['REMOTE_ADDR']));
if (is_numeric($value)) {
$data = array('votes_up' => $article->votes_up, 'votes_down' => $article->votes_down);
if ($value == -1) {
$data['votes_down']++;
}
if ($value == 1) {
$data['votes_up']++;
}
$manager->updateData($data, array('id' => $article->id));
}
$article = $manager->getSingleItem(array('id', 'votes_up', 'votes_down'), array('id' => $id));
$result['rating'] = $this->getArticleRating($article, 10);
} else {
$result['error'] = true;
$result['error_message'] = $this->getLanguageConstant('message_vote_error');
}
}
print json_encode($result);
}
开发者ID:tareqy,项目名称:Caracal,代码行数:39,代码来源:articles.php
注:本文中的fix_id函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论