本文整理汇总了PHP中_re函数的典型用法代码示例。如果您正苦于以下问题:PHP _re函数的具体用法?PHP _re怎么用?PHP _re使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_re函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _order_validate_delivery
/**
* Order validation
*/
function _order_validate_delivery()
{
$_POST['exp_date'] = $_POST['exp_date_mm'] . $_POST['exp_date_yy'];
$force_ship_type = module('shop')->FORCE_GROUP_SHIP[module('shop')->USER_GROUP];
if ($force_ship_type) {
$_POST["ship_type"] = $force_ship_type;
}
if (!strlen($_POST["ship_type"]) || !isset(module('shop')->_ship_types[$_POST["ship_type"]])) {
_re("Shipping type required");
}
foreach ((array) module('shop')->_b_fields as $_field) {
if (!strlen($_POST[$_field]) && in_array($_field, module('shop')->_required_fields)) {
_re(t(str_replace("b_", "Billing ", $_field)) . " " . t("is required"));
}
}
if ($_POST["email"] != "" && !common()->email_verify($_POST["email"])) {
_re("email not valid.");
}
/* foreach ((array)module('shop')->_s_fields as $_field) {
if (!strlen($_POST[$_field]) && in_array($_field, module('shop')->_required_fields)) {
_re(t(str_replace("s_", "Shipping ", $_field))." ".t("is required"));
}
}
if (!common()->email_verify($_POST["s_email"])) {
_re("Shipping email not valid.");
} */
}
示例2: supplier_edit
/**
*/
function supplier_edit()
{
$_GET['id'] = intval($_GET['id']);
if (empty($_GET['id'])) {
return _e('Empty ID!');
}
$supplier_info = db()->query_fetch('SELECT * FROM ' . db('shop_suppliers') . ' WHERE id=' . $_GET['id']);
if (main()->is_post()) {
if (!$_POST['name']) {
_re('Product name must be filled');
}
if (!common()->_error_exists()) {
$sql_array = ['name' => $_POST['name'], 'url' => $_POST['url'] ?: common()->_propose_url_from_name($_POST['name']), 'desc' => $_POST['desc'], 'meta_keywords' => $_POST['meta_keywords'], 'meta_desc' => $_POST['meta_desc'], 'sort_order' => intval($_POST['sort_order'])];
module('manage_shop_revisions')->check_revision(__FUNCTION__, $_GET['id'], 'shop_suppliers');
db()->update('shop_suppliers', db()->es($sql_array), 'id=' . $_GET['id']);
module('manage_shop_revisions')->new_revision(__FUNCTION__, $_GET['id'], 'shop_suppliers');
common()->admin_wall_add(['shop supplier updated: ' . $_POST['name'], $_GET['id']]);
if (!empty($_FILES)) {
$man_id = $_GET['id'];
$this->_upload_image($man_id, $url);
}
}
return js_redirect('./?object=' . main()->_get('object') . '&action=suppliers');
}
$thumb_path = module('manage_shop')->supplier_img_dir . $supplier_info['url'] . '_' . $supplier_info['id'] . module('manage_shop')->THUMB_SUFFIX . '.jpg';
if (!file_exists($thumb_path)) {
$thumb_path = '';
} else {
$thumb_path = module('manage_shop')->supplier_img_webdir . $supplier_info['url'] . '_' . $supplier_info['id'] . module('manage_shop')->THUMB_SUFFIX . '.jpg';
}
$replace = ['name' => $supplier_info['name'], 'sort_order' => $supplier_info['sort_order'], 'desc' => $supplier_info['desc'], 'thumb_path' => $thumb_path, 'delete_image_url' => './?object=' . main()->_get('object') . '&action=delete_image&id=' . $supplier_info['id'], 'form_action' => './?object=' . main()->_get('object') . '&action=supplier_edit&id=' . $supplier_info['id'], 'back_url' => './?object=' . main()->_get('object') . '&action=suppliers'];
return form($replace)->text('name')->textarea('desc', 'Description')->text('url')->text('meta_keywords')->text('meta_desc')->save_and_back();
}
示例3: coupon_edit
/**
*/
function coupon_edit()
{
$_GET['id'] = intval($_GET['id']);
if (empty($_GET['id'])) {
return _e('Empty ID!');
}
$coupon_info = db()->query_fetch('SELECT * FROM ' . db('shop_coupons') . ' WHERE id=' . $_GET['id']);
if (main()->is_post()) {
if (!$_POST['code']) {
_re('Code must be entered');
} else {
$_POST['code'] = $this->_cleanup_code($_POST['code']);
$cnt = db()->get_one("SELECT COUNT(`id`) AS `cnt` FROM `" . db('shop_coupons') . "` WHERE `code`='" . $_POST['code'] . "' AND `id`!=" . $_GET['id']);
if ($cnt != 0) {
_re('Code already exists');
}
}
if (!common()->_error_exists()) {
$sql_array = ['code' => $this->_cleanup_code($_POST['code']), 'user_id' => intval($_POST['user_id']), 'sum' => intval($_POST['sum']), 'status' => intval($_POST['status']), 'cat_id' => intval($_POST['cat_id']), 'order_id' => intval($_POST['order_id']), 'time_start' => strtotime($_POST['time_start']), 'time_end' => strtotime($_POST['time_end'])];
db()->update('shop_coupons', db()->es($sql_array), 'id=' . $_GET['id']);
common()->admin_wall_add(['shop coupon updated: ' . $this->_cleanup_code($_POST['code']), $_GET['id']]);
return js_redirect('./?object=' . main()->_get('object') . '&action=coupons');
}
}
$replace = ['code' => $coupon_info['code'], 'user_id' => $coupon_info['user_id'], 'sum' => $coupon_info['sum'], 'status' => $coupon_info['status'], 'cat_id' => $coupon_info['cat_id'], 'order_id' => $coupon_info['order_id'], 'time_start' => date('d.m.Y I:s', $coupon_info['time_start']), 'time_end' => date('d.m.Y I:s', $coupon_info['time_end']), 'form_action' => './?object=' . main()->_get('object') . '&action=coupon_edit&id=' . $coupon_info['id'], 'back_url' => './?object=' . main()->_get('object') . '&action=coupons'];
return form($replace)->text('code')->integer('user_id')->integer('sum')->select_box('status', $this->_statuses)->select_box('cat_id', module('manage_shop')->_cats_for_select, ['desc' => 'Main category', 'edit_link' => './?object=category_editor&action=show_items&id=shop_cats', 'translate' => 0])->integer('order_id')->datetime_select('time_start', null, ['with_time' => 1])->datetime_select('time_end', null, ['with_time' => 1])->save_and_back();
}
示例4: _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);
}
}
示例5: _order_validate_select_payment
/**
* Order validation
*/
function _order_validate_select_payment()
{
module('shop')->_order_validate_delivery();
if (!$_POST["pay_type"] || !isset(module('shop')->_pay_types[$_POST["pay_type"]])) {
_re("Wrong payment type");
}
}
示例6: _order_validate_do_payment
/**
* Order validation
*/
function _order_validate_do_payment()
{
module('shop')->_order_validate_select_payment();
if (empty($_POST["order_id"])) {
_re("Missing order ID");
}
if (empty($_POST["total_sum"])) {
_re("Missing total sum");
}
}
示例7: _order_validate_data
/**
* validate order data for view order
*/
function _order_validate_data()
{
if (empty($_POST["order_id"])) {
_re("Order empty");
}
$order_info = db()->query_fetch("SELECT * FROM " . db('shop_orders') . " WHERE id=" . intval($_POST["order_id"]));
if (empty($order_info)) {
_re("No such order");
}
if (empty($_POST["email"])) {
_re("e-mail empty");
} elseif (!common()->email_verify($_POST["email"])) {
_re("email not valid.");
} elseif ($order_info["email"] != $_POST["email"]) {
_re("The order has been issued on other name");
}
}
示例8: attribute_edit
/**
*/
function attribute_edit()
{
if (empty($_GET['id'])) {
return _e('no id');
}
$_GET['id'] = intval($_GET['id']);
$A = db()->query_fetch('SELECT * FROM `' . db('shop_productparams') . '` WHERE `id`=' . $_GET['id']);
$options = db()->get_2d('SELECT `id`,`title` FROM ' . db('shop_productparams_options') . ' WHERE `productparams_id`=' . $_GET['id'] . ' ORDER BY `title`');
$A['value_list'] = implode("\n", $options);
if (main()->is_post()) {
if (empty($_POST['title'])) {
_re('Title is required');
}
if (empty($_POST['value_list'])) {
_re('Values list is required');
}
if (!common()->_error_exists()) {
$value_list = [];
foreach ((array) explode("\n", $_POST['value_list']) as $val) {
$v = trim($val);
if ($v != '') {
$value_list[$v] = $v;
}
}
$options_list = array_flip($options);
foreach ($value_list as $val) {
if (!empty($options_list[$val])) {
// same option - leave as is
unset($options_list[$val]);
} else {
// insert new
db()->INSERT('shop_productparams_options', ['productparams_id' => $_GET['id'], 'title' => $val]);
}
}
if (count($options_list != 0)) {
// options not found - delete these
db()->query('DELETE FROM `' . db('shop_productparams_options') . '` WHERE `id` IN (' . implode(',', $options_list) . ') AND `productparams_id`=' . $_GET['id']);
}
db()->UPDATE('shop_productparams', db()->es(['title' => $_POST['title']]), 'id=' . $_GET['id']);
common()->admin_wall_add(['shop product attribute updated: ' . $_POST['title'], $_GET['id']]);
return js_redirect('./?object=' . main()->_get('object') . '&action=attributes');
}
}
$replace = ['form_action' => './?object=' . main()->_get('object') . '&action=' . $_GET['action'] . '&id=' . $A['id'], 'error' => _e(), 'title' => $A['title'], 'value_list' => $A['value_list'], 'back_url' => './?object=' . main()->_get('object') . '&action=attributes', 'active' => 1];
return form($replace)->text('title')->textarea('value_list')->save_and_back();
}
示例9: edit
/**
*/
function edit()
{
$_GET['id'] = intval($_GET['id']);
$a = db()->query_fetch('SELECT * FROM ' . db('comments') . ' WHERE id=' . intval($_GET['id']));
if (empty($a)) {
return _e('No such record');
}
if (main()->is_post()) {
if (empty($_POST['text'])) {
_re('Comment text required');
}
if (!common()->_error_exists()) {
db()->update_safe('comments', ['text' => $_POST['text']], 'id=' . intval($a['id']));
return js_redirect('');
}
}
return form($a + ['back_link' => './?object=' . $_GET['object']])->info_date('add_date', 'full')->info('object_name')->info('object_id')->user_info('user_id')->textarea('text')->save_and_back();
}
示例10: show
function show()
{
conf('_login_form_displayed', true);
if (!empty($_POST)) {
if (empty($_POST['login']) && empty($_POST['email'])) {
_re('Login or Email required');
}
// Check if user with such login exists
if (!empty($_POST['login'])) {
$A = db()->query_fetch('SELECT id,name,login,password,email,nick FROM ' . db('user') . ' WHERE login="' . _es($_POST['login']) . '"');
if (empty($A['id'])) {
_re('Login was not found', 'login');
}
if (!common()->_error_exists()) {
$result = $this->_send_info_to_user($A);
if (!$result) {
_re('Server mail error');
}
}
// Check if user with such email exists
} elseif (!empty($_POST['email'])) {
$Q = db()->query('SELECT id,name,login,password,email,nick FROM ' . db('user') . ' WHERE email="' . _es($_POST['email']) . '"');
if (!db()->num_rows($Q)) {
_re('Email was not found', 'email');
}
// Check if errors exists and send all found accounts
if (!common()->_error_exists()) {
while ($A = db()->fetch_assoc($Q)) {
$result = $this->_send_info_to_user($A);
if (!$result) {
_re('Server mail error');
}
}
}
}
if (!common()->_error_exists()) {
$success_msg = t('Password has been sent to your email address. It should arrive in a couple of minutes.');
}
}
$replace = ['form_action' => './?object=' . $_GET['object']];
$login_form = form($replace, ['legend' => 'Enter your login', 'class' => 'form-vertical'])->validate(['login' => 'trim|required'])->text('login', 'Enter your login')->submit('', 'Get Password', ['class' => 'btn btn-small']);
$email_form = form($replace, ['legend' => 'Enter your email', 'class' => 'form-vertical'])->validate(['email' => 'trim|required'])->email('email', 'Enter your email')->submit('', 'Get Password', ['class' => 'btn btn-small']);
return tpl()->parse(__CLASS__ . '/main', ['error' => _e(), 'success' => !empty($success_msg) ? $success_msg : '', 'login_form' => $login_form, 'email_form' => $email_form]);
}
示例11: _order_step_select_payment
/**
* Order step
*/
function _order_step_select_payment($FORCE_DISPLAY_FORM = false)
{
// Show previous form if needed
if (common()->_error_exists() || empty($_POST)) {
return module('shop')->_order_step_delivery();
}
if (module('shop')->FORCE_PAY_METHOD) {
$_POST["pay_type"] = module('shop')->FORCE_PAY_METHOD;
$FORCE_DISPLAY_FORM = false;
}
if (main()->is_post() && !$FORCE_DISPLAY_FORM) {
module('shop')->_order_validate_select_payment();
// Verify products
if (!common()->_error_exists()) {
$ORDER_ID = module('shop')->_order_create();
$ORDER_ID = intval($ORDER_ID);
}
// Order id is required to continue, check it again
if (empty($ORDER_ID) && !common()->_error_exists()) {
_re("SHOP: Error while creating `order`, please <a href='" . process_url("./?object=support") . "'>contact</a> site admin");
}
// Display next form if we have no errors
if (!common()->_error_exists()) {
module('shop')->_CUR_ORDER_ID = $ORDER_ID;
return module('shop')->_order_step_do_payment(true);
}
}
$DATA = $_POST;
if (!isset($DATA["pay_type"])) {
$DATA["pay_type"] = key(module('shop')->_pay_types);
}
$hidden_fields = "";
$hidden_fields .= module('shop')->_hidden_field("ship_type", $_POST["ship_type"]);
foreach ((array) module('shop')->_b_fields as $_field) {
$hidden_fields .= module('shop')->_hidden_field($_field, $_POST[$_field]);
}
/* foreach ((array)module('shop')->_s_fields as $_field) {
$hidden_fields .= module('shop')->_hidden_field($_field, $_POST[$_field]);
} */
$hidden_fields .= module('shop')->_hidden_field('card_num', $_POST['card_num']);
$hidden_fields .= module('shop')->_hidden_field('exp_date', $_POST['exp_date']);
$replace = ["form_action" => "./?object=shop&action=" . $_GET["action"] . "&id=" . $SELF_METHOD_ID, "error_message" => _e(), "pay_type_box" => module('shop')->_box("pay_type", $DATA["pay_type"]), "hidden_fields" => $hidden_fields, "back_link" => "./?object=shop&action=order&id=delivery", "cats_block" => module('shop')->_categories_show()];
return tpl()->parse("shop/order_select_payment", $replace);
}
示例12: unit_edit
/**
*/
function unit_edit()
{
$_GET['id'] = intval($_GET['id']);
if (empty($_GET['id'])) {
return _e('Empty ID!');
}
$unit_info = db()->query_fetch('SELECT * FROM ' . db('shop_product_units') . ' WHERE id=' . $_GET['id']);
if (main()->is_post()) {
if (!$_POST['title']) {
_re('Unit title must be filled');
}
if (!common()->_error_exists()) {
$sql_array = ['title' => $_POST['title'], 'description' => $_POST['description'], 'step' => intval($_POST['step']), 'k' => tofloat($_POST['k'])];
db()->update('shop_product_units', _es($sql_array), 'id=' . $_GET['id']);
common()->admin_wall_add(['shop product unit updated: ' . $_POST['title'], $_GET['id']]);
}
return js_redirect('./?object=' . main()->_get('object') . '&action=units');
}
$replace = ['title' => $unit_info['title'], 'description' => $unit_info['description'], 'step' => $unit_info['step'], 'k' => $unit_info['k'], 'form_action' => './?object=' . main()->_get('object') . '&action=unit_edit&id=' . $unit_info['id'], 'back_url' => './?object=' . main()->_get('object') . '&action=units'];
return form($replace)->text('title')->textarea('description', 'Description')->text('step')->text('k')->save_and_back();
}
示例13: edit
/**
*/
function edit()
{
$_GET['id'] = intval($_GET['id']);
// Do save data
if (!empty($_POST)) {
// Position could not be empty
if (empty($_POST['ad'])) {
_re('Place is empty');
}
// Content html could not be empty
if (empty($_POST['html'])) {
_re('Html is empty');
}
if (!_ee()) {
return $this->save();
}
}
$info = db()->query_fetch('SELECT * FROM ' . db('advertising') . ' WHERE id=' . $_GET['id']);
$editor = db()->query_fetch('SELECT * FROM ' . db('sys_admin') . ' WHERE id=' . $info['edit_user_id']);
$replace = ['form_action' => './?object=' . $_GET['object'] . '&action=' . $_GET['action'] . '&id=' . $_GET['id'], 'ad' => $info['ad'], 'editor' => $editor['first_name'] . ' ' . $editor['last_name'], 'edit_date' => date('d/m/Y', $info['edit_date']), 'customer' => $info['customer'], 'date_start' => $info['date_start'] ? $info['date_start'] : time(), 'date_end' => $info['date_end'] ? $info['date_end'] : time(), 'cur_date' => time(), 'html' => stripslashes($info['html']), 'active' => $info['active'], 'error_message' => _e(), 'back_link' => './?object=' . $_GET['object'] . '&action=listing'];
return form2($replace)->info('ad', 'Placeholder')->info('editor', 'Last editor')->info('edit_date', 'Edit date')->text('customer', 'Customer')->text('ad', 'Placeholder')->textarea('html', 'Content')->date_box('date_start', '', ['desc' => 'Date start'])->date_box('date_end', '', ['desc' => 'Date end'])->active_box()->save_and_back();
}
示例14: go
/**
* Do upload archive to server
*/
function go($new_file_path, $name_in_form = 'archive')
{
ignore_user_abort(true);
if (empty($new_file_path)) {
trigger_error(__CLASS__ . ': New file path id required', E_USER_WARNING);
return false;
}
if (empty($name_in_form)) {
$name_in_form = 'archive';
}
$ARCHIVE = is_array($name_in_form) ? $name_in_form : $_FILES[$name_in_form];
if ($ARCHIVE['type'] && !isset($this->ALLOWED_MIME_TYPES[$ARCHIVE['type']])) {
_re('Invalid file mime type');
}
if (common()->_error_exists()) {
return false;
}
$ARCHIVE_DIR = dirname($new_file_path);
if (!file_exists($ARCHIVE_DIR)) {
mkdir($ARCHIVE_DIR, 0777, true);
}
$ARCHIVE_PATH = $new_file_path;
if ($is_local) {
$move_result = false;
if (!file_exists($ARCHIVE_PATH) && file_exists($ARCHIVE['tmp_name'])) {
file_put_contents($ARCHIVE_PATH, file_get_contents($ARCHIVE['tmp_name']));
unlink($ARCHIVE['tmp_name']);
$move_result = true;
}
} else {
$move_result = move_uploaded_file($ARCHIVE['tmp_name'], $ARCHIVE_PATH);
}
if (!$move_result || !file_exists($ARCHIVE_PATH) || !filesize($ARCHIVE_PATH) || !is_readable($ARCHIVE_PATH)) {
trigger_error('Moving uploaded archive error', E_USER_WARNING);
return false;
}
return true;
}
示例15: go
/**
* Email given text to a friend
*/
function go($text = "")
{
$cur_page_md5 = md5($_GET["object"] . "%%" . $_GET["action"] . "%%" . $_GET["id"]);
// Verify and send email
if (!empty($_POST["go"])) {
// Check if email is already registered for someone
if (!common()->email_verify($_POST["email"])) {
_re("Invalid e-mail, please check your spelling!");
}
if (empty($_POST["name"])) {
_re("Friend name required!");
}
if (empty($_POST["message"])) {
_re("Message text required!");
}
// Check for flood
if (!empty($_SESSION[$this->SESSION_TTL_NAME][$cur_page_md5]) && $_SESSION[$this->SESSION_TTL_NAME][$cur_page_md5] > time() - $this->TTL) {
_re("You are not allowed to send current page more than once in future " . ($_SESSION[$this->SESSION_TTL_NAME][$cur_page_md5] + $this->TTL - time()) . " seconds!");
}
// Try to send email
if (!common()->_error_exists()) {
$subject = "Your friend " . $_POST["name"] . " sent to you from " . SITE_NAME;
$text_to_send = (!empty($_POST["comment"]) ? $_POST["comment"] . "<br />\r\n<br />\r\n" : "") . $_POST["message"];
$send_result = common()->quick_send_mail($_POST["email"], $subject, $text_to_send);
// Anti-flooder
$_SESSION[$this->SESSION_TTL_NAME][$cur_page_md5] = time();
$replace2 = ["result" => intval((bool) $send_result)];
return tpl()->parse("system/common/email_page_result", $replace2);
}
}
// Show form
if (empty($_POST["go"]) || common()->_error_exists()) {
$replace = ["error_message" => _e(), "form_action" => "./?object=" . $_GET["object"] . "&action=" . $_GET["action"] . "&id=" . $_GET["id"], "name" => _prepare_html(isset($_POST["name"]) ? $_POST["name"] : (!empty($this->_user_info["display_name"]) ? $this->_user_info["display_name"] : $this->_user_info["name"])), "email" => _prepare_html(isset($_POST["email"]) ? $_POST["email"] : $this->_user_info["email"]), "message" => _prepare_html(isset($_POST["message"]) ? $_POST["message"] : $text), "comment" => _prepare_html($_POST["comment"]), "page_preview" => isset($_POST["message"]) ? $_POST["message"] : $text];
return tpl()->parse("system/common/email_page_form", $replace);
}
}