Exemplo n.º 1
0
/**
 * 
 * SITE
 */
function createSite($id = "site")
{
    $site = new site("reservoirlog CMS");
    $site->changeID($id);
    $site->layout = "default";
    $site->style = "default";
    $site->save();
    //$site->display();
    return $site;
}
Exemplo n.º 2
0
 function get_site()
 {
     $site = new site();
     $site_array = $site::all();
     if (empty($site_array)) {
         $site_array = $site->set_default();
     } else {
         $site_array = $site_array[0];
     }
     return $site_array;
 }
Exemplo n.º 3
0
 function created()
 {
     $site = new site();
     $site->name = $_POST['name'];
     $site->bonus_type = $_POST['bonus_type'];
     $site->bonus_max = $_POST['bonus_max'];
     $site->convert_rate = $_POST['convert_rate'];
     $site->affiliate_url = "";
     $site->url = "";
     $site->comment = $_POST['comment'];
     $site->create();
     header("location: index.php");
 }
Exemplo n.º 4
0
 /**
  * Template loading and setup routine.
  */
 public function __construct()
 {
     parent::__construct();
     // checke request is ajax
     $this->ajax_request = request::is_ajax();
     // Load the template
     $this->template = new View($this->template);
     if ($this->auto_render == TRUE) {
         Event::add('system.post_controller', array($this, '_render'));
     }
     /**
      * 判断用户登录情况
      */
     if (isset($_REQUEST['session_id'])) {
         $session = Session::instance($_REQUEST['session_id']);
         $manager = role::get_manager($_REQUEST['session_id']);
     } else {
         $session = Session::instance();
         $manager = role::get_manager();
     }
     /* 当前请求的URL */
     $current_url = urlencode(url::current(TRUE));
     //当前用户管理的站点的ID
     $this->site_id = site::id();
 }
Exemplo n.º 5
0
 public function cash()
 {
     $this->live_cash = 0;
     $this->played = 0;
     $this->cash = 0;
     $this->transactions = transaction::from_account($this->account_id);
     # här kommer transaktionerna
     foreach ($this->transactions as $transaction) {
         $transactions[] = $transaction;
         if ($transaction->type == "cash_in") {
             $this->cash += $transaction->amount;
         } elseif ($transaction->type == "bonus") {
             $this->cash += $transaction->amount;
         } elseif ($transaction->type == "cash_out") {
             $this->cash -= $transaction->amount;
         }
     }
     # här kommer betsen
     $this->bets = bet::from_account($this->account_id);
     foreach ($this->bets as $bet) {
         $bet->match = match::from_id($bet->match_id);
         $bet->account = account::from_id($bet->account_id);
         $bet->account->site = site::from_id($bet->account->site_id);
         $this->played += $bet->bet;
         if ($bet->match->result == "undecided") {
             $this->live_cash += $bet->bet;
             $this->cash -= $bet->bet;
         } else {
             $this->cash -= $bet->bet;
             $this->cash += $bet->result;
         }
     }
     return $this->cash;
 }
Exemplo n.º 6
0
 public function index()
 {
     $route_data = Myroute::instance()->get();
     if ($_POST) {
         $site_next_flow = site::site_next_flow($this->current_flow);
         $submit_target = intval($this->input->post('submit_target'));
         if (Myroute::instance()->edit($_POST)) {
             //判断添加成功去向
             switch ($submit_target) {
                 case 2:
                     remind::set(Kohana::lang('o_global.update_success'), $site_next_flow['url'], 'success');
                 default:
                     remind::set(Kohana::lang('o_global.update_success'), 'site/route', 'success');
             }
         } else {
             remind::set(Kohana::lang('o_global.update_error'), 'site/route');
         }
     }
     $this->template->content = new View("site/route_edit");
     $this->template->content->is_modify = 0;
     if ($this->manager_is_admin == 1) {
         $this->template->content->is_modify = 1;
     }
     $this->template->content->data = $route_data;
     $this->template->content->site_id = $this->site_id;
 }
Exemplo n.º 7
0
 private function get_member_list()
 {
     // Call site settings for stored roster & member ranks to track
     $siteSettings = site::setting();
     // Decode JSON from stored roster data
     $roster = json_decode($siteSettings[0]['fullRoster'], true);
     $data = array();
     // Decode JSON from stored roster ranks
     $ranks = json_decode($siteSettings[0]['rosterRanks'], true);
     $filterRanks = array();
     // Ranks to track
     foreach ($ranks as $key => $value) {
         try {
             // echo $key . ' == ' . $value['track'] . '<br/>';
             if ($value['track']) {
                 $filterRanks[] = $key;
             }
         } catch (Exception $e) {
             //
         }
     }
     foreach ($roster['members'] as $key => $character) {
         // echo var_dump($character['character']);
         // echo $character['character']['name'];
         if (in_array($character['rank'], $filterRanks)) {
             $data[] = $character['character']['name'];
         }
     }
     json::resp(array('success' => true, 'data' => $data));
 }
