Jump to content
php.lv forumi

sms koda validācija


eT`

Recommended Posts

Tātad es caur esteria gribu pieslēgt SMS pakalpojumu, bet viņi pateica ka pašam jāuzkodē koda pārbaudītājs

tātad es te dabūju vienu paraugu un gribu zināt kas tur un kā tur jālabo lai kad aizsūta sms atnāk 8 ciparu kods un to ievadot viss notiek.

 

<?php

require "include/bittorrent.php";
dbconn();
stdhead();

function insertlog($uid, $text) {
$text = sqlesc($text);
$added = sqlesc(get_date_time());
$uid = sqlesc($uid);
mysql_query("INSERT INTO smslog (uid, added, txt) VALUES($uid, $added, $text)") or sqlerr(__FILE__, __LINE__);
}

function remote_file($f){ 
$cr = curl_init($f); 
curl_setopt($cr, CURLOPT_SSL_VERIFYPEER, FALSE); 
curl_setopt($cr, CURLOPT_RETURNTRANSFER, TRUE); 
$curl_ret = curl_exec($cr); curl_close($cr); 
return explode("\n",$curl_ret); 
}

$sms = isset($_POST['sms']) ? htmlspecialchars($_POST['sms']) : (isset($_GET['sms']) ? htmlspecialchars($_GET['sms']) : 'nosms');
$slr = isset($_POST['slr']) ? htmlspecialchars($_POST['slr']) : (isset($_GET['slr']) ? htmlspecialchars($_GET['slr']) : 'noslr');

if ($sms == 'nosms' || $slr == 'noslr') {
stderr("Error", "wtf?");
}

if (!$_POST["code"]){
stderr("Error","Where is your code?");

} else {

$code = mysql_escape_string($_POST["code"]);
   $user_id = mysql_escape_string($_POST['userid']);
$user_name = mysql_escape_string($_POST['username']);
$user_title = mysql_escape_string($_POST['usertitle']);

//$answer = join('', file("http://sms.solarf.lv/confirm.php?code=$code&id=4&price=slr".$slr.""));
$answer = join('', remote_file("http://sms.solarf.lv/confirm.php?code=$code&id=4&price=slr".$slr.""));
if ($answer == "key_ok" ) {
stdmsg($tracker_lang['success'], $tracker_lang['codevalid']);  

/********************************************* 0.35 begin ************************************************************/
if ($slr == '35') {
if ($sms == 'up3gb') {
$q = "UPDATE users SET uploaded = uploaded + 3221225472 WHERE id=".sqlesc($user_id)."";
$msg = sqlesc("SMS:".$tracker_lang['upincr']." [b]3GB[/b]\n"); 
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> pievienoja 3GB pie upload.");
writecomment($user_id, "SMS:Pievienoja 3GB izmantojot SMS sistēmu.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows

} elseif ($sms == 'setdonortoweek') {
$days = '7'; //uz cik dienām
$timenow = time();
$donoruntil = get_date_time($timenow + $days * 86400);
$q = "UPDATE users SET donor = 'yes', donoruntil = ".sqlesc($donoruntil)." WHERE id = ".sqlesc($user_id)."";
$msg = sqlesc("SMS:".$tracker_lang['donorsetted']." ".$days." ".$tracker_lang['todays']."\n"); 
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> iestatīja sev donora statusu uz ".sqlesc($days)." dienām.");
writecomment($user_id, "SMS:Ieestatīja sev donora statusu uz <b>".sqlesc($days)."</b> dienām.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows
} //if elseif
} //if slr 35
/********************************************* 0.35 end ************************************************************/


/********************************************* 0.60 begin ************************************************************/
if ($slr == '60') {
if ($sms == 'incrup5gb') {
$q = "UPDATE users SET uploaded = uploaded + 5368709120 WHERE id=".sqlesc($user_id)."";
$msg = sqlesc("SMS:".$tracker_lang['upincr']." [b]5GB[/b]\n");
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> pievienoja 5GB pie upload.");
writecomment($user_id, "SMS:Pievienoja 5GB izmantojot SMS sistēmu.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows

} elseif ($sms == 'decrdown3gb') {
$smsdecreasegbamount = '3221225472';
if($smsdecreasegbamount > $CURUSER['downloaded']){
$smsdecreasegb = 'SET downloaded = "0"';
}else{
$smsdecreasegb = 'SET downloaded = downloaded - 3221225472';
}
$q = "UPDATE `users` ".$smsdecreasegb." WHERE id=".sqlesc($user_id)."";
$msg = sqlesc("SMS:".$tracker_lang['downdecr']." [b]3GB[/b]\n");
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> noņēma 3GB no download.");
writecomment($user_id, "SMS:Noskaitīja 3GB no download izmantojot SMS sistēmu.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows
} //if elseif
} //if slr 60
/********************************************* 0.95 end ************************************************************/

/********************************************* 0.95 begin ************************************************************/
if ($slr == '95') {
if ($sms == 'up8gb') {
$q = "UPDATE users SET uploaded = uploaded + 8589934592 WHERE id=".sqlesc($user_id)."";
$msg = sqlesc("SMS:".$tracker_lang['upincr']." [b]8GB[/b]\n"); 
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> pievienoja 8GB pie upload.");
writecomment($user_id, "SMS:Pievienoja 8GB izmantojot SMS sistēmu.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows

}elseif ($sms == 'down5gb') {
$smsdecreasegbamount = '5368709120';
if($smsdecreasegbamount > $CURUSER['downloaded']){
$smsdecreasegb = 'SET downloaded = "0"';
}else{
$smsdecreasegb = 'SET downloaded = downloaded - 5368709120';
}
$q = "UPDATE `users` ".$smsdecreasegb." WHERE id=".sqlesc($user_id)."";
$msg = sqlesc("SMS:".$tracker_lang['downdecr']." [b]5GB[/b]\n"); 
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> noņēma 5GB no download.");
writecomment($user_id, "SMS:Noskaitīja 5GB no download izmantojot SMS sistēmu.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows

}elseif ($sms == 'remwarn') {
$q = "UPDATE users SET warned = 'no', warneduntil = '0000-00-00 00:00:00' WHERE id = ".sqlesc($user_id)."";
$msg = sqlesc("".$tracker_lang['warnremoved']."\n"); 
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> noņēma brīdinājumu.");
writecomment($user_id, "SMS:Noņēma brīdinājumu izmantojot SMS sistēmu.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows

}elseif ($sms == 'setusername') {
//$limit = (@mysql_fetch_row(@mysql_query("SELECT COUNT(*) FROM users WHERE username = ".sqlesc($user_name).""))) or sqlerr(__FILE__, __LINE__);
//if (number_format($limit[0]) > 0)
//    stderr($tracker_lang['oh noes'], "Nick already exists..") 
$q = "UPDATE users SET username = ".sqlesc($user_name)." WHERE id = ".sqlesc($user_id)."";
$msg = sqlesc("".$tracker_lang['newusername']." [b]".$user_name."[/b]\n"); 
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> nomainīja savu lietotājvārdu uz ".sqlesc($user_name).".");
writecomment($user_id,"SMS:Nomainīja savu lietotājvārdu uz: ".sqlesc($user_name).".");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows

}elseif ($sms == 'settitle') {
$q = "UPDATE users SET title = ".sqlesc($user_title)." WHERE id = ".sqlesc($user_id)."";
$msg = sqlesc("".$tracker_lang['newtitle']." [b]".sqlesc($user_title)."[/b]\n"); 
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> nomainīja savu iesauku uz ".sqlesc($user_title).".");
writecomment($user_id, "SMS:Nomainīja savu iesauku uz: ".sqlesc($user_title).".");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows

} elseif ($sms == 'setdonortomonth') {
$days = '31'; //uz cik dienām
$timenow = time();
$donoruntil = get_date_time($timenow + $days * 86400);
$q = "UPDATE users SET donor = 'yes', donoruntil = ".sqlesc($donoruntil)." WHERE id = ".sqlesc($user_id)."";
$msg = sqlesc("SMS:".$tracker_lang['donorsetted']." ".$days." ".$tracker_lang['todays']."\n"); 
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> uzlika donora statusu uz ".sqlesc($days)." dienām..");
writecomment($user_id, "SMS:Ieestatīja sev donora statusu uz ".sqlesc($days)." dienām.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows

} elseif ($sms == 'setviptoweek') {
$days = '7'; //uz cik dienām
$timenow = time();
$donoruntil = get_date_time($timenow + $days * 86400);
$q = "UPDATE users SET class = '3', vipuntil = ".sqlesc($donoruntil)." WHERE id = ".sqlesc($user_id)."";
$msg = sqlesc("vip to week\n"); 
$msg = sqlesc("SMS:".$tracker_lang['vipsetted']." ".$days." ".$tracker_lang['todays']."\n"); 
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> uzlika VIP statusu uz ".sqlesc($days)." dienām..");
writecomment($user_id, "SMS:Ieestatīja sev VIP statusu uz ".sqlesc($days)." dienām.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows

} //if elseif
} //if slr95
/********************************************* 0.95 end ************************************************************/

/********************************************* 150 begin ************************************************************/
if ($slr == '150') {
if ($sms == 'incrup14gb') {
$q = "UPDATE users SET uploaded = uploaded + 15032385536 WHERE id=".sqlesc($user_id)."";
$msg = sqlesc("SMS:".$tracker_lang['upincr']." [b]14GB[/b]\n"); 
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> pievienoja 14GB pie upload.");
writecomment($user_id, "SMS:Pievienoja 14GB izmantojot SMS sistēmu.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows

}elseif ($sms == 'decrdown8gb') {
$smsdecreasegbamount = '8589934592';
if($smsdecreasegbamount > $CURUSER['downloaded']){
$smsdecreasegb = 'SET downloaded = "0"';
}else{
$smsdecreasegb = 'SET downloaded = downloaded - 8589934592';
}
$q = "UPDATE `users` ".$smsdecreasegb." WHERE id=".sqlesc($user_id)."";
$msg = sqlesc("SMS:".$tracker_lang['downdecr']." [b]8GB[/b]\n"); 
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> noņēma 8GB no download.");
writecomment($user_id, "SMS:Noskaitīja 8GB no download izmantojot SMS sistēmu.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows

} elseif ($sms == 'setviptomonth') {
$days = '31'; //uz cik dienām
$timenow = time();
$donoruntil = get_date_time($timenow + $days * 86400);
$q = "UPDATE users SET class = '3', vipuntil = ".sqlesc($donoruntil)." WHERE id = ".sqlesc($user_id)."";
$msg = sqlesc("SMS:".$tracker_lang['vipsetted']." ".$days." ".$tracker_lang['todays']."\n");
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> uzlika VIP statusu uz ".sqlesc($days)." dienām..");
writecomment($user_id, "SMS:Ieestatīja sev VIP statusu uz ".sqlesc($days)." dienām.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows
} //if elseif
} //if slr 150
/********************************************* 150 end ************************************************************/

/********************************************* 200 begin ************************************************************/
if ($slr == '200') {
if ($sms == 'incrup19gb') {
$q = "UPDATE users SET uploaded = uploaded + 20401094656 WHERE id=".sqlesc($user_id)."";
$msg = sqlesc("SMS:".$tracker_lang['upincr']." [b]19GB[/b]\n"); 
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> pievienoja 19GB pie upload.");
writecomment($user_id, "SMS:Pievienoja 19GB izmantojot SMS sistēmu.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows

}elseif ($sms == 'decrdown12gb') {
$smsdecreasegbamount = '12884901888';
if($smsdecreasegbamount > $CURUSER['downloaded']){
$smsdecreasegb = 'SET downloaded = "0"';
}else{
$smsdecreasegb = 'SET downloaded = downloaded - 12884901888';
}
$q = "UPDATE `users` ".$smsdecreasegb." WHERE id=".sqlesc($user_id)."";
$msg = sqlesc("SMS:".$tracker_lang['downdecr']." [b]12GB[/b]\n");  
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> noņēma 12GB no download.");
writecomment($user_id, "SMS:Noskaitīja 12GB no download izmantojot SMS sistēmu.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows

} elseif ($sms == 'setdonortoyear') {
$days = '365'; //uz cik dienām
$timenow = time();
$donoruntil = get_date_time($timenow + $days * 86400);
$q = "UPDATE users SET donor = 'yes', donoruntil = ".sqlesc($donoruntil)." WHERE id = ".sqlesc($user_id)."";
$msg = sqlesc("SMS:".$tracker_lang['donorsetted']." ".$days." ".$tracker_lang['todays']."\n");
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> uzlika donora statusu uz ".sqlesc($days)." dienām..");
writecomment($user_id, "SMS:Ieestatīja sev donora statusu uz ".sqlesc($days)." dienām.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows

} elseif ($sms == 'setvipto3months') {
$days = '93'; //uz cik dienām
$timenow = time();
$donoruntil = get_date_time($timenow + $days * 86400);
$q = "UPDATE users SET class = '3', vipuntil = ".sqlesc($donoruntil)." WHERE id = ".sqlesc($user_id)."";
$msg = sqlesc("SMS:".$tracker_lang['vipsetted']." ".$days." ".$tracker_lang['todays']."\n");
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> uzlika VIP statusu uz ".sqlesc($days)." dienām..");
writecomment($user_id, "SMS:Ieestatīja sev VIP statusu uz ".sqlesc($days)." dienām.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows
} //if elseif
} //if slr 200
/********************************************* 200 end ************************************************************/

/********************************************* 250 begin ************************************************************/
if ($slr == '250') {
if ($sms == 'incrup24gb') {
$q = "UPDATE users SET uploaded = uploaded + 25769803776 WHERE id=".sqlesc($user_id)."";
$msg = sqlesc("SMS:".$tracker_lang['upincr']." [b]24GB[/b]\n");  
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> pievienoja 24GB pie upload.");
writecomment($user_id, "SMS:Pievienoja 24GB izmantojot SMS sistēmu.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows

}elseif ($sms == 'decrdown15gb') {
$smsdecreasegbamount = '16106127360';
if($smsdecreasegbamount > $CURUSER['downloaded']){
$smsdecreasegb = 'SET downloaded = "0"';
}else{
$smsdecreasegb = 'SET downloaded = downloaded - 16106127360';
}
$q = "UPDATE `users` ".$smsdecreasegb." WHERE id=".sqlesc($user_id)."";
$msg = sqlesc("SMS:".$tracker_lang['downdecr']." [b]15GB[/b]\n");  
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> noņēma 15Gb no download.");
writecomment($user_id, "SMS:Noskaitīja 15GB no download izmantojot SMS sistēmu.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows
} //if elseif
} //if slr 250
/********************************************* 250 end ************************************************************/

/********************************************* 300 begin ************************************************************/
if ($slr == '300') {
if ($sms == 'incrup30gb') {
$q = "UPDATE users SET uploaded = uploaded + 32212254720 WHERE id=".sqlesc($user_id)."";
$msg = sqlesc("SMS:".$tracker_lang['upincr']." [b]30GB[/b]\n");  
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> pievienoja 30GB pie upload.");
writecomment($user_id, "SMS:Pievienoja 30GB izmantojot SMS sistēmu.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows

}elseif ($sms == 'decrdown20gb') {
$smsdecreasegbamount = '21474836480';
if($smsdecreasegbamount > $CURUSER['downloaded']){
$smsdecreasegb = 'SET downloaded = "0"';
}else{
$smsdecreasegb = 'SET downloaded = downloaded - 21474836480';
}
$q = "UPDATE `users` ".$smsdecreasegb." WHERE id=".sqlesc($user_id)."";
$msg = sqlesc("SMS:".$tracker_lang['downdecr']." [b]20GB[/b]\n");   
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> noņēma 20Gb no download.");
writecomment($user_id, "SMS:Noskaitīja 20GB no download izmantojot SMS sistēmu.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows

} elseif ($sms == 'setdonor0') {
$days = '730'; //uz cik dienām
$timenow = time();
$donoruntil = get_date_time($timenow + $days * 86400);
$q = "UPDATE users SET donor = 'yes', donoruntil = ".sqlesc($donoruntil).", donorsms = donorsms + 1 WHERE id = ".sqlesc($user_id)."";
$msg = sqlesc("SMS:".$tracker_lang['donorsetted']." ".sqlesc($days)." ".$tracker_lang['todays']."\n"); 
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> uzlika donora statusu uz ".sqlesc($days)." dienām.");
writecomment($user_id, "SMS:Ieestatīja sev donora statusu uz ".sqlesc($days)." dienām.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows

} elseif ($sms == 'setdonor1') {
$q = "UPDATE users SET donor = 'yes', donoruntil = '0000-00-00 00:00:00', donorsms = donorsms + 1 WHERE id = ".sqlesc($user_id)."";
$msg = sqlesc("SMS:".$tracker_lang['donorsetted']." ".$tracker_lang['donorsettetinf']."\n"); 
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> uzlika donora statusu uz neierobežotu laiku.");
writecomment($user_id, "SMS:Ieestatīja sev donora statusu uz neierobežotu laiku.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows

} elseif ($sms == 'setviptohalfyear') {
$days = '183'; //uz cik dienām
$timenow = time();
$donoruntil = get_date_time($timenow + $days * 86400);
$q = "UPDATE users SET class = '3', vipuntil = ".sqlesc($donoruntil)." WHERE id = ".sqlesc($user_id)."";
$msg = sqlesc("SMS:".$tracker_lang['vipsetted']." ".$days." ".$tracker_lang['todays']."\n");
$dt = sqlesc(get_date_time());
$result = mysql_query($q);
if (mysql_affected_rows()>=1) {
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $user_id, $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
insertlog($user_id, "<a href=\"/userdetails.php?id=".$user_id."\">".$CURUSER['username']."</a> uzlika VIP statusu uz ".sqlesc($days)." dienām..");
writecomment($user_id, "SMS:Ieestatīja sev VIP statusu uz ".sqlesc($days)." dienām.");
echo "<script language='JavaScript'>window.location='/sms.php';</script>";
} else {
stdmsg($tracker_lang['oh noes'], $tracker_lang['fcknerror']);
} //if mysql affected rows
} //if elseif
} //if slr 300
/********************************************* 300 end ************************************************************/



} //if key ok
if ($answer=="key_bad") {
stderr($tracker_lang['error'], $tracker_lang['invalidcode']);
} 
} //if post code

stdfoot();
?>

 

šis it kā ir uz solarf.lv bet nu šo jau var pārveidot tā ka iet uz tā esteria.?

pēc šīs rindiņas

$answer = join('', remote_file("http://sms.solarf.lv/confirm.php?code=$code&id=4&price=slr".$slr.""));

 

saprotu, ka viņiem jābūt kkādam failam, kas droši vien ir tas kas atbild par koda izsūtīšanu un šis paraugs ir tas kas pārbauda vai kods ir derīgs.

 

datubāzē jau man ir tabula 'smslog' bet nezinu tagad kas jādara tālāk.

 

Ja kāds var palīdzēt būtu tiešām jauki jo esmu mazliet iestrēdzis :/

 

Paldies.

Link to comment
Share on other sites

Dirsā to paraugu, uztaisi pats.

Uztaisi tabulu Codes ar trīs laukiem - GUID (Unikāls vērtības identifikators), Value (Šī identifikatora vērtība) un Date (datums un laiks, kad tika pievienots šis ieraksts (būs nepieciešams dzēšanai, lai datu bāzē neglabājas kaut kādi mēsli))

Tālāk. Uzģenerē šo astoņus ciparus garo skaitli un ieglabā mainīgajā.

Tālāk. Uzģenerē šīs tikko uzģenerētās vērtības (astoņus ciparus garā skaitļa) unikālo identifikatoru, teiksim 32 divus simbolus garu ciparu, skaitļu un simbolu virkni (Ja tas jau iepriekš netika uzģenerēts).

Tagad tev ir zināma gan koda vērtība, gan koda identifikators, šīs abas vērtības saglabā tabulā (date lauciņā saglabā tekošai datumu un laiku).

Tālāk. Tagad uzģenerē bildīti, kura attēlo tikko uzģenerēto kodu (teiksim, ar PHP GD bibliotēkas palīdzību).

Viss. Šo tikko uzģenerēto bildīti ieliksi formā, kurā lietotājam tā būs jāpārraksta ar roku input laukā.

Tajā pašā formā input laukā (hidden) saglabāsi to GUID vērtību.

Kad formas dati tiek iepostoti, tev būs zināmi gan lietotāja ievadītā koda vērtība, gan GUIDS. Tātad atliek atselektēt no datubāzes kodu pēc guida un paskatīties vai tas sakrīt ar lietotāja ievadīto kodu. Ja sakrīt, kods ievadīts pareizs, ja nē, tad nepareizs. Ja sakrīt, izdzēs to ierakstu no tabulas. Un pašās beigās izdzēs arī visus ierakstus, kas ir vecāki par teiksim 20 minūtēm (kā to izdarīt ar vienkāršu kveriju, var izlasīt šeit: http://php.lv/f/index.php?showtopic=11563&hl=)

Edited by Zandis Murāns
Link to comment
Share on other sites

×
×
  • Create New...