本文整理汇总了PHP中main函数的典型用法代码示例。如果您正苦于以下问题:PHP main函数的具体用法?PHP main怎么用?PHP main使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了main函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _order_step_delivery
/**
* Order step
*/
function _order_step_delivery($FORCE_DISPLAY_FORM = false)
{
// Validate previous form
if (main()->is_post() && !$FORCE_DISPLAY_FORM) {
module('shop')->_order_validate_delivery();
// Display next form if we have no errors
if (!common()->_error_exists()) {
return module('shop')->_order_step_select_payment(true);
}
}
if (main()->USER_ID) {
$order_info = module('shop')->_user_info;
}
// Fill fields
foreach ((array) module('shop')->_b_fields as $_field) {
$replace[$_field] = _prepare_html(isset($_POST[$_field]) ? $_POST[$_field] : module('shop')->_user_info[substr($_field, 2)]);
}
// Fill shipping from billing
foreach ((array) module('shop')->_s_fields as $_field) {
if (module('shop')->_user_info["shipping_same"] && !isset($_POST[$_field])) {
$s_field = "b_" . substr($_field, 2);
$replace[$_field] = _prepare_html(isset($_POST[$s_field]) ? $_POST[$s_field] : module('shop')->_user_info[$s_field]);
} else {
$replace[$_field] = _prepare_html(isset($_POST[$_field]) ? $_POST[$_field] : module('shop')->_user_info[$_field]);
}
}
$force_ship_type = module('shop')->FORCE_GROUP_SHIP[module('shop')->USER_GROUP];
$SELF_METHOD_ID = substr(__FUNCTION__, strlen("_order_step_"));
$replace = my_array_merge((array) $replace, ["form_action" => "./?object=shop&action=" . $_GET["action"] . "&id=" . $SELF_METHOD_ID, "error_message" => _e(), "ship_type_box" => module('shop')->_box("ship_type", $force_ship_type ? $force_ship_type : $_POST["ship_type"]), "back_link" => "./?object=shop&action=order", "cats_block" => module('shop')->_categories_show()]);
return tpl()->parse("shop/order_delivery", $replace);
}
示例2: show
function show()
{
header('Content-Type: text/xml', $replace = true);
$host = DEBUG_MODE ? $_GET['host'] : '' ?: $_SERVER['HTTP_HOST'];
// $_GET['host'] just for debug purposes
$prod_hosts = main()->PRODUCTION_DOMAIN ?: parse_url(WEB_PATH, PHP_URL_HOST);
if (is_string($prod_hosts)) {
$prod_hosts = [$prod_hosts];
}
// Based on example from twitter https://twitter.com/crossdomain.xml
if (!main()->is_dev() && in_array($host, $prod_hosts)) {
$out = '<?xml version="1.0" ?>
<cross-domain-policy xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.adobe.com/xml/schemas/PolicyFile.xsd">
<allow-access-from domain="' . $host . '"/>
<allow-access-from domain="api.' . $host . '"/>
<allow-access-from domain="search.' . $host . '"/>
<allow-access-from domain="static.' . $host . '"/>
<site-control permitted-cross-domain-policies="master-only"/>
<allow-http-request-headers-from domain="*.' . $host . '" headers="*" secure="false"/>
</cross-domain-policy>
';
} else {
// !!! DO NOT USE THIS FOR PRODUCTON:
// http://stackoverflow.com/questions/213251/can-someone-post-a-well-formed-crossdomain-xml-sample
// http://www.hardened-php.net/library/poking_new_holes_with_flash_crossdomain_policy_files.html#badly_configured_crossdomain.xml
$out = '<?xml version="1.0" ?><cross-domain-policy><allow-access-from domain="*" /></cross-domain-policy>';
}
header('Content-Type: text/xml', $replace = true);
exit;
}
示例3: _operation_form
protected function _operation_form()
{
// import options
is_array($_GET) && extract($_GET, EXTR_PREFIX_ALL | EXTR_REFS, '');
is_array($_POST) && extract($_POST, EXTR_PREFIX_ALL | EXTR_REFS, '_');
// var
$api = _class('api');
$payment_api = _class('payment_api');
$result = [];
// check input data
list($account_id, $account) = $payment_api->get_account();
if (empty($account_id)) {
js_redirect('/login_form', false, 'User id empty');
}
// operation
$operation = $payment_api->operation(['operation_id' => $_operation_id]);
if (!$operation) {
$result = ['status' => false, 'status_message' => t('Операция отсутствует (id: %operation_id)', ['%operation_id' => $_operation_id])];
return $this->_operation_tpl($result);
}
// user
$user_id = main()->USER_ID;
if ($user_id != $account['user_id']) {
return $api->_reject();
}
// import operation
is_array($operation) && extract($operation, EXTR_PREFIX_ALL | EXTR_REFS, 'o');
// prepare data
$data = ['title' => $o_title, 'amount' => $payment_api->money_html($o_amount)];
$form = ['code' => @$__code ?: @$_code, 'action' => url_user($_SERVER['REQUEST_URI'])];
$result = ['data' => $data, 'form' => $form];
return $result;
}
示例4: pics_browser
function pics_browser()
{
if (isset($_GET['active']) && $_GET['active'] == 1) {
$active = ' AND p.active = \'1\' ';
} elseif (isset($_GET['active']) && $_GET['active'] == 0) {
$active = ' AND p.active = \'\' ';
} else {
$active = '';
}
if (main()->is_post()) {
foreach ($_POST['delete'] as $k => $v) {
list($id, $product_id) = explode("_", $k);
module('manage_shop')->_product_image_delete($id, $product_id);
}
}
$cats_list = _class('_shop_categories', 'modules/shop/')->recursive_get_child_ids(62521);
$sql = "SELECT `i`.`product_id`,`i`.`id` FROM `" . db('shop_products') . "` AS `p`, `" . db('shop_product_images') . "` AS `i` WHERE `p`.`id`=`i`.`product_id` AND `p`.`cat_id` IN ('" . implode("','", $cats_list) . "')" . $active;
list($add_sql, $pages, $total_records, $page_current, $pages_total, $pages_limited) = common()->divide_pages($sql);
$R = db()->query($sql . $add_sql);
$items = [];
while ($A = db()->fetch_assoc($R)) {
$_cls_products = _class('_shop_products', 'modules/shop/');
$image = $_cls_products->_product_image($A['product_id'], true);
$items[] = ['id' => $A['product_id'], 'image_id' => $A['id'], 'image' => $image['big']];
}
$replace = ['items' => $items, 'total' => $total_records, 'pages' => $pages];
$tpl_name = 'manage_shop/pics_browser';
return tpl()->parse($tpl_name, $replace);
}
示例5: test_basic
public function test_basic()
{
$model_base = _class('model');
$this->assertTrue(is_object($model_base));
$this->assertTrue(is_a($model_base, 'yf_model'));
$this->assertSame($model_base, _class('yf_model'));
$model_exists = main()->_class_exists('film_model');
if (!$model_exists) {
$this->assertTrue(main()->_class_exists('film_model'));
}
$film_model = _class('film_model');
$this->assertTrue(is_object($film_model));
$this->assertTrue(is_a($film_model, 'film_model'));
$this->assertTrue(is_a($film_model, 'yf_model'));
$film_model2 = model('film');
$this->assertNotSame($film_model2, $film_model);
$this->assertTrue(is_object($film_model2));
$this->assertTrue(is_a($film_model2, 'film_model'));
$this->assertTrue(is_a($film_model2, 'yf_model'));
$film_model3 = model('film');
$this->assertNotSame($film_model2, $film_model3);
$this->assertTrue(is_object($film_model2));
$this->assertTrue(is_a($film_model2, 'film_model'));
$this->assertTrue(is_a($film_model2, 'yf_model'));
}
示例6: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
init_yf();
if (!defined('PROJECT_PATH') || !strlen(constant('PROJECT_PATH'))) {
$output->writeln('Error: not inside a project');
return false;
}
foreach ((array) main()->get_data('locale_langs') as $lang => $linfo) {
echo '== ' . $lang . ' ==' . PHP_EOL;
list($tr_vars) = module('locale_editor')->_get_vars_from_files($lang);
if (!$tr_vars) {
continue;
}
$fname = './langs_exported_' . $lang . '.csv';
$data = [];
$data['__'] = '"key";"val"';
foreach ((array) $tr_vars as $k => $v) {
$k = trim($k);
$v = trim($v);
if (!strlen($k)) {
continue;
}
$data[$k] = '"' . str_replace('"', '\\\\"', str_replace('_', ' ', $k)) . '";"' . str_replace('"', '\\\\"', str_replace('_', ' ', $v)) . '"';
}
ksort($data);
file_put_contents($fname, implode(PHP_EOL, $data));
passthru('ls -l ' . escapeshellarg($fname));
}
}
示例7: _order_step_do_payment
/**
* Order step
*/
function _order_step_do_payment($FORCE_DISPLAY_FORM = false)
{
$basket_contents = module('shop')->_basket_api()->get_all();
if (module('shop')->FORCE_PAY_METHOD) {
$_POST["pay_type"] = module('shop')->FORCE_PAY_METHOD;
}
// Show previous form if needed
if (common()->_error_exists() || empty($_POST)) {
return module('shop')->_order_step_select_payment();
}
$ORDER_ID = intval($_POST["order_id"] ? $_POST["order_id"] : module('shop')->_CUR_ORDER_ID);
if (empty($ORDER_ID)) {
_re("Missing order ID");
}
// Get order info
$order_info = db()->query_fetch("SELECT * FROM " . db('shop_orders') . " WHERE id=" . intval($ORDER_ID) . " AND user_id=" . intval(main()->USER_ID) . " AND status='pending'");
if (empty($order_info["id"])) {
_re("Missing order record");
}
// Payment by courier, skip next step
if (!common()->_error_exists() && $_POST["pay_type"] == 1 or $_POST["pay_type"] == 3 or $_POST["pay_type"] == 4) {
module('shop')->_basket_api()->clean();
return js_redirect("./?object=shop&action=" . $_GET["action"] . "&id=finish&page=" . intval($ORDER_ID));
}
// Authorize.net payment type
if ($_POST["pay_type"] == 2) {
module('shop')->_basket_api()->clean();
return module('shop')->_order_pay_authorize_net($order_info);
}
}
示例8: _init
public function _init()
{
if (!$this->ENABLE) {
return null;
}
// load api
require_once __DIR__ . '/payment_provider/ecommpay/EcommPay.php';
$this->api = new EcommPay($this->KEY_PUBLIC, $this->KEY_PRIVATE);
$this->url_result = url_user('/api/payment/provider?name=ecommpay&operation=response');
$this->url_server = url_user('/api/payment/provider?name=ecommpay&operation=response&server=true');
// translation
$strs =& $this->method_allow['payout']['pay_card']['option'];
foreach ($strs as $key => &$str) {
$str = t($str);
}
// payout default option
$user_id = main()->USER_ID;
if ($user_id) {
$user = user($user_id);
$option_default =& $this->method_allow['payout']['pay_card']['option_default'];
$option_default = ['card' => $user['card'], 'sender_first_name' => $user['first_name'], 'sender_last_name' => $user['last_name'], 'sender_middle_name' => $user['middle_name'] ?: $user['patronymic'], 'sender_passport_number' => $user['passport_num'], 'sender_passport_issue_date' => $user['passport_issue_date'], 'sender_passport_issued_by' => $user['passport_issued_by'] ?: $user['passport_released'], 'sender_phone' => @str_replace([' ', '-', '+'], '', $user['phone']), 'sender_birthdate' => $user['birthdate'] ?: $user['birth_date'], 'sender_address' => $user['address'] ?: $user['address2'], 'sender_city' => $user['city'] ?: $user['city2'], 'sender_postindex' => $user['zip_code'] ?: $user['zip_code2']];
$option_default =& $this->method_allow['payout']['qiwi']['option_default'];
$option_default = ['account_number' => @str_replace([' ', '-', '+'], '', $user['phone'])];
}
// parent
parent::_init();
}
示例9: _get_group_prices
function _get_group_prices($product_ids = [])
{
if (is_numeric($product_ids)) {
$return_single = $product_ids;
$product_ids = [$product_ids];
}
// Get user groups (id > 2 - skip guest and member)
$user_groups = main()->get_data("user_groups");
if (isset($user_groups[1])) {
unset($user_groups[1]);
}
if (isset($user_groups[2])) {
unset($user_groups[2]);
}
if (empty($user_groups) || empty($product_ids)) {
return false;
}
$group_prices = [];
// Get prices per group
$Q = db()->query("SELECT * FROM " . db('shop_group_options') . " \n\t\t\tWHERE product_id IN (" . implode(",", $product_ids) . ") \n\t\t\t\tAND group_id IN (" . implode(",", array_keys($user_groups)) . ")");
while ($A = db()->fetch_assoc($Q)) {
if (!isset($user_groups[$A["group_id"]])) {
continue;
}
$group_prices[$A["product_id"]][$A["group_id"]] = floatval($A["price"]);
}
if ($return_single) {
return $group_prices[$return_single];
}
return $group_prices;
}
示例10: yf_email_page
/**
* Constructor
*/
function yf_email_page()
{
$this->_user_info =& main()->USER_INFO;
if (!$this->_user_info) {
$this->_user_info = user(main()->USER_ID);
}
}
示例11: __call
/**
* Catch missing method call
*/
public function __call($name, $args)
{
$where_prefix = 'where_';
$scope_prefix = 'scope_';
$get_prefix = 'get_attr_';
$set_prefix = 'set_attr_';
if (strpos($name, $where_prefix) !== false) {
$name = substr($name, strlen($where_prefix));
array_unshift($args, 't0.' . $name);
return call_user_func_array([$this, 'where'], $args);
} elseif (strpos($name, $scope_prefix) !== false) {
if (method_exists($this, $name)) {
return call_user_func_array([$this, $name], $args);
}
} elseif (strpos($name, $get_prefix) !== false) {
$accessor = $get_prefix . $name;
if (method_exists($this, $accessor)) {
return $this->{$accessor}($args);
}
} elseif (strpos($name, $set_prefix) !== false) {
$mutator = $set_prefix . $name;
if (method_exists($this, $mutator)) {
return $this->{$mutator}($args);
}
}
return main()->extend_call($this, $name, $args);
}
示例12: _track_error
/**
* Track user error message
*
* @param string
* @return void
*/
function _track_error($error_message = "")
{
if (empty($error_message)) {
return false;
}
// Try to get user error message source
$backtrace = debug_backtrace();
$cur_trace = $backtrace[1];
$next_trace = $backtrace[2];
// Prepare log text
$text = "## LOG STARTS AT " . date("Y-m-d H:i:s") . "; QUERY_STRING: " . $_SERVER["QUERY_STRING"] . "; REFERER: " . $_SERVER["HTTP_REFERER"] . "; USER_ID: " . main()->USER_ID . "; USER_GROUP: " . main()->USER_GROUP . "; SITE_ID: " . SITE_ID . "; USER_AGENT: " . $_SERVER["HTTP_USER_AGENT"] . " ##\r\n";
$text .= "URL: http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\r\n";
$text .= "SOURCE FILE: \"" . $cur_trace["file"] . "\" at LINE " . $cur_trace["line"] . "; " . (!empty($next_trace["class"]) ? "METHOD: " . $next_trace["class"] . "->" . $next_trace["function"] : "FUNCTION: " . $next_trace["function"]) . ";\r\n";
$text .= "MESSAGE: " . $error_message . "\r\n";
$text .= "## LOG ENDS ##\r\n";
// Do add current error info to the log file
$h = fopen(INCLUDE_PATH . $this->LOG_USER_ERRORS_FILE_NAME, "a");
fwrite($h, $text);
fclose($h);
// Do store message into database (also check if that possible)
if ($this->LOG_INTO_DB && is_object(db())) {
$error_type = 0;
db()->insert_safe('log_user_errors', ['error_level' => intval($error_type), 'error_text' => $error_message, 'source_file' => $cur_trace['file'], 'source_line' => intval($cur_trace['line']), 'date' => time(), 'site_id' => (int) conf('SITE_ID'), 'user_id' => intval($_SESSION[MAIN_TYPE_ADMIN ? 'admin_id' : 'user_id']), 'user_group' => intval($_SESSION[MAIN_TYPE_ADMIN ? 'admin_group' : 'user_group']), 'is_admin' => MAIN_TYPE_ADMIN ? 1 : 0, 'ip' => common()->get_ip(), 'query_string' => WEB_PATH . '?' . $_SERVER['QUERY_STRING'], 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'referer' => $_SERVER['HTTP_REFERER'], 'request_uri' => $_SERVER['REQUEST_URI'], 'env_data' => $this->DB_LOG_ENV ? $this->_prepare_env() : '', 'object' => $_GET['object'], 'action' => $_GET['action']]);
}
}
示例13: _get_info_from_db
/**
* Get first sites info from db
*/
function _get_info_from_db()
{
if (!empty($this->info)) {
return false;
}
// Get sites infos from db
$sites_info_from_db = main()->get_data("sites");
// Get users sites paths
foreach ((array) $sites_info_from_db as $A) {
$tmp = $A;
foreach ((array) $tmp as $k => $v) {
$tmp[$k] = stripslashes($v);
}
$A = $tmp;
// Skip sites with empty paths
if (empty($A["real_path"]) || empty($A["web_path"])) {
continue;
}
$web_path = eval("return '" . $A["web_path"] . "';") . "/";
$web_path = str_replace("\\", "/", str_replace("//", "/", $web_path));
$real_path = eval("return " . $A["real_path"] . ";") . "/";
$real_path = str_replace("\\", "/", str_replace("//", "/", $real_path));
// Skip wrong sites paths
if ($real_path == "/" || !file_exists($real_path)) {
continue;
}
// Store info
$this->info[$A["id"]]["name"] = $A["name"];
$this->info[$A["id"]]["WEB_PATH"] = $web_path;
$this->info[$A["id"]]["REAL_PATH"] = $real_path;
}
}
示例14: test
function test()
{
$time_start = microtime(true);
require_once YF_PATH . 'libs/phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = module('test')->SMTP_OPTIONS['smtp_host'];
$mail->SMTPAuth = true;
$mail->Username = module('test')->SMTP_OPTIONS['smtp_user_name'];
$mail->Password = module('test')->SMTP_OPTIONS['smtp_password'];
if (module('test')->SMTP_OPTIONS['smtp_secure']) {
$mail->SMTPSecure = module('test')->SMTP_OPTIONS['smtp_secure'];
}
$mail->From = module('test')->TEST_MAIL['email_from'];
if (module('test')->TEST_MAIL['name_from']) {
$mail->FromName = module('test')->TEST_MAIL['name_from'];
}
$mail->AddAddress(module('test')->TEST_MAIL['email_to'], module('test')->TEST_MAIL['name_to']);
$mail->IsHTML(true);
$mail->Subject = module('test')->TEST_MAIL['subject'];
$mail->Body = module('test')->TEST_MAIL['html'];
$mail->AltBody = module('test')->TEST_MAIL['text'];
$result = $mail->Send();
$error_message .= $mail->ErrorInfo;
$body .= $result ? '<b style="color:green;">Send successful</b>' : '<b style="color:red;">Send failed</b>';
$body .= !$result ? '<br /><b>Reason:</b><br /> ' . $error_message . implode('<br />\\n', (array) main()->_all_core_error_msgs) . '<br />' : '';
$body .= '<br />Spent time: ' . common()->_format_time_value(microtime(true) - $time_start) . ' sec.<br />';
return $body;
}
示例15: _preload_data
/**
*/
function _preload_data()
{
if ($this->_preload_complete) {
return true;
}
$this->_preload_complete = true;
asset('bfh-select');
$this->lang_def_country = main()->get_data('lang_def_country');
$this->_boxes = ['lang_code' => 'select_box("lang_code", $this->_langs, $selected, false, 2, "", false)', 'cur_langs' => 'select_box("lang_code", $this->_cur_langs, $selected, false, 2, "", false)', 'file_format' => 'radio_box("file_format", $this->_file_formats, $selected, true, 2, "", false)', 'mode' => 'radio_box("mode", $this->_modes, $selected, true, 2, "", false)', 'search_type' => 'radio_box("search_type", $this->_search_types, $selected, false, 2, "", false)', 'location' => 'select_box("location", $this->_used_locations, $selected, false, 2, "", false)', 'module' => 'select_box("module", $this->_modules, $selected, false, 2, "", false)'];
$this->_modules = _class('admin_methods')->find_active_modules();
$langs = [];
foreach ((array) $this->_get_iso639_list() as $lang_code => $lang_params) {
$langs[$lang_code] = t($lang_params[0]) . (!empty($lang_params[1]) ? ' (' . $lang_params[1] . ') ' : '');
}
$this->_langs = $langs;
$this->_cur_langs_array = db()->get_all('SELECT * FROM ' . db('locale_langs') . ' ORDER BY is_default DESC, locale ASC');
if (empty($this->_cur_langs_array)) {
db()->insert_safe('locale_langs', ['locale' => 'en', 'name' => t('English'), 'charset' => 'utf-8', 'active' => 1, 'is_default' => 1]);
js_redirect('/@object/@action');
}
$langs_for_search[''] = t('All languages');
foreach ((array) $this->_cur_langs_array as $A) {
$langs_for_search[$A['locale']] = t($A['name']);
$cur_langs[$A['locale']] = t($A['name']);
}
$this->_langs_for_search = $langs_for_search;
$this->_cur_langs = $cur_langs;
// TODO: add support for these file formats for import/export:
// * JSON
// * PHP
// * GNU Gettext (.po) http://www.gutenberg.org/wiki/Gutenberg:GNU_Gettext_Translation_How-To, https://en.wikipedia.org/wiki/Gettext
$this->_file_formats = ['csv' => t('CSV, compatible with MS Excel'), 'xml' => t('XML')];
$this->_modes = [1 => t('Strings in the uploaded file replace existing ones, new ones are added'), 2 => t('Existing strings are kept, only new strings are added')];
}