• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP fix_chars函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中fix_chars函数的典型用法代码示例。如果您正苦于以下问题:PHP fix_chars函数的具体用法?PHP fix_chars怎么用?PHP fix_chars使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了fix_chars函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
 }
开发者ID:tareqy,项目名称:Caracal,代码行数:16,代码来源:captcha.php


示例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("*", "&#42;", $string);
        $string = str_replace(chr(92) . chr(34), "&#34;", $string);
        $string = str_replace("\r\n", "\n", $string);
        $string = str_replace("\\'", "&#39;", $string);
        $string = str_replace("'", "&#39;", $string);
        $string = str_replace(chr(34), "&#34;", $string);
        $string = str_replace("<", "&lt;", $string);
        $string = str_replace(">", "&gt;", $string);
    } else {
        foreach ($string as $key => $value) {
            $string[$key] = fix_chars($value);
        }
    }
    return $string;
}
开发者ID:tareqy,项目名称:Caracal,代码行数:28,代码来源:common.php


示例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;
 }
开发者ID:tareqy,项目名称:Caracal,代码行数:34,代码来源:affiliates.php


示例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];
                 }
             }
         }
     }
 }
开发者ID:tareqy,项目名称:Caracal,代码行数:31,代码来源:page_info.php


示例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();
         }
     }
 }
开发者ID:tareqy,项目名称:Caracal,代码行数:87,代码来源:search.php


示例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++;
    }
开发者ID:flyeven,项目名称:scraperwiki-scraper-vault,代码行数:31,代码来源:got.php


示例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();
 }
开发者ID:tareqy,项目名称:Caracal,代码行数:23,代码来源:shop_item_sizes_handler.php


示例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);
 }
开发者ID:tareqy,项目名称:Caracal,代码行数:12,代码来源:code_project.php


示例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();
         }
     }
 }
开发者ID:tareqy,项目名称:Caracal,代码行数:38,代码来源:tips.php


示例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();
         }
     }
 }
开发者ID:tareqy,项目名称:Caracal,代码行数:91,代码来源:shop_category_handler.php


示例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();
 }
开发者ID:tareqy,项目名称:Caracal,代码行数:20,代码来源:fedex.php


示例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);
 }
开发者ID:tareqy,项目名称:Caracal,代码行数:22,代码来源:links.php


示例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();
 }
开发者ID:tareqy,项目名称:Caracal,代码行数:14,代码来源:shop_currencies_handler.php


示例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);
//.........这里部分代码省略.........
开发者ID:flyeven,项目名称:scraperwiki-scraper-vault,代码行数:101,代码来源:sj_station_situation.php


示例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();
 }
开发者ID:tareqy,项目名称:Caracal,代码行数:15,代码来源:page_speed.php


