本文整理汇总了PHP中fix_chars函数的典型用法代码示例。如果您正苦于以下问题:PHP fix_chars函数的具体用法?PHP fix_chars怎么用?PHP fix_chars使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fix_chars函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isCaptchaValid
/**
* Checks validity of captcha against $value
*
* @param string $value
* @return boolean
*/
public function isCaptchaValid($value)
{
$result = false;
if (!isset($_SESSION['captcha'])) {
return $result;
}
$saved_value = fix_chars($_SESSION['captcha']);
$result = $saved_value == $value;
return $result;
}
示例2: fix_chars
/**
* Remove illegal characters and tags from input strings to avoid XSS.
* It also replaces few tags such as [b] [small] [big] [i] [u] [tt] into
* <b> <small> <big> <i> <u> <tt>
*
* @param string $string Input string
* @return string
* @author MeanEYE
*/
function fix_chars($string, $strip_tags = true)
{
if (!is_array($string)) {
$string = strip_tags($string);
$string = str_replace("*", "*", $string);
$string = str_replace(chr(92) . chr(34), """, $string);
$string = str_replace("\r\n", "\n", $string);
$string = str_replace("\\'", "'", $string);
$string = str_replace("'", "'", $string);
$string = str_replace(chr(34), """, $string);
$string = str_replace("<", "<", $string);
$string = str_replace(">", ">", $string);
} else {
foreach ($string as $key => $value) {
$string[$key] = fix_chars($value);
}
}
return $string;
}
示例3: createReferral
/**
* Register new referral
*
* @return boolean
*/
private function createReferral()
{
$result = false;
$manager = AffiliatesManager::getInstance();
$referrals_manager = AffiliateReferralsManager::getInstance();
// prepare data
$uid = fix_chars($_REQUEST['affiliate']);
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
$base_url = url_GetBaseURL();
$landing = url_MakeFromArray($_REQUEST);
$landing = mb_substr($landing, 0, mb_strlen($base_url));
// get affiliate
$affiliate = $manager->getSingleItem($manager->getFieldNames(), array('uid' => $uid));
// if affiliate code is not valid, assign to default affiliate
if (!is_object($affiliate)) {
$affiliate = $manager->getSingleItem($manager->getFieldNames(), array('default' => 1));
}
// if affiliate exists, update
if (is_object($affiliate) && !is_null($referer)) {
$referral_data = array('url' => $referer, 'landing' => $landing, 'affiliate' => $affiliate->id, 'conversion' => 0);
$referrals_manager->insertData($data);
$id = $referrals_manager->getInsertedID();
$_SESSION['referral_id'] = $id;
// increase referrals counter
$manager->updateData(array('clicks' => '`clicks` + 1'), array('id' => $affiliate->id));
$result = true;
}
return result;
}
示例4: setDescription
/**
* Set page description for current execution.
*
* @param array $tag_params
* @param array $children
*/
private function setDescription($tag_params, $children)
{
global $language;
// set from language constant
if (isset($tag_params['constant'])) {
$language_handler = MainLanguageHandler::getInstance();
$constant = fix_chars($tag_params['constant']);
$this->page_description = $language_handler->getText($constant);
// set from article
} else {
if (isset($tag_params['article']) && class_exists('articles')) {
$manager = ArticleManager::getInstance();
$text_id = fix_chars($tag_params['article']);
// get article from database
$item = $manager->getSingleItem(array('content'), array('text_id' => $text_id));
if (is_object($item)) {
$content = strip_tags(Markdown($item->content[$language]));
$data = explode("\n", utf8_wordwrap($content, 150, "\n", true));
if (count($data) > 0) {
$this->page_description = $data[0];
}
}
}
}
}
示例5: 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();
}
}
}
示例6: foreach
$rowData = "";
$colCount = 0;
foreach ($rows as $cell) {
$rowData = $rowData . $cell->plaintext . ", ";
array_push($columns, fix_chars($cell->plaintext));
$data[$colCount] = array();
$colCount++;
}
} else {
$rows = $row->find("td");
$rowData = "";
$colCount = 0;
$rowResult = array();
foreach ($rows as $cell) {
$rowData = $rowData . $cell->plaintext . ", ";
array_push($data[$colCount], fix_chars($cell->plaintext));
$colCount++;
}
}
$rowCount++;
}
$colCount = 0;
$rowCount = 0;
$currentDate = date('Y-m-d');
foreach ($data[0] as $row) {
$cols = array();
$colCount = 0;
foreach ($columns as $col) {
array_push($cols, "aa");
$colCount++;
}
示例7: saveItem
/**
* Save new or changed item data
*/
private function saveItem()
{
$manager = ShopItemSizesManager::getInstance();
$id = isset($_REQUEST['id']) ? fix_id($_REQUEST['id']) : null;
$name = fix_chars($_REQUEST['name']);
if (is_null($id)) {
$window = 'shop_item_size_add';
$manager->insertData(array('name' => $name));
} else {
$window = 'shop_item_size_change';
$manager->updateData(array('name' => $name), array('id' => $id));
}
// show message
$template = new TemplateHandler('message.xml', $this->path . 'templates/');
$template->setMappedModule($this->name);
$params = array('message' => $this->_parent->getLanguageConstant('message_item_size_saved'), 'button' => $this->_parent->getLanguageConstant('close'), 'action' => window_Close($window) . ";" . window_ReloadContent('shop_item_sizes') . ';');
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
示例8: redirect
/**
* Redirect user based on specified code
*/
private function redirect()
{
define('_OMIT_STATS', 1);
$code = fix_chars($_REQUEST['code']);
$manager = CodeManager::getInstance();
$url = $manager->getItemValue("url", array("code" => $code));
$_SESSION['request_code'] = $code;
print url_SetRefresh($url, 0);
}
示例9: tag_TipList
/**
* Tag handler for tip list
*
* @param array $tag_params
* @param array $children
*/
public function tag_TipList($tag_params, $children)
{
$manager = TipManager::getInstance();
$conditions = array();
$limit = null;
$order_by = array('id');
$order_asc = true;
if (isset($tag_params['only_visible']) && $tag_params['only_visible'] == 1) {
$conditions['visible'] = 1;
}
if (isset($tag_params['order_by'])) {
$order_by = explode(',', fix_chars($tag_params['order_by']));
}
if (isset($tag_params['order_asc'])) {
$order_asc = $tag_params['order_asc'] == '1' || $tag_params['order_asc'] == 'yes';
}
if (isset($tag_params['limit'])) {
$limit = fix_id($tag_params['limit']);
}
$template = $this->loadTemplate($tag_params, 'list_item.xml');
$template->setMappedModule($this->name);
// get items
$items = $manager->getItems($manager->getFieldNames(), $conditions, $order_by, $order_asc, $limit);
if (count($items) > 0) {
foreach ($items as $item) {
$params = array('id' => $item->id, 'content' => $item->content, 'visible' => $item->visible, 'item_change' => url_MakeHyperlink($this->getLanguageConstant('change'), window_Open('tips_change', 400, $this->getLanguageConstant('title_tips_change'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'tips_change'), array('id', $item->id)))), 'item_delete' => url_MakeHyperlink($this->getLanguageConstant('delete'), window_Open('tips_delete', 400, $this->getLanguageConstant('title_tips_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'tips_delete'), array('id', $item->id)))));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
}
}
示例10: 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();
}
}
}
示例11: saveSettings
/**
* Save settings.
*/
private function saveSettings()
{
$key = fix_chars($_REQUEST['key']);
$password = fix_chars($_REQUEST['password']);
$account = fix_chars($_REQUEST['account']);
$meter = fix_chars($_REQUEST['meter']);
$this->saveSetting('fedex_key', $key);
$this->saveSetting('fedex_password', $password);
$this->saveSetting('fedex_account', $account);
$this->saveSetting('fedex_meter', $meter);
$template = new TemplateHandler('message.xml', $this->path . 'templates/');
$template->setMappedModule($this->name);
$params = array('message' => $this->getLanguageConstant('message_settings_saved'), 'button' => $this->getLanguageConstant('close'), 'action' => window_Close('fedex'));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
示例12: 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);
}
示例13: saveDefault
/**
* Save default currency
*/
private function saveDefault()
{
$currency = fix_chars($_REQUEST['currency']);
$this->_parent->saveDefaultCurrency($currency);
$template = new TemplateHandler('message.xml', $this->path . 'templates/');
$template->setMappedModule($this->name);
$params = array('message' => $this->_parent->getLanguageConstant('message_default_currency_saved'), 'button' => $this->_parent->getLanguageConstant('close'), 'action' => window_Close('shop_currencies_set_default'));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
示例14: scrapeTable
function scrapeTable($inputGrid, $stationID)
{
$entries = $inputGrid->find("tr");
$rowCount = 0;
foreach ($entries as $entry) {
$trainDepartureTime = "";
$isDeviationInDeparture = "";
$trainDeviatingDepartureTime = "";
$trainName = "";
$trainLink = "";
$trainDestination = "";
$trainOperatorName = "";
$trainOperatorLink = "";
$trainCurrentState = "";
$trainCurrentStatePlace = "";
$trainDeviationInMinutes = "";
$trainDeviationType = "";
$trainType = "";
$trainTrack = "";
$cells = $entry->find("td");
$colCount = 0;
if ($rowCount > 0) {
foreach ($cells as $cell) {
$divs = $cell->find("div");
$divCount = 0;
$isDeviationInDeparture = false;
foreach ($divs as $div) {
$data = strip_tags_attributes($div, '<a>', 'href');
if ($colCount == 0) {
if ($divCount == 0) {
$trainDepartureTime = $data;
# print("Ordinarie avgångstid: " . $trainDepartureTime);
}
if ($divCount == 1) {
if ($data == "Avgick") {
$isDeviationInDeparture = true;
} else {
$isDeviationInDeparture = false;
}
}
if ($divCount == 2 && $isDeviationInDeparture == true) {
$trainDeviatingDepartureTime = $data;
# print("\nAvgick: ". $data);
}
}
if ($colCount == 1) {
// 1. Tåg nr + länk
if ($divCount == 0) {
$trainLink = get_href($data);
$trainName = str_replace(" till", "", strip_tags(fix_chars($data)));
$trainName = str_replace("Tåg nr ", "", $trainName);
# print("Tåg nr: ". $trainName);
}
// 2. Destination
if ($divCount == 1) {
$trainDestination = fix_chars($data);
# print(" Till: " . $trainDestination );
}
// 3. Operatör + länk
if ($divCount == 2) {
$trainOperatorLink = get_href($data);
$trainOperatorName = fix_chars(trim(strip_tags($data)));
# print (" Operatör: " . $trainOperatorName . " (" . $trainOperatorLink . ")" );
}
}
if ($colCount == 2) {
// Tåg som just passerat / ankommit
if ($divCount == 0) {
if (strpos($data, "Ankom")) {
$trainCurrentState = "ARRIVED";
$trainCurrentStatePlace = str_replace("Ankom ", "", fix_chars($data));
} else {
$trainCurrentState = "PASSED";
$trainCurrentStatePlace = str_replace("Passerade ", "", fix_chars($data));
}
# print("--> " . $trainCurrentState . " " . $trainCurrentStatePlace );
}
// Avvikelse i minuter
if ($divCount == 1) {
if (strpos($data, "tidig")) {
$trainDeviationInMinutes = str_replace(" min tidig", "", fix_chars($data));
$trainDeviationType = "EARLY";
} else {
$trainDeviationInMinutes = str_replace(" min försenad", "", fix_chars($data));
$trainDeviationType = "EARLY";
}
# print(" (" . $trainDeviationInMinutes . " " . $trainDeviationType . ")");
}
}
if ($colCount == 3) {
// Hämta tågtyp
if ($divCount == 0) {
$trainType = fix_chars($data);
# print("Tågtyp: " . $trainType);
}
}
if ($colCount == 4) {
if ($divCount == 0) {
$trainTrack = trim($data);
# print("Spår: " . $data);
//.........这里部分代码省略.........
示例15: saveApiKey
/**
* Save new or changed API key.
*/
private function saveApiKey()
{
$api_key = fix_chars($_REQUEST['api_key']);
$this->saveSetting('api_key', $api_key);
// prepare and parse result message
$template = new TemplateHandler('message.xml', $this->path . 'templates/');
$template->setMappedModule($this->name);
$params = array('message' => $this->getLanguageConstant('message_api_key_saved'), 'button' => $this->getLanguageConstant('close'), 'action' => window_Close('page_speed_set_api_key'));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}