Ошибка с подключением к БД (вроде)
Всем привет, есть готовый сайт который работал отлично, начались какие то проблемы, что к чему не могу понять так мало знаний ( скрипт покупал готовый, создатель молчит)
Сайт выдает ошибку {"error":1,"msg":"Wrong request to server"} эту ошибку я нашел в файле proxy.class.php
Сам файл содержит такие строки
<?php
class App {
protected $actions = array("reg","get");
public function __construct($db) {
$this->db=$db;
$this->db->object=TRUE;
}
public function run(){
if(isset($_GET["method"]) && isset($_GET["key"])) {
$method = ($_GET["method"]) ? $_GET["method"] : "" ;
if(!in_array($method,$this->actions)) return $this->_404();
switch($_GET['method']) {
case "reg" : $this->regsister(); break;
case "get" : $this->get(); break;
default : $this->_404(); break;
}
} else $this->errno("Wrong request to server");
}
protected function _404(){
header('HTTP/1.0 404 Page not found');
exit("Sorry, page not found");
}
public function errno($msg) {
$array = array("error"=>1,"msg"=>"$msg");
exit(json_encode($array));
}
public function regsister() {
$key = htmlspecialchars($_GET['key']);
preg_match("/^[A-Z]+-[A-Z]+-[A-Z]+-[A-Z]+/", $key, $clear);
if(count($clear) == 0) $this->errno("Please enter the correct key");
$service = $this->db->get("settings",array("id"=>"?"),array("limit"=>1),array(1));
if($service->enable == 0) $this->errno("Service off");
if($key = $this->db->get("free",array("purchase"=>"?"),array("limit"=>1),array($clear[0]))) {
$ip = $_SERVER["REMOTE_ADDR"];
$array = explode('.',$ip);
$adress = $array[0].$array[1];
$keyaccess = $this->gen(25);
$time = date("Y-m-d H:i:s",time());
$insert = array(":mskey"=>$keyaccess,":purchase"=>$clear[0],":mstime"=>$time,":msactive"=>1,":adress"=>$adress,":expr"=>time()+$key->expr);
$this->db->insert("reg",$insert);
$this->db->delete("free",array("purchase"=>$clear[0]));
$array = array("error"=>0,"code"=>$keyaccess,"msg"=>"Successful registration");
echo json_encode($array);
} else $this->errno("Please specify a valid key");
}
protected function gen($length) {
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
$key = "";
for($i = 0; $i < $length; $i++) {
$key .= $chars{rand(0, strlen($chars) - 1)};
}
return $key;
}
public function get() {
isset($_GET['key']) ? $key = filter_var($_GET['key'], FILTER_SANITIZE_ENCODED) : $key = "";
isset($_GET['type']) ? $type = filter_var($_GET['type'], FILTER_SANITIZE_ENCODED) : $type = "";
$ip = $_SERVER["REMOTE_ADDR"];
if(strlen($key) == 25 && strlen($type) == 5 && ($type == "https" || $type == "socks")) {
$setting = $this->db->get("settings",array("id"=>"1"),array("limit"=>1));
if($user = $this->db->get("reg",array("mskey"=>"?"),array("limit"=>1),array($key))) {
$array = explode('.',$ip);
$adress = $array[0].$array[1];
if($ban = $this->db->get("banned",array("adress"=>"?"),array("limit"=>1),array($ip))) {
if($ban->attempts >= $setting->attempts) $this->errno("This IP address blocked");
}
if($adress == $user->adress) {
if($ban = $this->db->get("banned",array("adress"=>"?"),array("limit"=>1),array($ip))) {
$this->db->delete("banned",array("adress"=>$ip));
}
$this->getproxy($type);
} else {
$ins = array(":response"=>"NIADDRESS",":mskey"=>$user->mskey,":msoriginal"=>$user->adress,":msip"=>$ip,":ts"=>time());
$this->db->insert("logs",$ins);
$this->getproxy($type);
}
} else {
if($ban = $this->db->get("banned",array("adress"=>"?"),array("limit"=>1),array($ip))) {
if($ban->attempts == $setting->attempts-1) {
$this->db->update("banned",array("attempts"=>$setting->attempts,"ts"=>time()+$setting->tsban),array("adress"=>$ip));
$this->errno("User not found");
} elseif($ban->attempts == $setting->attempts) {
$current = $ban->ts - time();
if($current < 0) {
$this->db->delete("banned",array("adress"=>$ip));
$this->errno("User not found");
} else $this->errno("This IP address blocked");
} else {
$this->db->update("banned","attempts = attempts + 1",array("adress"=>$ip));
$this->errno("User not found");
}
} else {
$ins = array(":adress"=>$ip,":ts"=>time(),":attempts"=>1);
$this->db->insert("banned",$ins);
$this->errno("User not found");
}
}
} else $this->errno("Invalid compiled query");
}
private function getproxy($type) {
$text = file_get_contents(__DIR__."/app/temp/$type.txt");
echo nl2br( htmlspecialchars($text) );
}
}
Помогите решить проблему пожалуйста
Ответы (1 шт):
Автор решения: Serenity sun
→ Ссылка
у тебя в запросах GET отсутствует значение method или key. проверь их правильность