Exemplo n.º 8
0
 public function add()
 {
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST, array('content'));
         $site_next_flow = site::site_next_flow($this->current_flow);
         $submit_target = intval($this->input->post('submit_target'));
         $faq = Myfaq::instance();
         if ($faq->add($_POST)) {
             //判断添加成功去向
             switch ($submit_target) {
                 case 1:
                     remind::set(Kohana::lang('o_global.add_success'), 'site/faq/add', 'success');
                 case 2:
                     remind::set(Kohana::lang('o_global.add_success'), $site_next_flow['url'], 'success');
                 default:
                     remind::set(Kohana::lang('o_global.add_success'), 'site/faq', 'success');
             }
         } else {
             remind::set(Kohana::lang('o_global.add_error'), 'site/faq/add');
         }
     }
     $this->template->content = new View("site/faq_add");
     $this->template->content->title = "site faq add";
 }
Exemplo n.º 9
0
 private function check_streaks()
 {
     $users = ORM::factory('User')->where('current_streak', '>', 0)->find_all();
     if ((bool) $users->count()) {
         foreach ($users as $user) {
             $last = $user->pages->where('type', '=', 'page')->find();
             if ($last->loaded()) {
                 $nextday = site::day_slug(strtotime('+1 day', strtotime($last->day)));
                 $today = site::day_slug($user->timestamp());
                 $tomorrow = site::day_slug(strtotime('+1 day', $user->timestamp()));
                 if ($nextday != $today && $nextday != $tomorrow) {
                     $user->current_streak = 0;
                     $user->validation_required(false)->save();
                     if ($user->doing_challenge()) {
                         $user->fail_challenge();
                     }
                 }
             } else {
                 if ($user->doing_challenge()) {
                     $start = $user->challenge->start;
                     if ($user->timestamp() - $start > 24 * 60 * 60) {
                         $user->fail_challenge();
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 10
0
 public static function template($file = '')
 {
     $template = ZOTOP_PATH_THEMES . DS . site::theme() . DS . 'template';
     if (!empty($file)) {
         $template .= DS . str_replace('/', DS, trim($file, '/'));
     }
     return $template;
 }
Exemplo n.º 11
0
 /**
  * 构造方法
  */
 public function __construct()
 {
     parent::__construct();
     if ($this->is_ajax_request()) {
         $this->template = new View('layout/default_json');
     }
     $this->site_id = site::id();
 }
Exemplo n.º 12
0
 public function __construct()
 {
     parent::__construct();
     $this->site_id = site::id();
     if ($this->site_id <= 0) {
         die(Kohana::lang('o_global.access_denied'));
     }
 }
Exemplo n.º 13
0
 }
 public static function success($note, $redirect = false)
 {
     self::add('success', $note);
     if ($redirect) {
         site::redirect($redirect);
         die;
     }
Exemplo n.º 14
0
 public function printOne($sitePhone)
 {
     $siteName = site::GET($sitePhone->siteID)->name;
     $phoneName = phone::GET($sitePhone->phoneID)->name;
     echo "<table>";
     echo "<tr><td><b>\tСайт\t</b></td><td><a   href=\"/site/view/{$siteEmail->siteID}\">\t{$siteName}\t</a></td></tr>";
     echo "<tr><td><b>\tТелефон\t</b></td><td><a href=\"/phone/view/{$siteEmail->emailID}\">\t{$phoneName}\t</a></td></tr>";
     echo "</table>";
 }
Exemplo n.º 15
0
 public function GET($id)
 {
     if (!site::IFDELETED($id)) {
         $getQuery = "SELECT \r\n\t\t\t\t\tid, \r\n\t\t\t\t\tconvert(varchar(max), name) as name,\r\n\t\t\t\t\thostingID, \r\n\t\t\t\t\tmanagerID, \r\n\t\t\t\t\tregistratorID\r\n\t\t\t\tFROM \r\n\t\t\t\t\t[dbo].[site] \r\n\t\t\t\tWHERE \r\n\t\t\t\t\tid={$id};";
         $row = mssql_fetch_array(mssql_query($getQuery));
         $result = new site($row["id"], $row["name"], $row["hostingID"], $row["managerID"], $row["registratorID"]);
         return $result;
     }
 }
Exemplo n.º 16
0
 function __construct()
 {
     parent::__construct();
     $this->load->model('auth_model');
     $this->load->model('charts_model');
     $this->load->model('dates_model');
     $this->load->model('reports_model');
     $this->days = 7;
 }
Exemplo n.º 17
0
 public function printOne($siteEmail)
 {
     $siteName = site::GET($siteEmail->siteID)->name;
     $emailName = email::GET($siteEmail->emailID)->name;
     echo "<table>";
     echo "<tr><td><b>\tСайт:\t</b></td><td><a  href=\"/site/view/{$siteEmail->siteID}\">\t{$siteName}\t</a></td></tr>";
     echo "<tr><td><b>\temail:\t</b></td><td><a href=\"/email/view/{$siteEmail->emailID}\">\t{$emailName}\t</a></td></tr>";
     echo "</table>";
 }
Exemplo n.º 18
0
 public function action_twittercallback()
 {
     if (arr::get($_GET, 'denied', false)) {
         notes::error('Seems like you didn\'t want to log in with Twitter anyway. Feel free to try again if it was a mistake!');
         site::redirect();
     }
     $token = arr::get($_GET, 'oauth_token', false);
     $verifier = arr::get($_GET, 'oauth_verifier', false);
     if (!$token || !$verifier) {
         notes::error('Something went wrong in the process, and we didn\'t get the expected data back from Twitter. Please try again');
         site::redirect();
     }
     $connection = new TwitterOAuth(arr::get($this->creds, 'key'), arr::get($this->creds, 'secret'), Session::instance()->get_once('twitter_oauth_token'), Session::instance()->get_once('twitter_oauth_token_secret'));
     $token = $connection->getAccessToken($verifier);
     $oauth_token = arr::get($token, 'oauth_token', '');
     $oauth_token_secret = arr::get($token, 'oauth_token_secret', '');
     $user_id = arr::get($token, 'user_id', '');
     $screen_name = arr::get($token, 'screen_name', '');
     $oauth = ORM::factory('Oauth')->where('type', '=', 'twitter')->where('token', '=', $oauth_token)->find();
     if ($oauth->loaded()) {
         try {
             $user = $oauth->user;
             user::force_login($user);
         } catch (exception $e) {
             if ($user->loaded()) {
                 if (user::logged()) {
                     // Random error, but user got logged in. We don't care, YOLO!
                 } else {
                     notes::error('Whoops! Something wen\'t wrong and we couldn\'t log you in. Please try again or send us a message if the problem persists.');
                     Kohana::$log->add(Log::ERROR, '1. Couldnt log user in: ' . $e->getMessage());
                 }
             }
         }
         site::redirect('write');
     } else {
         try {
             $user = ORM::factory('User');
             $user->username = $screen_name;
             $user->validation_required(false)->save();
             $user->add_role('login');
             $oauth = ORM::factory('Oauth');
             $oauth->user_id = $user->id;
             $oauth->type = 'twitter';
             $oauth->token = $oauth_token;
             $oauth->token_secret = $oauth_token_secret;
             $oauth->service_id = $user_id;
             $oauth->screen_name = $screen_name;
             $oauth->save();
             user::force_login($user);
         } catch (exception $e) {
             Kohana::$log->add(Log::ERROR, '2. Couldnt create user: '******'Whoops! Something wen\'t wrong and we couldn\'t log you in. Please try again or send us a message if the problem persists.');
         }
         site::redirect('/write');
     }
 }
Exemplo n.º 19
0
 public static function getAll()
 {
     $link = site::getLink();
     $sql = "SELECT `id` FROM `sites` ORDER BY `order` ASC";
     $data = site::db_query($sql);
     foreach ($data as &$site) {
         $site = new portfolio($site['id']);
     }
     return $data;
 }
Exemplo n.º 20
0
 function __construct()
 {
     parent::__construct();
     $this->load->model('admin/orders_model');
     //user has logged in
     if ($this->login_model->check_login()) {
     } else {
         $this->session->set_userdata('front_error_message', 'Please sign up/in to continue');
         redirect('checkout');
     }
 }
Exemplo n.º 21
0
 public function action_write()
 {
     $errors = false;
     $page = false;
     if (user::logged()) {
         $page = $this->request->param('page');
         if ($_POST && strlen(arr::get($_POST, 'content', '')) > 0) {
             $content = arr::get($_POST, 'content', '');
             if ($page->type == 'page') {
                 $raw = $page->rawcontent();
                 if ($raw != "") {
                     $content = $raw . "\n" . $content;
                 }
             } else {
                 if ($page->type == 'autosave') {
                     $page->type = 'page';
                 }
             }
             try {
                 $page->wordcount = site::count_words($content);
                 $page->content = $content;
                 if ($page->wordcount >= 750 && !(bool) $page->counted) {
                     user::update_stats($page);
                     $page->counted = 1;
                 }
                 $page->duration = $page->duration + (time() - arr::get($_POST, 'start', 999));
                 $page->update();
                 $oldsaves = ORM::factory('Page')->where('type', '=', 'autosave')->where('user_id', '=', user::get()->id)->find_all();
                 if ((bool) $oldsaves->count()) {
                     foreach ($oldsaves as $old) {
                         $old->delete();
                     }
                 }
                 achievement::check_all(user::get());
                 notes::success('Your page has been saved!');
                 //site::redirect('write/'.$page->day);
             } catch (ORM_Validation_Exception $e) {
                 $errors = $e->errors('models');
             }
         }
     } else {
         if ($_POST) {
             notes::error('You must be logged in to save your page. Please log in and submit again.');
         }
     }
     $this->bind('errors', $errors);
     $this->bind('page', $page);
     $this->template->daystamp = $this->request->param('daystamp');
     $this->template->page = $page;
     seo::instance()->title("Write Your Morning Pages");
     seo::instance()->description("Morning Pages is about writing three pages of stream of consciousness thought every day. Become a better person by using MorninPages.net");
 }
Exemplo n.º 22
0
 public static function init($action = "news")
 {
     self::$routerData = Router::getParams();
     if (!isset(self::$routerData['clanid'])) {
         self::$routerData['clanid'] = 1;
     }
     if (!isset(self::$routerData['site'])) {
         self::$routerData['site'] = "news";
     }
     SiteData::siteExists(self::$routerData['clanid']);
     self::$clanData = SiteData::getSiteData(self::$routerData['clanid']);
     self::testTemplateType();
 }
 public function newEntry()
 {
     if (user::accessLevel($_COOKIE['id']) == 1) {
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             site::INSERT($_POST['name'], $_POST['hostingID'], $_POST['managerID'], $_POST['registratorID']);
             //header("Location: /site");
         } else {
             siteController::loadView('new', $args = array());
         }
     } else {
         echo "You have no access";
     }
 }
Exemplo n.º 24
0
 public function action_show()
 {
     $token = $this->request->param('id');
     $mail = ORM::factory('Mail')->where('token', '=', $token)->find();
     if ($mail->loaded()) {
         $view = View::factory('templates/mail');
         $view->mail = $mail;
         echo $view;
     } else {
         notes::add('error', 'Mail not found!');
         site::redirect('');
         die;
     }
 }
Exemplo n.º 25
0
 /**
  * 构造方法
  */
 public function __construct()
 {
     $package_name = substr(dirname(__FILE__), strlen(APPPATH . 'controllers/'));
     empty($package_name) && ($package_name = 'default');
     $this->package_name = $package_name;
     $this->class_name = strtolower(substr(__CLASS__, 0, strpos(__CLASS__, '_')));
     $this->phprpc_server = Kohana::config('phprpc.remote.statking.host');
     $this->site_ids = role::get_site_ids();
     $this->site_id = site::id();
     parent::__construct();
     if ($this->is_ajax_request() == TRUE) {
         $this->template = new View('layout/default_json');
     }
 }
Exemplo n.º 26
0
 public function action_info()
 {
     if (!user::logged()) {
         ajax::error('You must be logged in');
     }
     $user = user::get();
     $today = $user->pages->where('day', '=', site::day_slug($user->timestamp()))->find();
     $wordcount = 0;
     if ($today->loaded()) {
         $wordcount = $today->wordcount;
     }
     $doingChallenge = $user->doing_challenge();
     ajax::success('ok', array('email' => $user->email, 'bio' => $user->bio, 'website' => $user->website, 'wordcount' => $wordcount, 'options' => array('reminder' => (bool) $user->option->reminder, 'reminder_hour' => $user->option->reminder_hour, 'reminder_minute' => $user->option->reminder_minute, 'reminder_meridiem' => $user->option->reminder_meridiem, 'timezone_id' => $user->option->timezone_id, 'theme_id' => $user->option->theme_id, 'privacymode' => (bool) $user->option->privacymode, 'privacymode_minutes' => $user->option->privacymode_minutes, 'hemingwaymode' => (bool) $user->option->hemingwaymode, 'public' => (bool) $user->option->public, 'rtl' => (bool) $user->option->rtl, 'language' => $user->option->language), 'doingChallenge' => $doingChallenge, 'challengeProgress' => $doingChallenge ? $user->challenge->progress : 0));
 }
Exemplo n.º 27
0
 function profile()
 {
     $match_id = $_GET['match_id'];
     $match = match::from_id($match_id);
     $bets = bet::from_match($match_id);
     foreach ($bets as $bet) {
         $bet->account = account::from_id($bet->account_id);
         $bet->account->site = site::from_id($bet->account->site_id);
         $bet->match = match::from_id($bet->match_id);
     }
     $data['match'] = $match;
     $data['bets'] = $bets;
     $this->view('matches/profile_view.php', $data, 'main_template.php');
 }
Exemplo n.º 28
0
 public function index()
 {
     /* 初始化默认查询条件 */
     $newsletter_query_struct = array('where' => array('user_id' => 0), 'like' => array(), 'orderby' => array(), 'limit' => array('per_page' => 20, 'offset' => 0));
     /* 权限检查 得到所有可管理站点ID列表 */
     $site_id_list = role::check('newsletter');
     /* Newsletter列表模板 */
     $this->template->content = new View("user/newsletter");
     /* 搜索功能 */
     $search_arr = array('email', 'ip');
     $search_value = $this->input->get('search_value');
     $search_type = $this->input->get('search_type');
     $where_view = array();
     if ($search_arr) {
         foreach ($search_arr as $value) {
             if ($search_type == $value && strlen($search_value) > 0) {
                 $newsletter_query_struct['where'][$value] = $search_value;
                 if ($value == 'ip') {
                     $newsletter_query_struct['where'][$value] = tool::myip2long($search_value);
                 }
             }
         }
         $where_view['search_type'] = $search_type;
         $where_view['search_value'] = $search_value;
     }
     //当前切入的站点查询条件
     $site_in = site::current_query_site_ids();
     $where_view['site_id'] = '';
     $newsletter_query_struct['where']['site_id'] = $site_in;
     /* 列表排序 */
     $orderby_arr = array(0 => array('id' => 'DESC'), 1 => array('id' => 'ASC'), 2 => array('site_id' => 'ASC'), 3 => array('site_id' => 'DESC'), 4 => array('email' => 'ASC'), 5 => array('email' => 'DESC'), 6 => array('date_add' => 'ASC'), 7 => array('date_add' => 'DESC'), 8 => array('ip' => 'ASC'), 9 => array('ip' => 'DESC'), 10 => array('active' => 'ASC'), 11 => array('active' => 'DESC'));
     $orderby = controller_tool::orderby($orderby_arr);
     $newsletter_query_struct['orderby'] = $orderby;
     /* 每页显示条数 */
     $per_page = controller_tool::per_page();
     $newsletter_query_struct['limit']['per_page'] = $per_page;
     /* 调用分页 */
     $this->pagination = new Pagination(array('total_items' => Mynewsletter::instance()->query_count($newsletter_query_struct), 'items_per_page' => $per_page));
     $newsletter_query_struct['limit']['offset'] = $this->pagination->sql_offset;
     $newsletters = Mynewsletter::instance()->query_assoc($newsletter_query_struct);
     foreach ($newsletters as $key => $value) {
         $site = Mysite::instance($value['site_id'])->get();
         $newsletters[$key]['site'] = $site;
     }
     /* 调用列表 */
     $this->template->content->newsletter_list = $newsletters;
     /* 搜索信息保存 */
     $this->template->content->where = $where_view;
 }
Exemplo n.º 29
0
    /**
	 * Add a message to the "popnotes" session.
	 * @param String Type of message.
	 * @param String Message
	 * @return void
	 */
    public static function add($type, $note, $redirect = false)
    {
        $session = Session::instance();
        $popnotes = $session->get('popnotes');
        if (!$popnotes) {
            $popnotes = array();
        }
        $content = array('type' => $type, 'note' => $note);
        $popnotes[] = $content;
        $session->set('popnotes', $popnotes);
Exemplo n.º 30
0
 function __construct()
 {
     parent::__construct();
     $this->load->model('auth_model');
     $this->load->model('banner_model');
     $this->load->model('subscription_model');
     $this->load->model('stripe_model');
     $this->load->model('reports_model');
     //user has logged in
     if ($this->auth_model->check_login()) {
     } else {
         $this->session->set_userdata('error_message', 'Please sign in to continue');
         redirect('sign-in');
     }
 }