public static function GetProfilePage($assocArr = null) { $tpl = new Template(); $tpl->SetParams($assocArr); $userInfo = Users_Model::GetUserById($_SESSION['user']['id']); $tpl->SetParams($userInfo); return $tpl->Fetch('templates/users/user-profile.tpl'); }
function index() { $current_user = Users_Model::get_current_user(); $posts = Users_Model::get_facebook_posts(); $post_chart = array('Posts'); $post_count = 0; $likes = Users_Model::get_facebook_likes(); $likes_chart = array('Likes'); $likes_count = 0; $date_start = $date_first = strtotime('-7 DAYS'); $date_end = time(); if ($this->is_ajax() && isset($_POST['startDate']) && isset($_POST['endDate'])) { $date_start = $_POST['startDate']; $date_end = $_POST['endDate']; } while ($date_start <= $date_end) { $index = date('d.m', $date_start); $post_chart[$index] = 0; $likes_chart[$index] = 0; // Posts if (!empty($posts)) { foreach ($posts['data'] as $post) { if (date('Y-m-d', strtotime($post->created_time)) == date('Y-m-d', $date_start)) { $post_chart[$index]++; $post_count++; } } } // Likes if (!empty($likes->data)) { foreach ($likes->data as $like) { if (date('Y-m-d', strtotime($like->created_time)) == date('Y-m-d', $date_start)) { $likes_chart[$index]++; $likes_count++; } } } $date_start = strtotime('+1 day', $date_start); } $categories = array_slice(array_keys($post_chart), 1); $post_chart = array_values($post_chart); $likes_chart = array_values($likes_chart); if ($this->is_ajax() && isset($_POST['startDate']) && isset($_POST['endDate'])) { echo json_encode(array('status' => true, 'html' => $this->load->view('facebook/_facebook_chart', array('chart_categories' => $categories, 'post_count' => $post_count, 'post_chart' => $post_chart, 'likes_count' => $likes_count, 'likes_chart' => $likes_chart, 'startDate' => date('d/m/y', $date_first), 'endDate' => date('d/m/y', $date_end)), TRUE), 'chart_categories' => $categories, 'post_chart' => $post_chart, 'likes_chart' => $likes_chart)); exit; } else { $this->layout('admin', 'facebook/facebook', array('current_user' => $current_user, 'post_count' => $post_count, 'post_chart' => $post_chart, 'likes_count' => $likes_count, 'likes_chart' => $likes_chart, 'chart_categories' => $categories, 'startDate' => date('d/m/y', $date_first), 'endDate' => date('d/m/y', $date_end))); } }
public function index() { $dis = array(); $dis['view'] = 'admin/home'; $admin_login = $this->session->userdata('login'); if (sizeof($admin_login) > 0) { $current_user = Users_Model::find_by_user_id($admin_login['user_id']); $dis['current_user'] = $current_user; if ($current_user->type == 2) { $dis['mes'] = "Only Administrator / Customer is allowed to this page. Log in as Administrator / Customer"; } $this->view_front($dis); } else { header("Location: http://w.gregfurlong.ie/login"); } }
public function twitter() { $current_user = Users_Model::get_current_user(); $twitter_meta = $current_user->get_usermeta('twitter_meta'); $favorites = $current_user->get_twitter_favorites(); $tweets = $current_user->get_all_tweets(); $favorites_chart = array('Favorites'); $retweets_chart = array('Retweets'); $favorites_count = 0; $retweets_count = 0; $date_start = $date_first = strtotime('-7 DAYS'); $date_end = time(); if ($this->is_ajax() && isset($_POST['startDate']) && isset($_POST['endDate'])) { $date_start = $_POST['startDate']; $date_end = $_POST['endDate']; } while ($date_start <= $date_end) { $index = date('d.m', $date_start); $favorites_chart[$index] = 0; $retweets_chart[$index] = 0; // Favorites foreach ($favorites as $favorite) { if (date('Y-m-d', strtotime($favorite->created_at)) == date('Y-m-d', $date_start)) { $favorites_chart[$index]++; $favorites_count++; } } // Retweets foreach ($tweets as $tweet) { if (date('Y-m-d', strtotime($tweet->created_at)) == date('Y-m-d', $date_start)) { $retweets_chart[$index] += $tweet->retweet_count; $retweets_count += $tweet->retweet_count; } } $date_start = strtotime('+1 day', $date_start); } $categories = array_slice(array_keys($favorites_chart), 1); $favorites_chart = array_values($favorites_chart); $retweets_chart = array_values($retweets_chart); if ($this->is_ajax() && isset($_POST['startDate']) && isset($_POST['endDate'])) { echo json_encode(array('status' => true, 'html' => $this->load->view('dashboard/social/_twitter_chart', array('favorites_chart' => $favorites_chart, 'chart_categories' => $categories, 'startDate' => date('Y/d/m', $date_first), 'endDate' => date('Y/d/m', $date_end), 'favorites_count' => $favorites_count, 'retweets_count' => $retweets_count), TRUE), 'favorites_chart' => $favorites_chart, 'retweets_chart' => $retweets_chart, 'chart_categories' => $categories)); exit; } else { $this->view_admin(array('view' => 'social/twitter', 'current_user' => $current_user, 'twitter_meta' => $twitter_meta, 'favorites_chart' => $favorites_chart, 'retweets_chart' => $retweets_chart, 'chart_categories' => $categories, 'startDate' => date('Y/d/m', $date_first), 'endDate' => date('Y/d/m', $date_end), 'favorites_count' => $favorites_count, 'retweets_count' => $retweets_count)); } }
public function orders($id = null) { if ($_SERVER['REQUEST_METHOD'] == "DELETE") { return Orders_Model::DeleteOrder($id); } if ($_SERVER['REQUEST_METHOD'] == "PUT") { $data = json_decode(file_get_contents("php://input"), true); return Orders_Model::UpdateOrder($data, $id); } if (isset($id)) { return Users_Model::GetUserById($id); } $t = Orders_Model::GetAllOrders(); $orders = array(); foreach ($t as $item) { array_push($orders, $this->getoneorder($item)); } return $orders; }
function settings() { $dis = array(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $active = MD5(time()); $admin_login = $this->session->userdata('login'); $user = Users_Model::find_by_user_id($admin_login['user_id']); if ($user->type == 2) { $user->delete(); $message = "<p class='success'>Your account was successfully closed.</p>"; $dis['mes'] = $message; } elseif ($user->type == 1) { $user->active = $active; $user->save(); $users_in_company = Users_Model::find('all', array('company' => $user->email)); foreach ($users_in_company as $customer) { $customer->active = $active; $customer->save(); } $admin_user = Users_Model::find_by_type(0); $body = "You are about to close your account. An activation email has been sent to the email address you provided. Session you click the link to Close your account \n\n "; $body .= BASE_URL . "users/close/" . str_replace("'", "", $active); if (mail($admin_user->email, 'Close account at izCMS', $body, 'FROM: localhost')) { $message = "<p class='success'>Email has been sent to your address. You must click the link to close your account.</p>"; } else { $message = "<p class='error'>Can not send an email to you. We apologize for this inconvenience.</p>"; } $dis['mes'] = $message; } else { $message = "<p class='error'>You are the administrator. Your account can't be closed !!!</p>"; $dis['mes'] = $message; } } $dis['view'] = 'users/settings'; $this->view_front($dis); }
<?php $users = Users_Model::find('all', array('company' => $current_user->email)); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $delete_list = $_POST['delete']; for ($i = sizeof($delete_list); $i > 0; $i--) { $users[$delete_list[$i - 1]]->delete(); } if ($_FILES["csv"]["size"] > 0) { //get the csv file $file = $_FILES["csv"]["tmp_name"]; $handle = fopen($file, "r"); $mimes = array('application/vnd.ms-excel', 'text/plain', 'text/csv', 'text/tsv'); if (in_array($_FILES['csv']['type'], $mimes)) { while ($data = fgetcsv($handle, 2000, ",", "'")) { $user = new Users_Model(); $user->first_name = $data[0]; $user->last_name = $data[1]; $user->email = $data[2]; $user->pass = MD5($data[3]); $user->registration_date = date("Y-m-d H:i:s"); $user->company = $current_user->email; $user->save(); } } } $result = "Succeed"; $users = Users_Model::find('all', array('company' => $current_user->email)); } ?> <style>
<?php $customers = Users_Model::find('all', array('type' => 1)); ?> <div class="col-md-12 tagline"> <div class="tagline_wrap"> <div class="form-wrap"> <h1>Sign Up</h1> <a class="btn btn-block btn-social btn-facebook" href="<?php echo BASE_URL; ?> login/facebook"> <i class="fa fa-facebook"></i> Sign in with facebook </a> <a class="btn btn-block btn-social btn-twitter" href="<?php echo BASE_URL; ?> login/twitter"> <i class="fa fa-twitter"></i> Sign in with Twitter </a>
<div id="ajax-content"> <?php if (!Users_Model::is_twitter_account() && !Users_Model::has_twitter_account()) { ?> <div class="tw-add-account"> <div id="dashboard-header" class="row dashboard-head"> <div class="dashboard-headline"> <div class="col-xs-12 col-sm-8 col-md-8"> <h3>Add a Twitter Account</h3> <br> <p>Please add you Twitter account to get feed.</p> </div> <div class="clearfix"></div> </div> </div> <div class="row stats_wrap"> <div class="col-xs-12 col-sm-8 col-md-8"> <a href="/Twitter/add_account" class="btn btn-info add-twitter-account">Add an account</a> </div> </div> </div> <?php } else { ?> <div class="col-xs-12 col-md-12 daily-progress">
public function add_account() { $response = Users_Model::attach_twitter_account(base_url('Twitter/add_account')); switch ($response['status']) { case "redirect": case "redirect_error": case "success": redirect($response['url']); break; case "error": $dis['message'] = '<p class="error">' . $response['message'] . '</p>'; break; } }
public function layout($type = '', $views = '', $data = array()) { $dis['base_url'] = BASE_URL; $dis['this'] = $this; $dis['page_title'] = $this->page_title; $dis['site_title'] = $this->site_title; $dis['js_variables'] = $this->_js_variables; $dis['js_scripts'] = $this->_js; $dis['csses'] = $this->_css; $login = $this->session->userdata('login'); $this->load->model('Users_Model'); $dis['userlogin'] = Users_Model::find_by_user_id($login['user_id']); if (!isset($dis['menu_active']) || empty($dis['menu_active'])) { $dis['menu_active'] = $this->menu_active; } $data = array_merge($dis, $data); $this->load->view("layout/{$type}/header", $data); $this->load->view($views, $data); $this->load->view("layout/{$type}/footer", $data); }
public static function login() { if (isset($_POST['email']) && isset($_POST['password'])) { $users = Users_Model::find_by_email_and_pass_and_active($_POST['email'], MD5($_POST['password']), NULL); if (sizeof($users) > 0) { $userdata = array('user_id' => $users->user_id, 'email' => $users->email, 'user_level' => $users->user_level, 'first_name' => $users->first_name, 'last_name' => $users->last_name, 'account_type' => $users->type); $_SESSION['login'] = $userdata; return true; } else { return false; } } }
<div id="ajax-content"> <?php if (!Users_Model::is_facebook_account()) { ?> <div class="fb-add-account"> <div id="dashboard-header" class="row dashboard-head"> <div class="dashboard-headline"> <div class="col-xs-12 col-sm-8 col-md-8"> <h3>Add a Facebook Account</h3> <br> <p>Please add you Facebook account to get information.</p> </div> <div class="clearfix"></div> </div> </div> <div class="row stats_wrap"> <div class="col-xs-12 col-sm-8 col-md-8"> <input type="button" class="btn btn-info add-facebook-account" value="Add an account"> </div> </div> </div> <?php } else { ?>
public function AuthAction($route) { if (Core::$user->isUser()) { header('Location: /users/profile'); die; } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $res = Users_Model::UserAuth($_POST['login'], $_POST['password']); } if ($res['Status'] == 1) { header('Location: /'); die; } $resArr = array(); $resArr['Title'] = 'Аутентификация'; $resArr['PageTitle'] = 'Вход на сайт'; $resArr['Content'] = Users_View::GetAuth($res); return $resArr; }