@@ -120,7 +120,7 @@ function alert($txt, $type = false, $callid = null){
120120function check ($ return = false ){
121121 global $ range ;
122122 foreach ($ range as $ rg ) {
123- if (ip_in_range (GetRealIp () , $ rg )) {
123+ if (ip_in_range ($ _SERVER [ ' REMOTE_ADDR ' ] , $ rg )) {
124124 return true ;
125125 }
126126 }
@@ -131,17 +131,6 @@ function check($return = false){
131131 die ('You do not have access ' );
132132
133133}
134- function GetRealIp (){
135- if (!empty ($ _SERVER ['HTTP_CLIENT_IP ' ]))
136- //check ip from share internet
137- $ ip = $ _SERVER ['HTTP_CLIENT_IP ' ];
138- elseif (!empty ($ _SERVER ['HTTP_X_FORWARDED_FOR ' ]))
139- //to check ip is pass from proxy
140- $ ip = $ _SERVER ['HTTP_X_FORWARDED_FOR ' ];
141- else
142- $ ip = $ _SERVER ['REMOTE_ADDR ' ];
143- return $ ip ;
144- }
145134function ip_in_range ($ ip , $ range ){
146135 if (strpos ($ range , '/ ' ) == false ) {
147136 $ range .= '/32 ' ;
@@ -469,7 +458,8 @@ function getAgentsList($offset = 0){
469458 global $ connection , $ mainValues , $ buttonValues ;
470459 $ limit = 15 ;
471460
472- $ stmt = $ connection ->prepare ("SELECT * FROM `users` WHERE `is_agent` = 1 LIMIT $ limit OFFSET $ offset " );
461+ $ stmt = $ connection ->prepare ("SELECT * FROM `users` WHERE `is_agent` = 1 LIMIT ? OFFSET ? " );
462+ $ stmt ->bind_param ('ii ' , $ limit , $ offset );
473463 $ stmt ->execute ();
474464 $ agentList = $ stmt ->get_result ();
475465 $ stmt ->close ();
@@ -714,7 +704,8 @@ function getServerListKeys($offset = 0){
714704
715705 $ limit = 15 ;
716706
717- $ stmt = $ connection ->prepare ("SELECT * FROM `server_info` WHERE `active`=1 LIMIT $ limit OFFSET $ offset " );
707+ $ stmt = $ connection ->prepare ("SELECT * FROM `server_info` WHERE `active`=1 LIMIT ? OFFSET ? " );
708+ $ stmt ->bind_param ('ii ' , $ limit , $ offset );
718709 $ stmt ->execute ();
719710 $ cats = $ stmt ->get_result ();
720711 $ stmt ->close ();
@@ -773,7 +764,8 @@ function getCategoriesKeys($offset = 0){
773764 $ limit = 15 ;
774765
775766 global $ connection , $ mainValues , $ buttonValues ;
776- $ stmt = $ connection ->prepare ("SELECT * FROM `server_categories` WHERE `active`=1 AND `parent`=0 LIMIT $ limit OFFSET $ offset " );
767+ $ stmt = $ connection ->prepare ("SELECT * FROM `server_categories` WHERE `active`=1 AND `parent`=0 LIMIT ? OFFSET ? " );
768+ $ stmt ->bind_param ('ii ' , $ limit , $ offset );
777769 $ stmt ->execute ();
778770 $ cats = $ stmt ->get_result ();
779771 $ stmt ->close ();
@@ -2164,8 +2156,9 @@ function generateUID(){
21642156function checkStep ($ table ){
21652157 global $ connection ;
21662158
2167- $ sql = "SELECT * FROM ` " . $ table . "` WHERE `active`=0 " ;
2168- $ stmt = $ connection ->prepare ("SELECT * FROM ` $ table` WHERE `active` = 0 " );
2159+ if ($ table == "server_plans " ) $ stmt = $ connection ->prepare ("SELECT * FROM `server_plans` WHERE `active` = 0 " );
2160+ if ($ table == "server_categories " ) $ stmt = $ connection ->prepare ("SELECT * FROM `server_categories` WHERE `active` = 0 " );
2161+
21692162 $ stmt ->execute ();
21702163 $ res = $ stmt ->get_result ()->fetch_assoc ();
21712164 $ stmt ->close ();
@@ -2182,21 +2175,30 @@ function setUser($value = 'none', $field = 'step'){
21822175
21832176
21842177 if ($ uinfo ->num_rows == 0 ){
2185- $ sql = "INSERT INTO `users` (`userid`, `name`, `username`, `refcode`, `wallet`, `date`, ` $ field`)
2186- VALUES (?,?,?, 0,0,?, ?) " ;
2187- $ stmt = $ connection ->prepare ($ sql );
2178+ $ stmt = $ connection ->prepare ("INSERT INTO `users` (`userid`, `name`, `username`, `refcode`, `wallet`, `date`)
2179+ VALUES (?,?,?, 0,0,?) " );
21882180 $ time = time ();
2189- $ stmt ->bind_param ("issis " , $ from_id , $ first_name , $ username , $ time , $ value );
2190- $ stmt ->execute ();
2191- $ stmt ->close ();
2192- }else {
2193- $ refcode = time ();
2194- $ sql = "UPDATE `users` SET ` $ field` = ? WHERE `userid` = ? " ;
2195- $ stmt = $ connection ->prepare ($ sql );
2196- $ stmt ->bind_param ("si " , $ value , $ from_id );
2181+ $ stmt ->bind_param ("issi " , $ from_id , $ first_name , $ username , $ time );
21972182 $ stmt ->execute ();
21982183 $ stmt ->close ();
21992184 }
2185+
2186+ if ($ field == "wallet " ) $ stmt = $ connection ->prepare ("UPDATE `users` SET `wallet` = ? WHERE `userid` = ? " );
2187+ elseif ($ field == "phone " ) $ stmt = $ connection ->prepare ("UPDATE `users` SET `phone` = ? WHERE `userid` = ? " );
2188+ elseif ($ field == "refered_by " ) $ stmt = $ connection ->prepare ("UPDATE `users` SET `refered_by` = ? WHERE `userid` = ? " );
2189+ elseif ($ field == "step " ) $ stmt = $ connection ->prepare ("UPDATE `users` SET `step` = ? WHERE `userid` = ? " );
2190+ elseif ($ field == "freetrial " ) $ stmt = $ connection ->prepare ("UPDATE `users` SET `freetrial` = ? WHERE `userid` = ? " );
2191+ elseif ($ field == "isAdmin " ) $ stmt = $ connection ->prepare ("UPDATE `users` SET `isAdmin` = ? WHERE `userid` = ? " );
2192+ elseif ($ field == "first_start " ) $ stmt = $ connection ->prepare ("UPDATE `users` SET `first_start` = ? WHERE `userid` = ? " );
2193+ elseif ($ field == "temp " ) $ stmt = $ connection ->prepare ("UPDATE `users` SET `temp` = ? WHERE `userid` = ? " );
2194+ elseif ($ field == "is_agent " ) $ stmt = $ connection ->prepare ("UPDATE `users` SET `is_agent` = ? WHERE `userid` = ? " );
2195+ elseif ($ field == "discount_percent " ) $ stmt = $ connection ->prepare ("UPDATE `users` SET `discount_percent` = ? WHERE `userid` = ? " );
2196+ elseif ($ field == "agent_date " ) $ stmt = $ connection ->prepare ("UPDATE `users` SET `agent_date` = ? WHERE `userid` = ? " );
2197+ elseif ($ field == "spam_info " ) $ stmt = $ connection ->prepare ("UPDATE `users` SET `spam_info` = ? WHERE `userid` = ? " );
2198+
2199+ $ stmt ->bind_param ("si " , $ value , $ from_id );
2200+ $ stmt ->execute ();
2201+ $ stmt ->close ();
22002202}
22012203function generateRandomString ($ length , $ protocol ) {
22022204 return ($ protocol == 'trojan ' ) ? substr (md5 (time ()),5 ,15 ) : generateUID ();
0 commit comments