private function add_ads($shares) { $show = rand(0, 1); if ($show && $this->settings['ui_pin']['pin_ad'] && ($ads = $this->settings['pinpage_ad'])) { if ($ad = rand_pop($ads)) { $ad_share['share_type'] = 'ad'; $ad_share['key'] = $ad['key']; $ad_share['ad_name'] = $ad['ad_name']; $ad_share['width'] = $ad['width']; $ad_share['height'] = $ad['height']; $ad_share['ad_position'] = 'pinpage_ad'; $index = rand(0, array_length($shares) - 1); array_splice($shares, $index, 0, array($ad_share)); } } return $shares; }
public function forumline($user_id) { if ($this->forum_open) { $num_per_page = 4; $args = array("page" => 2); $uc_id = $this->spArgs('ucid'); if ($user_id) { $conditions['user_id'] = $user_id; $args['uid'] = $user_id; if (!$uc_id) { $ptx_user = spClass("ptx_user"); $user = $ptx_user->getuser_byid($user_id); $uc_id = $user['uc_id']; } } if (!$uc_id || !is_numeric($uc_id)) { spError(T('no_bbs_account_bind')); return; } $args['ucid'] = $uc_id; $conditions['authorid'] = $uc_id; $next_time = $this->spArgs("next_time"); $this->need_static = false; if ($next_time) { $now = $next_time; } else { $now = time(); $this->need_static = $this->page == 1 ? true : false; } $forum_post = spClass('forum_post'); $conditions['lt_time'] = $now; $last_post = $forum_post->find_one($conditions, " forum_post.dateline DESC ", " forum_post.pid,forum_post.dateline "); $last_time = $last_post['dateline']; $last_post_month = (int) date('m', $last_time); $last_post_month_days = (int) date('t', $last_time); $last_post_year = (int) date('Y', $last_time); $this_month_time_first = time(0, 0, 0, $last_post_month, 1, $last_post_year); $this_month_time_last = time(24, 59, 59, $last_post_month, $last_post_month_days, $last_post_year); $conditions['gt_time'] = $this_month_time_first; $conditions['lt_time'] = $this_month_time_last; $this_month_last_post = $forum_post->find_one($conditions, " forum_post.dateline DESC ", " forum_post.pid,forum_post.dateline "); $posts = $forum_post->search($conditions, $this->page, $num_per_page, NULL, " forum_post.dateline DESC "); if (array_length($posts) == $num_per_page) { $next_search_time = $posts[$num_per_page - 1]['dateline']; //$this->resetPage = true; } else { $next_search_time = $this_month_time_first; $this->resetPage = true; } if ($this_month_last_post['pid'] == $posts[0]['pid']) { $this->timeline_date = $last_post_year . '年' . $last_post_month . '月'; } $forum_attachment = spClass('forum_attachment'); foreach ($posts as $key => $post) { $posts[$key]['images'] = $forum_attachment->search_attach_images($post['pid']); $post['message'] = messageclean($post['message']); $post['message'] = tpl_modifier_bbcode2html($post['message']); $posts[$key]['message'] = $post['message']; } $args['next_time'] = $next_search_time; $this->nextpage_url = spUrl($this->current_controller, $this->current_action, $args); $this->forumlineView($posts, 'post'); //$this->set_user_banner($user_id); $this->output("user/forumline"); } }
private function save_share_upload() { $cover_url = $this->spArgs('cover_filename'); $all_files = $this->spArgs('all_files'); //$all_files_arr = explode('|', $all_files); $all_files_arr = unserialize(stripslashes($all_files)); $length = array_length($all_files_arr); if ($this->permission['other_permission']['upload_maxnum'] && $length > $this->permission['other_permission']['upload_maxnum']) { $this->ajax_failed_response(T('reach_upload_maxnum') . $this->permission['other_permission']['upload_maxnum']); } $file_name = $this->current_user['user_id'] . '_' . time() . ''; $date_dir = '/data/attachments/' . date("Y/m/d/"); !is_dir(APP_PATH . $date_dir) && @mkdir(APP_PATH . $date_dir, 0777, true); $this->save_upload_file($cover_url, $date_dir, $file_name, true); $img_array = array(); foreach ($all_files_arr as $key => $up_image) { if ($up_image && trim($up_image['url']) != '') { if ($up_image['cover']) { $img_array[] = array('id' => $key, 'url' => $date_dir . $file_name, 'desc' => delete_html($up_image['desc']), 'cover' => $up_image['cover']); continue; } $this->save_upload_file($up_image['url'], $date_dir, $file_name . '_' . $key, false); $img_array[] = array('id' => $key, 'url' => $date_dir . $file_name . '_' . $key, 'desc' => delete_html($up_image['desc']), 'cover' => $up_image['cover']); } } $this->create_share_item($date_dir . $file_name, array_length($img_array), $img_array); return true; }
public function check_channel_item() { if ($this->check_admin()) { $act = $this->spArgs("act"); $channel_name = $this->spArgs("channel", 'taobao'); $channel = spClass("Channel"); $number = 50; $page = $this->spArgs("page", 1); $ptx_item = spClass('ptx_item'); $condition['reference_channel'] = 'taobao'; $items = $ptx_item->search(null, $page, $number, " ptx_item.reference_itemid,ptx_item.promotion_url,ptx_item.item_id ", NULL); $pid = $this->settings['api_setting']['Taobao']['PID']; foreach ($items as $item) { if (!strpos($item['promotion_url'], $pid) && $item['reference_itemid']) { $promotion = $channel->get_promotion_url($channel_name, $item['reference_itemid']); sleep(1); if ($promotion) { $scon['item_id'] = $item['item_id']; $ptx_item->updateField($scon, 'promotion_url', $promotion['promotion_url']); } } } if (array_length($items) > 0) { $start = ($page - 1) * $number; $end = $start + $number; $str = T('processing_data') . "{$start}----{$end}"; $url = spUrl('admin', 'check_channel_item', array('page' => $page + 1)); admin_show_message($str, $this, $url, 1500); return; } else { $str = T('processing_data_success'); $url = spUrl('admin', 'update_cache'); admin_show_message($str, $this, $url, 1500); } } }