Jump to content
php.lv forumi

Unlock sms kods


Ernijs_E

Recommended Posts

Sveiki :)

Gribēju savā projektā - glabatuve.net , ielikt sms unlock pakalpojumu, ko sniedz techpoint.lv provadieris. Bet saskāros ar kļūdu:

Notice: Undefined index: code in /home/a2806417/public_html/sms/index.php on line 24
Notice: Undefined index: code in /home/a2806417/public_html/sms/index.php on line 27

 

Config.php kods:

<?

// ieliekam user_id no techpoint.lv statistikas
$ntp_user_id = '380';


// cenu klasts automatiskai parbaudei, lai noteiktu koda vertibu, neiesakam mainīt.
$prices = array ('15','25','35','50','60','75','95','150','200','250','300');


?>

 

index.php fails:

<?
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
include('config.php');


// šī funkcija nav obligāta, bet iesakam to lietot, ar šo funkciju var filtrēt visus GET / POST mainīgos, lai nepieļautu injekcijas
function iDfilter($id) {
$output = mysql_escape_string(str_replace('\'','',str_replace('"','',str_replace('`','',str_replace(';','',$id)))));
return $output;
}


function check_result($code) {
global $prices;
foreach($prices as $i => $key){
	$answer = @file_get_contents("http://sms.techpoint.lv/confirm.php?code=$code&id=$ntp_user_id&price=$key", FALSE, NULL, 0, 140);
	if ($answer == 'key_ok') {
		return $key;
	}
}
}

$code = iDfilter($_POST['code']);
if(isset($code)) {

$key = check_result($_POST['code']);
if(isset($key)) {
	// $key ir koda vertība, piemeram, NTP300 vai NTP250, tas vajadzīgs lai mēs zinātu cik liela vērtība ir kodam
	// talāk varam izpildīt jebkuru darbību jo kods ir pareizs
	// UZMANĪBU! pārbaudot šadu kodu Jūs to arī aktivizējat, tapēc nepielaižat kļudu, citadāk klients zaudē kodu un neiegūst pakalpojumu
	echo 'Kods ir pareizs! Links te!<br />';
	echo 'Koda cena: '.$key;
} else {
	echo 'Ievadītais kods ir nepareizs!';
}

}


?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title>sample script</title>
<meta http-equiv="expires" content="0" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="Resource-type" content="document" />
<meta name="Robots" content="INDEX,FOLLOW" />
<meta name="keywords" content="netpoint, netpoint technologies, web design, web development, studio, IT, mobile, SMS, solutions, internet, hosting, web hosting, game hosting, colocation, server, server rent, data center, sms provider, internet provider, network, information technologies, web-design, design" />
<meta name="author" content="A. Terehovichs, sia netpoint technologies" />
<meta name="owner"  content="sia netpoint technologies" />
<meta name="copyright" content="(c) 2003-2009" />
</head>
<body>


<form action="" method="POST">
	NTP kods: <input type="text" name="code" /><br />
	<input type="submit" name="submit" value="Pārbaudīt" />
</form>


</body>
</html>

Link to comment
Share on other sites

man jau likās, ka arī uzrakstīju, ko izlabot...

Tev ir:

...
$code = iDfilter($_POST['code']);
if(isset($code)) {
...
}

es uzrakstīju, lai šo daļu tu pārtaisi par:

...
if(array_key_exists('code',$_POST)){
$code = iDfilter($_POST['code']);
if(isset($code)) {
...
}
}

Link to comment
Share on other sites

$code = iDfilter($_POST['code']);
if(isset($code)) {
   $key = check_result($_POST['code']);

aizvieto ar

if(isset($_POST['code'])) {
   $key = check_result(iDfilter($_POST['code']));

savādi, ka sākumā viņi izfiltrē vērtību ar iDfilter(), bet pēc tam tik un tā padot oriģinālo $_POST['code'] :D

turklāt mysql_escape_string() skaitās deprecated...

Edited by 2easy
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...