示例16: tag_CheckoutForm

 /**
  * Handle drawing checkout form
  *
  * @param array $tag_params
  * @param array $children
  */
 public function tag_CheckoutForm($tag_params, $children)
 {
     $account_information = array();
     $shipping_information = array();
     $billing_information = array();
     $payment_method = null;
     $stage = isset($_REQUEST['stage']) ? fix_chars($_REQUEST['stage']) : null;
     $recurring = isset($_SESSION['recurring_plan']) && !empty($_SESSION['recurring_plan']);
     // decide whether to include shipping and account information
     if (isset($tag_params['include_shipping'])) {
         $include_shipping = fix_id($tag_params['include_shipping']) == 1;
     } else {
         $include_shipping = true;
     }
     $bad_fields = array();
     $info_available = false;
     // grab user information
     if (!is_null($stage)) {
         // get payment method
         $payment_method = $this->getPaymentMethod($tag_params);
         if (is_null($payment_method)) {
             throw new PaymentMethodError('No payment method selected!');
         }
         // get billing information
         $billing_information = $this->getBillingInformation($payment_method);
         $billing_required = array('billing_full_name', 'billing_card_type', 'billing_credit_card', 'billing_expire_month', 'billing_expire_year', 'billing_cvv');
         $bad_fields = $this->checkFields($billing_information, $billing_required, $bad_fields);
         // get shipping information
         if ($include_shipping && $stage == 'set_info') {
             $shipping_information = $this->getShippingInformation();
             $shipping_required = array('name', 'email', 'street', 'city', 'zip', 'country');
             $bad_fields = $this->checkFields($shipping_information, $shipping_required, $bad_fields);
         }
     }
     $info_available = count($bad_fields) == 0 && !is_null($payment_method);
     if ($info_available) {
         $address_manager = ShopDeliveryAddressManager::getInstance();
         $currency_manager = ShopCurrenciesManager::getInstance();
         // get fields for payment method
         $return_url = url_Make('checkout_completed', 'shop', array('payment_method', $payment_method->get_name()));
         $cancel_url = url_Make('checkout_canceled', 'shop', array('payment_method', $payment_method->get_name()));
         // get currency info
         $currency = $this->settings['default_currency'];
         $currency_item = $currency_manager->getSingleItem(array('id'), array('currency' => $currency));
         if (is_object($currency_item)) {
             $transaction_data['currency'] = $currency_item->id;
         }
         // get buyer
         $buyer = $this->getUserAccount();
         if ($include_shipping) {
             $address = $this->getAddress($buyer, $shipping_information);
         } else {
             $address = null;
         }
         // update transaction
         $transaction_type = $recurring ? TransactionType::SUBSCRIPTION : TransactionType::SHOPPING_CART;
         $summary = $this->updateTransaction($transaction_type, $payment_method, '', $buyer, $address);
         // emit signal and return if handled
         if ($stage == 'set_info') {
             Events::trigger('shop', 'before-checkout', $payment_method->get_name(), $return_url, $cancel_url);
             foreach ($result_list as $result) {
                 if ($result) {
                     $this->showCheckoutRedirect();
                     return;
                 }
             }
         }
         // create new payment
         if ($recurring) {
             // recurring payment
             $checkout_fields = $payment_method->new_recurring_payment($_SESSION['recurring_plan'], $billing_information, $return_url, $cancel_url);
         } else {
             // regular payment
             $checkout_fields = $payment_method->new_payment($transaction_data, $billing_information, $summary['items_for_checkout'], $return_url, $cancel_url);
         }
         // load template
         $template = $this->loadTemplate($tag_params, 'checkout_form.xml');
         $template->registerTagHandler('cms:checkout_items', $this, 'tag_CheckoutItems');
         $template->registerTagHandler('cms:delivery_methods', $this, 'tag_DeliveryMethodsList');
         // parse template
         $params = array('checkout_url' => $payment_method->get_url(), 'checkout_fields' => $checkout_fields, 'checkout_name' => $payment_method->get_title(), 'currency' => $this->getDefaultCurrency(), 'recurring' => $recurring, 'include_shipping' => $include_shipping);
         // for recurring plans add additional params
         if ($recurring) {
             $plans = $payment_method->get_recurring_plans();
             $plan_name = $_SESSION['recurring_plan'];
             $plan = $plans[$plan_name];
             $params['plan_name'] = $plan['name'];
             $params['plan_description'] = $this->formatRecurring(array('price' => $plan['price'], 'period' => $plan['interval_count'], 'period' => $plan['interval_count'], 'unit' => $plan['interval'], 'setup' => $plan['setup_price'], 'trial_period' => $plan['trial_count'], 'trial_unit' => $plan['trial']));
         } else {
             $params['sub-total'] = number_format($summary['total'], 2);
             $params['shipping'] = number_format($summary['shipping'], 2);
             $params['handling'] = number_format($summary['handling'], 2);
             $params['total_weight'] = number_format($summary['weight'], 2);
             $params['total'] = number_format($summary['total'] + $summary['shipping'] + $summary['handling'], 2);
//.........这里部分代码省略.........
开发者ID:tareqy,项目名称:Caracal,代码行数:101,代码来源:shop.php


示例17: deleteFeed_Commit

 /**
  * Perform feed removal
  */
 private function deleteFeed_Commit()
 {
     $id = fix_id(fix_chars($_REQUEST['id']));
     $manager = NewsFeedManager::getInstance();
     $manager->deleteData(array('id' => $id));
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $this->getLanguageConstant("message_news_deleted"), 'button' => $this->getLanguageConstant("close"), 'action' => window_Close('news_feeds_delete') . ";" . window_ReloadContent('news'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
开发者ID:tareqy,项目名称:Caracal,代码行数:15,代码来源:news.php


示例18: 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


示例19: tag_Form

 /**
  * Handle drawing a single form.
  *
  * @param array $tag_params
  * @param array $children
  */
 public function tag_Form($tag_params, $children)
 {
     $conditions = array();
     $manager = ContactForm_FormManager::getInstance();
     $field_manager = ContactForm_FormFieldManager::getInstance();
     // get parameters
     if (isset($tag_params['text_id'])) {
         $conditions['text_id'] = fix_chars($tag_params['text_id']);
     }
     if (isset($tag_params['id'])) {
         $conditions['id'] = fix_id($tag_params['id']);
     }
     // load template
     $template = $this->loadTemplate($tag_params, 'form.xml');
     $template->registerTagHandler('cms:fields', $this, 'tag_FieldList');
     // get form from the database
     $item = $manager->getSingleItem($manager->getFieldNames(), $conditions);
     if (is_object($item)) {
         $fields = $field_manager->getItems(array('id'), array('form' => $item->id, 'type' => 'file'));
         $params = array('id' => $item->id, 'text_id' => $item->text_id, 'name' => $item->name, 'action' => !empty($item->action) ? $item->action : url_Make('submit', $this->name), 'template' => $item->template, 'use_ajax' => $item->use_ajax, 'show_submit' => $item->show_submit, 'show_reset' => $item->show_reset, 'show_cancel' => $item->show_cancel, 'show_controls' => $item->show_submit || $item->show_reset || $item->show_cancel, 'has_files' => count($fields) > 0);
         $template->restoreXML();
         $template->setLocalParams($params);
         $template->parse();
     }
 }
开发者ID:tareqy,项目名称:Caracal,代码行数:31,代码来源:contact_form.php


示例20: _saveUpload

 /**
  * Store file in new location
  */
 private function _saveUpload($field_name)
 {
     $result = array('error' => false, 'message' => '');
     if (is_uploaded_file($_FILES[$field_name]['tmp_name'])) {
         // prepare data for recording
         $file_name = $this->_getFileName(fix_chars(basename($_FILES[$field_name]['name'])));
         if (move_uploaded_file($_FILES[$field_name]['tmp_name'], $this->path . 'files/' . $file_name)) {
             // file was moved properly, record new data
             $result['filename'] = $file_name;
             $result['message'] = $this->getLanguageConstant('message_file_uploaded');
         } else {
             // error moving file to new location. folder permissions?
             $result['error'] = true;
             $result['message'] = $this->getLanguageConstant('message_file_save_error');
         }
     } else {
         // there was an error during upload, notify user
         $result['error'] = true;
         $result['message'] = $this->getLanguageConstant('message_file_upload_error');
     }
     return $result;
 }
开发者ID:tareqy,项目名称:Caracal,代码行数:25,代码来源:downloads.php




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP fix_course_sortorder函数代码示例发布时间:2022-05-15
下一篇:
PHP fix_align_rtl函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap