static public function Consume($coupon,$store_id,$doer_id,$verifytype=4) { if ( !$coupon['consume']=='N' ) return false; $u = array( 'ip' => Utility::GetRemoteIp(), 'consume_time' => time(), 'consume' => 'Y', 'verifytype'=>$verifytype, 'store_id'=>$store_id, 'doer_id'=>$doer_id, ); DB::Update('order',$coupon['order_id'],array('had_consume'=>1)); Table::UpdateCache('coupon', $coupon['id'], $u); //判断是否点评返利成功,点评并返利成功的订单的消费券可以继续返利 $orderdp=DB::LimitQuery('order_dp',array( 'condition'=>array('order_id'=>$coupon['order_id'],'has_return'=>1) )); if(!empty($orderdp)){ ZFlow::CreateFromCoupon($coupon); } ZCredit::CreateFromConsume($coupon); return true; }
function update_order($data) { if (!isset($data['order_id']) || !isset($data['express_no']) || !isset($data['express_id'])) { return false; } $id = (int) $data['order_id']; $express_no = $data['express_no']; $express_id = $data['express_id']; $order = DB::Update('order', array('id' => $id), array('express_no' => $express_no, 'express_id' => $express_id)); }
function set_sms_api_options($sms_api_username, $sms_api_password, $sms_api_phone) { if ($sms_api_username !== '' && $sms_api_password !== '' && $sms_api_phone !== '') { $fl1 = DB::Update('settings', 'sms_api_username', array('var' => $sms_api_username), 'name'); $fl2 = DB::Update('settings', 'sms_api_password', array('var' => $sms_api_password), 'name'); $fl3 = DB::Update('settings', 'sms_api_phone', array('var' => $sms_api_phone), 'name'); return $fl1 && $fl2 && $fl3; } else { return false; } }
function logsearch() { global $DB, $C; if (!isset($DB)) { $DB = new DB($C['db_hostname'], $C['db_username'], $C['db_password'], $C['db_name']); $DB->Connect(); } if (preg_match_all('~[\'"]([^\'"]+)[\'"]|(\\b\\w+\\b)~', $_GET['s'], $matches)) { $date = gmdate('Y-m-d H:i:s', _timewithtz()); foreach ($matches[0] as $match) { $match = str_replace(array('"', '\''), '', $match); if (strlen($match) < 4) { continue; } if ($DB->Update('UPDATE `lx_search_terms` SET `searches`=`searches`+1,`date_last_search`=? WHERE `term`=?', array($date, $match)) < 1) { $DB->Update('INSERT INTO `lx_search_terms` VALUES (?,?,?,?)', array(null, $match, 1, $date)); } } } }
public function update() { $fields = func_get_args(); if (empty($fields)) { return true; } $up_array = array(); foreach ($fields as $f) { if (array_key_exists($f, $this->column_values)) { $up_array[$f] = $this->column_values[$f]; } } if (empty($up_array)) { return true; } return DB::Update($this->table_name, $this->pk_value, $up_array, $this->pk_name); }
public function update($condition, $updateRow, $oldCondition = null, $actorType = 0, $actorID = 0) { if (!is_array($condition)) { $tableID = $condition; $condition = array($this->primaryKey => $condition); } $tableID = $tableID ? $tableID : $condition[$this->primaryKey]; $tableID = $tableID ? $tableID : $oldCondition[$this->primaryKey]; if ($this->hasUpdateTime) { $updateRow['update_time'] = $updateRow['update_time'] ? $updateRow['update_time'] : time(); } if ($tableID && !$oldCondition && $this->useLog && $this->logTable) { $oldCondition = $this->fetch($tableID); } $result = DB::Update($this->tableName, $condition, $updateRow, $this->writeDB); if ($result) { $this->log($tableID, $oldCondition, $updateRow, DB_Log::TYPE_UPDATE, $actorType, $actorID); } else { $this->error = DB::$error; } return $result; }
/* update order */ DB::Update('order', array('team_id' => $id), array( 'allowrefund' => $team['allowrefund'], )); } //dbx($team); $insert = array_unique($insert); $table = new Table('team', $team); $table->SetStrip('detail', 'systemreview', 'notice', 'teambeizhu', 'teamviewb'); if ( $team['id'] && $team['id'] == $id ) { $table->SetPk('id', $id); $table->update($insert); DB::Update('team',$id,array('dptpl_id'=>$_POST['dptpl_id'])); log_admin('team', '编辑team项目',$insert); Session::Set('notice', '编辑项目信息成功'); redirect( WEB_ROOT . "/manage/team/index.php"); } else if ( $team['id'] ) { log_admin('team', '非法编辑team项目',$insert); Session::Set('error', '非法编辑'); redirect( WEB_ROOT . "/manage/team/index.php"); } if ( $table->insert($insert) ) { log_admin('team', '新建team项目',$insert); Session::Set('notice', '新建项目成功'); redirect( WEB_ROOT . "/manage/team/index.php");
$DB->Connect(); // Check consistency of last_updates $last_updates = unserialize(GetValue('last_updates')); if ($DB->Count('SELECT COUNT(*) FROM `tlx_daily_stats` WHERE `date_stats`=?', array($last_updates['daily']))) { // Update the daily value $today = gmdate('Y-m-d', TIME_NOW); $last_updates['daily'] = $today; StoreValue('last_updates', serialize($last_updates)); } // Load table data IniParse("{$GLOBALS['BASE_DIR']}/includes/tables.php", TRUE, $table_defs); // Load existing tables $tables = $DB->GetTables(); // Create the tlx_account_ranks table if (!isset($tables['tlx_account_ranks'])) { $DB->Update("CREATE TABLE IF NOT EXISTS `tlx_account_ranks` ( {$table_defs['tlx_account_ranks']} ) TYPE=MyISAM"); } // Create the tlx_account_ranks table if (!isset($tables['tlx_account_category_ranks'])) { $DB->Update("CREATE TABLE IF NOT EXISTS `tlx_account_category_ranks` ( {$table_defs['tlx_account_category_ranks']} ) TYPE=MyISAM"); } // Update the tlx_categories table $columns = $DB->GetColumns('tlx_categories', TRUE); if (!isset($columns['page_url'])) { $DB->Update('ALTER TABLE `tlx_categories` ADD COLUMN `page_url` TEXT AFTER `forward_url`'); } // Update the tlx_daily_stats table $columns = $DB->GetColumns('tlx_daily_stats', TRUE); if (!isset($columns['clicks'])) { $DB->Update('ALTER TABLE `tlx_daily_stats` ADD COLUMN `clicks` INT UNSIGNED NOT NULL'); }
function update() { if (User::is_admin()) { $item_id = EClassApi::getParam('item_id'); $info = EClassApi::getParam('id'); if ($info == 'description') { $value = Url::get('value'); if (get_magic_quotes_gpc()) { $value = stripslashes($value); } require_once ROOT_PATH . 'includes/htmLawed.php'; $config = array('safe' => 1, 'elements' => '*', 'deny_attribute' => 'class, id'); $spec = 'a = title, href;'; // The 'a' element can have only these attributes $value = htmLawed($value, $config, $spec); $value = EClassApi::clean_value($value); } else { /* $value = EClassApi::cleanHtml(EClassApi::filter_title(Url::get('value'))); $value = EClassApi::trimSpace(str_replace("\n"," ",$value)); */ $value = EClassApi::getParam('value'); mb_internal_encoding("UTF-8"); $value = mb_strtoupper(mb_substr($value, 0, 1)) . mb_substr($value, 1); } $info_array = array('name', 'description'); if (!in_array($info, $info_array)) { die("no_info"); } $row = Item::get_item($item_id); $item_memcache = $row; if ($info == 'description' && strlen(EClassApi::plainText(EClassApi::post_db_parse_html($value))) < 15) { echo "unsuccess"; exit; } /* if(!User::is_foodnet_team()){ $arr_badwords = EClassApi::checkBadWord($value,true); $value_badwords = $arr_badwords["bad"]."@enbac@".$arr_badwords["bad_key"]; if((strlen(trim($row['bad_words']))!=strlen(trim($value_badwords))) && strlen($arr_badwords["bad"])>0){ die('bad_content'); } } */ //if( $item_id && User::is_login()){ if ($item_id) { //if(($row["user_id"] == User::id() && !User::is_block()) || User::have_permit(ADMIN_ITEM) || User::have_cat_permit($row["category_id"])){ if ($info == 'name' && strlen($value) >= 5 && strlen($value) <= 150) { $input = array('name' => $value); $item_memcache['name'] = $value; $output = $value; if ($value != $row['name'] && $row['is_up_auto'] == 1) { //Nếu thay đổi tên thì cập nhật cho cả lịch up tin DB::query("UPDATE up_item_schedule SET des='{$value}' WHERE item_id=" . $row['id']); } } else { if ($info == 'description') { $sapo = EClassApi::word_limit(String::html2txt(EClassApi::post_db_parse_html($value)), 30, ''); $input = array('description' => $value, 'sapo' => $sapo); $item_memcache['description'] = $value; $output = preg_replace("/\\[([\\s]*[0-9]{1,2}[\\s]*)\\]/eis", "\$this->embeded('\$1','{$item_id}')", EClassApi::parseBBCode(Url::get('value'))); } else { $input = array(); } } $item_memcache['modify_user_name'] = User::user_name(); $item_memcache['filter_des'] = ""; $input['modify_user_name'] = User::user_name(); if ($row["status"] == 2) { $item_memcache['modify_time_user'] = TIME_NOW; $input['modify_time_user'] = TIME_NOW; } if ($input) { DB::Update('item', $input, "id='" . $item_id . "'"); ///update realtime if (SORL_FILTER_ON) { $solr = new Solr_Search(); $solr->doUpdateItem($item_id); } //----- if (MEMCACHE_ON) { eb_memcache::do_put("item:{$item_id}", $item_memcache); } } echo $output; exit; /* } else{ die("no_permission"); } */ } } die("no_perm"); }
public static function UpdateCache($n, $id, $r = array()) { DB::Update($n, $id, $r); return Cache::Del(Cache::GetObjectKey($n, $id)); }
// $albumList = DB::LimitQuery('dp_album',array( 'condition'=>array('order_id'=>$order_id), )); include template('manage_misc_dp_edit'); } elseif($action == 'del'){ $order_id = $_GET['id']; DB::Delete('order_dp_item',array('order_id'=>$order_id)); DB::Delete('order_dp',array('order_id'=>$order_id)); DB::Delete('dp_album',array('order_id'=>$order_id)); DB::Update('order',$order_id,array('had_dp'=>0)); Session::Set('notice', '删除成功'); redirect( WEB_ROOT . "/manage/misc/dp.php"); } elseif ($action == 'delAlbum') { $id = $_GET['id']; $album = Table::Fetch("dp_album",$id); $order_id = $album['order_id']; DB::Delete("dp_album",array('id'=>$id)); @unlink('/static/'.$album['image']); Session::Set('notice', '删除图片成功'); redirect( WEB_ROOT . "/manage/misc/dp.php?action=edit&id=".$order_id); } else{ $condition = array(
*/ require_once dirname(dirname(__FILE__)) . '/app.php'; $action = strval($_GET['action']); /* 验证账户 */ if ($action == 'checkuser') { $username = $_GET['u']; $password = $_GET['p']; $result = MCard::checkUser($username, $password); if ($result) { Session::Set('apply_card_real_u', $result['id']); $arr_step_1 = array('user_id' => $result['id'], 'create_time' => time(), 'step' => 1); DB::Insert('mcard', $arr_step_1); $json = array('done' => true); echo formatJSON($json); die; } else { // 无信息 $json = array('done' => false); echo formatJSON($json); die; } } else { if ($action == 'sendsms') { $mobile = $_GET['m']; $card_user_id = abs(intval($_SESSION['apply_card_real_u'])); $card = DB::GetTableRow('mcard', array('user_id' => $card_user_id)); $code = mt_rand(1000, 9999); DB::Update('mcard', $card['id'], array('code' => $code)); sms_mcard_secret($mobile, $code); } }
$update['small_image'] = upload_image('small_image',$activity['small_image'],'activity'); $update['begin_time'] = strtotime($update['begin_time']); $update['end_time'] = strtotime($update['end_time']); $update['result_time'] = strtotime($update['result_time']); $insert_id = DB::Update("activity",$activity_id,$update); Session::Set('notice', '编辑活动成功!'); redirect( WEB_ROOT . "/manage/activity/index.php"); } // 所有商户 $partners = DB::LimitQuery('partner', array( 'condition'=>array('fid'=>0),
<?php /** * 编辑商圈功能 * @author abei <*****@*****.**> */ require_once(dirname(dirname(dirname(__FILE__))) . '/app.php'); require_once(dirname(__FILE__) . '/current.php'); need_manager(); $id = abs(intval($_GET['id'])); $team = $eteam = Table::Fetch('team', $id); if($_POST){ $insert = $_POST['insert']; $result = DB::Update('team',$id,$insert); Session::Set('notice', '更新商圈成功'); redirect( WEB_ROOT . "/manage/team/index.php"); } $condition = array(); $condition['zone'] = 'bizarea'; $condition['fid'] = 0; $areaList = DB::LimitQuery('category',array( 'condition'=>$condition )); if($team['area_id'] > 0){ $cond = array(); $cond['zone'] = 'bizarea';
<?php /** * 导入商家 * */ die; require_once dirname(dirname(__FILE__)) . '/app.php'; $file = file("data/card.csv"); foreach ($file as $row) { $arr = explode(',', $row); $id = $arr[0]; $arr = array('mcard_bizer_no' => '000' . $arr[1]); DB::Update('store', $id, $arr); } echo "done";
// Do not allow browsers to cache this script header("Expires: Mon, 26 Jul 1990 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); define('TGPX', TRUE); require_once '../includes/common.php'; require_once "{$GLOBALS['BASE_DIR']}/includes/mysql.class.php"; $DB = new DB($C['db_hostname'], $C['db_username'], $C['db_password'], $C['db_name']); $DB->Connect(); // Load table IniParse("{$GLOBALS['BASE_DIR']}/includes/tables.php", TRUE, $table_defs); // Create tx_ads if it doesn't already exist $tables = $DB->GetTables(); if (!isset($tables['tx_ads'])) { $DB->Update("CREATE TABLE IF NOT EXISTS `tx_ads` ( {$table_defs['tx_ads']} ) ENGINE=MyISAM"); } // Create tx_ads_used if it doesn't already exist $tables = $DB->GetTables(); if (!isset($tables['tx_ads_used'])) { $DB->Update("CREATE TABLE IF NOT EXISTS `tx_ads_used` ( {$table_defs['tx_ads_used']} ) ENGINE=MyISAM"); } // Create tx_ads_used_page if it doesn't already exist $tables = $DB->GetTables(); if (!isset($tables['tx_ads_used_page'])) { $DB->Update("CREATE TABLE IF NOT EXISTS `tx_ads_used_page` ( {$table_defs['tx_ads_used_page']} ) ENGINE=MyISAM"); } // Create tx_iplog_ads if it doesn't already exist $tables = $DB->GetTables(); if (!isset($tables['tx_iplog_ads'])) { $DB->Update("CREATE TABLE IF NOT EXISTS `tx_iplog_ads` ( {$table_defs['tx_iplog_ads']} ) ENGINE=MyISAM");
$cookie = 'linkxcaptcha'; break; } $image = null; $padding_x = 12; $padding_y = 12; $padding_chars = 5; $gdinfo = gd_info(); $verification = $gdinfo['FreeType Support'] && HaveFonts() ? new TTFVerificationCode() : new VerificationCode(); $verification->Create(); // Insert code into database and set session cookie $session = sha1(uniqid(rand(), true)); setcookie($cookie, $session, time() + 86400, '/', $C['cookie_domain']); $DB = new DB($C['db_hostname'], $C['db_username'], $C['db_password'], $C['db_name']); $DB->Connect(); $DB->Update('DELETE FROM `lx_captcha` WHERE `date_added` < ?', array(time() - 3600)); $DB->Update("INSERT INTO `lx_captcha` VALUES (?, ?, ?)", array($session, $verification->code_as_string, time())); $DB->Disconnect(); // Ouput the image if ($_SERVER['REQUEST_METHOD']) { if ($gdinfo['PNG Support']) { header("Content-type: image/png"); imagepng($verification->image); } else { header("Content-type: image/jpeg"); imagejpeg($verification->image); } } // Class to create verification codes with TTF fonts class TTFVerificationCode {
function CreateTables() { global $t; $DB = new DB($_REQUEST['db_hostname'], $_REQUEST['db_username'], $_REQUEST['db_password'], $_REQUEST['db_name']); $DB->Connect(); $tables = array(); IniParse("{$GLOBALS['BASE_DIR']}/includes/tables.php", TRUE, $tables); foreach ($tables as $name => $create) { $DB->Update("CREATE TABLE IF NOT EXISTS {$name} ( {$create} ) TYPE=MyISAM"); } $password = RandomPassword(); $domain = preg_replace('~^www\\.~', '', $_SERVER['HTTP_HOST']); $t->assign('password', $password); $DB->Update('DELETE FROM lx_administrators WHERE username=?', array('administrator')); $DB->Update('INSERT INTO lx_administrators VALUES (?,?,?,?,?,?,?,?,?,?)', array('administrator', sha1($password), '', 0, 'Administrator', "webmaster@{$domain}", 'administrator', '', 0, 0)); $DB->Disconnect(); }
<?php /** * 不推荐关键词 * @author abei <*****@*****.**> */ require_once(dirname(dirname(dirname(__FILE__))) . '/app.php'); $name = $_GET['name']; DB::Update('search_log',array('name'=>$name),array('is_top'=>0)); Session::Set('notice', '不推荐成功'); redirect( WEB_ROOT . "/manage/mltad/search.php"); ?>
team_state($team); if ($team['state'] != 'failure') { $minus = $team['conduser'] == 'Y' ? 1 : $order['quantity']; Table::UpdateCache('team', $team['id'], array('now_number' => array("now_number - {$minus}"))); } /* credit */ ZCredit::Refund($order['user_id'], $order); /* coupons */ if (in_array($team['delivery'], array('coupon', 'pickup'))) { $coupons = Table::Fetch('coupon', array($order['id']), 'order_id'); foreach ($coupons as $one) { Table::Delete('coupon', $one['id']); } } else { if ($team['delivery'] == 'voucher') { DB::Update('voucher', array('order_id' => $order['id']), array('order_id' => 0, 'user_id' => 0, 'sms' => 0)); } } /* order update */ Table::UpdateCache('order', $id, array('express_no' => '')); log_admin('order', '订单' . $order['id'] . '退款'); Session::Set('notice', '退款成功'); json(null, 'refresh'); } elseif ('orderremove' == $action) { need_auth('order'); $order = Table::Fetch('order', $id); if ($order['state'] != 'unpay') { json('付款订单不能删除', 'alert'); } /* card refund */ if ($order['card_id']) {
function TopicArticlesUpdate($ArticleID, $TopicID) { $DB = new DB(); return $DB->Update('update tbl_articles set TopicID=' . $TopicID . ' where ArticleID=' . $ArticleID); }
$DB = new DB($C['db_hostname'], $C['db_username'], $C['db_password'], $C['db_name']); $DB->Connect(); // Get scanner configuration information $config = $DB->Row('SELECT * FROM `tlx_scanner_configs` WHERE `config_id`=?', array($config_id)); if (!$config) { echo "Invalid configuration ID {$config_id}\n"; exit; } $configuration = unserialize($config['configuration']); // See if another instance of this scanner configuration is already running if ($config['pid'] != 0 && $config['status_updated'] > time() - 300) { echo "This scanner configuration is already running\n"; exit; } // Clear previous scan results $DB->Update('DELETE FROM `tlx_scanner_results` WHERE `config_id`=?', array($config_id)); // Set the last run time, pid, and status $DB->Update('UPDATE `tlx_scanner_configs` SET `current_status`=?,`status_updated`=?,`date_last_run`=?,`pid`=? WHERE `config_id`=?', array('Starting...', time(), MYSQL_NOW, getmypid(), $config_id)); // Setup the MySQL query $s =& GenerateQuery(); // Get the galleries to scan $result = $DB->Query($s->Generate(), $s->binds); $current_account = 0; $total_accounts = $DB->NumRows($result); // Create history entry $DB->Update('INSERT INTO `tlx_scanner_history` VALUES (?,?,?,?,?,?,?,?,?,?)', array(null, $config_id, MYSQL_NOW, null, $total_accounts, 0, 0, 0, 0, 0)); $history_id = $DB->InsertID(); if ($total_accounts == 0) { $DB->Update('UPDATE `tlx_scanner_configs` SET `current_status`=?,`status_updated`=? WHERE `config_id`=?', array("No accounts to scan - exiting", time(), $config_id)); sleep(10); }
} // Check dsbl.org for spam submissions if ($C['dsbl_comment'] && CheckDsbl($_SERVER['REMOTE_ADDR'])) { $v->SetError($L['DSBL_MATCHED']); } if (!$v->Validate()) { $errors = join('<br />', $v->GetErrors()); $t->assign('error', $errors); $t->display('error-nice.tpl'); exit; } $link = $DB->Row('SELECT * FROM lx_links WHERE link_id=?', array($_REQUEST['link_id'])); if ($link) { $status = $C['approve_comments'] ? 'pending' : 'approved'; $username = $account ? $account['username'] : ''; $DB->Update('INSERT INTO lx_link_comments VALUES (?,?,?,?,?,?,?,?,?)', array(null, $link['link_id'], $username, $_REQUEST['email'], $_REQUEST['name'], $_SERVER['REMOTE_ADDR'], MYSQL_NOW, $status, $_REQUEST['comment'])); if ($status == 'approved') { $DB->Update('UPDATE lx_links SET comments=comments+1 WHERE link_id=?', array($link['link_id'])); } $_REQUEST['comment_id'] = $DB->InsertID(); $t->assign_by_ref('comment', $_REQUEST); // Send e-mail to appropriate administrators $result = $DB->Query('SELECT * FROM lx_administrators'); while ($admin = $DB->NextRow($result)) { if ($admin['notifications'] & E_COMMENT) { SendMail($admin['email'], 'email-admin-comment.tpl', $t); } } $DB->Free($result); // Clear cache for the link details page if ($status == 'approved') {
public static function ExecuteNoneQuery($sql = '') { return DB::Update($sql); }
// DB::Delete('rbac_manage_role_relation',array('role_id'=>$role_id)); DB::Delete('rbac_role_resource',array('role_id'=>$role_id)); DB::Delete('rbac_auth_role',array('id'=>$role_id)); Session::Set('notice', '删除角色成功'); redirect( WEB_ROOT . "/manage/user/auth.php"); } elseif($action == 'edit'){ $role_id = $_GET['id']; $role = Table::Fetch('rbac_auth_role',$role_id); if($_POST){ $arr = $_POST['role']; DB::Update('rbac_auth_role',$role_id,$arr); Session::Set('notice', '编辑角色成功'); redirect( WEB_ROOT . "/manage/user/auth.php"); } include template('manage_user_auth_edit'); } elseif($action == 'delrelation'){ $relation_id = $_GET['id']; $relation = Table::Fetch('rbac_manage_role_relation',$relation_id); $role_id = $relation['role_id']; DB::Delete('rbac_manage_role_relation',array('id'=>$relation_id)); Session::Set('notice', '添加角色成功');
function ConvertData() { global $C, $DB, $from_shell; $errors = array(); if (!is_dir($_REQUEST['directory'])) { $errors[] = "The directory " . htmlspecialchars($_REQUEST['directory']) . " does not exist on your server"; return DisplayMain($errors); } if (!is_file("{$_REQUEST['directory']}/tgpr.pl")) { $errors[] = "The tgpr.pl file could not be found in the " . htmlspecialchars($_REQUEST['directory']) . " directory"; return DisplayMain($errors); } if (!is_readable("{$_REQUEST['directory']}/tgpr.pl")) { $errors[] = "The tgpr.pl file in the " . htmlspecialchars($_REQUEST['directory']) . " directory could not be opened for reading"; return DisplayMain($errors); } // Check version $version_file_contents = file_get_contents("{$_REQUEST['directory']}/tgpr.pl"); if (preg_match('~\\$VERSION\\s+=\\s+\'(.*?)\'~', $version_file_contents, $matches)) { list($a, $b, $c) = explode('.', $matches[1]); if ($b < 2 || strpos($c, '-SS') === FALSE) { $errors[] = "Your TGP Rotator installation is outdated; please upgrade to the very latest snapshot release (1.2.1-SS)"; return DisplayMain($errors); } } else { $errors[] = "Unable to extract version information from tgpr.pl; your version of TGP Rotator is likely too old"; return DisplayMain($errors); } // Extract MySQL information $mysql_file_contents = file_get_contents("{$_REQUEST['directory']}/data/variables"); if ($mysql_file_contents === FALSE) { $errors[] = "Unable to read contents of the variables file"; return DisplayMain($errors); } $vars = array(); if (preg_match_all('~^\\$([a-z0-9_]+)\\s+=\\s+\'(.*?)\';$~msi', $mysql_file_contents, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { $vars[$match[1]] = $match[2]; } } if (!isset($vars['USERNAME']) || !isset($vars['DATABASE']) || !isset($vars['HOSTNAME'])) { $errors[] = "Unable to extract MySQL database information from the variables file"; return DisplayMain($errors); } if (!is_writable("{$GLOBALS['BASE_DIR']}/annotations")) { $errors[] = "Change the permissions on the TGPX annotations directory to 777"; return DisplayMain($errors); } if ($C['preview_dir'] == $vars['THUMB_DIR']) { $errors[] = "The TGPX Thumbnail URL cannot be the same as the TGP Rotator Thumbnail URL"; return DisplayMain($errors); } $CONVERTDB = new DB($vars['HOSTNAME'], $vars['USERNAME'], $vars['PASSWORD'], $vars['DATABASE']); $CONVERTDB->Connect(); $CONVERTDB->Update('SET wait_timeout=86400'); $columns = $CONVERTDB->GetColumns('tr_Galleries'); if (!in_array('Thumbnail_URL', $columns)) { $errors[] = "Your TGP Rotator installation is outdated; please upgrade to the latest snapshot release"; return DisplayMain($errors); } if (!$from_shell) { echo "<pre>"; } // Copy annotations FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Copying annotation font files and images...\n"); echo "Copying annotation font files and images...\n"; flush(); $annotations =& DirRead($vars['ANNOTATION_DIR'], '^[^.]'); foreach ($annotations as $annotation) { @copy("{$vars['ANNOTATION_DIR']}/{$annotation}", "{$GLOBALS['BASE_DIR']}/annotations/{$annotation}"); } // Copy thumbnail previews FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Copying thumbnail preview images...\n"); echo "Copying thumbnail preview images...\n"; flush(); $thumbs =& DirRead($vars['THUMB_DIR'], '\\.jpg$'); foreach ($thumbs as $thumb) { @copy("{$vars['THUMB_DIR']}/{$thumb}", "{$C['preview_dir']}/t_{$thumb}"); @chmod("{$C['preview_dir']}/t_{$thumb}", 0666); } // // Dump annotations FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting annotation settings...\n"); echo "Converting annotation settings...\n"; flush(); $annotations = array(); $DB->Update('DELETE FROM `tx_annotations`'); $result = $CONVERTDB->Query('SELECT * FROM `tr_Annotations`'); while ($annotation = $CONVERTDB->NextRow($result)) { $DB->Update('INSERT INTO `tx_annotations` VALUES (?,?,?,?,?,?,?,?,?,?,?,?)', array(null, $annotation['Identifier'], strtolower($annotation['Type']), $annotation['String'], 0, $annotation['Font_File'], $annotation['Size'], $annotation['Color'], $annotation['Shadow'], $annotation['Image_File'], $annotation['Transparency'], $annotation['Location'])); $annotations[$annotation['Unique_ID']] = $DB->InsertID(); } $CONVERTDB->Free($result); // // Dump categories FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting categories...\n"); echo "Converting categories...\n"; flush(); $categories = array(); $category_ids = array(); $DB->Update('DELETE FROM `tx_categories`'); $result = $CONVERTDB->Query('SELECT * FROM `tr_Categories`'); while ($category = $CONVERTDB->NextRow($result)) { $tag = CreateCategoryTag($category['Name']); $categories[$category['Name']] = $tag; $DB->Update('INSERT INTO `tx_categories` VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', array(null, $category['Name'], $tag, empty($category['Pictures']) ? 0 : 1, $category['Pictures'], 10, 30, 12288, "{$vars['THUMB_WIDTH']}x{$vars['THUMB_HEIGHT']}", 1, $annotations[$category['Ann_Pictures']], empty($category['Movies']) ? 0 : 1, $category['Movies'], 5, 30, 102400, "{$vars['THUMB_WIDTH']}x{$vars['THUMB_HEIGHT']}", 1, $annotations[$category['Ann_Movies']], -1, 0, null, null, null)); $category_ids[$category['Name']] = $DB->InsertID(); } $CONVERTDB->Free($result); // // Dump sponsors FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting sponsors...\n"); echo "Converting sponsors...\n"; flush(); $counter = 1; $sponsors = array(); $DB->Update('DELETE FROM `tx_sponsors`'); $result = $CONVERTDB->Query('SELECT DISTINCT `Sponsor` FROM `tr_Galleries` WHERE `Sponsor`!=?', array('')); while ($sponsor = $CONVERTDB->NextRow($result)) { $sponsors[$sponsor['Sponsor']] = $counter; $DB->Update("INSERT INTO `tx_sponsors` VALUES (?,?,?)", array($counter++, $sponsor['Sponsor'], null)); } $CONVERTDB->Free($result); // // Dump gallery data FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting gallery data...\n"); echo "Converting gallery data...\n"; flush(); $DB->Update('DELETE FROM `tx_galleries`'); $DB->Update('DELETE FROM `tx_gallery_fields`'); $DB->Update('DELETE FROM `tx_gallery_icons`'); $DB->Update('DELETE FROM `tx_gallery_previews`'); $DB->Update('ALTER TABLE `tx_galleries` AUTO_INCREMENT=0'); $DB->Update('ALTER TABLE `tx_gallery_previews` AUTO_INCREMENT=0'); $result = $CONVERTDB->Query('SELECT * FROM `tr_Galleries` ORDER BY `Gallery_ID`'); $preview_sizes = array(); while ($gallery = $CONVERTDB->NextRow($result)) { $DB->Update("INSERT INTO `tx_galleries` VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", array(null, $gallery['Gallery_URL'], $gallery['Description'], $gallery['Keywords'], $gallery['Thumbnails'], $C['from_email'], null, $gallery['Weight'], $gallery['Clicks'], $_SERVER['REMOTE_ADDR'], null, !empty($gallery['Sponsor']) ? $sponsors[$gallery['Sponsor']] : null, 'permanent', strtolower($gallery['Type']), $gallery['Status'] == 'Pending' ? 'approved' : strtolower($gallery['Status']), $gallery['Status'] == 'Disabled' ? 'approved' : null, date(DF_DATETIME, TimeWithTz($gallery['Added'])), date(DF_DATETIME, TimeWithTz($gallery['Added'])), date(DF_DATETIME, TimeWithTz($gallery['Added'])), empty($gallery['Scheduled_Date']) ? null : "{$gallery['Scheduled_Date']} 00:00:00", empty($gallery['Display_Date']) ? null : "{$gallery['Display_Date']} 12:00:00", null, null, 'TGPR Convert', '', null, 0, empty($gallery['Thumbnail_URL']) ? 0 : 1, $gallery['Allow_Scan'], $gallery['Allow_Thumb'], $gallery['Times_Selected'], $gallery['Used_Counter'], $gallery['Build_Counter'], null, MIXED_CATEGORY . " " . $categories[$gallery['Category']])); $gallery_id = $DB->InsertID(); $gallery_info = array('gallery_id' => $gallery_id); $insert = CreateUserInsert('tx_gallery_fields', $gallery_info); $DB->Update('INSERT INTO `tx_gallery_fields` VALUES (' . $insert['bind_list'] . ')', $insert['binds']); foreach (explode(',', $gallery['Icons']) as $icon_id) { if (isset($icons[$icon_id])) { $DB->Update('INSERT INTO `tx_gallery_icons` VALUES (?,?)', array($gallery_id, $icons[$icon_id])); } } if (!empty($gallery['Thumbnail_URL'])) { $dimensions = ''; if (!empty($gallery['Thumb_Width']) && !empty($gallery['Thumb_Height'])) { $dimensions = "{$gallery['Thumb_Width']}x{$gallery['Thumb_Height']}"; $preview_sizes[$dimensions] = TRUE; } $DB->Update('INSERT INTO `tx_gallery_previews` VALUES (?,?,?,?)', array(null, $gallery_id, '', $dimensions)); $preview_id = $DB->InsertID(); if (preg_match('~^' . preg_quote($vars['THUMB_URL']) . '~i', $gallery['Thumbnail_URL'])) { $gallery['Thumbnail_URL'] = "{$C['preview_url']}/{$preview_id}.jpg"; $DB->Update('UPDATE `tx_gallery_previews` SET `preview_url`=? WHERE `preview_id`=?', array($gallery['Thumbnail_URL'], $preview_id)); @rename("{$C['preview_dir']}/t_{$gallery['Gallery_ID']}.jpg", "{$C['preview_dir']}/{$preview_id}.jpg"); } } } $CONVERTDB->Free($result); // Update the stored thumbnail preview sizes $sizes = unserialize(GetValue('preview_sizes')); if (!is_array($sizes)) { $sizes = array(); } $sizes = array_merge($sizes, array_keys($preview_sizes)); StoreValue('preview_sizes', serialize(array_unique($sizes))); // // Dump TGP page data FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting TGP pages...\n"); echo "Converting TGP pages...\n"; flush(); $build_order = 1; $DB->Update('DELETE FROM `tx_pages`'); $DB->Update('ALTER TABLE `tx_pages` AUTO_INCREMENT=0'); $result = $CONVERTDB->Query('SELECT * FROM `tr_Pages` ORDER BY `Build_Order`'); while ($page = $CONVERTDB->NextRow($result)) { $template = file_get_contents("{$_REQUEST['directory']}/data/pages/{$page['Page_ID']}"); $template = ConvertTemplate($template); $compiled = ''; $page['Directory'] = preg_replace('~/$~', '', $page['Directory']); $DB->Update('INSERT INTO `tx_pages` VALUES (?,?,?,?,?,?,?,?,?)', array(null, "{$page['Directory']}/{$page['Filename']}", $page['Page_URL'], $page['Category'] == 'Mixed' ? null : $category_ids[$page['Category']], $build_order++, 0, null, $template, $compiled)); } $CONVERTDB->Free($result); FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "\nData conversion complete!"); echo "\nData conversion complete!\n"; if (!$from_shell) { echo "</pre>"; } }
function UpdateAreaGroupID($ParentAreaID, $GroupID) { $DB = new DB(); $sql = 'UPDATE `tbl_location` SET GroupID=' . $GroupID . ' WHERE AreaID=' . $ParentAreaID; if ($DB->Update($sql)) { $sql = 'Select AreaID FROM `tbl_location` WHERE ParentAreaID=' . $ParentAreaID; $rs = $DB->Select($sql); if ($rs) { foreach ($rs as $list) { UpdateAreaGroupID($list['AreaID'], $GroupID); } } } }
function edit_user_info() { $user_id = (int) Url::get('user_id', 0); $info = AZLib::getParam('id'); $value = AZLib::getParam('value'); $input = array(); $output = ''; if ($user_id && (User::have_permit(ADMIN_USER) || User::id() == $user_id && !User::is_block())) { if ($info == 'up_item') { if (User::is_admin()) { $user = DB::select('user', "id={$user_id}"); if (User::is_root()) { $value = (int) $value; $input = array('up_item' => $value > 0 ? $value : 0); $output = '<b>' . $value . '</b>'; echo $output; $admin = User::$current->data; if ($user) { $up_count = $value - $user['up_item']; if ($up_count != 0) { //type: 0:Tiền mặt; 1:thu tại nhà; 2:chuyển khoản; 3:Free, KM; 8:Online $up_log_sql = "INSERT INTO up_log (`user_id`,\t`user_name`,\t\t\t`admin_id`,\t\t`admin_name`,\t\t\t`time`,\t `up_count`,`up_before`,\t\t`up_after`,\t`price`,\t`type`,\t\t`note`)\r\n\t VALUES ({$user['id']},\t'{$user['user_name']}',{$admin['id']},\t'{$admin['user_name']}'," . TIME_NOW . ",{$up_count},'{$user['up_item']}',{$value},\t\t0,\t\t\t3,\t\t\t'')"; DB::query($up_log_sql); if ($up_count > 0) { $update = DB::query('UPDATE user SET up_item=up_item + ' . $up_count . ' WHERE id=' . $user_id); } else { $update = DB::query('UPDATE user SET up_item=up_item - ' . abs($up_count) . ' WHERE id=' . $user_id); } //DB::Update('user',$input,"id=$user_id"); User::getUser($user_id, 0, 1); } } } else { $output = "<b>" . (int) $user['up_item'] . "</b>"; echo $output; } exit; } else { $output = '<b>' . $value . '</b>'; echo $output; exit; } } elseif (!AZLib::checkBadWord($value) || User::have_permit(ADMIN_USER)) { $output = 'Chức năng này đang được bổ sung. Ấn F5 để tải lại trang.'; if ($info == 'blast') { $input = array('blast' => $value); $userblast = ' ' . AZLib::BBCode(AZLib::cleanHtml($value)); if (strpos($userblast, 'http://')) { $user_blast = $userblast; while (strpos($user_blast, 'http://')) { $tmp = substr($user_blast, strpos($user_blast, 'http://')); if (strpos($tmp, ' ') || strpos($tmp, '<')) { if (strpos($tmp, ' ') && strpos($tmp, '<') && strpos($tmp, ' ') > strpos($tmp, '<')) { $blast_url = substr($tmp, 0, strpos($tmp, '<')); } else { $blast_url = substr($tmp, 0, strpos($tmp, ' ')); } } else { $blast_url = $tmp; } $user_blast = str_replace($blast_url, '', $user_blast); } $new_blast_url = ' <a href="' . $blast_url . '" target="_blank">Click here</a>'; $userblast = substr($user_blast . $new_blast_url, 1); } $user = User::getUser($user_id); if ($value) { //blast không trống if ($value != $user['blast']) { //Thay đổi blast DB::delete("feed", "user_id={$user_id} AND type = 8"); //thêm vào feed cho các thành viên theo đuôi DB::query("INSERT INTO \tfeed \t(type, \tuser_id, act_user_id, time)\r\n VALUES\t(8,\t\t{$user_id}, {$user_id}, " . TIME_NOW . ")"); } } else { //Xoá blast DB::delete("feed", "user_id={$user_id} AND type = 8"); } $output = $userblast . ' <img src="style/images/icon/icon_edit.gif" title="Click để sửa..." alt="Click để sửa..." class="hand_point" rel="blast" align="absmiddle">'; } elseif ($info == 'address') { $input = array('address' => trim($value)); $output = AZLib::word_limit($value, 12, ''); } elseif ($info == 'mobile_phone') { $value = preg_replace("/[^0-9]/", "", $value); if (!AZLib::is_mobile($value)) { $value = ''; } $input = array('mobile_phone' => trim($value)); $output = AZLib::word_limit($value, 10, ''); } elseif ($info == 'home_phone') { if (User::have_permit(ADMIN_USER) || User::$current->data['phone_verify'] == 0) { $value = preg_replace("/[^0-9]/", "", $value); if (AZLib::is_mobile($value) || substr($value, 0, 1) != "0") { $value = ''; } $input = array('home_phone' => trim($value)); $output = AZLib::word_limit($value, 10, ''); } } elseif ($info == 'yahoo_id') { $input = array('yahoo_id' => trim($value)); $output = AZLib::word_limit($value, 12, ''); } elseif ($info == 'skype_id') { $input = array('skype_id' => trim($value)); $output = AZLib::word_limit($value, 12, ''); } elseif ($info == 'website') { $input = array('website' => trim($value)); $website = $value; if ($website != '') { if (strrpos($website, 'ttp://') != 1) { $website = 'http://' . $website; } if (strlen($website) > 8) { if (strpos($website, '/', 8) > 0) { $website = substr($website, 0, strpos($website, '/', 8)); } } } $website = '<a href="' . $value . '" target="_blank" class="lineHeight18"><strong>' . AZLib::strippedLink($website, 26) . '</strong></a>'; $output = $website; } elseif ($info == 'email' && User::is_admin()) { $input = array('email' => trim($value)); $output = $value; } elseif ($info == 'signature') { $input = array('signature' => trim($value)); $output = AZLib::parseBBCode(AZLib::cleanHtml($value)); } else { $output = ''; } echo $output; } else { echo 'Nội dung có từ xấu! Click để sửa nhanh.'; exit; } } else { echo 'Bạn không có quyền sửa thông tin thành viên'; exit; } if ($input) { DB::Update('user', $input, "id={$user_id}"); User::getUser($user_id, 0, 1); } exit; }
'condition' => array( 'team_id' => $id, 'user_id' => $login_user_id, 'state' => 'unpay', 'rstate' => 'normal', ), 'one' => true, )); } /* end order */ /* change attentions */ $current_team = DB::LimitQuery('team', array('condition' => array('id' => $id),'select' => 'attention, ips')); if(strpos($current_team[0]['ips'], Utility::GetRemoteIp()) === false){ DB::Update('team', array('id' => $id), array( 'ips' => '-'. Utility::GetRemoteIp(), 'attention' => $current_team[0]['attention'] + 1, )); } /* end change attentions */ /*kxx team_type */ if ($team['team_type'] == 'seconds') { die(include template('team_view_seconds')); } if ($team['team_type'] == 'goods') { die(include template('team_view_goods')); } /*xxk*/ $ll = $partner['longlat']; if ($ll) list($lati,$longi) = preg_split('/[,\s]+/',$ll,-1,PREG_SPLIT_NO_EMPTY); /**
} if (!$id) { $team['now_number'] = $team['pre_number']; } else { $field = strtoupper($table->conduser) == 'Y' ? null : 'quantity'; $now_number = Table::Count('order', array('team_id' => $id, 'state' => 'pay'), $field); $team['now_number'] = $now_number + $team['pre_number']; /* 增加了总数,未卖完状态 */ if ($team['max_number'] > $team['now_number']) { $team['close_time'] = 0; $insert[] = 'close_time'; } /* update coupon */ DB::Update('coupon', array('team_id' => $id), array('expire_time' => $team['expire_time'], 'partner_id' => $team['partner_id'])); /* update order */ DB::Update('order', array('team_id' => $id), array('allowrefund' => $team['allowrefund'])); } //dbx($team); $insert = array_unique($insert); $table = new Table('team', $team); $table->SetStrip('detail', 'systemreview', 'notice'); if ($team['id'] && $team['id'] == $id) { $table->SetPk('id', $id); $table->update($insert); log_admin('team', '编辑team项目', $insert); Session::Set('notice', '编辑项目信息成功'); redirect(WEB_ROOT . "/manage/team/index.php"); } else { if ($team['id']) { log_admin('team', '非法编辑team项目', $insert); Session::Set('error', '非法编辑');