Advertisement
Guest User

Untitled

a guest
May 9th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.27 KB | None | 0 0
  1. <?
  2. class func{
  3.     var $host = "localhost";
  4.     var $user = "user";
  5.     var $pass = "pass";
  6.    
  7.     function login($username,$password){
  8.         $con = mysql_connect($this->host,$this->user,$this->pass) OR die("ERROR - QUERY");
  9.         mysql_select_db("fame_zap",$con) OR die("ERROR - DATABASE");
  10.        
  11.         $username = htmlentities($username);
  12.         $username = mysql_real_escape_string($username);
  13.         $query = "select username,password,salt from users where username='$username'";
  14.  
  15.         $r = mysql_query($query) OR die("ERROR - QUERY");
  16.         $user = mysql_result($r,0,"username");
  17.         $pass = mysql_result($r,0,"password");
  18.         $salt = mysql_result($r,0,"salt");
  19.  
  20.         $password = md5($salt.$password.$salt);
  21.  
  22.         if($pass == $password){
  23.             return 1;
  24.         }else{
  25.             return 0;
  26.         }
  27.     }
  28.    
  29.     function userid($username){
  30.         $con = mysql_connect($this->host,$this->user,$this->pass) OR die("ERROR - QUERY");
  31.         mysql_select_db("fame_zap",$con) OR die("ERROR - DATABASE");
  32.        
  33.         $username = htmlentities($username);
  34.         $username = mysql_real_escape_string($username);
  35.         $query = "select id from users where username='$username'";
  36.  
  37.         $r = mysql_query($query) OR die("ERROR - QUERY");
  38.         $uid = mysql_result($r,0);
  39.  
  40.         return $uid;
  41.     }
  42.    
  43.     function username($userid){
  44.         $query = "select username from users where id='$userid'";
  45.  
  46.         $con = mysql_connect($this->host,$this->user,$this->pass) OR die("ERROR - QUERY");
  47.         mysql_select_db("fame_zap",$con) OR die("ERROR - DATABASE");
  48.  
  49.         $r = mysql_query($query) OR die("ERROR - QUERY");
  50.         $uname = mysql_result($r,0);
  51.  
  52.         return $uname;
  53.     }
  54.    
  55.     function userg($gid){
  56.         $query = "select color,title,avatar from usergroups where id='$gid'";
  57.  
  58.         $con = mysql_connect($this->host,$this->user,$this->pass) OR die("ERROR - QUERY");
  59.         mysql_select_db("fame_zap",$con) OR die("ERROR - DATABASE");
  60.  
  61.         $r = mysql_query($query) OR die("ERROR - QUERY");
  62.         $color = mysql_result($r,0,"color");
  63.         $title = mysql_result($r,0,"title");
  64.         $avatar = mysql_result($r,0,"avatar");
  65.  
  66.         return $color.">>".$title;
  67.     }
  68.    
  69.     function gid($userid){
  70.         $query = "select usergroupid from users where id='$userid'";
  71.  
  72.         $con = mysql_connect($this->host,$this->user,$this->pass) OR die("ERROR - QUERY");
  73.         mysql_select_db("fame_zap",$con) OR die("ERROR - DATABASE");
  74.  
  75.         $r = mysql_query($query) OR die("ERROR - QUERY");
  76.         $gid = mysql_result($r,0);
  77.        
  78.         $gid = $this->userg($gid);
  79.  
  80.         return $gid;
  81.     }
  82.    
  83.     function date($date){
  84.         $mon = substr($date, -8, -6);
  85.         $mon = str_replace("0","",$mon);
  86.         $day = substr($date, -6, -4);
  87.         $day = str_replace("0","",$day);
  88.         $eday = substr($date, -5, -4);
  89.         $yea = substr($date, -4);
  90.        
  91.         switch($mon){
  92.             case "1":
  93.                 $month = "January";
  94.             break;
  95.            
  96.             case "2":
  97.                 $month = "Febuary";
  98.             break;
  99.            
  100.             case "3":
  101.                 $month = "March";
  102.             break;
  103.            
  104.             case "4":
  105.                 $month = "April";
  106.             break;
  107.            
  108.             case "5":
  109.                 $month = "May";
  110.             break;
  111.            
  112.             case "6":
  113.                 $month = "June";
  114.             break;
  115.            
  116.             case "7":
  117.                 $month = "July";
  118.             break;
  119.            
  120.             case "8":
  121.                 $month = "August";
  122.             break;
  123.            
  124.             case "9":
  125.                 $month = "September";
  126.             break;
  127.            
  128.             case "10":
  129.                 $month = "October";
  130.             break;
  131.            
  132.             case "11":
  133.                 $month = "November";
  134.             break;
  135.            
  136.             case "12":
  137.                 $month = "December";
  138.             break;
  139.         }
  140.        
  141.         switch($eday){
  142.             case "0":
  143.                 $end = "th";
  144.             break;
  145.            
  146.             case "1":
  147.                 $end = "st";
  148.             break;
  149.            
  150.             case "2":
  151.                 $end = "nd";
  152.             break;
  153.            
  154.             case "3":
  155.                 $end = "rd";
  156.             break;
  157.            
  158.             case "4":
  159.                 $end = "th";
  160.             break;
  161.            
  162.             case "5":
  163.                 $end = "th";
  164.             break;
  165.            
  166.             case "6":
  167.                 $end = "th";
  168.             break;
  169.            
  170.             case "7":
  171.                 $end = "th";
  172.             break;
  173.            
  174.             case "8":
  175.                 $end = "th";
  176.             break;
  177.            
  178.             case "9":
  179.                 $end = "th";
  180.             break;
  181.         }
  182.        
  183.         return $month." ".$day.$end.", ".$yea;
  184.     }
  185.    
  186.     function time($time){
  187.         $hou = substr($time, -4, -2);
  188.         $hou = str_replace("0","",$hou);
  189.         $min = substr($time, -2);
  190.         $pam = "am";
  191.        
  192.         if($hou > 12){
  193.             $hou = $hou - 12;
  194.             $pam = "pm";
  195.         }
  196.        
  197.         return $hou.":".$min." ".$pam;
  198.     }
  199.    
  200.     function editpost($postid,$userid,$content){
  201.         $con = mysql_connect($this->host,$this->user,$this->pass) OR die("ERROR - QUERY");
  202.         mysql_select_db("fame_zap",$con) OR die("ERROR - DATABASE");
  203.        
  204.         $date = date("mdY");
  205.         $con = mysql_real_escape_string($content);
  206.         $query = "update news set content = '$con' edit = '1',edit_user = '$userid',edit_date = '$date' WHERE id = '$postid' LIMIT 1";
  207.  
  208.         $r = mysql_query($query) OR die("ERROR - QUERY");
  209.        
  210.         if(!$r){
  211.             return 0;
  212.         }else{
  213.             return 1;
  214.         }
  215.     }
  216.    
  217.     function subpost($userid,$content){
  218.         $con = mysql_connect($this->host,$this->user,$this->pass) OR die("ERROR - QUERY");
  219.         mysql_select_db("fame_zap",$con) OR die("ERROR - DATABASE");
  220.        
  221.         $date = date("mdY");
  222.         $time = strftime("%H%M");
  223.         $con = mysql_real_escape_string($content);
  224.         $query = "insert news set userid = '$userid',date = '$date',time = '$time',content = '$con'";
  225.  
  226.         $r = mysql_query($query) OR die("ERROR - QUERY");
  227.        
  228.         if(!$r){
  229.             return 0;
  230.         }else{
  231.             return 1;
  232.         }
  233.     }
  234.    
  235.     function post_exist($id){
  236.         $query = "select * from news where id='$id'";
  237.  
  238.         $con = mysql_connect($this->host,$this->user,$this->pass) OR die("ERROR - QUERY");
  239.         mysql_select_db("fame_zap",$con) OR die("ERROR - DATABASE");
  240.  
  241.         $r = mysql_query($query) OR die("ERROR - QUERY");
  242.         $ck = mysql_num_rows($r);
  243.        
  244.         if($ck == 0){
  245.             return 0;
  246.         }else{
  247.             return 1;
  248.         }
  249.     }
  250.    
  251.     function pullcontent($postid){
  252.         $query = "select userid,time,date,content from news where id='$postid'";
  253.  
  254.         $con = mysql_connect($this->host,$this->user,$this->pass) OR die("ERROR - QUERY");
  255.         mysql_select_db("fame_zap",$con) OR die("ERROR - DATABASE");
  256.  
  257.         $r = mysql_query($query) OR die("ERROR - QUERY");
  258.         $content = mysql_result($r,0,"content");
  259.         $user = mysql_result($r,0,"userid");
  260.         $date = mysql_result($r,0,"date");
  261.         $time = mysql_result($r,0,"time");
  262.        
  263.         $uname = $this->username($user);
  264.         $uname = htmlentities($uname);
  265.         $date = $this->date($date);
  266.         $time = $this->time($time);
  267.        
  268.         return $uname.">>".$date.">>".$time.">>".$content;
  269.     }
  270.    
  271.     function findedit($postid){
  272.         $query = "select edit from news where id='$postid'";
  273.  
  274.         $con = mysql_connect($this->host,$this->user,$this->pass) OR die("ERROR - QUERY");
  275.         mysql_select_db("fame_zap",$con) OR die("ERROR - DATABASE");
  276.  
  277.         $r = mysql_query($query) OR die("ERROR - QUERY");
  278.         $edit = mysql_result($r,0);
  279.  
  280.         if($edit == "1"){
  281.             return 1;
  282.         }else{
  283.             return 0;
  284.         }
  285.     }
  286.    
  287.     function pulleditu($postid){
  288.         $query = "select edit_user,edit_date from news where id='$postid'";
  289.  
  290.         $con = mysql_connect($this->host,$this->user,$this->pass) OR die("ERROR - QUERY");
  291.         mysql_select_db("fame_zap",$con) OR die("ERROR - DATABASE");
  292.  
  293.         $r = mysql_query($query) OR die("ERROR - QUERY");
  294.         $edit_u = mysql_result($r,0,"edit_user");
  295.         $edit_d = mysql_result($r,0,"edit_date");
  296.        
  297.         $uname = $this->username($edit_u);
  298.         $uname = htmlentities($uname);
  299.         $date = $this->date($edit_d);
  300.        
  301.         return "Post Edited on $date by $uname";
  302.     }
  303.    
  304.     function pulleditd($postid){
  305.         $query = "select edit_date from news where id='$postid'";
  306.  
  307.         $con = mysql_connect($this->host,$this->user,$this->pass) OR die("ERROR - QUERY");
  308.         mysql_select_db("fame_zap",$con) OR die("ERROR - DATABASE");
  309.  
  310.         $r = mysql_query($query) OR die("ERROR - QUERY");
  311.         $edit_d = mysql_result($r,0);
  312.        
  313.         return $edit_d;
  314.     }
  315. }
  316.  
  317. $funcl = new func;
  318. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement