public function testUpdate() { $row = $this->table->create(array())->current(); $data = array("created" => new \pq\DateTime("2013-03-03 03:03:03"), "counter" => 2, "number" => 2.2, "data" => "this is a test", "list" => array(3, 2, 1), "prop" => null); $row = $this->table->update(array("id = " => $row->id), $data)->current(); $data = array("id" => $row->id->get()) + $data; $this->assertEquals($data, $row->getData()); }
/** * @return mixed The primary key value(s), as an associative array if the * key is compound, or a scalar if the key is single-column. */ protected function _doUpdate() { /** * Get expressions for a WHERE clause * based on the primary key value(s). */ $where = $this->_getWhereQuery(false); /** * Compare the data to the modified fields array to discover * which columns have been changed. */ $diffData = array_intersect_key($this->getArrayCopy(), $this->_cleanData); /** * Execute the UPDATE (this may throw an exception) * Do this only if data values were changed. * Use the $diffData variable, so the UPDATE statement * includes SET terms only for data values that changed. */ if (count($diffData) > 0) { $this->_table->update($diffData, $where); } /** * Return the primary key value(s) as an array */ $primaryKey = $this->_getPrimaryKey(true); return $primaryKey; }
public function testUpdateData() { $table = new Table(__DIR__ . '/data/sample.json'); $this->assertSame([['_id' => '2', 'name' => 'bar']], $table->find(['_id' => '2'])); $table->update(['_id' => '2'], ['name' => 'gaz']); $this->assertSame([['_id' => '2', 'name' => 'gaz']], $table->find(['_id' => '2'])); }
public static function SetState($team) { if ($team['now_number'] >= $team['max_number']) { $team['state'] = 'soldout'; } else { if ($team['now_number'] >= $team['min_number']) { $team['state'] = 'success'; } else { $team['state'] = 'failuer'; } } $team['close_time'] = $team['close_time'] ? $team['close_time'] : strtotime(date('Y-m-d')); $table = new Table('team', $team); $table->update(array('close_time', 'state')); self::SetOrderState($team); }
if (empty($mysqlRs)) { exit("所有数据处理完毕!"); } foreach ($mysqlRs as $value) { $id = $value["id"]; if (!strstr($value["redword"], "+")) { continue; } echo $value["keyword"] . "\n"; echo $value["redword"]; echo "\n"; $redword = str_replace("+", "", $value["redword"]); $redword = preg_replace("/[\\s]+/is", " ", $redword); echo $redword; echo "\n"; $conn->update("update gckeyword.key_proword set redword = '" . $redword . "' where id = '" . $value["id"] . "'"); try { $beanstalk->choose('v3www_prokeyword_cachewrite'); echo $beanstalk->put($value["keyword"], array('priority' => 1024, 'delay' => 0, 'ttr' => 86400)), "\n"; } catch (\Exception $e) { } exit; } } class Config { public static $dbArr = array('localhost' => array('192.168.12.70', "root", "123456", "test"), 'online' => array('192.168.2.163', "gongchangdb", "gongchangdb7232275", "caijiproductinfo"), 'info' => array('192.168.2.101', 'hangye', 'hangye7232275', 'hangye'), 'local' => array('192.168.8.18', 'root', 'gc7232275', 'gcoperate'), "local170" => array('192.168.8.170', "root", "gc7232275", "test"), 'local189' => array('192.168.8.189', 'gongchang', 'gongchang123', 'gckeyword'), 'main' => array('read.mysql.ch.gongchang.com', 'gcwork', 'gcwork7232275', 'catesearch'), 'maind' => array('write.mysql.ch.gongchang.com', 'gcwork', 'gcwork7232275', 'catesearch'), "product" => array("pdinfo.read.mysql.ch.gongchang.com", "gccontent", "gccontent7232275", "caijiproductinfo"), 'club' => array('55651c3e54ae6.sh.cdb.myqcloud.com', 'cdb_outerroot', 'ScIwH*3fEB(', 'cn_clubnew', 8287), 'txonline' => array('172.17.18.4', 'gckeyword', 'WVwVaxADjX9z3PHd', 'gckeyword')); public static $cateApiUrl = 'http://cate.ch.gongchang.com/cate_json/'; } class Table {
<?php require_once dirname(dirname(__FILE__)) . '/app.php'; need_partner(); $id = abs(intval($_GET['id'])); $ask = Table::Fetch('ask', $id); $partner_id = abs(intval($_SESSION['partner_id'])); need_biz_auth($ask['partner_id'] == $partner_id); if (!$ask) { redirect(WEB_ROOT . '/biz/ask.php'); } if ($ask['type'] == 'transfer' && empty($ask['comment'])) { $ask['comment'] = '顶'; } if ($_POST && $id == $_POST['id']) { $table = new Table('ask', $_POST); $table->update(array('comment', 'content')); redirect(udecode($_GET['r'])); } $team = Table::Fetch('team', $ask['team_id']); $user = Table::Fetch('user', $ask['user_id']); include template('biz_askedit');
<?php require_once dirname(dirname(__FILE__)) . '/app.php'; need_partner(); $partner_id = abs(intval($_SESSION['partner_id'])); $login_partner = Table::Fetch('partner', $partner_id); foreach ($_GET as $key => $val) { if ($val == 'Checkoff') { $coupon = Table::Fetch('coupon', $key); $array = array('consume', 'consume_time'); $coupon['consume'] = 'Y'; $coupon['consume_time'] = time(); $table = new Table('coupon', $coupon); $flag = $table->update($array); if ($flag) { Session::Set('notice', 'coupon has been Checkoff.'); } } elseif ($val == 'Print') { print_r("this is priint"); } } $title = strval($_GET['title']); $condition = $t_con = array('partner_id' => $partner_id); if ($title) { $t_con[] = "title like '%" . mysql_escape_string($title) . "%'"; $teams = DB::LimitQuery('team', array('condition' => $t_con)); $team_ids = Utility::GetColumn($teams, 'id'); if ($team_ids) { $condition['team_id'] = $team_ids; } else { $title = null;
need_manager(); need_auth('market'); $finance_id = abs(intval($_GET['id'])); if (!$finance_id || !$finance = Table::FetchForce('finance', $finance_id) ) { Session::Set('error', '结算信息不存在'); redirect( WEB_ROOT . '/manage/partner/index.php' ); } if(is_post()){ $table = new Table('finance', array('id'=>$finance_id, 'tell'=>'', 'remark'=>'', 'method'=>'')); $table->tell = trim(strval($_POST['tell'])); $table->remark = trim(strval($_POST['remark'])); $table->method = trim(strval($_POST['method'])); $table->update(array('tell', 'remark', 'method',)); Session::Set('notice', '更新结算信息成功,不可更改结算时间'); redirect( WEB_ROOT . '/manage/partner/showcalculate.php?id='.$finance_id); } $sql = "SELECT COUNT(*) AS num, team_id FROM `coupon` WHERE `consume_time` <= ".$finance['end_time']." AND `consume_time` > ".$finance['begin_time']." AND `partner_id` = ".$finance['partner_id']." AND `consume` = 'Y' GROUP BY `team_id`"; $coupons = DB::GetQueryResult($sql, false); //die(print_R($coupons)); $coupons_count = count($coupons); list($pagesize, $offset, $pagestring) = pagestring($coupons_count, 20); $sql .= ' LIMIT '.$offset.','.$pagesize; $coupons = DB::GetQueryResult($sql, false); $team_ids = Utility::GetColumn($coupons, 'team_id'); $teams = Table::Fetch('team', $team_ids);
$partner = Table::Fetch('partner', $_POST['id']); if($partner['fid']!=$partner_id) { Session::Set('error', '请合法操作,该账号不属于你的管理'); redirect( WEB_ROOT . '/m_biz/account.php'); } $table = new Table('partner', $_POST); $table->SetStrip('location', 'other'); //check username $table->username = $p_username = trim(strval($table->username)); $u_partner = Table::Fetch('partner', $p_username, 'username'); if($u_partner){ Session::Set('error', '该用户名已存在'); redirect( WEB_ROOT . '/m_biz/changeusername.php?id='.$partner['id']); } $result = $table->update(array('username', )); if(!$result){ Session::Set('error', '账号信息修改失败'); redirect( WEB_ROOT . '/m_biz/changeusername.php?id='.$partner['id']); }else{ Session::Set('notice', '账号信息修改成功'); redirect( WEB_ROOT . '/m_biz/account.php'); } }else{ Session::Set('error', '密码输入错误'); redirect( WEB_ROOT . '/m_biz/account.php'); } }
$table->image = upload_image('upload_image', $team['image'], 'team'); $table->image1 = upload_image('upload_image1', $team['image1'], 'team', 380); $table->image2 = upload_image('upload_image2', $team['image2'], 'team', 380); $error_tip = array(); if (!$error_tip) { if ($table->update($insert)) { if ($_POST['charity_id'] != 0) { if ($_POST['deal_charity_id'] != "") { $dealcharity['id'] = $_POST['deal_charity_id']; } $dealcharity['charity_id'] = $_POST['charity_id']; $dealcharity['value'] = str_replace('%', '', $_POST['charityvalue']); $dealcharity['deal_id'] = $_POST['id']; $dcTable = new Table('deals_charity', $dealcharity); $dealinsert = array('charity_id', 'value', 'deal_id'); $dcTable->update($dealinsert); } Session::Set('notice', 'Modify deal information successfully'); Utility::Redirect(WEB_ROOT . "/manage/team/index.php"); } else { Session::Set('error', 'Modify team information failed, check your system setting please.'); } } } $charity = Table::Fetch('deals_charity', $id, 'deal_id'); if ($charity) { $charityvalue = $charity['value'] . '%'; } $groups = DB::LimitQuery('category', array('condition' => array('zone' => 'group'))); $groups = Utility::OptionArray($groups, 'id', 'name'); $partners = DB::LimitQuery('partner', array('order' => 'ORDER BY id DESC'));
*/ $file = "keyword.txt"; $fp = fopen($file, "r"); $conn = new Table("txonline"); while (!feof($fp)) { $line = fgets($fp); $keyword = trim($line); if (empty($keyword)) { continue; } $keywordRs = $conn->findOne("select id, keyword from gckeyword.key_proword where keyword = '{$keyword}' limit 1"); if (empty($keywordRs)) { continue; } echo $keyword . "\n"; $conn->update("update gckeyword.key_proword set is_select = 0 where id = '" . $keywordRs["id"] . "'"); } class Config { public static $dbArr = array('localhost' => array('192.168.12.70', "root", "123456", "test"), 'online' => array('192.168.2.163', "gongchangdb", "gongchangdb7232275", "caijiproductinfo"), 'info' => array('192.168.2.101', 'hangye', 'hangye7232275', 'hangye'), 'local' => array('192.168.8.18', 'root', 'gc7232275', 'gcoperate'), "local170" => array('192.168.8.170', "root", "gc7232275", "test"), 'local189' => array('192.168.8.189', 'gongchang', 'gongchang123', 'gckeyword'), 'main' => array('read.mysql.ch.gongchang.com', 'gcwork', 'gcwork7232275', 'catesearch'), 'maind' => array('write.mysql.ch.gongchang.com', 'gcwork', 'gcwork7232275', 'catesearch'), "product" => array("pdinfo.read.mysql.ch.gongchang.com", "gccontent", "gccontent7232275", "caijiproductinfo"), 'club' => array('55651c3e54ae6.sh.cdb.myqcloud.com', 'cdb_outerroot', 'ScIwH*3fEB(', 'cn_clubnew', 8287), 'txonline' => array('172.17.18.4', 'gckeyword', 'WVwVaxADjX9z3PHd', 'gckeyword')); public static $cateApiUrl = 'http://cate.ch.gongchang.com/cate_json/'; } class Table { public $conn = ''; public $config; public function __construct($connName) { $db = Config::$dbArr; $this->config = $db[$connName]; try {
<?php require_once dirname(dirname(__FILE__)) . '/app.php'; need_login(); if ($_POST) { $table = new Table('user', $_POST); $table->SetPk('id', $login_user_id); $update = array('username', 'realname', 'zipcode', 'address', 'mobile', 'avatar'); if ($table->password == $table->password2 && $table->password) { $update[] = 'password'; $table->password = ZUser::GenPassword($table->password); } $table->avatar = upload_image('upload_image', $login_user['avatar'], 'user'); $table->update($update); Utility::Redirect(WEB_ROOT . '/account/settings.php '); } include template('account_settings');
function team_state(&$team) { if ($team['max_number'] > 0 && $team['now_number'] >= $team['max_number']) { if ($team['close_time'] == 0) { $team['close_time'] = $team['end_time']; } return $team['state'] = 'soldout'; } else { if ($team['end_time'] <= time()) { $team['close_time'] = $team['end_time']; if ($team['now_number'] < $team['min_number']) { $team['state'] = 'failure'; $table = new Table('team', $team); $table->update(array('close_time', 'state')); return $team['state'] = 'failure'; } return $team['state'] = 'success'; } } return $team['state'] = 'none'; }
$store = Table::Fetch('store', $_POST['store_id']); if($store['partner_id']!=$partner_id) { Session::Set('error', '请合法操作,该门店不属于你的管理'); redirect( WEB_ROOT . '/m_biz/index.php'); } $partner = Table::Fetch('partner', $_POST['id']); if($partner['fid']!=$partner_id) { Session::Set('error', '请合法操作,该账号不属于你的管理'); redirect( WEB_ROOT . '/m_biz/account.php'); } $table = new Table('partner', $_POST); $table->SetStrip('location', 'other'); $table->password = ZPartner::GenPassword($_POST['password']); $result = $table->update(array('password',)); if(!$result){ Session::Set('error', '密码修改失败'); redirect( WEB_ROOT . '/m_biz/changeusername.php?id='.$partner['id']); }else{ Session::Set('notice', '账号信息修改成功'); redirect( WEB_ROOT . '/m_biz/account.php'); } }else{ Session::Set('error', '密码输入错误'); redirect( WEB_ROOT . '/m_biz/account.php'); } }
$newEnd = $new4; } elseif ($new3) { $newEnd = $new3; } elseif ($new2) { $newEnd = $new2; } $oldEnd = 0; if ($old4) { $oldEnd = $old4; } elseif ($old3) { $oldEnd = $old3; } elseif ($old2) { $oldEnd = $old2; } /* 更新下新分类里的末级分类 */ $conn->update("update forbuyscateinfo.fbcate_cateinfo set is_leaf = 1 where cateid = '" . $newEnd . "'"); /* 将old分类里的末级分类标记为is_map*/ $conn->update("update forbuyscateinfo.f_cate set is_map = 1 where cid = '" . $oldEnd . "'"); /* 绑定下对应关系 */ $insertArr = array("old1" => $old1, "old2" => $old2, "old3" => $old3, "old4" => $old4, "new1" => $new1, "new2" => $new2, "new3" => $new3, "new4" => $new4); $conn->insert($insertArr, "forbuyscateinfo.fbcate_catemap"); output("分类copy并且对应成功!", "http://catemap.forbuyers.cn/map.php"); function getCateNew($catename) { global $conn; $result = $conn->findOne("select cateid, catename, parentid from forbuyscateinfo.fbcate_cateinfo where catename = '{$catename}' limit 1"); if (empty($result)) { return array(); } return $result; }
/** * Record can't be updated cause its not new * * @expectedException CDbException */ public function testUpdateException() { $table = new Table(); $table->setAttribute('TABLE_NAME', 'test2'); $table->update(); }
<?php require_once(dirname(dirname(__FILE__)) . '/app.php'); need_partner_m(); $partner_id = abs(intval($_SESSION['partner_id'])); $login_partner = $partner = Table::Fetch('partner', $partner_id); if ( $_POST ) { $table = new Table('partner', $_POST); $table->SetStrip('location', 'other'); $table->SetPk('id', $partner_id); if ( $table->password == $table->password2 && $table->password ) { $update[] = 'password'; $table->password = ZPartner::GenPassword($table->password); } $flag = $table->update($update); if ( $flag ) { Session::Set('notice', '密码修改成功,请将修够后的新密码通知到其他使用此账号的人员.'); redirect( WEB_ROOT . "/biz/settings.php"); } Session::Set('error', '修改商户信息失败'); $partner = $_POST; } include template('biz_settings');
$table->open = (strtoupper($table->open)=='Y') ? 'Y' : 'N'; $table->store_logo = upload_image('store_logo',$store['store_logo'],'team'); $table->store_bg = upload_image('store_bg',$store['store_bg'],'team'); $table->store_banner = upload_image('store_banner',$store['store_banner'],'team'); $table->store_small_logo = upload_image('store_small_logo',$store['store_small_logo'],'team'); $table->image = upload_image('image',$store['image'],'team'); $up_array = array( 'name', 'brand', 'city_id', 'longlat', 'region', 'partner_id', 'type', 'telphone', 'address', 'create_time', 'businesszone', 'location', 'other', 'open', 'longlat','head', 'contact','jtxl','yysj','mcard_bizer_no', 'store_logo','store_bg','store_banner','store_small_logo','car_yh','image' ); $flag = $table->update( $up_array ); if ( $flag ) { Session::Set('notice', '修改门店信息成功'); redirect( WEB_ROOT . "/manage/store/edit.php?id={$id}"); } Session::Set('error', '修改门店信息失败'); $store = $_POST; } $partners = DB::LimitQuery('partner', array( 'condition'=>array('fid'=>0), 'order' => 'ORDER BY id DESC', )); $partners = Utility::OptionArray($partners, 'id', 'title'); include template('manage_store_edit');
<?php require_once dirname(dirname(dirname(__FILE__))) . '/app.php'; need_manager(true); $pages = array('help_tour' => '玩转' . $INI['system']['abbreviation'], 'help_faqs' => '常见问题', 'help_zuitu' => '什么是' . $INI['system']['abbreviation'], 'help_api' => '开发API', 'about_contact' => '联系方式', 'about_us' => '关于' . $INI['system']['abbreviation'], 'about_job' => '工作机会', 'about_terms' => '用户协议', 'about_privacy' => '隐私声明'); $id = strval($_GET['id']); if ($id && !in_array($id, array_keys($pages))) { Utility::Redirect(WEB_ROOT . "/manage/system/page.php"); } $n = Table::Fetch('page', $id); if ($_POST) { $table = new Table('page', $_POST); $table->SetStrip('value'); if ($n) { $table->SetPk('id', $id); $table->update(array('id', 'value')); } else { $table->insert(array('id', 'value')); } Session::Set('notice', "页面:{$pages[$id]}编辑成功"); Utility::Redirect(WEB_ROOT . "/manage/system/page.php?id={$id}"); } $value = $n['value']; include template('manage_system_page');
<?php require_once dirname(dirname(dirname(__FILE__))) . '/app.php'; need_manager(); need_auth('admin'); $id = abs(intval($_REQUEST['id'])); $category = Table::Fetch('category', $id); $table = new Table('category', $_POST); $table->letter = strtoupper($table->letter); $uarray = array('zone', 'ename', 'letter', 'name', 'czone', 'sort_order'); if (!$_POST['name'] || !$_POST['ename'] || !$_POST['letter']) { Session::Set('error', '中文名称、英文名称、首字母均不能为空'); Utility::Redirect(null); } if ($category) { if ($flag = $table->update($uarray)) { Session::Set('notice', '编辑分类成功'); } else { Session::Set('error', '编辑分类失败'); } option_category($category['zone'], true); } else { if ($flag = $table->insert($uarray)) { Session::Set('notice', '新建分类成功'); } else { Session::Set('error', '新建分类失败'); } } option_category($table->zone, true); Utility::Redirect(null);
$oc = array("user_id"=>$_SESSION['user_id'],'team_id'=>$id); $lottery_new = DB::LimitQuery('lottery', array( 'condition' => $oc, 'order' => 'ORDER BY `add_time` DESC', )); $lottery_id = $lottery_new['0']['id']; $team_shop_lottery = unserialize($team['package_upload_image']); //var_dump($team_shop_lottery); if ( $_POST ) { $table = new Table('lottery', array('gifts_name'=>$_POST['lottery_gifts'],'address'=>$_POST['address'],'id'=>$lottery_id)); $insert = array( 'gifts_name', 'address', ); if ($flag = $table->update($insert)) { $lottery_id = abs(intval($table->id)); redirect(WEB_ROOT."/team/lottery.php?action=gifts&id={$id}&lottery_id={$lottery_id}"); } } include template('team_getgifts');
/** * Users admin */ public static function main() { // Users roles $roles = array('admin' => __('Admin', 'users'), 'editor' => __('Editor', 'users'), 'user' => __('User', 'users')); // Get uses table $users = new Table('users'); if (Option::get('users_frontend_registration') === 'true') { $users_frontend_registration = true; } else { $users_frontend_registration = false; } if (Request::post('users_frontend_submit')) { if (Security::check(Request::post('csrf'))) { if (Request::post('users_frontend_registration')) { $users_frontend_registration = 'true'; } else { $users_frontend_registration = 'false'; } if (Option::update('users_frontend_registration', $users_frontend_registration)) { Notification::set('success', __('Your changes have been saved.', 'users')); } else { Notification::set('error', __('Your changes was not saved.', 'users')); } Request::redirect('index.php?id=users'); } else { die('Request was denied because it contained an invalid security token. Please refresh the page and try again.'); } } // Check for get actions // --------------------------------------------- if (Request::get('action')) { // Switch actions // ----------------------------------------- switch (Request::get('action')) { // Add // ------------------------------------- case "add": if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin'))) { // Errors $errors = array(); if (Request::post('register')) { if (Security::check(Request::post('csrf'))) { $user_login = trim(Request::post('login')); $user_password = trim(Request::post('password')); $user_email = trim(Request::post('email')); if ($user_login == '') { $errors['users_empty_login'] = __('Required field', 'users'); } if ($user_password == '') { $errors['users_empty_password'] = __('Required field', 'users'); } if ($user_email == '') { $errors['users_empty_email'] = __('Required field', 'users'); } if ($users->select("[login='******']")) { $errors['users_this_user_already_exists'] = __('This user already exists', 'users'); } if ($users->select("[email='" . $user_email . "']")) { $errors['users_this_email_already_exists'] = __('This email already exists', 'users'); } if (count($errors) == 0) { if ($users->insert(array('login' => Security::safeName($user_login), 'password' => Security::encryptPassword(Request::post('password')), 'email' => Request::post('email'), 'hash' => Text::random('alnum', 12), 'date_registered' => time(), 'role' => Request::post('role')))) { Notification::set('success', __('New user have been registered.', 'users')); } else { Notification::set('error', __('New user was not registered.', 'users')); } Request::redirect('index.php?id=users'); } } else { die('Request was denied because it contained an invalid security token. Please refresh the page and try again.'); } } // Display view View::factory('box/users/views/backend/add')->assign('roles', $roles)->assign('errors', $errors)->display(); } else { Request::redirect('index.php?id=users&action=edit&user_id=' . Session::get('user_id')); } break; // Edit // ------------------------------------- // Edit // ------------------------------------- case "edit": // Get current user record $user = $users->select("[id='" . (int) Request::get('user_id') . "']", null); if (isset($user['firstname'])) { $user_firstname = $user['firstname']; } else { $user_firstname = ''; } if (isset($user['lastname'])) { $user_lastname = $user['lastname']; } else { $user_lastname = ''; } if (isset($user['email'])) { $user_email = $user['email']; } else { $user_email = ''; } if (isset($user['twitter'])) { $user_twitter = $user['twitter']; } else { $user_twitter = ''; } if (isset($user['skype'])) { $user_skype = $user['skype']; } else { $user_skype = ''; } if (isset($user['about_me'])) { $user_about_me = $user['about_me']; } else { $user_about_me = ''; } if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin', 'editor'))) { if (Request::post('edit_profile') and ((int) Session::get('user_id') == (int) Request::get('user_id') or in_array(Session::get('user_role'), array('admin')))) { if (Security::check(Request::post('csrf'))) { if (Security::safeName(Request::post('login')) != '') { if ($users->update(Request::post('user_id'), array('login' => Security::safeName(Request::post('login')), 'firstname' => Request::post('firstname'), 'lastname' => Request::post('lastname'), 'email' => Request::post('email'), 'skype' => Request::post('skype'), 'twitter' => Request::post('twitter'), 'about_me' => Request::post('about_me'), 'role' => Request::post('role')))) { Notification::set('success', __('Your changes have been saved.', 'users')); } else { Notification::set('error', __('Your changes was not saved.', 'users')); } Request::redirect('index.php?id=users&action=edit&user_id=' . Request::post('user_id')); } } else { die('Request was denied because it contained an invalid security token. Please refresh the page and try again.'); } } if (Request::post('edit_profile_password')) { if (Security::check(Request::post('csrf'))) { if (trim(Request::post('new_password')) != '') { if ($users->update(Request::post('user_id'), array('password' => Security::encryptPassword(trim(Request::post('new_password')))))) { Notification::set('success', __('Your changes have been saved.', 'users')); } else { Notification::set('error', __('Your changes was not saved.', 'users')); } Request::redirect('index.php?id=users&action=edit&user_id=' . Request::post('user_id')); } } else { die('Request was denied because it contained an invalid security token. Please refresh the page and try again.'); } } if ((int) Session::get('user_id') == (int) Request::get('user_id') or in_array(Session::get('user_role'), array('admin')) && count($user) != 0) { // Display view View::factory('box/users/views/backend/edit')->assign('user', $user)->assign('user_firstname', $user_firstname)->assign('user_lastname', $user_lastname)->assign('user_email', $user_email)->assign('user_twitter', $user_twitter)->assign('user_skype', $user_skype)->assign('user_about_me', $user_about_me)->assign('roles', $roles)->display(); } else { echo __('Monstra says: This is not your profile...', 'users'); } } break; // Delete // ------------------------------------- // Delete // ------------------------------------- case "delete": if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin')) && (int) $_SESSION['user_id'] != (int) Request::get('user_id')) { if (Security::check(Request::get('token'))) { $user = $users->select('[id="' . Request::get('user_id') . '"]', null); if ($users->delete(Request::get('user_id'))) { Notification::set('success', __('User <i>:user</i> have been deleted.', 'users', array(':user' => $user['login']))); } else { Notification::set('error', __('User <i>:user</i> was not deleted.', 'users', array(':user' => $user['login']))); } Request::redirect('index.php?id=users'); } else { die('Request was denied because it contained an invalid security token. Please refresh the page and try again.'); } } break; } } else { if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin'))) { // Dislay view View::factory('box/users/views/backend/index')->assign('roles', $roles)->assign('users_list', $users->select())->assign('users_frontend_registration', $users_frontend_registration)->display(); } else { Request::redirect('index.php?id=users&action=edit&user_id=' . Session::get('user_id')); } } }
die('success'); } elseif ($team['end_time'] < time()) { Phplog::RecordOrderFailLog(" 团购已结束 团购订单号:" . $order_id); //团购已超时 die('success'); } //1 $table = new Table('order'); $table->SetPk('id', $order_id); $table->pay_id = $out_trade_no; $table->money = $total_fee; $table->order_id = $out_trade_no; $table->state = 'pay'; $table->quantity = $quantity; $table->service = 'chinabank'; $flag = $table->update(array('state', 'pay_id', 'money', 'order_id', 'quantity', 'service')); if ($flag) { $table = new Table('pay'); $table->id = $out_trade_no; $table->order_id = $order_id; $table->money = $total_fee; $table->currency = 'CNY'; $table->bank = '网银(支付宝)'; $table->service = 'chinabank'; $table->create_time = time(); $table->insert(array('id', 'order_id', 'money', 'currency', 'service', 'create_time', 'bank')); $order = Table::Fetch('order', $order_id); //update team,user,order,flow state// ZTeam::BuyOne($order); //查找地市 $area = Table::Fetch('t_city_category_rel', $team["city_id"], 'category_id');
$out_trade_no = $_GET['out_trade_no']; //获取订单号 $total_fee = $_GET['total_fee']; //获取总价格 @(list($_, $order_id, $city_id, $_) = explode('-', $out_trade_no, 4)); if ($verify_result) { if ($_GET['trade_status'] == 'TRADE_FINISHED' || $_GET['trade_status'] == 'TRADE_SUCCESS') { $order = Table::Fetch('order', $order_id); if ($order['state'] == 'unpay') { //1 $table = new Table('order'); $table->SetPk('id', $order_id); $table->pay_id = $out_trade_no; $table->money = $total_fee; $table->state = 'pay'; $flag = $table->update(array('state', 'pay_id', 'total_fee')); if ($flag) { $table = new Table('pay'); $table->id = $out_trade_no; $table->order_id = $order_id; $table->money = $total_fee; $table->currency = 'CNY'; $table->bank = '支付宝'; $table->service = 'alipay'; $table->create_time = time(); $table->insert(array('id', 'order_id', 'money', 'currency', 'service', 'create_time', 'bank')); //update team,user,order,flow state// ZTeam::BuyOne($order); } } Utility::Redirect(WEB_ROOT . "/order/pay.php?id={$order_id}");
$table->SetStrip('detail', 'systemreview', 'notice'); $table->begin_time = strtotime($_POST['begin_time']); $table->city_id = abs(intval($table->city_id)); $table->partner_id = abs(intval($partner_id)); $table->end_time = strtotime($_POST['end_time']); $table->expire_time = strtotime($_POST['expire_time']); $table->image = upload_image('upload_image', $team['image'], 'team', true); $table->image1 = upload_image('upload_image1', $team['image1'], 'team'); $table->image2 = upload_image('upload_image2', $team['image2'], 'team'); //team_type == goods if ($table->team_type == 'goods') { $table->min_number = 1; } $error_tip = array(); if (!$error_tip) { if ($table->update($insert)) { print $table->title; $field = strtoupper($table->conduser) == 'Y' ? null : 'quantity'; $now_number = Table::Count('order', array('team_id' => $table->id, 'state' => 'pay'), $field); $need_update = array('now_number' => $now_number); /* 增加了总数,未卖完状态 */ if ($table->max_number > $table->now_number) { $need_update['close_time'] = 0; } Table::UpdateCache('team', $table->id, $need_update); Session::Set('notice', '团购修改成功'); Utility::Redirect(WEB_ROOT . "/biz/index.php"); } else { Session::Set('error', '修改团信息失败,请检查系统环境?'); } }
function save_system($ini) { $system = Table::Fetch('system', 1); $ini = ZSystem::GetUnsetINI($ini); $value = Utility::ExtraEncode($ini); $table = new Table('system', array('value' => $value)); if ($system) { $table->SetPK('id', 1); } return $table->update(array('value')); }
$INI['system']['gzip'] = abs(intval($INI['system']['gzip']>0)); $INI['system']['partnerdown'] = abs(intval($INI['system']['partnerdown']>0)); $INI['system']['conduser'] = abs(intval($INI['system']['conduser']>0)); $INI['system']['currencyname'] = strtoupper($INI['system']['currencyname']); //2013.07.29 $sorts = array('MO', 'NO', 'AF', 'NI'); $sorts_key = array_search($INI['system']['sorttype'], $sorts); if(!$sorts_key) $sorts_key = 0; $INI['system']['sorttype'] = $sorts[($sorts_key + 1)%4]; save_config(); $value = Utility::ExtraEncode($INI); $table = new Table('system', array('value'=>$value)); if ( $system ) $table->SetPK('id', 1); $flag = $table->update(array( 'value')); log_admin('system', '编辑基本设置',$_POST); Session::Set('notice', '更新系统信息成功'); redirect( null ); } include template("manage_system_index{$ts}"); function current_system_index($s=null) { global $city; $filter = array( 'a' => 'AAAAAAA', 'b' => 'BBBBBBBBB', 'c' => 'CCCCCCCC', 'd' => 'DDDDDDDDD', 'e' => 'EEEEEEEEE',
<?php require_once dirname(dirname(__FILE__)) . '/app.php'; need_partner(); $partner_id = abs(intval($_SESSION['partner_id'])); $login_partner = $partner = Table::Fetch('partner', $partner_id); if ($_POST) { $table = new Table('partner', $_POST); $table->SetStrip('location', 'other'); $table->SetPk('id', $partner_id); $flag = $table->update(array('title', 'bank_name', 'bank_user', 'bank_no', 'location', 'other', 'homepage', 'contact', 'mobile', 'phone')); if ($table->password == $table->password2 && $table->password) { $update[] = 'password'; $table->password = ZPartner::GenPassword($table->password); } if ($flag) { Session::Set('notice', 'Change partner information OK'); Utility::Redirect(WEB_ROOT . "/biz/settings.php"); } Session::Set('error', 'Change partner information failed'); $partner = $_POST; } include template('biz_settings');
'expire_time' => $team['expire_time'], )); /* 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);
$text = "{$v_oid}{$v_pstatus}{$v_amount}{$v_moneytype}{$key}"; $md5string = strtoupper(md5($text)); /* 判断返回信息,如果支付成功,并且支付结果可信,则做进一步的处理 */ if ($v_md5str == $md5string) { if ($v_pstatus == "20") { list($o_mid, $order_id, $city_id, $_) = explode('-', $v_oid, 4); //0 $order = Table::Fetch('order', $order_id); if ($order['state'] == 'unpay') { //1 $table = new Table('order'); $table->SetPk('id', $order_id); $table->pay_id = $v_oid; $table->money = $v_amount; $table->state = 'pay'; $flag = $table->update(array('state', 'pay_id', 'money')); if ($flag) { $table = new Table('pay'); $table->id = $v_oid; $table->order_id = $order_id; $table->money = $v_amount; $table->currency = $v_moneytype; $table->bank = mb_convert_encoding($v_pmode, 'UTF-8', 'GBK'); $table->service = 'chinabank'; $table->create_time = time(); $table->insert(array('id', 'order_id', 'money', 'currency', 'service', 'create_time', 'bank')); } //update team,user,order,flow state// ZTeam::BuyOne($order); } echo "ok";