public function display() { //load calander $time = gettimeofday(); $time = getdate($time['sec']); $calender = new calender($time); $calender->build(); $this->smarty->assign('calender', $calender->getArray()); //$this->smarty->display('calender.tpl'); }
public function ajax_sign() { $data = array('uid' => $this->visitor->info['id'], 'username' => $this->visitor->info['username']); $point_score = $this->point(); if (!$this->_sign_mod->where($data)->find()) { //如果从未签到过 /*积分奖励算法*/ //$this->_user_mod->where($data)->setInc('score',$this->point()); //$this->_user_mod->where($data)->setField('sign_time',strtotime(date('Ymd'))); $score_data = array('score' => array('exp', 'score+' . $point_score), 'sign_time' => strtotime(date('Ymd'))); $this->_user_mod->where(array('id' => $data['uid']))->setField($score_data); //改变用户积分 //更新为已经签到 $this->_sign_mod->create($data); $this->_sign_mod->add(); //添加一条签到记录 $data['score'] = $point_score; $this->_sign_log_mod->create($data); $this->_sign_log_mod->add(); //添加一条积分记录 $score_log_data['uid'] = $this->visitor->info['id']; $score_log_data['uname'] = $this->visitor->info['username']; $score_log_data['action'] = 'sign'; $score_log_data['score'] = $point_score; $this->_score_log_mod->create($score_log_data); $this->_score_log_mod->add(); } else { //如果签到过 $sign_date = $this->_sign_mod->where($data)->find(); $last_date = strtotime(date('Y-m-d')); if ($sign_date['last_date'] == $last_date) { //今天已经签到 $cl = new calender(); $data['table'] = $cl->sign_calender(); $data['point'] = $point_score; $data['tmr_point'] = $point_score; $this->ajaxReturn(1, L('sign_system'), $data); } else { if ($sign_date['last_date'] + 86400 == $last_date) { //今天未签到昨天签到过 /*积分奖励算法*/ //$this->_user_mod->where($data)->setInc('score',$point_score); //$this->_user_mod->where($data)->setField('sign_time',strtotime(date('Ymd'))); $score_data = array('score' => array('exp', 'score+' . $point_score), 'sign_time' => strtotime(date('Ymd'))); $this->_user_mod->where(array('id' => $data['uid']))->setField($score_data); //改变用户积分 //更新为已经签到 $this->_sign_mod->where($data)->setInc('sign_count'); $this->_sign_mod->where($data)->setField('last_date', strtotime(date('Ymd'))); //添加一条签到记录 $data['score'] = $point_score; $this->_sign_log_mod->create($data); $this->_sign_log_mod->add(); //添加一条积分记录 $score_log_data['uid'] = $this->visitor->info['id']; $score_log_data['uname'] = $this->visitor->info['username']; $score_log_data['action'] = 'sign'; $score_log_data['score'] = $point_score; $this->_score_log_mod->create($score_log_data); $this->_score_log_mod->add(); } else { //无连续签到 从头算起 /*积分奖励算法*/ //$this->_user_mod->where($data)->setInc('score',$point_score); //$this->_user_mod->where($data)->setField('sign_time',strtotime(date('Ymd'))); $score_data = array('score' => array('exp', 'score+' . $point_score), 'sign_time' => strtotime(date('Ymd'))); $this->_user_mod->where(array('id' => $data['uid']))->setField($score_data); //改变用户积分 //更新为已经签到 $sign_data = $data; $sign_data['sign_count'] = '1'; $sign_data['last_date'] = strtotime(date('Ymd')); $this->_sign_mod->where($data)->save($sign_data); //添加一条签到记录 $data['score'] = $point_score; $this->_sign_log_mod->create($data); $this->_sign_log_mod->add(); //添加一条积分记录 $score_log_data['uid'] = $this->visitor->info['id']; $score_log_data['uname'] = $this->visitor->info['username']; $score_log_data['action'] = 'sign'; $score_log_data['score'] = $point_score; $this->_score_log_mod->create($score_log_data); $this->_score_log_mod->add(); } } } $cl = new calender(); $data['table'] = $cl->sign_calender(); $data['point'] = $point_score; if ($sign_info = $this->_sign_mod->field('id,username,last_date,sign_count')->where(array('uid' => $this->visitor->info['id']))->find()) { if ($sign_info['sign_count'] >= C('ftx_score_rule.sign_day')) { $data['tmr_point'] = $point_score; } else { $data['tmr_point'] = $point_score + C('ftx_score_rule.sign_add'); } } $this->ajaxReturn(1, L('sign_system'), $data); }
<?php require_once 'global.php'; //init $site = isset($_GET['site']) && array_key_exists($_GET['site'], $C->RECORD_URLS) ? $_GET['site'] : 'tootoo'; $engine = isset($_GET['engine']) ? $_GET['engine'] : 'google'; $tj_starttime = strtotime($C->TJ_STARTTIME[$site]); //统计开始时间 //$date = isset($_GET['date']) && !empty($_GET['date']) && strtotime($_GET['date']) < time() && strtotime($_GET['date']) >= $tj_starttime ? $_GET['date'] : date('Y-n-d', strtotime('last day')); $date = isset($_GET['date']) && !empty($_GET['date']) ? $_GET['date'] : date('Y-n-d', strtotime('last day')); $prevdate = date('Y-n-d', strtotime($date) - 7 * 24 * 3600); //日历 $calender = new calender(); $calender->set_url($site, $engine); $calender_str = $calender->build($date); //抓取当月平均值(2010.9.6新加的) $file_crawl_mon = './data/crawl/' . $engine . '/' . $site . '/' . md5('all') . '/' . date('Ym', strtotime($date)) . '.txt'; //echo $file_crawl_mon; $crawl_average = file_exists($file_crawl_mon) ? file($file_crawl_mon) : 0; if ($crawl_average) { $total = 0; foreach ($crawl_average as $v) { $tmp = explode('#####', $v); $arr = unserialize($tmp[1]); $total += $arr['count']; } $crawl_average_value = number_format($total / count($crawl_average)); //echo $crawl_average_value; } //收录统计 $r = new record();
function configEdit() { $team = $_GET['team']; $this->title = 'Opensource Calendar'; $this->addYUI = 1; $this->addAutocomplete = 1; $this->onCall = 1; $this->menu = 'backup'; $this->view = 'calendar/calendar'; $this->pagetitle = 'Opensource Calendar'; $dbh = Connection::cal_ro(); $this->action = 'configCalendar'; $this->next_action = 'configEdit'; $this->caltype = 'oncall'; $this->timeaction = 'configTime'; $obj_assignee = new calendarConfig(); $teamid = $obj_assignee->getTeamid($dbh, $team); $admingrp = $obj_assignee->getAdmingroup($dbh, $team); $this->is_allowed = $this->checkUserPermission($admingrp); $this->svn_url = __SVN_URL . "dp/oncall.txt?view=log"; $month = isset($_REQUEST['month']) && $_REQUEST['month'] != '' ? $_REQUEST['month'] : date("m"); $year = isset($_REQUEST['year']) && $_REQUEST['year'] != '' ? $_REQUEST['year'] : date("Y"); $this->month = $month; $this->year = $year; $this->showTime = 1; $this->next_action = 'configEdit'; $obj_cal = new calender($month, $year); $this->days = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); $obj_cal->getDetails(); $this->assignee = $obj_assignee->getConfigList($dbh, $teamid, $month, $year); $this->teamlist = $obj_assignee->getTeamlist($dbh); $this->title = 'Opensource Calendar'; $this->addYUI = 1; $this->addAutocomplete = 1; $this->onCall = 1; $this->menu = 'backup'; $this->view = 'calendar/addedit'; $dbh = Connection::cal_rw(); $this->caltype = 'oncall'; $this->timeaction = 'configTime'; $this->pagetitle = $team . " Calendar"; $this->help = "Start Date|End Date|timezone(IN|US)|Oncall Type(PRI|SEC|PRIMARY|SECONDARY)|Username<br>"; $this->help .= "Example:<br>2009-08-01|2009-08-10|US|PRI|jack<br>"; $obj = new calendarConfig(); $admingrp = $obj->getAdmingroup($dbh, $team); $this->is_allowed = $this->checkUserPermission($admingrp); if (!$this->is_allowed) { $messages = OpsContext::get('messages'); $messages->errors[] = "You don't have sufficient privilege to <b>Edit</b> this calendar! <br>"; return forward_to('this', 'configCalendar'); } $this->invalid_crumb = 0; if (getenv(".bycrumb") != $_REQUEST['crumb'] && $_REQUEST['btnSubmit'] != '') { $this->invalid_crumb = 1; } if (!$this->invalid_crumb) { if ($_REQUEST['oncall']) { $chk_old = $obj->checkIntermediateUpdate($dbh, $_REQUEST['lockid'], 'O'); $this->lockid = $_REQUEST['lockid']; $this->oncall = $_REQUEST['oncall']; if (!$chk_old) { try { $res = $obj->editConfig($dbh, $_REQUEST, $team); if ($res) { $obj->releaseCalendarLock($dbh, $_REQUEST['lockid']); $this->done = true; return redirect_to('calendar', 'configCalendar'); } } catch (Exception $e) { $messages = OpsContext::get('messages'); $messages->errors[] = $e->getMessage(); } } else { $messages = OpsContext::get('messages'); $messages->errors[] = "Your update session expired/Calendar updated by other user!"; $obj->releaseCalendarLock($dbh, $_REQUEST['lockid']); return forward_to('this', 'configCalendar'); } } else { list($edit_userid, $time_diff, $lock_id) = $obj->checkCalendarEdit($dbh, 'O'); if (!$edit_userid) { $this->lockid = $obj->lockCalendarEdit($dbh, 'O'); $recs = $obj->getConfigList($dbh, $teamid); $timezones = $obj->getZoneList($dbh); $oncall = ''; foreach ($recs as $rec) { $oncall .= $rec[from_dt] . "|" . $rec[to_dt] . "|" . $rec[timezone] . "|" . ($rec[oncall_type] == 1 ? "PRI" : "SEC") . "|" . $rec[username] . "\n"; if ($start == '' || strtotime($start) < strtotime($rec[to_dt])) { $start = $rec['to_dt']; } } $start = trim($start) == '' ? date("Y-m-d", strtotime("next Friday")) : $start; $arr_dates = $obj->generateDates($start, 7); foreach ($arr_dates as $adates) { foreach ($timezones as $zone) { $oncall .= $adates[0] . "|" . $adates[1] . "|" . $zone[name] . "|PRI|" . "\n"; $oncall .= $adates[0] . "|" . $adates[1] . "|" . $zone[name] . "|SEC|" . "\n"; } } $this->oncall = $oncall; } else { $this->edituser = $edit_userid; $this->lockid = $lock_id; $this->usage = $this->remainingDuration($time_diff); $this->duration = $this->remainingDuration($time_diff, 1); $this->calendar_type = "this Calendar."; } } } else { error("INVALID Crumb"); } $this->oncall_tab = " class='selected'"; }