Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.85 KB | None | 0 0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. class Main extends CI_Controller {
  4.  
  5.     var $data = array();
  6.  
  7.     public function Main()
  8.     {
  9.         parent::__construct();
  10.         $this->data = $this->spergauth->loggedIn(FALSE);
  11.         $this->load->library('form_validation');
  12.     }
  13.  
  14.     public function index($from = "")
  15.     {
  16.        
  17.         if (count($this->data) > 1) {
  18.             $this->_displayMainPage($this->data);
  19.             return TRUE;
  20.         }
  21.  
  22.         $spergop = $this->input->post('spergop');
  23.         $this->load->helper('cookie');
  24.        
  25.         if ( ! $spergop ) {
  26.             $message = '';
  27.             switch ($from) {
  28.                 case "notloggedin":
  29.                     $message = "You need to be signed in to view this page.";              
  30.                 break;
  31.                 case "loggedout":
  32.                     $message = "You have been logged out out.";            
  33.                 break;
  34.                 case "banned":
  35.                     if ( ! get_cookie('banlookup') ) {
  36.                         $message = '';
  37.                         break;
  38.                     }
  39.                    
  40.                     $userLoginString = clean(get_cookie('banlookup'));
  41.                     $query = $this->db->query("SELECT * FROM users WHERE userkey='$userLoginString'");
  42.        
  43.                     if ($query->num_rows() != 1) {
  44.                         $message = '';
  45.                         break;
  46.                     }
  47.                    
  48.                     $row = $query->row_array();
  49.                     $uid = $row['id'];
  50.                    
  51.                     if ( $row['banned'] != 1 ) {
  52.                         $message = '';
  53.                         break;
  54.                     }
  55.                    
  56.                     $query = $this->db->query("SELECT * FROM ban_reasons WHERE userid='$uid'");
  57.                     if ($query->num_rows() != 1) {
  58.                         $message = '';
  59.                         break;
  60.                     }
  61.                    
  62.                     $row = $query->row_array();
  63.                     $reason = $row['public_reason'];
  64.                    
  65.                     $message = "Your account has been banned.";
  66.                    
  67.                     if ($reason != '')
  68.                     $message .= "<br /><br /><b>Reason</b>:<br><div style='margin-top:5px;margin-left:15px;'>" . nl2br($reason) . "</div>";
  69.                    
  70.                 break;
  71.                 case "differentip":
  72.                     $message = "You have been logged out by the usage of this account on a different IP address.";             
  73.                 break;
  74.             }
  75.             $this->_displayWelcome($message);
  76.             return TRUE;
  77.         }
  78.        
  79.         $this->load->model('usermodel', 'user');
  80.        
  81.         switch ($spergop) {
  82.             case "login":
  83.                 $this->_handleLogin();
  84.             break;
  85.             case "register":
  86.                 $this->_handleReg();
  87.             break;
  88.             case "forgot":
  89.                 $this->_handleForgot();
  90.             break;
  91.             default:
  92.                 $this->_displayWelcome("Something has gone horribly wrong.");
  93.             break;
  94.         }
  95.     }
  96.    
  97.     public function register($from = "")
  98.     {
  99.         /*
  100.  
  101.         if (count($this->data) > 1) {
  102.             $this->_displayMainPage($this->data);
  103.             return TRUE;
  104.         }
  105. */
  106.     }
  107.    
  108.     public function showit() {
  109.  echo spergHash('68.109.24.2');
  110.     }
  111.  
  112.    
  113.     public function logout()
  114.     {
  115.         $message = '';
  116.        
  117.         if (count($this->data) > 1) {
  118.             $this->spergauth->logout();
  119.             $message = "You have been successfully logged out.";
  120.         }
  121.        
  122.         $this->_displayWelcome($message);
  123.     }
  124.  
  125.     private function _displayMainPage()
  126.     {
  127.  
  128. $money = 3;
  129. $full = 26;
  130.  
  131. $a = $full - $money;
  132. $fillto = ($a > 0) ? $money : $full;
  133. $bar = '[';
  134. for($i=0;$i<$fillto;$i++) $bar .= '=';
  135. if ($a > 0)
  136. for($i=0;$i<$a;$i++) $bar .= ' ';
  137. $bar .= ']';
  138. if ($a < 0)
  139. for($i=0;$i<0-$a;$i++) $bar .= '=';
  140.  
  141. if ($money >= $full)
  142. $showdonations = '<pre><b>This Month\'s Donations:</b> <font color="#1DB400">✔ Server Bill Paid</font><br></pre>'
  143. else
  144. $showdonations = "<pre><b>This Month's Donations:</b> " . $bar . " <font color=\"#8F4800\">\$ " . $money*10 . "</font>/260</pre>";
  145.  
  146.  
  147.  
  148.         $this->data['title'] = "Main";
  149.         // $this->data['barText'] = "<center>We're back, baby!<br><br><img src=\"" . base_url() . "static/images/nyan.gif\" align=\"center\">";
  150.  
  151.        
  152.  
  153.         $this->data['barText'] = "<center>We're back, baby!</center><br>";
  154.         $this->db->cache_on();
  155.  
  156.         $query = $this->db->query("SELECT featured_movie.*, users.name as username, movies.name_prefix, movies.name, movies.year, movies.link FROM featured_movie
  157. INNER JOIN users ON users.id = featured_movie.by
  158. INNER JOIN movies ON movies.id = featured_movie.m_id
  159. WHERE featured_movie.id = 1");
  160.         $this->db->cache_off();
  161.  
  162.         $row = $query->row_array();
  163.  
  164. $this->data['barText'] .= "<div style=\"display:block;white-space: nowrap;
  165. \"><div class=\"b_link\" style=\"white-space: normal; display:inline-block;width:750px;margin-right:20px;text-align:left;\">Featured Movie: <i>";
  166.  
  167. $name = ($row['name_prefix'] != '') ? $row['name_prefix']." ".$row['name'] : $row['name'];
  168. $this->data['barText'] .= anchor('movies/watch/' . $row['m_id'], "<u>" . $name . " (" . $row['year'] . ")</u>");
  169.  
  170. $this->data['barText'] .= "</i><br><br><div style=\"font-weight:normal;font-size:13px;\">";
  171. $this->data['barText'] .= "<div style=\"border-left: 5px solid #00ccff; padding-right:5px; padding-left:5px; display:block;height:286px;overflow-y:scroll;\">";
  172. $this->data['barText'] .= nl2br($row['review']);
  173. $this->data['barText'] .= "</div>";
  174. $this->data['barText'] .= "<div class=\"b_link\" style=\"margin-top:10px;\"><b>Review By:</b> " . anchor('user/page/' . $row['by'], $row['username']) . "</div>";
  175. $this->data['barText'] .= "<div style=\"border-top:1px solid #bbb;height:1px;width:92%;margin-left:auto;margin-right:auto;display:block;margin-top:30px;margin-bottom:30px;\"></div>
  176.  
  177. $showdonations
  178.  
  179. </div></div>
  180. <div style=\"display:inline-block;\"><center> " . anchor('movies/watch/' . $row['m_id'] , "<img src=\"" . base_url() . "static/images/movies/" . $row['art'] . "\" height=\"420\">") . "</center></div></div></div>";
  181.         $this->load->view('header', $this->data);
  182.         $this->load->view('main', $this->data);
  183.         $this->load->view('footer', $this->data);
  184.    
  185.     }
  186.  
  187.     private function _handleLogin()
  188.     {
  189.         if ($this->form_validation->run('login') == FALSE) {
  190.             $this->_displayWelcome("The form was filled out incorrectly:<br>");
  191.             return FALSE;
  192.         }
  193.        
  194.         $login = $this->spergauth->checkLogin($this->input->post('username'), $this->input->post('password'));
  195.  
  196.         if ( count($login) == 1 ) {
  197.             $this->_displayWelcome($login['message']);
  198.             return TRUE;
  199.         }
  200.  
  201.         $this->data = $login;
  202.  
  203.         $this->_displayMainPage();
  204.         return TRUE;
  205.     }
  206.  
  207.     private function _handleReg()
  208.     {
  209.         if ($this->form_validation->run('register') == FALSE) {
  210.             $this->_displayWelcome("The form was filled out incorrectly:<br>");
  211.             return FALSE;
  212.         }
  213.        
  214.         $passed_username = $this->input->post('username');
  215.         $encoded_username = urlencode($passed_username);
  216.         $username = clean($passed_username);
  217.        
  218.         $user_array = $this->user->get_user_from_name($username);
  219.         if (count($user_array) > 0) {
  220.             $this->_displayWelcome("You appear to already be registered. Please try logging in.");
  221.             return TRUE;
  222.         }
  223.        
  224.        
  225.         $luelinks = $this->spergauth->checkLuelinks($encoded_username, $username);
  226.  
  227.         if ( ! $luelinks ) {
  228.             $this->_displayWelcome("User is not logged into LL on (".$_SERVER['REMOTE_ADDR'].").");
  229.             return TRUE;
  230.         }
  231.  
  232.         $email = clean($this->input->post('email'));
  233.         $password = spergHash($this->input->post('password'));
  234.         $userkey = $this->spergauth->randomhash();
  235.         $sig = '~ ' . $username;
  236.         $ip = spergHash($_SERVER['REMOTE_ADDR']);
  237.        
  238.         $this->user->add_user($username, $email, $password, $ip, $userkey, $sig);
  239.  
  240.         $this->_displayWelcome("You have successfully registered as <b>" . $username . "</b>. You may now login.");
  241.         return TRUE;
  242.        
  243.     }
  244.    
  245.         private function _handleForgot()
  246.     {
  247.         if ($this->form_validation->run('forgot') == FALSE) {
  248.             $this->_displayWelcome("The form was filled out incorrectly:<br>");
  249.             return FALSE;
  250.         }
  251.        
  252.         $passed_username = $this->input->post('username');
  253.         $encoded_username = urlencode($passed_username);
  254.         $username = clean($passed_username);
  255.        
  256.         $user_array = $this->user->get_user_from_name($username);
  257.         if (count($user_array) == 0) {
  258.             $this->_displayWelcome("You aren't registered. Please make an account.");
  259.             return TRUE;
  260.         }
  261.        
  262.        
  263.         $luelinks = $this->spergauth->checkLuelinks($encoded_username, $username);
  264.  
  265.         if ( ! $luelinks ) {
  266.             $this->_displayWelcome("User is not logged into LL on (".$_SERVER['REMOTE_ADDR'].").");
  267.             return TRUE;
  268.         }
  269.  
  270.         $password = spergHash($this->input->post('password'));
  271.  
  272.         $this->user->update_password($username, $password);
  273.  
  274.         $this->_displayWelcome("Your password has been changed. You may now login with your new password.");
  275.         return TRUE;
  276.        
  277.     }
  278.    
  279.     private function _displayWelcome($message='') {
  280.         $article_file = file_get_contents('/var/newslinks.txt');
  281.         $articles_array = explode("\n", $article_file);
  282.        
  283.         for ($i=0;$i<count($articles_array);$i++) {
  284.             $articles[$articles_array[$i]] = $articles_array[$i+1];
  285.             $i++;
  286.         }
  287.        
  288.         // $articles = array_reverse($articles);
  289.        
  290.         $lues = array('llamas understand everything', 'linking unicorns everwhere', 'lovers upset eternity', 'loot used earwax', 'life\'s unscripted education', 'lie under engagements', 'larry understands everything', 'life\'s underrated events', 'lethal user of electricity', 'lettuce, umbrellas, and eggplants', 'lybia, uganda, egypt', 'little uber edits', 'lovers understanding everything', 'links unify everyone', 'losers user ebay', 'looking up establishments', 'lions under euthanazation', 'latest utility environment', 'lunds universitet espanol', 'lakeside underground e-zine', 'logistic utility enhancements', 'learning ugly essentials', 'lightning uses electricity', 'lakehead university extras', 'lengthy utopia of entities', 'lacking unhappiness everyday', 'logic under editorials', 'learn, understand, and evolve', 'last undead empire', 'lush urban environment', 'lonely user\'s e-mails', 'life: uninteresting and entertaining', 'live, unlike elvis', 'lambda ulcer echo', 'life, understandably erratic', 'lucky undone escort', 'live up everyday', 'lost ukrainians for emancipation', 'lost unaware editiorials', 'laguna universal empire', 'lasting under ectoplasm', 'links under earth', 'listerine undermines e-coli');
  291.        
  292.         srand ((double) microtime() * 1000000);
  293.         $randnum = rand(0,count($lues)-1);
  294.         $this->data['lue'] = $lues[$randnum];
  295.  
  296.        
  297.         $this->data['articles'] = $articles;
  298.         $this->data['message'] = $message;
  299.         $this->load->view('welcome', $this->data);     
  300.     }
  301.  
  302. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement