Recent
:: georg
3 hrs ago
:: RetroFOX
7 hrs ago
:: This post is secret Bystroushaak
9 hrs ago
:: This post is secret Bystroushaak
9 hrs ago
:: This post is secret looser
11 hrs ago
:: This post is secret looser
11 hrs ago
:: anonymous
11 hrs ago
:: anonymous
11 hrs ago
:: RIFAS
11 hrs ago
:: RIFAS
11 hrs ago
:: jbeanmoreau777
12 hrs ago
:: anonymous
13 hrs ago
:: anonymous
16 hrs ago
:: anonymous
16 hrs ago
:: anonymous
16 hrs ago
rss 2.0 feed

Make New Post
Posts: 19043

Syntax:       Wrapping:  

   #15387 Posted by ocelot 2009-07-03 14:46:55
Formated by GeSHi
  1. <?php
  2. @ini_set("memory_limit","12M");
  3.  
  4. $kreditpromote2 = '0.1';
  5.  
  6. // include the needed pages for settings
  7. include("vars.php");
  8. include("dbconnect.php");
  9. include("funcs.php");
  10. include("geoip.php");
  11.  
  12. // extract the variables (will be removed later on for better security and coding!)
  13. @extract($_GET);
  14. @extract($_SERVER);
  15. @extract($_POST);
  16.  
  17. $ip = $REMOTE_ADDR;
  18.  
  19. // check the referring url to make sure it is set
  20. $refurl = $HTTP_REFERER;
  21. if (!isset($refurl))
  22. {
  23. $refurl="NO_REF";
  24. $curapproved="NO_REF";
  25. }
  26.  
  27. $eredm = mysql_query("SELECT * FROM ptpdesign");
  28. $pagedesign=str_replace('[SITEURL]',$site_url,$pagedesign);
  29. $pagedesign=str_replace('[MEMBER_ID]',$id,$pagedesign);
  30.  
  31. $ma = date("Y-m-d");
  32.  
  33. $error=0;
  34.  
  35. $eredm = mysql_query("SELECT * FROM ptphits1 WHERE h_date='$ma' AND h_user='$id' AND h_ip='' ") or die(mysql_error());
  36.  
  37. // if row exists
  38. if (mysql_num_rows($eredm)>0)
  39. {
  40. $error = 1;
  41. }
  42.  
  43.  
  44.  
  45. if ($error == 1)
  46. {
  47. $info_message = "User <b>$id</b> has already received credit for your visit today";
  48. }
  49.  
  50.  
  51. // If no error continue to use this click
  52. if ($error == 0)
  53. {
  54. $objGeoIP = new GeoIP();
  55. // search for the $ip
  56. $objGeoIP->search_ip($ip);
  57. if ($objGeoIP->found())
  58. {
  59. $curcountry = $objGeoIP->getCountryName();
  60.  
  61. // for some reason the geo script leaves the country with whitespace at the end :S
  62. $curcountry = trim($curcountry);
  63.  
  64. $sql = 'SELECT * FROM `countries` WHERE `country` = "' . $curcountry . '"';
  65.  
  66. $eredm = mysql_query($sql);
  67.  
  68. if (mysql_num_rows($eredm)==0)
  69. {
  70. $shouldcredit = $def_credit;
  71. $tier = 0;
  72. }
  73.  
  74. else
  75. {
  76. $s = mysql_fetch_array($eredm);
  77. $tier = $s["tier"];
  78. $e = mysql_query("SELECT tcredit,tname FROM tiers WHERE tid=$tier");
  79. $shouldcredit = $s["tcredit"];
  80. }
  81. }
  82. else
  83. {
  84. $shouldcredit = $def_credit;
  85. $tier=0;
  86. }
  87.  
  88. if ($curapproved != "NO_REF")
  89. {
  90. $eredm = mysql_query("UPDATE `ptpapproved` SET `tothits` = (tothits + 1), `totcredits` = (totcredits + $shouldcredit) WHERE url='$curapproved'") or die(mysql_error());
  91. }
  92.  
  93. // choosing the site to show
  94. $eredm = mysql_query("SELECT * FROM ptpsites ORDER BY rand()") or die(mysql_error());
  95. if (mysql_num_rows($eredm)==0)
  96. {
  97. // if no site then showing the default one
  98. $showurl = $def_site;
  99. }
  100.  
  101. else
  102. {
  103. $sor = mysql_fetch_array($eredm);
  104. $showurl = $sor["url"];
  105. $showurlid = $sor["siteid"];
  106. $e = mysql_query("UPDATE ptpsites SET credits=credits-1 WHERE siteid=$sor[siteid]") or die(mysql_error());
  107. }
  108.  
  109. if (!$showurlid)
  110. {
  111. $showurlid=0;
  112. }
  113.  
  114. // crediting the user, adding the hit in the database
  115. $eredm = mysql_query("INSERT INTO ptphits1(h_date,h_user,h_ip,h_referrer,h_site) VALUES('$ma','$id','$ip','$refurl',$showurlid)") or die(mysql_error());
  116.  
  117. $eredm = mysql_query("UPDATE users SET earned=earned+$kreditpromote2,totcash=totcash+$kreditpromote2 WHERE username='$id'") or die(mysql_error());
  118.  
  119. // crediting the users upline
  120. if ($max_ref_level>0)
  121. {
  122. $eredm = mysql_query("SELECT * FROM users WHERE username='$id'") or die(mysql_error());
  123. if (mysql_num_rows($eredm)>0)
  124. {
  125. $sor = mysql_fetch_array($eredm);
  126. extract($sor);
  127. $r[1]=$referrer1;
  128. $r[2]=$referrer2;
  129. $r[3]=$referrer3;
  130. $r[4]=$referrer4;
  131. $r[5]=$referrer5;
  132. $r[6]=$referrer6;
  133. $r[7]=$referrer7;
  134. $r[8]=$referrer8;
  135. $r[9]=$referrer9;
  136. $r[10]=$referrer10;
  137. }
  138.  
  139. for ($i=1;$i<=$max_ref_level;$i++)
  140. {
  141. $ccomm=$reflevel[$i];
  142. $refuser=$r[$i];
  143.  
  144. if ((strlen($refuser)>0) and ($refuser!="_"))
  145. {
  146. $ccredit = ($shouldcredit/100)*$ccomm;
  147. $eredm = mysql_query("UPDATE users SET refpoints=refpoints+$ccredit, totpoints=totpoints+$ccredit WHERE username='$refuser'") or die(mysql_error());
  148. }
  149. }
  150. }
  151. $info_message = "<font color=black>User <b>$id</b> has been credited with <b>$kreditpromote2</b> credits for showing you this page</font>";
  152. }
  153.  
  154.  
  155. $pagedesign=str_replace('[CREDIT_MESSAGE]',$info_message,$pagedesign);
  156.  
  157. if (!$showurl)
  158. {
  159. $showurl=$def_site;
  160. }
  161.  
  162. $pagedesign=str_replace('[SITE]',$showurl,$pagedesign);
  163.  
  164.  
  165. // showing the banners
  166. $n = substr_count($pagedesign,'[BANNER');
  167. if ($n>0)
  168. {
  169. for ($i=1;$i<=$n;$i++)
  170. {
  171. $cbanner = getbanner();
  172. $cstring = '[BANNER'.$i.']';
  173. $pagedesign=str_replace($cstring,$cbanner,$pagedesign);
  174. }
  175. }
  176.  
  177. // showing all textlinks
  178. $allinks = getalllinks();
  179. $pagedesign=str_replace('[ALLTEXTLINK]',$allinks,$pagedesign);
  180.  
  181. // showing random textlinks
  182. $n = substr_count($pagedesign,'[TEXTLINK');
  183. if ($n>0)
  184. {
  185. for ($i=1;$i<=$n;$i++)
  186. {
  187. $clink = getrandomtextlink();
  188. $cstring = '[TEXTLINK'.$i.']';
  189. $pagedesign=str_replace($cstring,$clink,$pagedesign);
  190. }
  191. }
  192.  
  193. print($pagedesign);
  194. ?><br><br>
Parsed in 0.36128306 seconds
::  Inline view Inline view ::  Email this post Email  ::  Print Print   

:: Download   Download Text File15387.txt   Download Gziped text File15387.txt.gz   Download HTML File15387.html   Download PDF File15387.pdf
:: Print into    Print into HTML FileHTML document   Print into PDF FilePDF document

:: Make Diff

:: Erase Post

* Code:

To highlight particular lines, prefix each line with @@


Description:


Secret key (for later deletion)
Syntax:     


comments (0)


Copyright © 2006 Openpastebin