daily pastebin goal
67%
SHARE
TWEET

Untitled

a guest Jun 4th, 2017 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?
  2. // sausagecash.com
  3. // class.php
  4.  
  5. define('FATAL', E_USER_ERROR);
  6. define('ERROR', E_USER_WARNING);
  7. define('WARNING', E_USER_NOTICE);
  8. $errors = new errors(1);
  9.  
  10. class User {
  11.     function check_login($username,$password) {
  12.         if(mysql_num_rows(mysql_query("SELECT username,password FROM users WHERE username='".mysql_real_escape_string($username)."' AND password='".mysql_real_escape_string($password)."'"))>0) {
  13.             return true;
  14.         } else {
  15.             trigger_error("Login Error. Could not validate username and/or password", ERROR);
  16.             return false;
  17.         }
  18.     }
  19.    
  20.     function checkUsername($username) {
  21.         if(mysql_num_rows(mysql_query("SELECT username FROM users WHERE username='".mysql_real_escape_string($username)."'"))>0) {
  22.             return "<img src='/unavailable.jpg'>";
  23.         } else { return "<img src='/available.gif'>"; }
  24.     }
  25.    
  26.     function getValue($username,$item) {
  27.         if($result=mysql_query("SELECT ".$item." FROM users WHERE username='".$username."'")) {
  28.             $x=mysql_fetch_row($result); return $x[0];
  29.             } else {
  30.                 trigger_error("Error grabbing member column value", WARNING);
  31.                 return false;
  32.             }
  33.     }
  34.    
  35.     function reset_pw($email) {
  36.         if(mysql_num_rows(mysql_query("SELECT email FROM users WHERE email='".mysql_real_escape_string($email)."'"))>0) {
  37.             $characters = "abcdefghijklmnopqrstuvwxyz1234567890";
  38.             $newpw="";
  39.             for($i=0;$i<=rand(8,12);$i++) {
  40.                 shuffle($characters); $newpw .= $characters[0];
  41.             }
  42.             if(mysql_query("UPDATE users SET password='".$newpw."' WHERE email='".mysql_real_escape_string($email)."'")) { return true; } else { trigger_error("Error updating password", ERROR); }
  43.         } else { trigger_error("Error finding email address", ERROR); return false; }
  44.     }
  45.    
  46.     function create_user($username,$password,$email,$realname,$taxid,$phone,$nickname,$paytype,$payinfo) {
  47.         if(mysql_query("INSERT INTO users (username,password,email,realname,taxid,phone,nickname,paytype,payinfo) VALUES ('".$username."','".$password."','".$email."','".$realname."','".$taxid."','".$phone."','".$nickname."','".$paytype."','".$payinfo."')")) { return true; } else { trigger_error("Error adding user to database", WARNING); }
  48.     }
  49.    
  50.     function delete_user($user_id) {
  51.         if(mysql_query("DELETE FROM users WHERE id='".$user_id."'")) { return true; } else { trigger_error("Error deleting user from database", WARNING); return false; }
  52.     }
  53.    
  54.     function modify_user($username,$password,$email,$realname,$taxid,$phone,$nickname,$paytype,$payinfo) {
  55.         if(mysql_query("UPDATE users SET password='".mysql_real_escape_string($password)."', email='".mysql_real_escape_string($email)."', realname='".mysql_real_escape_string($realname)."', taxid='".mysql_real_escape_string($taxid)."', phone='".mysql_real_escape_string($phone)."', nickname='".mysql_real_escape_string($nickname)."', paytype='".mysql_real_escape_string($paytype)."', payinfo='".mysql_real_escape_string($payinfo)."' WHERE username='".$username."'")) { return true; } else { trigger_error("Error modifying user", WARNING); }
  56.     }
  57. }
  58.  
  59. class News {
  60.     function create_story($title,$story) {
  61.         if(mysql_query("INSERT INTO news (title,article) VALUES ('".$title."','".$story."')")) { return true; } else { trigger_error("Error adding news story", ERROR); return false; }
  62.     }
  63.     function displayArticles($howmany) {
  64.         if($result=mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT ".$howmany)) {
  65.             while($x=mysql_fetch_array($result)) {
  66.                 echo "<p class='news'><b>".$x["title"]."</b><Br>".$x["article"]."</p>";
  67.             }
  68.         } else {
  69.             trigger_error("Error reading news items from database", ERROR);
  70.             return false;
  71.         }
  72.     }
  73.  
  74. }
  75.  
  76. class Leads {
  77.     function click($user_id,$ip,$type) {
  78.         switch($type) {
  79.             case CLICK:
  80.                 if(!mysql_num_rows(mysql_query("SELECT * FROM leads WHERE ipaddr='".$ip."'"))>0) {
  81.                     if(mysql_query("INSERT INTO leads (username,month,day,year,ipaddr,type) VALUES ('".$user_id."',".date("n").",".date("j").",".date("Y").",'".$ip."','CLICK')")) { return true; } else { trigger_error("Error inserting click into database", WARNING); }
  82.                 } else { return true; }
  83.             exit;
  84.             case LEAD:
  85.                 if(mysql_query("UPDATE leads SET type='LEAD' WHERE ipaddr='".$ip."' AND username='".$user_id."' LIMIT 1")) { return true; } else { trigger_error("Error updating click to lead", WARNING); }
  86.             exit;
  87.         }
  88.     }
  89.    
  90.     function divide ($numerator, $denominator) {
  91.         if ($numerator == 0 || $denominator==0)
  92.         return (round(0,4)*100);
  93.         else
  94.         return (round(($numerator/$denominator)));
  95.         }
  96.    
  97.     function displayMonth($user_id,$month,$year) {
  98.         if($result=mysql_query("SELECT day FROM leads WHERE username='".$user_id."' AND month='".$month."' AND year='".$year."' ORDER BY day DESC LIMIT 1")) {
  99.             echo "<table><tr><td class='header'>Date</td><td class='header'>Uniques</td><td class='header'>Sales</td><td class=header>Ratio</td><td class=header>Payout</td></tr>";
  100.             $x=mysql_fetch_row($result);
  101.             if($month==date("n") && $year==date("Y")) { $theend=date("j"); } else { $theend=$x[0]; }
  102.             $totalratio1=0;
  103.             $totalratio2=0;
  104.             for($i=1;$i<=$theend;$i++) {
  105.                 $leadcount = mysql_num_rows(mysql_query("SELECT * FROM leads WHERE username='".$user_id."' AND month='".$month."' AND year='".$year."' AND day='".$i."' AND type='LEAD'"));
  106.                 $clickcount = mysql_num_rows(mysql_query("SELECT * FROM leads WHERE username='".$user_id."' AND month='".$month."' AND year='".$year."' AND day='".$i."'"));
  107.                 echo "<tr><td>".$month."/".$i."/".$year."</td><td>".$clickcount."</td><td>".$leadcount."</td><td>";
  108.                     if($this->divide($clickcount,$leadcount)>1) { echo "1:".$this->divide($clickcount,$leadcount); } else { echo "0:".$this->divide($clickcount,$leadcount); }
  109.                     $totalratio1+=$leadcount; $totalratio2+=$clickcount;
  110.                 echo "</td><td>$".(20*$leadcount)."</td></tr>";
  111.             }
  112.             echo "<tr><td align=left><b>Total</b></td><td>".$totalratio2."</td><td>".$totalratio1."</td><td>";
  113.             if($this->divide($totalratio2,$totalratio1)>1) { echo "1:".$this->divide($totalratio2,$totalratio1); } else { echo "0:".$this->divide($totalratio2,$totalratio1); }
  114.             echo "</td><td>$".(20*mysql_num_rows(mysql_query("SELECT * FROM leads WHERE username='".$user_id."' AND month='".$month."' AND year='".$year."' AND type='LEAD'")))."</td></tr></table>";
  115.         } else { trigger_error("Error fetching tracking information from database", WARNING); return false; }
  116.     }
  117.    
  118.     function RevenueToday($user_id) {
  119.         return (20*mysql_num_rows(mysql_query("SELECT * FROM leads WHERE username='".$user_id."' AND month='".date("n")."' AND year='".date("Y")."' AND day='".date("j")."' AND type='LEAD'")));
  120.     }
  121. }
  122.  
  123. class Payouts {
  124.     function displayList($username) {
  125.         $result=mysql_query("SELECT * FROM payouts WHERE username='".$username."'");
  126.         echo "<table><tr><td class='header'>Period</td><td class='header'>Amount</td><td class='header'>Status</td></tr>";
  127.         while($x=mysql_fetch_array($result)) {
  128.             echo "<tr><td>".$x["period"]."</td><td>".$x["amount"]."</td><td>".$x["status"]."</td></tr>";
  129.         }
  130.         echo "</table>";
  131.     }
  132. }
  133.  
  134. class errors {
  135.     var $debug_level = 0;
  136.     function errors($debug_level = 0)
  137.     {
  138.         $this->debug_level = $debug_level;
  139.         set_error_handler(array($this, 'handle_error'));
  140.     }
  141.     function handle_error($type, $string, $file, $line, $vars)
  142.     {
  143.         switch ($type)
  144.         {
  145.             case FATAL:
  146.             switch ($this->debug_level)
  147.             {
  148.                 default:
  149.                 case 0:
  150.                     echo 'Error: '.$string.' in '.$file.' on line'. $line.'<br />';
  151.                     print_r($var);
  152.                     exit;
  153.                 case 1:
  154.                     echo 'There has been an error. Sorry for the inconvenience.';
  155.                     exit;
  156.             }
  157.             case ERROR:
  158.             echo '<pre><b>ERROR</b> ['.$type.'] '.$string.'<br />'."</pre>\n";
  159.             break;
  160.             case WARNING:
  161.             echo '<pre><b>WARNING</b> ['.$type.'] '.$string.'<br />'."</pre>\n";
  162.             break;
  163.         }
  164.     }
  165. }
  166.  
  167. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top