· 9 years ago · Oct 02, 2016, 07:06 PM
1<?php
2error_reporting(E_ALL);
3// NAGYON FONTOS! IP ellenőrzés a PHP elején
4if ($_SERVER['REMOTE_ADDR'] != '91.82.220.18') die();
5if(isset($_GET['urlteszt'])) die("ok|Teszt");
6// hibaüzenetek letiltása
7ini_set('display_errors', 0);
8// A kulcsszóhoz megadott URL paraméterei:
9$azonosito = $_GET['id']; // üzenet egyedi azonosÃtója
10$kuldo = $_GET['kuldo']; // edsms küldő telefonszáma
11$fogado = $_GET['fogado']; // emelt dÃjas szám
12$prefix = $_GET['prefix']; // prefix
13$szoveg = $_GET['text']; // sms tartalma
14$teszt = $_GET['teszt']; // 1, ha a teszt sms felületrÅ‘l érkezett (nem kerül jóváÃrásra)
15$security = $_GET['security']; // biztonsági kulcs
16echo 'ok|Köszönjük az emelt dÃjas SMS támogatásod! - hungarycs.hu';
17switch ( $fogado )
18{
19 case "0690444154" : { $bertek = "203"; $nertek = "94"; break;}
20 case "0690642142" : { $bertek = "320"; $nertek = "148"; break;}
21 case "0690888112" : { $bertek = "508"; $nertek = "236"; break;}
22 case "0690888380" : { $bertek = "1016"; $nertek = "472"; break;}
23 case "0690888405" : { $bertek = "2032"; $nertek = "944"; break;}
24 case "0690649648" : { $bertek = "5080"; $nertek = "2360"; break;}
25}
26
27//Mentés MYSQL-be ----
28$servername = "localhost";
29$username = "u002408_hunsms";
30$password = "H7474h74";
31$dbname = "u002408_sms";
32// Create connection
33$conn = mysqli_connect($servername, $username, $password, $dbname);
34// Check connection
35if (!$conn)
36{
37 //die("Sikertelen csatlakozás: " . mysqli_connect_error());
38 $file = 'sms-error.txt';
39 if(!file_exists($file))
40 {
41 /*$ourFileName = "testFile.txt";
42 $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
43 fclose($ourFileHandle);*/
44
45 $myfile = fopen("sms-error.txt", "w") or die("can't open file");
46 $txt = "---\n";
47 fwrite($myfile, $txt);
48 fclose($myfile);
49 }
50 $current = file_get_contents($file);
51 $current .= "\n Sikertelen csatlakozás: ".mysqli_connect_error()." \n" ;
52 file_put_contents($file, $current);
53}
54//mysql_query("SET NAMES 'utf8'");
55//Tábla készÃtés
56// sql to create table
57$sql = "CREATE TABLE IF NOT EXISTS smsbevetel (
58id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
59date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
60text VARCHAR(160) NOT NULL,
61sender VARCHAR(30) NOT NULL,
62number VARCHAR(30) NOT NULL,
63bertek VARCHAR(30) NOT NULL,
64nertek VARCHAR(30) NOT NULL,
65smsid VARCHAR(50) NOT NULL,
66)";
67$QrySql = mysqli_query($conn, $sql);
68
69if ($QrySql)
70{
71 //echo "Table MyGuests created successfully";
72 echo 'ok|Köszönjük az emelt dÃjas SMS támogatásod! - hungarycs.hu'; // ok| és válasz sms szövege
73}
74else
75{
76 // echo "Error creating table: " . mysqli_error($conn);
77 //echo "Hiba történt az adatbázis legrenerálása közben: " . mysqli_error($conn);
78
79
80 $file = 'sms-error.txt';
81 if(!file_exists($file))
82 {
83 /*$ourFileName = "testFile.txt";
84 $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
85 fclose($ourFileHandle);*/
86
87 $myfile = fopen("sms-error.txt", "w");
88 $txt = "---\n";
89 fwrite($myfile, $txt);
90 fclose($myfile);
91 }
92 $current = file_get_contents($file);
93 $current .= "\n Hiba történt az adatbázis legenerálása közben: ".mysqli_error($conn)." \n" ;
94 file_put_contents($file, $current);
95}
96
97$datum = date("Y-m-d H:i:s"); //Dátum
98
99$sql = "INSERT INTO smsbevetel (date, text, sender, number, bertek, nertek, smsid)
100VALUES ('".$datum."', '".$szoveg."', '".$kuldo."','".$fogado."','".$bertek."','".$nertek."','".$azonosito."')";
101$QrySql = mysqli_query($conn, $sql);
102
103if ($QrySql) {
104 //echo "New record created successfully";
105}
106else
107{
108 //echo "Hiba történt az adatbázisban az új rekord felvétele közben: " . $sql . "<br>" . mysqli_error($conn);
109
110 $file = 'sms-error.txt';
111 if(!file_exists($file))
112 {
113 /*$ourFileName = "testFile.txt";
114 $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
115 fclose($ourFileHandle);*/
116
117 $myfile = fopen("sms-error.txt", "w");
118 $txt = "---\n";
119 fwrite($myfile, $txt);
120 fclose($myfile);
121 }
122 $current = file_get_contents($file);
123 $current .= "\n Hiba történt az adatbázisban az új rekord felvétele közben: ". $sql ." ".mysqli_error($conn)." \n" ;
124 file_put_contents($file, $current);
125}
126
127mysqli_close($conn);
128//MYSQL mentés vége ----
129
130// sms feldolgozása, pl: felhasználónév generálás; kredit jóváÃrás stb.
131
132?>