function piclens_gallery() { $item_id = EClassApi::getParam('item_id'); $entry = ''; if ($item_id) { $sql = 'select id, original_image_url, title, position from item_image where item_id = ' . intval($item_id) . ' ORDER BY position '; DB::query($sql); if (DB::num_rows()) { $entry = ''; while ($rows = DB::fetch_row()) { $rows['title'] = $rows['title'] ? $rows['title'] : "Image {$rows['position']}"; $rows['title'] = trim(XMLLib::_xml_encode_attribute($rows['title'])); if (ereg('/', $rows['original_image_url'])) { $url = trim(XMLLib::_xml_encode_attribute("http://" . IMAGE_PATH . "{$rows['original_image_url']}")); } else { $url = trim(XMLLib::_xml_encode_attribute("http://" . IMAGE_PATH . "uploaded/items/{$rows['original_image_url']}")); } $entry .= "\n\t\t \t \t<item>\n\t\t \t \t\t\t<title>" . stripslashes($rows['title']) . "</title>\n\t\t\t\t\t\t<link>{$url}</link>\n\t\t\t\t\t\t<guid>Image {$rows['position']}</guid>\n\t\t\t\t\t\t<media:thumbnail url=\"{$url}\" />\n\t\t\t\t\t\t<media:content url=\"{$url}\" />\n\t\t\t\t</item>\n\t\t \t \t"; } @header("Content-type: text/xml"); echo "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n\t\t\t <rss version=\"2.0\" xmlns:media=\"http://search.yahoo.com/mrss\">\n\t\t\t <channel>\t\t\t\n\t\t\t <title>Enbac.com</title>\n\t\t\t <link>http://www.chonmon.vn/</link>\n\t\t\t <description>Enbac.com - </description>\n\t\t\t <logo url=\"style/images/logo.piclens.png\" />\n\t\t\t"; echo $entry; echo "\n\t\t \t </channel>\n\t\t\t </rss>\n\t\t\t"; } else { die("no_info"); } } else { die("no_info"); } }
function flash_view_gallery() { $user_id = (int) Url::get('user_id'); if ($user_id) { $sql = 'select id, original_image_url, des FROM item_image WHERE user_id = ' . $user_id . ' AND root_id=0 ORDER BY id DESC LIMIT 0,200'; DB::query($sql); if (DB::num_rows()) { $entry = ''; while ($rows = DB::fetch_row()) { $rows['des'] = $rows['des'] ? $rows['des'] : "Image {$rows['id']}"; $rows['des'] = trim(XMLLib::_xml_encode_attribute($rows['des'])); if (eregi('/', $rows['original_image_url'])) { $url = trim(XMLLib::_xml_encode_attribute("http://" . IMAGE_PATH . "{$rows['original_image_url']}")); } else { $url = trim(XMLLib::_xml_encode_attribute("http://" . IMAGE_PATH . "uploaded/items/{$rows['original_image_url']}")); } $entry .= "\n\t\t\t\t\t\t\t<photo imageurl=\"{$url}\" linkurl=\"http://chonmon.vn\">\n\t\t\t\t\t\t\t\t<title>{$rows['des']}</title>\n\t\t\t\t\t\t\t</photo>\t\t \t \t\n\t\t\t\t \t \t"; } @header("Content-type: text/xml"); echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?" . '>'; echo "<tiltviewergallery><photos>"; echo $entry; echo "</photos></tiltviewergallery>"; } else { die("no_info"); } } else { die("no_info"); } }
/** * create one test case * * @param integer $case * @param integer $stopcase * @return boolean true after last case */ function create_case($case, $stopcase) { global $date, $login, $ngroup; $stop = 0; $branch = 0; static $branch1 = 0; $casedesc = $case." (".$stopcase."/".$branch1.")"; echo "Test case ".$casedesc."\n"; Login::$member = $login; // create period if ($stopcase == ++$stop) { // period without ballot voting $sql = "INSERT INTO period (debate, preparation, voting, ballot_assignment, ballot_preparation, counting, ballot_voting, ngroup) VALUES ( now(), now() + interval '1 week', now() + interval '2 weeks', NULL, NULL, now() + interval '4 weeks', false, ".$ngroup->id." )"; DB::query($sql); return; } else { // period with ballot voting $sql = "INSERT INTO period (debate, preparation, voting, ballot_assignment, ballot_preparation, counting, ballot_voting, ngroup, postage) VALUES ( now(), now() + interval '1 week', now() + interval '2 weeks', now() + interval '1 week', now() + interval '3 weeks', now() + interval '4 weeks', true, ".$ngroup->id.", true ) RETURNING id"; $result = DB::query($sql); $row = DB::fetch_row($result); $period = new Period($row[0]); } ${'branch'.++$branch.'_array'} = array(0, 5, 15); $ballot_count = ${'branch'.$branch.'_array'}[${'branch'.$branch}]; for ( $i=1; $i<=$ballot_count; $i++ ) { // create a ballot $ballot = new Ballot; $ballot->ngroup = $ngroup->id; $ballot->name = "Test ballot ".$casedesc; $ballot->agents = "Test agents"; $ballot->period = $period->id; $ballot->opening = "8:00"; $ballot->create(); // add participants for ( $j=1; $j<=$i-1; $j++ ) { add_participant($period, $ballot, $case, "a".$ballot_count."i".$i."j".$j); } } // add postal voters for ( $j=1; $j<=10; $j++ ) { add_participant($period, true, $case, "a".$ballot_count."i0j".$j); } if ($stopcase == ++$stop) return; // approve ballots with 10 or more participants $sql = "SELECT * FROM ballot WHERE period=".intval($period->id); $result = DB::query($sql); while ( $ballot = DB::fetch_object($result, "Ballot") ) { if ($ballot->voters < 10) continue; $ballot->approved = true; $ballot->update(["approved"]); } if ($stopcase == ++$stop) return; // add further participants without assigning them to ballots for ($i=1; $i<=100; $i++) { add_participant($period, null, $case, "t".$date."c".$case."i".$i); } // move to phase "ballot_assignment" time_warp($period, "1 week"); cron(); if ($stopcase == ++$stop) return; // move to phase "ballot_preparation" time_warp($period, "2 weeks"); cron(); // continue with next case if branches are still available for ($i=1; $i<=$branch; $i++) { if (isset(${'branch'.$i.'_array'}[++${'branch'.$i}])) { for ($j=1; $j<$i; $j++) ${'branch'.$j}=0; return true; } } // end of last case return "end"; }
// analysis script // load configuration file include_once "config.php"; // load the database class include_once "includes/db_mysql.php"; $db = new DB($config); $class_lookup = array(1 => "no_news", 2 => "news", 3 => "news_op"); $class_mapping = array(1 => 1, 2 => 2, 3 => 2); $class_name_mapping = array("no_news" => "no_news", "news" => "news", "news_op" => "news"); include_once "page_base.php"; include_once "classify.php"; include_once "stemmer.php"; include_once "cluster.php"; $cluster_main = new cluster(); $db->query("SELECT * FROM `init_tweets` WHERE `test`=1 ORDER BY RAND() LIMIT 10"); while ($tweet = $db->fetch_row()) { $cluster_main->tf_idf($tweet['tweet'], $tweet['id']); echo "<br /><br />"; } /* $main_class = new classify(array(1=>"no_news", 2=>"news"), $class_mapping, false); $main_class->add_tweets(array(), 591); $class_totals = array(1=>0, 2=>0); $news_items = array(); $missdirect = array(); $db->query("SELECT * FROM `init_tweets` WHERE `test`=1"); while($tweet = $db->fetch_row()) { $result = $main_class->classify_tweet($tweet['tweet']); if($class_lookup[$result] == $class_name_mapping[$tweet['class']])
function get_user_info() { global $display; $user_id = AZLib::getParam('user_id'); $info = AZLib::getParam('id'); $info_array = array('blast', 'address', 'mobile_phone', 'home_phone', 'yahoo_id', 'skype_id', 'email', 'website', 'signature', 'up_item'); if (!in_array($info, $info_array)) { die("no_info"); } if ($user_id && (User::have_permit(ADMIN_USER) || User::id() == $user_id && !User::is_block())) { $sql = "SELECT {$info} FROM user WHERE id='{$user_id}'"; DB::query($sql); $row = DB::fetch_row(); echo str_replace('!', '!', $row["{$info}"]); } else { die("no_perm"); } }
/** * create one test case * * @param integer $case * @param integer $stopcase * @return mixed null after one stopcase, false after one branchcase, true after last case */ function create_case($case, $stopcase) { global $bcase, $date, $login, $proposal, $proposal2, $casetitle, $ngroup; $stop = 0; $branch = 0; $casedesc = $case." (stop: ".$stopcase.", branches:"; foreach ($bcase as $value) $casedesc .= " ".$value; $casedesc .= ")"; echo "Test case ".$casedesc."\n"; Login::$member = $login; $proposal = null; $proposal2 = null; $casetitle = ""; // create area $area = new Area; $area->ngroup = $ngroup->id; $area->name = "Test area case ".$casedesc; $area->create(); // create new proposal $proposal = new Proposal; $proposal->title = "Test ".$date." case ".$casedesc; $proposal->content = "Test content"; $proposal->reason = "Test reason"; $proposal->create("Test proponent ".$date." proposal case ".$casedesc, $area->id); $proponents = array(Login::$member); if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { $casetitle = "draft"; return; } $issue = $proposal->issue(); if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { $proposal->remove_proponent(Login::$member); cron(); $casetitle = "remove proponent from draft"; return; } if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { $proposal->remove_proponent(Login::$member); time_warp($issue, "1 week"); cron(); $casetitle = "remove proponent from draft and finally revoke proposal"; return; } if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { $proposal->remove_proponent(Login::$member); add_proponent($proposal, "px"); time_warp($issue, "1 week"); cron(); $casetitle = "remove proponent from draft, add new proponent"; return; } // add proponents for ( $i=2; $i<=REQUIRED_PROPONENTS; $i++ ) { add_proponent($proposal, "pi".$i); $proponents[] = Login::$member; } if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { $casetitle = "draft with proponents"; return; } $proposal->submit(); if ($proposal->state=="submitted") { if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { foreach ($proponents as $proponent) { $proposal->remove_proponent($proponent); } cron(); $casetitle = "remove all proponents from submitted proposal"; return; } if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { foreach ($proponents as $proponent) { $proposal->remove_proponent($proponent); } for ( $i=1; $i<=REQUIRED_PROPONENTS-1; $i++ ) { add_proponent($proposal, "pr".$i); } time_warp($issue, "1 week"); cron(); $casetitle = "remove all proponents from submitted proposal, add less than required new proponents and finally revoke proposal"; return; } if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { foreach ($proponents as $proponent) { $proposal->remove_proponent($proponent); } for ( $i=1; $i<=REQUIRED_PROPONENTS; $i++ ) { add_proponent($proposal, "pr".$i); } time_warp($issue, "1 week"); cron(); $casetitle = "remove all proponents from submitted proposal, add sufficient new proponents"; return; } $required_supporters = $proposal->quorum_required(); ${'branch'.++$branch.'_array'} = array(0, $required_supporters-1, $required_supporters); $supporter_count = ${'branch'.$branch.'_array'}[$bcase[$branch]]; for ( $i=1; $i<=$supporter_count-REQUIRED_PROPONENTS; $i++ ) { add_supporter($proposal, "a".$i); } if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { $casetitle = "alternative proposal with $supporter_count supporters"; return; } if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { time_warp($issue, CANCEL_NOT_ADMITTED_INTERVAL); cron(); $casetitle = "cancel long time not admitted proposal"; return; } // create alternative proposal $proposal2 = new Proposal; $proposal2->title = "Test ".$date." alternative proposal case ".$casedesc; $proposal2->content = "Test content"; $proposal2->reason = "Test reason"; $proposal2->issue = $proposal->issue; $proposal2->create("Test proponent ".$date." alternative proposal case ".$casedesc, $area->id); $proponents = array(Login::$member); if ($stopcase == ++$stop) { $casetitle = "alternative draft"; return; } // add proponents for ( $i=1; $i<=4; $i++ ) { add_proponent($proposal2, "qi".$i); $proponents[] = Login::$member; } if ($stopcase == ++$stop) { $casetitle = "alternative draft with proponents"; return; } $proposal2->submit(); if ($proposal2->state=="submitted" and $stopcase == ++$stop) { foreach ($proponents as $proponent) { $proposal2->remove_proponent($proponent); } cron(); $casetitle = "remove all proponents from submitted alternative proposal"; return; } $required_supporters = $proposal2->quorum_required(); ${'branch'.++$branch.'_array'} = array(0, $required_supporters-1, $required_supporters); $supporter_count2 = ${'branch'.$branch.'_array'}[$bcase[$branch]]; for ( $i=1; $i<=$supporter_count2; $i++ ) { add_supporter($proposal2, "a".$i); } if ($stopcase == ++$stop) { $casetitle = "alternative proposal with $supporter_count2 supporters"; return; } if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { time_warp($issue, CANCEL_NOT_ADMITTED_INTERVAL); cron(); $casetitle = "cancel long time not admitted alternative proposal"; return; } if ($proposal->state=="admitted" or $proposal2->state=="admitted") { // create period $sql = "INSERT INTO period (debate, preparation, voting, counting, ballot_voting, ngroup) VALUES ( now() + interval '1 week', now() + interval '2 weeks', now() + interval '3 weeks', now() + interval '4 weeks', false, ".$ngroup->id." ) RETURNING id"; $result = DB::query($sql); $row = DB::fetch_row($result); $period = $row[0]; // assign issue to period $issue->period = $period; /** @var $issue Issue */ $issue->update(["period"]); // assigned, but not yet started cron(); if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { $casetitle = "assigned issue"; return; } // move on to state "debate" time_warp($issue, "1 week"); cron(); $votingmode_required = $issue->quorum_votingmode_required(); ${'branch'.++$branch.'_array'} = array(0, $votingmode_required-1, $votingmode_required); $votingmode_demanders_count = ${'branch'.$branch.'_array'}[$bcase[$branch]]; for ( $i=1; $i<=$votingmode_demanders_count; $i++ ) { add_votingmode_demander($proposal2, "a".$i); } if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { $casetitle = "issue with $votingmode_demanders_count offline voting demanders"; return; } $proposal2->read(); ${'branch'.++$branch.'_array'} = array(false, true); if ( ${'branch'.$branch.'_array'}[$bcase[$branch]] and $proposal2->state!="cancelled" ) { // remove all proponents from alternative proposal during debate foreach ($proponents as $proponent) { $proposal2->remove_proponent($proponent); } } // move on to state "preparation" time_warp($issue, "1 week"); cron(); if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { $casetitle = "issue in voting preparation state"; return; } // move on to state "voting" time_warp($issue, "1 week"); cron(); if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { $casetitle = "issue in voting state"; return; } // random votes random_votes($issue); // move on to state "counting" and then "finished" time_warp($issue, "1 week"); cron(); if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { $casetitle = "issue in finished state"; return; } // move on to cleared time_warp($issue, CLEAR_INTERVAL); cron(); $casetitle = "issue finished and cleared"; } else { $casetitle = "no admitted proposal"; } } else { $casetitle = "proposal not submitted"; } // continue with next case if branches are still available for ($i=1; $i<=$branch; $i++) { if (isset(${'branch'.$i.'_array'}[++$bcase[$i]])) { for ($j=1; $j<$i; $j++) $bcase[$j]=0; return true; } } // end of last case return "end"; }
function produc_hot() { if (!User::is_login()) { echo 'no_login'; exit; } if (!User::have_permit(ADMIN_CATEGORY)) { echo 'no_perm'; exit; } $cat_id = AZLib::getParam('cat_id', '0'); $item_ids = AZLib::getParam('item_ids'); $vip_item_ids = AZLib::getParam('vip_item_ids'); if ($item_ids == '' && $vip_item_ids == '') { //$file = DIR_CACHE."html/product_hot/data_".$cat_id.".js"; //if(@file_exists($file)){ // StaticCache::delCache("product_hot/data_".$cat_id,"js"); //} $sql = "update configs set conf_val = '' where conf_key = 'product_hot_" . $cat_id . "'"; $sql_vip = "delete from item_vip where product_hot_cat_id =" . $cat_id; DB::query($sql); DB::query($sql_vip); AZLib::get_item_vip(0, true); AZLib::get_config(0, true); exit; } // item thuong $item_array = explode(',', $item_ids); $items = array(); foreach ($item_array as $item) { if ($item) { $items[] = intval($item); } } $id_items_after = ''; $item_ids = join(',', $items); $sql = "delete from configs where conf_key = 'product_hot_" . $cat_id . "'"; DB::query($sql); AZLib::get_config(0, true); if ($item_ids != '') { $sql = "SELECT id, name, brief, price, currency_id, img_url\r\n\t\t\t\t\t FROM item \r\n\t\t\t\t\t WHERE status = 1 AND id IN({$item_ids})"; $result = DB::query($sql); $i = 0; while ($item = mysql_fetch_array($result)) { if (isset($item['id'])) { $id_items[$i] = $item['id']; $i++; } } $id_items_after = ''; for ($i = 0; $i < count($item_array); $i++) { for ($j = 0; $j < count($id_items); $j++) { if ($item_array[$i] == $id_items[$j]) { $id_items_after .= $id_items[$j] . ","; } } } if ($id_items_after != '') { $id_items_after = substr($id_items_after, 0, -1); } $sql_check = "SELECT id FROM configs WHERE conf_key = 'product_hot_" . $cat_id . "'"; DB::query($sql_check); $row = DB::fetch_row(); if ($row['id'] != '') { $sql = "UPDATE configs SET conf_val = '" . $id_items_after . "' WHERE conf_key = 'product_hot_" . $cat_id . "'"; DB::query($sql); AZLib::get_config(0, true); // xoa cache config } else { $sql = "INSERT INTO configs (`conf_key`,`conf_val`) values ('product_hot_" . $cat_id . "','" . $id_items_after . "')"; DB::query($sql); AZLib::get_config(0, true); // xoa cache config } } //item vip $vip_item_array = explode(',', $vip_item_ids); $vip_items = array(); foreach ($vip_item_array as $vip_item) { if ($vip_item) { $vip_items[] = intval($vip_item); } } $vip_id_items_after = ''; $vip_item_ids = join(',', $vip_items); $sql_vip = "delete from item_vip where product_hot_cat_id =" . $cat_id; DB::query($sql_vip); AZLib::get_item_vip(0, true); if ($vip_item_ids != '') { $sql = "SELECT id, name, brief, price, currency_id, img_url\r\n\t\t\t\t\t FROM item \r\n\t\t\t\t\t WHERE status > 0 AND id IN({$vip_item_ids})"; $result = DB::query($sql); while ($item = mysql_fetch_array($result)) { if (isset($item['id'])) { $vip_id_items_after .= $item['id'] . ","; $sql_check = "select count(*) AS total from item_vip where item_id = " . $item['id'] . " And product_hot_cat_id=" . $cat_id; DB::query($sql_check); $row = DB::fetch_row(); if ($row['total'] == 0) { $sql = "insert into item_vip (`item_id`,`product_hot_cat_id`) values (" . $item['id'] . "," . $cat_id . ")"; DB::query($sql); AZLib::get_item_vip(0, true); } } } if ($vip_id_items_after != '') { $vip_id_items_after = substr($vip_id_items_after, 0, -1); } } $id_items_after .= '|' . $vip_id_items_after; // check file //if(@file_exists(DIR_CACHE."html/product_hot/data_".$cat_id.".js")){ //StaticCache::delCache("product_hot/data_".$cat_id,"js"); //} AZArrCache::del_cache('arrProductHotCache'); echo $id_items_after; exit; }
function update_relatedinfo() { global $_G, $_SGLOBAL, $_SC; $tables = array(); $skip = 0; $nextop = 'update_groupfield'; $query = DB::query('SHOW TABLES'); while ($row = DB::fetch_row($query)) { $tables[] = $row[0]; } if (!in_array($_SC['tablepre'] . 'goodrelated', $tables)) { $skip = 1; } else { $relatedupdate = DB::result_first('SELECT value FROM ' . tname('data') . ' WHERE variable =\'relatedupdate\''); if ($relatedupdate) { $skip = 1; } } if ($skip) { show_msg("[數據升級] 跳過商品關聯數據升級,進入下一步", 'update.php?step=data&op=' . $nextop); } $query = DB::query("SELECT * FROM " . tname('goodrelated')); while ($item = DB::fetch($query)) { inserttable('relatedinfo', array('itemid' => $item['goodid'], 'type' => 'good', 'relatedid' => $item['relatedid'], 'relatedtype' => $item['type'], 'shopid' => $item['shopid']), 0, true); } inserttable('data', array('variable' => 'relatedupdate', 'value' => 1), 0, true); show_msg("[數據升級] 商品關聯數據升級 完成,進入下一步", 'update.php?step=data&op=' . $nextop); }
function getcdr($called, $page, $rows, $exten = null, $sec = null, $cusnum = null, $stats = 0, $suname = null) { global $dbhost, $dbuser, $dbpass, $cdrdbname; $db = new DB($dbhost, $dbuser, $dbpass, $cdrdbname); $db->conn(); $call_list = array(); $nums = 20; if ($rows > 0) { $nums = $rows; } if ($rows > 100) { $nums = 100; } if ($page < 1) { $page = 1; } if ($exten == null) { $exteninfo = ""; } else { $exteninfo = "and (a.src = {$exten} or a.dst = {$exten})"; } if ($sec == null) { $secinfo = ""; } else { $secinfo = "and (a.billsec >= {$sec} and a.disposition='ANSWERED')"; } if ($cusnum == null) { $cusnuminfo = ""; } else { $cusnuminfo = "and (a.src = {$cusnum} or (a.dst = {$cusnum} or a.dst = 0{$cusnum}))"; } if ($stats == 0) { $statsinfo = ""; } else { $statsinfo = "and stats = {$stats}"; } $start = ($page - 1) * $nums; $selectinfo_a = "a.calldate,a.src,a.dst,a.uniqueid,a.billsec,a.disposition,a.stats"; // $selectinfo_b = ",b.ctype"; $selectinfo_c = ",c.uname"; $tab = "cdr a"; $sql_leftjoin_c = "left join exteninfo c on (a.src = c.exten or a.dst = c.exten)"; if ($suname == null) { $selectinfo = $selectinfo_a; $sql_leftjoin = ""; $ext_info = $exteninfo . " " . $secinfo . " " . $cusnuminfo . " " . $statsinfo; } else { $unameinfo = "and c.uname='{$suname}' and UNIX_TIMESTAMP(c.fromtime) <= UNIX_TIMESTAMP(a.calldate) and UNIX_TIMESTAMP(c.totime)>UNIX_TIMESTAMP(a.calldate)"; $selectinfo = $selectinfo_a . $selectinfo_c; $sql_leftjoin = $sql_leftjoin_c; $ext_info = $exteninfo . " " . $secinfo . " " . $cusnuminfo . " " . $statsinfo . " " . $unameinfo; } switch ($called) { case 0: $result = $db->query("select {$selectinfo} from {$tab} {$sql_leftjoin} where (length(a.src) = 4 and length(a.dst) > 4 {$ext_info}) or (length(a.src) > 4 and length(a.dst) = 4 {$ext_info}) order by a.calldate desc limit {$start},{$nums}"); $sql_result = "select {$selectinfo} from {$tab} {$sql_leftjoin} where (length(a.src) = 4 and length(a.dst) > 4 {$ext_info}) or (length(a.src) > 4 and length(a.dst) = 4 {$ext_info})"; $lenth = $db->get_one($db->query("select count(*) from ({$sql_result} limit {$start},{$nums}) as total")); $total = $db->get_one($db->query("select count(*) from ({$sql_result}) as total")); break; case 1: $result = $db->query("select {$selectinfo} from {$tab} {$sql_leftjoin} where length(a.src) = 4 and length(a.dst) > 4 {$ext_info} order by a.calldate desc limit {$start},{$nums}"); $sql_result = "select {$selectinfo} from {$tab} {$sql_leftjoin} where length(a.src) = 4 and length(a.dst) > 4 {$ext_info}"; $lenth = $db->get_one($db->query("select count(*) from ({$sql_result} limit {$start},{$nums}) as total")); $total = $db->get_one($db->query("select count(*) from ({$sql_result}) as total")); break; case 2: $result = $db->query("select {$selectinfo} from {$tab} {$sql_leftjoin} where length(a.src) > 4 and length(a.dst) = 4 {$ext_info} order by a.calldate desc limit {$start},{$nums}"); $sql_result = "select {$selectinfo} from {$tab} {$sql_leftjoin} where length(a.src) > 4 and length(a.dst) = 4 {$ext_info}"; $lenth = $db->get_one($db->query("select count(*) from ({$sql_result} limit {$start},{$nums}) as total")); $total = $db->get_one($db->query("select count(*) from ({$sql_result}) as total")); break; default: $result = $db->query("select {$selectinfo} from {$tab} {$sql_leftjoin} where (length(a.src) = 4 and length(a.dst) > 4 {$ext_info}) or (length(a.src) > 4 and length(a.dst) = 4 {$ext_info}) order by a.calldate desc limit {$start},{$nums}"); $sql_result = "select {$selectinfo} from {$tab} {$sql_leftjoin} where (length(a.src) = 4 and length(a.dst) > 4 {$ext_info}) or (length(a.src) > 4 and length(a.dst) = 4 {$ext_info})"; $lenth = $db->get_one($db->query("select count(*) from ({$sql_result} limit {$start},{$nums}) as total")); $total = $db->get_one($db->query("select count(*) from ({$sql_result}) as total")); } for ($i = 0; $i < $lenth; $i++) { $res_fet = $db->fetch_row($result); $calldate = $res_fet[0]; $src = $res_fet[1]; if (strlen($src) > 4) { $len = strlen($src) - 4; $pri_src = substr($src, 0, $len); $encnum = encrypt($src); $src = $pri_src . "****"; } $dst = $res_fet[2]; if (strlen($dst) > 4) { $len = strlen($dst) - 4; if ($len == 8) { $pri_dst = substr($dst, 1, $len - 1); //edit } else { $pri_dst = substr($dst, 0, $len); } $encnum = encrypt($dst); $dst = $pri_dst . "****"; } $extennum = 0; if (strlen($src) == 4) { $extennum = $src; } elseif (strlen($dst) == 4) { $extennum = $dst; } if (!isset($encnum)) { $encnum = null; } $uniqueid = $res_fet[3]; $duration = $res_fet[4]; $disposition = $res_fet[5]; if ($disposition == "ANSWERED") { $callday_list1 = explode(" ", $calldate); $callday = $callday_list1[0]; $callday_list2 = explode("-", $callday); $callday_dir = implode("/", $callday_list2); $recording_dir = "/var/spool/asterisk/monitor/{$callday_dir}/"; $http_pri = "{$callday_dir}/"; $fso = opendir($recording_dir); while ($flist = readdir($fso)) { $filename = basename($flist); $res = strstr($filename, $uniqueid); if ($res) { $recording = $http_pri . $filename; $ll = $res; break; } } closedir($fso); if (!isset($recording)) { $recording = null; } } else { $recording = null; $duration = 0; } $stats = $res_fet[6]; $ctype = $db->get_one($db->query("select ctype from calltype where dialnum='{$src}' or dialnum='{$dst}'")); if ($ctype == "") { $ctype = "pers"; } // $ctype = "pers"; if (isset($res_fet[7])) { $uname = $res_fet[7]; } else { $calldate_unixtime = strtotime($calldate); $sql_select_extinfo = "select a.uname from exteninfo a where a.exten='{$extennum}' and UNIX_TIMESTAMP(a.fromtime) < {$calldate_unixtime} order by a.fromtime desc limit 1"; $isuname = $db->get_one($db->query($sql_select_extinfo)); if (isset($isuname)) { $uname = $isuname; } else { $uname = "未知"; } } $line = array("calldate" => $calldate, "src" => $src, "dst" => $dst, "uniqueid" => $uniqueid, "duration" => $duration, "disposition" => $disposition, "recording" => $recording, "encnum" => $encnum, "stats" => $stats, "ctype" => $ctype, "uname" => $uname); $call_list[] = $line; unset($recording); } $db->close(); return array("total" => $total, "rows" => $call_list); }
/** * check if a comment has at least one new child * * @param integer $parent * @return boolean */ private function has_new_children($parent) { $sql = "SELECT id, seen.comment AS seen FROM comment LEFT JOIN seen ON seen.comment = comment.id AND seen.member = ".intval(Login::$member->id)." WHERE comment.proposal=".intval(self::$proposal->id)." AND rubric=".DB::esc($this->rubric)." AND parent=".intval($parent); $result = DB::query($sql); $children = array(); while ( $row = DB::fetch_row($result) ) { if ( !$row[1] ) return true; $children[] = $row[0]; } foreach ($children as $child) { if ( $this->has_new_children($child) ) return true; } }
function sqldumptable($table, $startfrom = 0, $currsize = 0) { global $_G, $_SGLOBAL, $sizelimit, $startrow, $extendins, $usehex, $complete, $excepttables; $offset = 300; $tabledump = ''; $tablefields = array(); $query = DB::query("SHOW FULL COLUMNS FROM {$table}", 'SILENT'); if (strexists($table, 'adminsession')) { return; } elseif (!$query && DB::errno() == 1146) { return; } elseif (!$query) { $usehex = false; } else { while ($fieldrow = DB::fetch($query)) { $tablefields[] = $fieldrow; } } if (!in_array($table, $excepttables)) { $tabledumped = 0; $numrows = $offset; $firstfield = $tablefields[0]; if ($extendins == '0') { while ($currsize + strlen($tabledump) + 500 < $sizelimit * 1000 && $numrows == $offset) { if ($firstfield['Extra'] == 'auto_increment') { $selectsql = "SELECT * FROM {$table} WHERE {$firstfield['Field']} > {$startfrom} LIMIT {$offset}"; } else { $selectsql = "SELECT * FROM {$table} LIMIT {$startfrom}, {$offset}"; } $tabledumped = 1; $rows = DB::query($selectsql); $numfields = DB::num_fields($rows); $numrows = DB::num_rows($rows); while ($row = DB::fetch_row($rows)) { $comma = $t = ''; for ($i = 0; $i < $numfields; $i++) { $t .= $comma . ($usehex && !empty($row[$i]) && (strexists($tablefields[$i]['Type'], 'char') || strexists($tablefields[$i]['Type'], 'text')) ? '0x' . bin2hex($row[$i]) : '\'' . mysql_escape_string($row[$i]) . '\''); $comma = ','; } if (strlen($t) + $currsize + strlen($tabledump) + 500 < $sizelimit * 1000) { if ($firstfield['Extra'] == 'auto_increment') { $startfrom = $row[0]; } else { $startfrom++; } $tabledump .= "INSERT INTO {$table} VALUES ({$t});\n"; } else { $complete = false; break 2; } } } } else { while ($currsize + strlen($tabledump) + 500 < $sizelimit * 1000 && $numrows == $offset) { if ($firstfield['Extra'] == 'auto_increment') { $selectsql = "SELECT * FROM {$table} WHERE {$firstfield['Field']} > {$startfrom} LIMIT {$offset}"; } else { $selectsql = "SELECT * FROM {$table} LIMIT {$startfrom}, {$offset}"; } $tabledumped = 1; $rows = DB::query($selectsql); $numfields = DB::num_fields($rows); if ($numrows = DB::num_rows($rows)) { $t1 = $comma1 = ''; while ($row = DB::fetch_row($rows)) { $t2 = $comma2 = ''; for ($i = 0; $i < $numfields; $i++) { $t2 .= $comma2 . ($usehex && !empty($row[$i]) && (strexists($tablefields[$i]['Type'], 'char') || strexists($tablefields[$i]['Type'], 'text')) ? '0x' . bin2hex($row[$i]) : '\'' . mysql_escape_string($row[$i]) . '\''); $comma2 = ','; } if (strlen($t1) + $currsize + strlen($tabledump) + 500 < $sizelimit * 1000) { if ($firstfield['Extra'] == 'auto_increment') { $startfrom = $row[0]; } else { $startfrom++; } $t1 .= "{$comma1} ({$t2})"; $comma1 = ','; } else { $tabledump .= "INSERT INTO {$table} VALUES {$t1};\n"; $complete = false; break 2; } } $tabledump .= "INSERT INTO {$table} VALUES {$t1};\n"; } } } $startrow = $startfrom; $tabledump .= "\n"; } return $tabledump; }
$vdash = mysql_real_escape_string(db_scrub($_GET["dash"])); # used to tell if /by-election or /byelection was used $vpostcode = db_scrub($_POST["vpostcode"]); # a string of letters (each a-e for strong favour to against) in order of the policies $vrand = db_scrub($_GET["vrand"]); $vevent = db_scrub($_GET["vevent"]); if ($vrand && $vevent) { //$db->query("drop table if exists pw_dyn_glenrothes_use"); //$db->query("create table pw_dyn_glenrothes_use (ltime timestamp, vrand int, vpostcode varchar(20), vconstituency varchar(40), vevent varchar(20))"); $vconstituency = db_scrub($_GET["mpc"]); $db->query("INSERT INTO pw_dyn_glenrothes_use (ltime, vrand, vpostcode, vconstituency, vevent)\n VALUES (NOW(), {$vrand}, '{$vpostcode}', '{$vconstituency}', '{$vevent}')"); if ($vevent == "houze") { header("Content-Type: text/html; charset=UTF-8"); $db->query("SELECT vrand, vpostcode, min(ltime), max(ltime) AS time_last, count(*), vevent FROM pw_dyn_glenrothes_use GROUP BY vrand ORDER BY time_last DESC"); print "<table>\n"; while ($row = $db->fetch_row()) { $vrand = $row[0]; $vpostcode = $row[1]; $vmin = $row[2]; $vmax = $row[3]; $vcount = $row[4]; $vevent = $row[5]; print "<tr><td>{$vpostcode}</td><td>{$min}</td><td>{$vmax}</td><td>{$vcount}</td><td>{$vevent}</td></tr>\n"; } print "</table>\n"; exit(0); } // case of just a img src sent out header("Content-Type: text/html; charset=UTF-8"); exit(0); }
function draw() { AZLib::getCats(); global $display; $this->beginForm(); $page_arr = array(); $page_arr['home'] = 'Trang chủ'; $page_arr['list_detail'] = 'Danh sách sản phẩm'; $page_arr['profile'] = 'Profile thành viên'; $page_arr['sign_in'] = 'Đăng nhập'; $page_arr['item_detail'] = 'Chi tiết sản phẩm'; $page_arr['online'] = 'Thành viên online'; $page_arr['message'] = 'Tin nhắn cá nhân'; $page_arr['post_item'] = 'Đăng sản phẩm'; $page_arr['personal'] = 'Trang cá nhân'; $page_arr['edit_page'] = 'Cấu hình page'; $page_arr['admin'] = 'Trang quản trị'; $page_arr['user'] = '******'; $page_arr['manage_item'] = 'Quản trị Tin'; $page_arr['manage_image'] = 'Quản trị Ảnh'; $page_arr['manage_comment'] = 'Quản Comment'; $page_arr['manage_comment_user'] = '******'; $page_arr['manage_bad_content'] = 'Quản trị tin xấu'; $page_arr['manage_badword'] = 'Quản trị Từ xấu'; $page_arr['partner'] = 'Quản trị Đối tác, ADV'; $page_arr['send_multi'] = 'Gửi tin nhắn cho tất cả Thành viên'; $page_arr['page'] = 'Quản trị Page'; $page_arr['module'] = 'Quản trị Modules'; $page_arr['shop'] = 'Trang cá nhân'; $page_arr['sph_search '] = 'Tìm kiếm'; $not_permit_view = array('edit_page', 'admin', 'user', 'manage_item', 'manage_comment', 'manage_image', 'manage_comment', 'manage_comment_user', 'manage_bad_content', 'manage_badword', 'partner', 'send_multi', 'page', 'module'); $cond = ''; $item_type = Url::get('item_type'); $item_id = Url::get('item_id'); $o_name = Url::get('o_name'); $o_id = (int) Url::get('o_id'); $where = 'site'; if ($item_type && $item_id && in_array($item_type, array(1, 2, 3))) { $cond = ' AND page="ItemDetail" AND item_id=' . $item_id . ' AND item_type=' . $item_type; if ($item_type == 3) { $where = '<font color=red>Sản phẩm đấu giá</font>'; } elseif ($item_type == 1) { $where = '<font color=red>Giao dịch mua</font>'; } else { $where = '<font color=red>Sản phẩm bán</font>'; } } if ($o_name != '') { $str_search = str_replace("'", '"', $o_name); $str_search = str_replace("'", '"', $str_search); $str_search = str_replace(""", '"', $str_search); $cond .= ' AND session_referer LIKE "%' . $str_search . '%"'; } if ($o_id) { $cond .= ' AND user_id =' . $o_id; } else { $o_id = ''; } $open_id_login = (int) Url::get('open_id_login', 0); if ($open_id_login) { $display->add('open_id_login_check', 'checked="checked"'); $cond .= " AND login_type = 1 "; } else { $display->add('open_id_login_check', ''); } $display->add('o_name', $o_name); $display->add('o_id', $o_id); $total_ss = DB::fetch('SELECT count(*) as total_ss FROM ' . _SESS_TABLE, 'total_ss', 0); $display->add('total_ss', $total_ss); $total = DB::fetch('SELECT count(*) as total FROM ' . _SESS_TABLE . ' WHERE session_expires >' . (TIME_NOW - 900) . ' ' . $cond); if ($total) { $total = (int) $total['total']; } else { $total = 0; } $sql = 'SELECT count(total) as total FROM ( SELECT count(user_id) as total FROM ' . _SESS_TABLE . ' WHERE session_expires >' . (TIME_NOW - 900) . ' AND user_id !=0 ' . $cond . ' GROUP BY user_id) as t'; $total_mem = DB::fetch($sql, 'total'); $paging = AZPagging::paging($limit, $total_mem, 25, 10, 'page_view'); DB::query('SELECT session_id, session_expires as time, session_ip as ip, user_id, user_name, session_referer, page, category_id, item_type, item_id, open_id FROM ' . _SESS_TABLE . ' WHERE session_expires >' . (TIME_NOW - 900) . ' AND user_id>0 ' . $cond . ' GROUP BY user_id ORDER BY time DESC' . $limit); $user_onlines = array(); $i = 1; while ($item = DB::fetch_row()) { //$item['viewing_time'] = AZLib::duration(TIME_NOW-$item['time']); if (date('d', TIME_NOW) != date('d', $item['time'])) { $item['viewing_time'] = date('H:i d/m/y', $item['time']); } else { $item['viewing_time'] = date('H:i', $item['time']); } $item['user_name'] = stripslashes($item['user_name']); $item['title'] = 'Thành viên'; $item['link'] = WEB_DIR . $item['user_name']; if (isset($page_arr[$item['page']]) && (User::is_admin() || !in_array($item['page'], $not_permit_view))) { $detail = ''; if ($item['page'] == 'list_detail' && isset(CGlobal::$allCategories[$item['category_id']])) { $detail = ' - ' . stripslashes(CGlobal::$allCategories[$item['category_id']]['name']); $parent_id = CGlobal::$allCategories[$item['category_id']]['parent_id']; if ($parent_id && isset(CGlobal::$allCategories[$parent_id])) { $detail = ' - ' . stripslashes(CGlobal::$allCategories[$parent_id]['name']) . $detail; } } $item['viewing_page_name'] = $page_arr[$item['page']] . $detail; } elseif ($item['page'] && (User::is_admin() || !in_array($item['page'], $not_permit_view))) { $item['viewing_page_name'] = $item['page']; } else { $item['viewing_page_name'] = 'enbac.com'; } if (!$item['session_referer'] || !User::is_admin() && in_array($item['page'], $not_permit_view)) { $item['viewing_page_url'] = WEB_ROOT; } else { $item['viewing_page_url'] = WEB_ROOT . stripslashes($item['session_referer']); } if (User::is_admin() && $item['ip']) { $ip_arr = explode('::', $item['ip']); $item['ip'] = 'S_IP: <b>' . $ip_arr[0] . '</b>'; $item['ip'] .= ' - C_IP: <b>' . $ip_arr[1] . '</b>'; } else { $item['ip'] = ''; } if (User::is_admin()) { $item['del_s'] = '<a href="' . Url::build_current(array('kick_out' => $item['session_id'])) . '">Kick Out</a>'; } else { $item['del_s'] = ''; } $user_onlines[$i++] = $item; } $display->add('where', $where); $display->add('total', $total); $display->add('total_mem', $total_mem); $display->add('user_onlines', $user_onlines); $display->add('paging', $paging); $total_guest = 0; $paging_guest = ''; $guest_onlines = array(); if (User::is_admin()) { $sql = 'SELECT count(*) as total FROM ' . _SESS_TABLE . ' WHERE session_expires >' . (TIME_NOW - 900) . ' AND user_id=0 ' . $cond . ' '; $total_guest = DB::fetch($sql, 'total'); $paging_guest = AZPagging::paging($limit, $total_guest, 25, 10, 'guest_view'); DB::query('SELECT session_id, session_expires as time, session_ip as ip, session_referer, page, category_id, item_type, item_id FROM ' . _SESS_TABLE . ' WHERE session_expires >' . (TIME_NOW - 900) . ' AND user_id=0 ' . $cond . ' ORDER BY time DESC' . $limit); $i = 1; while ($item = DB::fetch_row()) { //$item['viewing_time'] = AZLib::duration(TIME_NOW-$item['time']); if (date('d', TIME_NOW) != date('d', $item['time'])) { $item['viewing_time'] = date('H:i d/m/y', $item['time']); } else { $item['viewing_time'] = date('H:i', $item['time']); } $item['user_name'] = '<font color="green">guest</font>'; $item['viewing_page_url'] = WEB_ROOT; $item['link'] = WEB_ROOT; if (isset($page_arr[$item['page']]) && (User::is_admin() || !in_array($item['page'], $not_permit_view))) { $detail = ''; if ($item['page'] == 'list_detail' && isset(CGlobal::$allCategories[$item['category_id']])) { $detail = ' - ' . stripslashes(CGlobal::$allCategories[$item['category_id']]['name']); $parent_id = CGlobal::$allCategories[$item['category_id']]['parent_id']; if ($parent_id && isset(CGlobal::$allCategories[$parent_id])) { $detail = ' - ' . stripslashes(CGlobal::$allCategories[$parent_id]['name']) . $detail; } } $item['viewing_page_name'] = $page_arr[$item['page']] . $detail; } elseif ($item['page'] && (User::is_admin() || !in_array($item['page'], $not_permit_view))) { $item['viewing_page_name'] = $item['page']; } else { $item['viewing_page_name'] = 'enbac.com'; } if (!$item['session_referer'] || !User::is_admin() && in_array($item['page'], $not_permit_view)) { $item['viewing_page_url'] = WEB_ROOT; } else { $item['viewing_page_url'] = WEB_ROOT . stripslashes($item['session_referer']); } if (User::is_admin() && $item['ip']) { $ip_arr = explode('::', $item['ip']); $item['ip'] = 'S_IP: <b>' . $ip_arr[0] . '</b>'; $item['ip'] .= ' - C_IP: <b>' . $ip_arr[1] . '</b>'; } else { $item['ip'] = ''; } if (User::is_admin()) { $item['del_s'] = '<a href="' . Url::build_current(array('kick_out' => $item['session_id'])) . '">Kick Out</a>'; } else { $item['del_s'] = ''; } $guest_onlines[$i++] = $item; } } $display->add('total_guest', $total_guest); $display->add('guest_onlines', $guest_onlines); $display->add('paging_guest', $paging_guest); $display->output('OnlineUser'); $this->endForm(); }
/** * * @param Ngroup $ngroup * @return integer */ function create_period(Ngroup $ngroup) { $now = date("Y-m-d H:i:s", strtotime("yesterday 18:00")); $sql = "INSERT INTO period (debate, preparation, voting, counting, ballot_voting, ngroup) VALUES ( timestamp '$now', timestamp '$now' + interval '2 weeks', timestamp '$now' + interval '2 weeks 3 days', timestamp '$now' + interval '4 weeks 3 days', false, ".$ngroup->id." ) RETURNING id"; $result = DB::query($sql); $row = DB::fetch_row($result); return $row[0]; }
/** * display voting in state column */ private function display_voting() { if ( !Login::$member ) { echo _("Voting"); return; } if ( !Login::$member->entitled($this->area()->ngroup) ) { ?><span title="<?=_("You can not vote on this issue, because you are are not entitled in the group.")?>"><?=_("Voting")?></span><? return; } $sql = "SELECT vote_vote.token FROM vote_token LEFT JOIN vote_vote USING (token) WHERE member=".intval(Login::$member->id)." AND issue=".intval($this->id); $result = DB::query($sql); if ( list($token) = DB::fetch_row($result) ) { ?><a href="vote.php?issue=<?=$this->id?>"><?=_("Voting")?></a><? if ($token) { ?><span title="<?=_("You have voted on this issue.")?>">✓</span><? } } else { ?><span title="<?=_("You can not vote in this voting period, because you were not yet entitled when the voting started.")?>"><?=_("Voting")?></span><? } }
$t = 'Package'; break; case 4: $t = 'IP'; break; case 5: $t = 'Comment'; break; default: goto endlabel; } $r_value = DB::real_escape_string(str_replace('*', '%', str_replace('?', '_', $_GET['contents']))); $list_query = DB::fetch_all("SELECT * FROM `" . DCRM_CON_PREFIX . "UDID` WHERE `" . $t . "` LIKE '%" . $r_value . "%' ORDER BY `ID` DESC LIMIT " . (string) $page_a . ",10"); $page_c = show_table($list_query); $q_info = DB::query("SELECT count(*) FROM `" . DCRM_CON_PREFIX . "UDID` WHERE `" . $t . "` LIKE '%" . $r_value . "%'"); $info = DB::fetch_row($q_info); $totalnum = (int) $info[0]; $params = array('total_rows' => $totalnum, 'method' => 'html', 'parameter' => 'center.php?action=search&contents=' . $_GET['contents'] . '&type=' . $_GET['type'] . '&page=%page', 'now_page' => $page, 'list_rows' => 10); $page = new Core_Lib_Page($params); echo '<div class="page">' . $page->show(2) . '</div>'; } elseif (!empty($_GET['action']) and $_GET['action'] == "edit") { // 添加与编辑UDID if (!isset($_GET['add'])) { // 获取编辑信息 if (isset($_GET['id']) && is_numeric($_GET['id'])) { $request_id = (int) $_GET['id']; if ($request_id < 1) { _e('Illegal request!'); goto endlabel; } } else {
// count issues in each state $sql = "SELECT state, count(*) FROM issue JOIN area ON area.id = issue.area AND area.ngroup = ".intval($ngroup->id)." GROUP BY state"; $result = DB::query($sql); $counts = array( 'entry' => 0, 'debate' => 0, 'preparation' => 0, 'voting' => 0, 'counting' => 0, 'finished' => 0, 'cancelled' => 0 ); while ( $row = DB::fetch_row($result) ) $counts[$row[0]] = $row[1]; // count issues in entry stage with proposals in different states foreach ( array('draft', 'submitted', 'admitted') as $state ) { $sql = "SELECT count(DISTINCT issue.id) FROM issue JOIN area ON area.id = issue.area AND area.ngroup = ".intval($ngroup->id)." JOIN proposal ON proposal.issue = issue.id WHERE issue.state='entry' AND proposal.state='$state'"; $counts[$state] = DB::fetchfield($sql); } $params = array('ngroup'=>$ngroup->id); if ($search) $params['search'] = $search; ?> <div class="filter proposals">
if ($_POST['albumop'] == 'new') { require_once B_ROOT . './source/adminfunc/album.func.php'; $albumid = createalbum($shopid, $_POST['catid'], $authorid, $author, $_POST['albumname'], $_POST['albumdesc']); //更新相冊記錄為從論壇導入的相冊 $imgurl = $attachs[0]['url']; if (strpos($imgurl, 'http://') === 0) { $remoteattach = loadClass('attach')->saveremotefile($imgurl, array(320, 240)); $imgurl = $remoteattach['file']; } $updatesql[] = " `frombbs`='1', `tid`='tid', `subjectimage`='" . $imgurl . "' "; ssetcookie('i_albumid', $albumid, 900); } elseif (empty($albumid)) { cpmsg('import_albumid_error', '', '', '', true, true); } $query = DB::query('SELECT itemid, shopid, subject FROM ' . tname('albumitems') . " WHERE itemid='{$albumid}'"); list($albumid, $shopid, $albumsubject) = DB::fetch_row($query); if (empty($albumid) || empty($shopid)) { cpmsg('import_albumid_error', '', '', '', true, true); } $insertattach = array(); foreach ($attachs as $v) { $insertattach[] = inserttable('photoitems', array('shopid' => $shopid, 'albumid' => $albumid, 'bbsaid' => $v['aid'], 'uid' => $authorid, 'username' => $author, 'subject' => $v['desc'], 'subjectimage' => $v['url'], 'dateline' => $_G['timestamp'], 'lastpost' => $_G['timestamp'], 'allowreply' => 1, 'grade' => 3), 1); } $jumpurl = 'admin.php?action=import&step=3&jump=1&page=' . $page; $pics = count($insertattach); $updatesql[] = " `picnum`=`picnum`+{$pics} "; DB::query('UPDATE ' . tname('albumitems') . ' SET ' . implode(', ', $updatesql) . " WHERE itemid='{$albumid}'"); $importmsg = '<a href="store.php?id=' . $shopid . '&action=album&xid=' . $albumid . '" target="_blank">' . $albumsubject . '</a>'; //刪除列表緩存 $_BCACHE->deltype('sitelist', 'album'); $_BCACHE->deltype('storelist', 'album', $shopid);