Mine sisusse
Otsi siit
  • Rohkem valikuid...
Otsi tulemusi mis sisaldab...
Otsi tulemusi...
Jälgi teemat sisse logides  

SMS Skriptid

Soovitatud postitused

Taastan kuskilt hetkel vanu SMS skripte, et saaksite kasutada, muuta ja uuendada. Palun mitte ära kustutada, suts raske on neid üldse hetkel kätte saada. Counter-Strike kuid saab lihtsasti ringi ehitada.

 

Fortumo

 

SMS skriptide kood - Virtuaalraha/punktisüsteemi näidis

 

include '../../includes/dbconfig.php';


 if(!in_array($_SERVER['REMOTE_ADDR'],
     array('81.20.151.38', '81.20.148.122', '209.20.83.207', '79.125.125.1'))) {
   die("404 file not found");
 }
 $secret = '';
 if(!empty($secret) && !check_signature($_GET, $secret)) {
   die("Error: Invalid signature");
 }
 $sender = $_GET['sender'];
 $username = $_GET['message'];


mysql_connect("$dbhost", "$dbusername", "$dbpassword") or die(mysql_error()); mysql_select_db("$dbdatabase") or die(mysql_error());


$query  = "SELECT amount FROM accounts WHERE ownerid = '$username'";
$result = mysql_query($query);


while(list($credits) = mysql_fetch_row($result))


$buycredits = $credits + 0.64 ;
$buyeur = $credits + 10 / 15.6466 ;


$position=4;
$post = substr($buyeur, 0, $position); 




mysql_query("UPDATE accounts SET amount = '$buycredits' WHERE ownerid = '$username'");
mysql_query("UPDATE accounts SET date = UNIX_TIMESTAMP(NOW()) WHERE ownerid = '$username'");




$success = "Kasutajale $username lisati 0.64 EUR virtuaalraha. Sul on $buycredits EUR virtuaalraha."; 
echo $success; 


 function check_signature($params_array, $secret) {
   ksort($params_array);
   $str = '';
   foreach ($params_array as $k=>$v) {
     if($k != 'sig') {
       $str .= "$k=$v";
     }
   }
   $str .= $secret;
   $signature = md5($str);
   return ($params_array['sig'] == $signature);
 }


mysql_close();


?>

 

SMS skriptide kood - Counter-Strike RPG Mod'i credits lisamise näidis

 

include 'sec/cf.php';


 if(!in_array($_SERVER['REMOTE_ADDR'],
     array('81.20.151.38', '81.20.148.122', '79.125.125.1', '209.20.83.207'))) {
   die("Error: Unknown IP");
 }
 $secret = '';
 if(!empty($secret) && !check_signature($_GET, $secret)) {
   die("Error: Invalid signature");
 }
 $sender = $_GET['sender'];
 $username = $_GET['message'];


mysql_connect("$dbhost", "$dbuser", "$dbpass") or die(mysql_error()); mysql_select_db("$dbname") or die(mysql_error());


$querye = "SELECT * FROM rpgm_reg WHERE db_key = '$username'";
$result = mysql_query($querye) or die(mysql_error());
while($row = mysql_fetch_array($result)) {
$string = $row['1'];


list($xpassword, $score, $credits, $regeneration, $health, $resupply, $vampire, $sealth, $longjump, $icestab, $frostpistol, $denial, $impulse, $medic, $autobhop) = split('[ ]', $string);


$new_string = preg_replace('/[^a-z0-9\s]/i', '', $xpassword);
$new_string2 = preg_replace('/[^a-z0-9\s]/i', '', $score);
$new_string3 = preg_replace('/[^a-z0-9\s]/i', '', $credits);
$new_string4 = preg_replace('/[^a-z0-9\s]/i', '', $regeneration);
$new_string5 = preg_replace('/[^a-z0-9\s]/i', '', $health);
$new_string6 = preg_replace('/[^a-z0-9\s]/i', '', $resupply);
$new_string7 = preg_replace('/[^a-z0-9\s]/i', '', $vampire);
$new_string8 = preg_replace('/[^a-z0-9\s]/i', '', $sealth);
$new_string9 = preg_replace('/[^a-z0-9\s]/i', '', $longjump);
$new_string10 = preg_replace('/[^a-z0-9\s]/i', '', $icestab);
$new_string11 = preg_replace('/[^a-z0-9\s]/i', '', $frostpistol);
$new_string12 = preg_replace('/[^a-z0-9\s]/i', '', $denial);
$new_string13 = preg_replace('/[^a-z0-9\s]/i', '', $impulse);
$new_string14 = preg_replace('/[^a-z0-9\s]/i', '', $medic);
$new_string15 = preg_replace('/[^a-z0-9\s]/i', '', $autobhop);


$buycredits = $credits + 500 ;


$stringtogether = "$xpassword $score $buycredits $regeneration $health $resupply $vampire $sealth $longjump $icestab $frostpistol $denial $impulse $medic $autobhop" ;


mysql_query("UPDATE rpgm_reg SET data = '$stringtogether' WHERE db_key = '$username'");


$added = "500";
$success = "Sinu kasutajanimele $username on lisatud $added credits. Sul on nüüd $buycredits credits. Script by www.cf.ee"; 
echo $success; 
}


mysql_close();


?>

 

SMS skriptide kood - dbconfig.php näidis

 

$dbuser="kasutajanimi_kasutaja";
$dbpass="mingiparool";
$dbhost="127.0.0.1";
$dbname="kasutajanimi_andmebaas";
?>

 

SMS skriptide kood - EAC 24h serverite tellimise näidis

 

start.php

if(!in_array($_SERVER['REMOTE_ADDR'], 
   array('81.20.151.38', '81.20.148.122','209.20.83.207','79.125.125.1'))) {
   die("Error: Unknown IP");
}


$secret = '';
if(!empty($secret) && !check_signature($_GET, $secret)) {
   die("Error: Invalid signature");
}


function check_signature($params_array, $secret) {
   ksort($params_array);
   $str = '';
   foreach ($params_array as $k=>$v) {
       if($k != 'sig') {
           $str .= "$k=$v";
       }
   }
   $str .= $secret;
   $signature = md5($str);
   return ($params_array['sig'] == $signature);
}


$mobile = $_GET['sender'];
$email = $_GET['message'];


require 'curl.php';

 

 

vabad.php

define('CURL', 1);
require 'config.php';


mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());


if (isset($_GET['free']) && $_GET['free'] == 1) {
   mysql_query("UPDATE sms_serverid SET vaba = 1 WHERE id = 1;");
}


$result = mysql_query("SELECT * FROM sms_serverid WHERE vaba = 1;");
$countFree = mysql_num_rows($result);
if ($countFree == 0) {
   die("

 SMS Counter-Strike 1.6 vabu servereid hetkel ei ole.
");
}
echo "
 Kokku $countFree vaba Counter-Strike 1.6 server" . ($countFree == 1 ? '' : 'it') . ':

';
while ($server = mysql_fetch_array($result)) {
   echo $server['serveri_ip'] . '
';
}


echo '
SMS serverid on uuendamisel! 25.11.10
';


?>

 

 

functions.php

defined('CURL') or die();


function createRandomPassword()
{
   $chars = "abcdefghijkmnopqrstuvwxyz023456789"; 
   srand((double)microtime()*1000000); 
   $i = 0; 
   $pass = '' ; 

   while ($i         $num = rand() % 33; 
       $tmp = substr($chars, $num, 1); 
       $pass = $pass . $tmp; 
       $i++; 
   } 

   return $pass; 
}


function changeIniPassword($ftpServer, $ftpUser, $ftpPassword, $ftpFile, $gameServer, $newPwd, $oldPwd = null)
{
   $ftpUser = str_replace('@', '%40', $ftpUser);

   $url = "ftp://$ftpUser:$ftpPassword@$ftpServer$ftpFile";

   $curl = curl_init();
   curl_setopt($curl, CURLOPT_URL, $url);
   curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
   $ini = curl_exec ($curl);
   curl_close ($curl);

   $regExp = "/^($gameServer-)(" . ($oldPwd == null ? ".*?" : $oldPwd) . ")(-0)/ms";
   $newIni = preg_replace($regExp, "\${1}$newPwd$3", $ini);

   if ($newIni == $ini) {
       //didn't change password
       return false;
   }

   $temp = tmpfile();
   fwrite($temp, $newIni);
   fseek($temp, 0);

   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, $url);
   curl_setopt($ch, CURLOPT_UPLOAD, 1);
   curl_setopt($ch, CURLOPT_INFILE, $temp);
   curl_setopt($ch, CURLOPT_INFILESIZE, strlen($newIni));

   $error = curl_exec($ch);
   curl_close($ch); 
   fclose($temp);
   return true;
}

 

 

curl.php

define('CURL', 1);
require 'config.php';
require 'functions.php';


function curl($url, $user, $password)
{
   $header = array('Authorization: Basic ' . base64_encode($user . ':' . $password));
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, $url); 
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
   curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
   $result = curl_exec($ch);
   curl_close ($ch);
   return $result;
}


if (!isset($mobile) || !isset($email)) {
   die("Mobiil või email on puudu");
}
$tellimus = array('mobiil' => $mobile, 'email' => $email);


mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());


$result = mysql_query("SELECT t.id FROM sms_serverid s JOIN sms_tellimused t ON s.id = t.server 
   WHERE s.serveri_ip = '" . mysql_real_escape_string($email) . "'");
if (mysql_num_rows($result) == 1) {
   //tahetakse uuendada
   $id = mysql_result($result, 0);
   $result = mysql_query("UPDATE sms_tellimused SET kuupaev = ADDDATE(kuupaev, INTERVAL 24 HOUR) WHERE id = $id");
   if ($result) {
       echo 'Server ' . $email . ' pikendatud 24h võrra. Script by www.CF.ee';
   } else {
       echo 'Serveri pikendamine ebaõnnestus';
   }
   return;
}


//valime vaba serveri
$result = mysql_query("SELECT * FROM sms_serverid WHERE vaba = 1 LIMIT 1;");
if (mysql_num_rows($result) == 0) {
   die("Ühtegi vaba serverit ei ole");
}
$server = mysql_fetch_array($result);




$newPassword = createRandomPassword();
echo 'Parool: ' . $newPassword . ' ';


//muuda cPaneli parool
curl("http://sinudomeen.ee:2082/frontend/gs/passwd/changepass.html?oldpass={$server['parool']}&newpass=$newPassword", 
   $server['kasutajanimi'], $server['parool']);
$server['parool'] = $newPassword;




//muudame ftp parooli
curl("http://www.sinudomeen.ee:2082/frontend/gs/ftp/dopasswdftp.html?" . 
   "acct={$server['ftp_esimene_pool']}&password={$server['parool']}", $server['kasutajanimi'], $server['parool']);


//unintsalli server
curl("http://www.sinudomeen.ee:2082/frontend/gs/gameserv/Uninstall.html?game=cstrike&n=0", $server['kasutajanimi'], $server['parool']);


$ftpPassword = $newPassword;
$newCfgPassword = createRandomPassword();
changeIniPassword($ftpServer, $ftpUser, $ftpPassword, $ftpFile, $server['serveri_ip'], $newCfgPassword);




//lisame kasutaja andmebaasi
$sql = "INSERT INTO sms_tellimused (server, mobiil, email) 
   VALUES ({$server['id']}, '" . mysql_real_escape_string($tellimus['mobiil']) . "', 
       '" . mysql_real_escape_string($tellimus['email']) . "');";
mysql_query($sql);


//märgime server kasutatuks ja muudame parooli
mysql_query("UPDATE sms_serverid SET vaba = 0, parool = '$newPassword' WHERE id = {$server['id']}");


$to = $tellimus['email'];
$subject = "SMS Counter Strike Serveri Tellimus";
$body = "
Tere,


Kasutajanimi on {$server['kasutajanimi']}
Sinu parool on {$server['parool']}
Serveri IP on {$server['serveri_ip']}
FTP Kasutajanimi on {$server['ftp_esimene_pool']}@{$server['ftp_teine_pool']} ja parool on {$server['parool']}
FTP Port 21
FTP server www.sinudomeen.ee


cPaneli ligipääs aadressilt http://www.sinudomeen.ee/cpanel
Serverit saad kasutada 24h.


Script by www.sinudomeen.ee


Lugupidamisega,
sinudomeen.ee Tiim
";


if (mail($to, $subject, $body)) {
   echo("
Kasutajanimi: {$server['kasutajanimi']} Serveri IP: {$server['serveri_ip']} Info meiliga edukalt saadetud! Script by www.sinudomeen.ee");
} else {
   echo("
Meili saatmine ebaõnnestus...");
}
if ($sendAdminEmail) {
   mail($adminEmail, 'Telliti uus server', $body);
}

 

 

cron.php

define('CURL', 1);
require 'config.php';


mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());


//ALTER TABLE  `sms_tellimused` CHANGE  `kuupaev`  `kuupaev` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP


$result = mysql_query("SELECT server, id FROM sms_tellimused 
   WHERE server != 0 AND SUBDATE(NOW(), INTERVAL 24 HOUR) >= kuupaev;");
if (mysql_num_rows($result) == 0) {
   exit;
}


while ($order = mysql_fetch_array($result)) {
   //aeg täis
   mysql_query("UPDATE sms_tellimused SET server = 0 WHERE id = {$order['id']}");
   mysql_query("UPDATE sms_serverid SET vaba = 1 WHERE id = {$order['server']}");
}

 

 

config.php

defined('CURL') or die();


$dbhost = '127.0.0.1';
$dbuser = 'kasutaja_kasutajanimi';
$dbpass = 'parool';
$dbname = 'andmebaas_andmebaasinimi';


$adminEmail = 'kasutaja@sinudomeen.ee';
$sendAdminEmail = true;


$ftpUser = 'ftpkasutaja@sinudomeen.ee';
$ftpPassword = 'ftpparool';
$ftpServer = 'sinudomeen.ee';
$ftpFile = '/public_html/eacserverinimekiri.ini';

 

 

changepw.php


define('CURL', 1);
if (!empty($_POST['server']) && !empty($_POST['old']) && !empty($_POST['new1']) && !empty($_POST['new2'])) {

   $server = $_POST['server'];
   $old = $_POST['old'];
   $new1 = $_POST['new1'];
   $new2 = $_POST['new2'];

   if ($new1 != $new2) {
       echo 'Paroolid ei kattu!';
   } elseif ($new1 == $old) {
       echo 'Uus ja vana parool on samad';
   } else {
       require 'config.php';
       require 'functions.php';
       if (changeIniPassword($ftpServer, $ftpUser, $ftpPassword, $ftpFile, $server, $new1, $old)) {
           echo 'Parool muudetud!';
       } else {
           echo 'Parooli muutmine ebaõnnestus';
       }
   }
}
?>
</pre>
<form action="<?php%20echo%20%24_SERVER%5B'PHP_SELF'%5D?>" method="post">
Serveri parooli muutmine

Server: 

Vana parool: 

Uus parool: 

Uus parool uuesti: 


<

 

 

eacserverid.ini

80.79.114.131:27015-757x0am3-0
80.79.114.132:27015-afkkzprz-0
80.79.114.133:27015-afkkzprz-0
80.79.114.134:27015-afkkzprz-0
80.79.114.136:27015-bxsqhdby-0
80.79.114.137:27015-afkkzprz-0
80.79.114.138:27015-afkkzprz-0
80.79.114.139:27015-afkkzprz-0

 

 

MYSQL tabel sms_serverid

-- phpMyAdmin SQL Dump
-- version 3.4.10.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jun 30, 2012 at 01:55 PM
-- Server version: 5.1.63
-- PHP Version: 5.2.9


SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";




/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;


--
-- Database: `kasutajanimi_andmebaasinimi`
--


-- --------------------------------------------------------


--
-- Table structure for table `sms_serverid`
--


CREATE TABLE IF NOT EXISTS `sms_serverid` (
 `id` int(12) NOT NULL AUTO_INCREMENT,
 `vaba` int(12) NOT NULL DEFAULT '0',
 `serveri_ip` varchar(32) NOT NULL DEFAULT '',
 `kasutajanimi` varchar(100) NOT NULL DEFAULT '0',
 `parool` varchar(100) NOT NULL DEFAULT '0',
 `ftp_esimene_pool` varchar(100) NOT NULL DEFAULT '0',
 `ftp_teine_pool` varchar(100) NOT NULL DEFAULT '0',
 PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;


--
-- Dumping data for table `sms_serverid`
--


INSERT INTO `sms_serverid` (`id`, `vaba`, `serveri_ip`, `kasutajanimi`, `parool`, `ftp_esimene_pool`, `ftp_teine_pool`) VALUES
(1, 0, '80.79.114.142:27015', 'cpanelismsserverikasutajanimi', 'parool', 'sms', 'cpanelidomeeninimi.com'),
(2, 0, '80.79.114.143:27015', 'cpanelismsserveriteinekasutajanimi', 'parool', 'sms', 'cpanelidomeeninimi.com');


/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

 

 

MYSQL tabel sms_tellimused

-- phpMyAdmin SQL Dump
-- version 3.4.10.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jun 30, 2012 at 01:55 PM
-- Server version: 5.1.63
-- PHP Version: 5.2.9


SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";




/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;


--
-- Database: `kasutajanimi_andmebaasinimi`
--


-- --------------------------------------------------------


--
-- Table structure for table `sms_tellimused`
--


CREATE TABLE IF NOT EXISTS `sms_tellimused` (
 `id` int(12) NOT NULL AUTO_INCREMENT,
 `server` int(11) NOT NULL DEFAULT '0',
 `mobiil` varchar(100) NOT NULL DEFAULT '0',
 `email` varchar(100) NOT NULL DEFAULT '0',
 `kuupaev` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
 PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=18 ;


--
-- Dumping data for table `sms_tellimused`
--


INSERT INTO `sms_tellimused` (`id`, `server`, `mobiil`, `email`, `kuupaev`) VALUES
(1, 0, '37255555555', 'meiliaadress@sinudomeen.ee', '2011-05-03 18:47:21'),
(2, 0, '37255555555', 'meiliaadress@sinudomeen.ee', '2011-05-13 18:53:46'),


/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
[ATTACH]1[/ATTACH]

 

SMS skriptide kood - Fast Download

 

Kood avalikuks kasutamiseks, kõlbab nii Counter-Strike 1.6 Fast Download tarbeks failide kopeerimise toiminguteks kui ka mõneks muuks sarnaseks otstarbeks.

 

 

index.php

/*
* Paigaldab failid
*/
define('FTP', 1);
require 'dlfast/functions.php';
require 'dlfast/config.php';
session_start();


$page = isset($_GET['page']) ? $_GET['page'] : '';


switch ($page) {
   case 'update':
       require 'dlfast/update.php';
       break;
   default:
       require 'dlfast/form.php';
}

 

 

MySQL tabel exceptions

-- phpMyAdmin SQL Dump
-- version 3.4.10.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jun 30, 2012 at 06:05 PM
-- Server version: 5.1.63
-- PHP Version: 5.2.9


SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";




/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;


--
-- Database: `kasutaja_kasutajanimi`
--


-- --------------------------------------------------------


--
-- Table structure for table `exceptions`
--


CREATE TABLE IF NOT EXISTS `exceptions` (
 `file` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


--
-- Dumping data for table `exceptions`
--


INSERT INTO `exceptions` (`file`) VALUES
('server.cfg'),
('addons'),
('manual'),
('SAVE'),
('autobuy.txt'),
('mapcycle.txt'),
('motd.txt'),
('readme.txt'),
('rebuy.txt'),
('spectcammenu.txt'),
('steam_appid.txt'),
('titles.txt'),
('vip.txt'),
('banned.cfg'),
('cw.cfg'),
('dproto.cfg'),
('GameServerConfig.vdf'),
('delta.lst'),
('listip.cfg'),
('liblist.gam'),
('server.cfg'),
('pubi.cfg'),
('steam.inf'),
('rules.txt'),
('index.php'),
('index.html'),
('commandmenu.txt'),
('logs'),
('config.cfg'),
('listenserver.cfg'),
('spectatormenu.txt');


/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

 

 

MySQL tabel settings

-- phpMyAdmin SQL Dump
-- version 3.4.10.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jun 30, 2012 at 06:05 PM
-- Server version: 5.1.63
-- PHP Version: 5.2.9


SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";




/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;


--
-- Database: `kasutaja_kasutajanimi`
--


-- --------------------------------------------------------


--
-- Table structure for table `settings`
--


CREATE TABLE IF NOT EXISTS `settings` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `username` varchar(50) NOT NULL,
 `ftp_username` varchar(50) NOT NULL,
 `password` varchar(50) NOT NULL,
 `server` varchar(100) NOT NULL,
 `from` varchar(100) NOT NULL,
 `to` varchar(100) NOT NULL,
 `last_access` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
 `failed_tries` int(11) NOT NULL DEFAULT '0',
 PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=191 ;


--
-- Dumping data for table `settings`
--


INSERT INTO `settings` (`id`, `username`, `ftp_username`, `password`, `server`, `from`, `to`, `last_access`, `failed_tries`) VALUES
(44, 'kasutajanimi', 'kasutaja@sinudomeen.ee', 'parool', '127.0.0.1', '/.gameservers/cstrike_0/cstrike', '/home/kasutaja/public_html/kasutajanimi', '2012-02-20 18:19:01', 0),
(16, 'kasutajanimi', 'kasutaja@sinudomeen.ee', 'parool', '127.0.0.1', '/.gameservers/cstrike_0/cstrike', '/home/kasutaja/public_html/kasutajanimi', '2012-03-03 22:07:02', 0),
(17, 'kasutajanimi', 'kasutaja@sinudomeen.ee', 'parool', '127.0.0.1', '/.gameservers/cstrike_0/cstrike', '/home/kasutaja/public_html/kasutajanimi', '2012-03-03 22:07:25', 0),
(18, 'kasutajanimi', 'kasutaja@sinudomeen.ee', 'parool', '127.0.0.1', '/.gameservers/cstrike_0/cstrike', '/home/kasutaja/public_html/kasutajanimi', '2012-03-03 22:12:45', 0),
(19, 'kasutajanimi', 'kasutaja@sinudomeen.ee', 'parool', '127.0.0.1', '/.gameservers/cstrike_0/cstrike', '/home/kasutaja/public_html/kasutajanimi', '2012-03-03 22:17:21', 0),
(20, 'kasutajanimi', 'kasutaja@sinudomeen.ee', 'parool', '127.0.0.1', '/.gameservers/cstrike_0/cstrike', '/home/kasutaja/public_html/kasutajanimi', '0000-00-00 00:00:00', 0),
(21, 'kasutajanimi', 'kasutaja@sinudomeen.ee', 'parool', '127.0.0.1', '/.gameservers/cstrike_0/cstrike', '/home/kasutaja/public_html/kasutajanimi', '0000-00-00 00:00:00', 0),
(190, 'kasutajanimi', 'kasutaja@sinudomeen.ee', 'parool', '127.0.0.1', '/.gameservers/cstrike_0/cstrike', '/home/kasutaja/public_html/kasutajanimi', '2012-06-24 13:52:04', 0),
(165, 'kasutajanimi', 'kasutaja@sinudomeen.ee', 'parool', '127.0.0.1', '/.gameservers/cstrike_0/cstrike', '/home/kasutaja/public_html/kasutajanimi', '0000-00-00 00:00:00', 0),
(166, 'kasutajanimi', 'kasutaja@sinudomeen.ee', 'parool', '127.0.0.1', '/.gameservers/cstrike_0/cstrike', '/home/kasutaja/public_html/kasutajanimi', '2012-03-04 11:21:46', 0);


/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

 

 

SecureTrustCA.crt

-----BEGIN CERTIFICATE-----


-----END CERTIFICATE-----

 

 

/dlfast/config.php

defined('FTP') or die();


$keepOriginal = true; // kui false, siis jäetakse ainult bz2 failid
$extraDir = '/home/kasutajanimi/public_html/ftp'; // kaust, kust lisafaile kopeerida
$dbHost = '127.0.0.1';//'est-cen.cemty.ee';
$dbUsername = 'kasutaja_kasutajanimi'; //'scripts';
$dbPassword = 'parool'; //';
$dbDbName = 'kasutaja_andmebaasinimi'; //scripts_curltest';


$ftpServer = '127.0.0.1';
$ftpUsername = 'kasutaja@sinudomeen.ee';
$ftpPassword = '';

 

 

/dlfast/form.php

defined('FTP') or die();




pageHeader();
if (isset($_SESSION['errors'])) {
   $errors = $_SESSION['errors'];
   if (empty($errors)) {
       echo 'Uuendatud
';
   } else {
       echo 'Error
';
       foreach ($_SESSION['errors'] as $error) {
           echo $error . '
';
       }
   }
   unset($_SESSION['errors']);
}
?>















cPanel'i kasutajanimi



cPanel'i parool






Peale valimist 'Uuenda', palun
oota kuni teavitatakse edukast uuendamisest

Kui siin lehel uuendamisel muutus server.cfg fail teeb skript serverile stop ja start automaatselt.

Automaatsel uuendamisel (iga tunni tagant) serverile server.cfg muutmisel stop ja start ei tehta.






pageFooter();

 

 

/dlfast/ftp.php

defined('FTP') or define('FTP', 1);
require_once 'config.php';
require_once 'functions.php';




if (!isset($mysqlCon)) {
   $mysqlCon = mysql_connect($dbHost, $dbUsername, $dbPassword) or die(mysql_error());
   mysql_select_db($dbDbName, $mysqlCon) or die(mysql_error());
}




$globalExceptions = array();


$result = mysql_query("SELECT * FROM exceptions");
while ($exception = mysql_fetch_array($result)) {
   $globalExceptions[] = $exception['file'];
}


//$oldumask = umask(0);


$result = mysql_query("SELECT * FROM settings" . (isset($username) ? " WHERE username = '$username'" : ""));
while ($user = mysql_fetch_array($result)) {
   $ftpUsername = $user['ftp_username'];
   $ftpUsernameValid = substr($ftpUsername, 0, strpos($ftpUsername, '@'));
   $ftpPassword = $user['password'];
   $ftpServer = $user['server'];
   $serverCfgUrl = 'http://www.dlfast.net/' . $user['username'];
   $from = $user['from'];
   $to = $user['to'];

   $exceptions = array();
   foreach ($globalExceptions as $exception) {
       $exceptions[] = $from . '/' . $exception;
   }


   $ftpCon = ftp_connect($ftpServer);
   if (!@ftp_login($ftpCon, $ftpUsername, $ftpPassword)) {
       // FTP parool on vale

       if (isset($password)) {
           // ühe kasutaja muutmine, muudame ftp parooli
           curl('https://sinudomeen.ee:2083/json-api/cpanel?cpanel_jsonapi_version=2&cpanel_jsonapi_module=Ftp&'
               . 'cpanel_jsonapi_func=delftp&user=' . $ftpUsernameValid . '&destroy=1', $username, $password);

           // loome uue ftp kasutaja
           curl('https://sinudomeen.ee:2083/json-api/cpanel?cpanel_jsonapi_version=2&cpanel_jsonapi_module=Ftp&'
               . "cpanel_jsonapi_func=addftp&user=$ftpUsernameValid&pass=$ftpPassword&homedir=%2F&quota=0",
                   $username, $password);
           if (!@ftp_login($ftpCon, $ftpUsername, $ftpPassword)) {
               ftpConnecFailure($user['id'], $user['failed_tries'], $to);
               $_SESSION['errors'] = array('Uuendamine ebaõnnestus');
               header('Location: index.php');
               exit;
           }
       } else {
           ftpConnecFailure($user['id'], $user['failed_tries'], $to);
           continue;
       }
   }

   // successfully connected, reset failed tries
   mysql_query("UPDATE settings SET failed_tries = 0 WHERE id = {$user['id']}");

   //servers.cfg edit
   if (ftp_size($ftpCon, $from . '/server.cfg') != -1) {
       // fail olemas
       $tempFile = tmpfile();
       $serversFile = $from . '/server.cfg';
       ftp_fget($ftpCon, $tempFile, $serversFile, FTP_BINARY);

       fseek($tempFile, 0);
       $contents = fread($tempFile, ftp_size($ftpCon, $serversFile));
       $contents2 = $contents;

       $contents = preg_replace('/sv_allowupload "(.*?)"/', 'sv_allowupload "1"', $contents);
       $contents = preg_replace('/sv_allowdownload "(.*?)"/', 'sv_allowdownload "1"', $contents);
       $contents = preg_replace('/sv_downloadurl "?[^"\n]*"?/', 'sv_downloadurl "' . $serverCfgUrl . '"', $contents, -1, $count);
       if ($count == 0) {
           //no replacements -> no such line, let's add
           $contents = preg_replace('/(sv_allowdownload.*?$.*?^.+?^)/ms', "$1sv_downloadurl \"$serverCfgUrl\" \r\n", $contents);
       }
       //echo $contents;
       fseek($tempFile, 0);
       fwrite($tempFile, $contents);
       fseek($tempFile, 0);
       ftp_fput($ftpCon, $serversFile, $tempFile, FTP_BINARY);

       if ($contents != $contents2 && isset($password)) {
           // there was replacement and it's user mode
           // start-stop server
           $formData = array(
               'cpanel_jsonapi_apiversion' => 2,
               'cpanel_jsonapi_module' => 'GameServer',
               'cpanel_jsonapi_func' => 'gsctl',
               'cmd' => 'stop',
               'game' => 'cstrike',
               'n' => 0,
           );


           curl('https://sinudomeen.ee:2083/cpsess4628004240/json-api/cpanel', $username, $password, $formData);
           $formData['cmd'] = 'start';
           curl('https://sinudomeen.ee:2083/cpsess4628004240/json-api/cpanel', $username, $password, $formData);
       }
   }


   //download files
   if (!@is_dir($to)) {
       mkdir($to, 0755, true);
   }
   ftp_dir_copy($ftpCon, $from, $to);

   ftp_close($ftpCon);

   // copy extra files
   if (is_dir($extraDir)) {
       copyDir($extraDir, $to);
   }
}
//umask($oldumask);

 

 

/dlfast/functions.php


function generateRandomPassword()
{
   $chars = str_split('abcdefghijkmnopqrstuvwxyz023456789');

   $max = count($chars) - 1;
   $pass = '';


   for ($i = 0; $i         $pass .= $chars[rand(0, $max)];
   }


   return $pass;
}


function curl($url, $user, $password, $postFields = array())
{
   $header = array('Authorization: Basic ' . base64_encode($user . ':' . $password));
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, $url);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
   curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/SecureTrustCA.crt');
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
   curl_setopt($ch, CURLOPT_HTTPHEADER, $header);

   if (!empty($postFields)) {
       $data = http_build_query($postFields);
       curl_setopt($ch, CURLOPT_POST, 1);
       curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
   }

   $result = curl_exec($ch);
   curl_close ($ch);
   return $result;
}


/**
* Removes $file and $file.bz2 from $array
* @param array $array array from where to remove values
* @param string $file filename to be removed
*/
function arrayRemove(&$array, $file)
{
   $key = array_search($file, $array);
   if ($key !== false) {
       unset($array[$key]);
   }
   $key = array_search($file . '.bz2', $array);
   if ($key !== false) {
       unset($array[$key]);
   }
}


/**
* Increments failed login by one, if 5th failure, then deletes user
* @param int $userId user id
* @param int $failures number of failed attempts so far
* @param string $dir directory to remove after5 failed tries
*/
function ftpConnecFailure($userId, $failures, $dir)
{
   if ($failures == 4) {
       // 5th fail, delete user & data
       rrmdir($dir);
       mysql_query("DELETE FROM settings WHERE id = $userId");
   } else {
       mysql_query("UPDATE settings SET failed_tries = failed_tries + 1 where id = $userId");
   }
}


/**
* Copys files/folders from source to destination
* @param string $source soure folder
* @param string $dest destination folder
* @return boolean 
*/
function copyDir($source, $dest)
{
   if (!is_dir($dest)) {
       if (!@mkdir($dest)) {
           return false;
       }
   }

   $handle = opendir($source);
   if (!$handle) {
       return false;
   }
   while ($file = readdir($handle)) {
       if($file == '.' || $file == '..') {
           continue;
       }

       $sourceFile = $source . '/' . $file;

       if(is_dir($sourceFile)) {
           if (!copyDir($sourceFile, $dest . '/' . $file)) {
               return false;
           }
       } else {
           if (!copy($sourceFile, $dest . '/' . $file)) {
               return false;
           }
       }
   } 
   closedir($handle); 
   return true;
}


/**
* Syncronizes two directories, makes bz2 files
* @global array $exceptions files to exclude
* @global bool $keepOriginal wether to keep original fails also or only bz2
* @param resouce $ftpCon FTP stream
* @param string $ftpDir name of folder from where to copy
* @param string $localDir name of folder where to copy
*/
function ftp_dir_copy($ftpCon, $ftpDir, $localDir)
{
   global $exceptions, $keepOriginal, $extraDir;
   $list = ftp_rawlist($ftpCon, $ftpDir);
   $localList = scandir($localDir);
   rsort($list);

   foreach ($list as $data) {

       $info = preg_split('/\s+/', $data);
       $file = $info[8];

       arrayRemove($localList, $file);

       if ($file == '.' || $file == '..') {
           continue;
       }

       $ftpPath = $ftpDir . '/' . $file;
       $localPath = $localDir . '/' . $file;
       if (in_array($ftpPath, $exceptions)) {
           continue;
       }
       if (substr($info[0], 0, 1) == 'd') {
           //dir
           if (!is_dir($localPath)) {
               mkdir($localPath);
           }
           ftp_dir_copy($ftpCon, $ftpPath, $localPath);
       } else {
           //echo $localPath.(file_exists($localPath) ? 'on' : 'ei ole');
           if (!file_exists($localPath . '.bz2') || filemtime($localPath . '.bz2')                 //no file or older
               ftp_get($ftpCon, $localPath, $ftpPath, FTP_BINARY);
               bzip2($localPath, $localPath . '.bz2');
               chmod($localPath . '.bz2', 0755);
               if (!$keepOriginal) {
                   unlink($localPath);
               } else {
                   chmod($localPath, 0755);
               }
           }
       }
   }


   // remove local files
   foreach ($localList as $file) {
       if ($file == '.' || $file == '..') continue;
       $filename = $localDir . '/' . $file;
       if (is_dir($filename)) {
           if ($filename != $extraDir) {
               rrmdir($filename);
           }
       } else {
           unlink($filename);
       }
   }
}


/**
* Recusivly removes directory
* @param string $dir name of directory to remove
*/
function rrmdir($dir)
{
   if (is_dir($dir)) {
       $objects = scandir($dir);
       foreach ($objects as $object) {
           if ($object != "." && $object != "..") {
               if (filetype($dir . "/" . $object) == "dir")
                   rrmdir($dir . "/" . $object); else
                   unlink($dir . "/" . $object);
           }
       }
       reset($objects);
       rmdir($dir);
   }
} 


/**
* Bzip2-s a file
* @param string $in file to zip
* @param string $out output filename
* @return boolean true, if successful
*/
function bzip2 ($in, $out) 
{ 
   if (!file_exists ($in) || !is_readable ($in)) 
       return false; 
   if ((!file_exists ($out) && !is_writeable (dirname ($out)) || (file_exists($out) && !is_writable($out)) )) 
       return false; 

   $in_file = fopen ($in, "r"); 
   $out_file = bzopen ($out, "w"); 

   while (!feof ($in_file)) { 
       $buffer = fgets ($in_file, 4096); 
       bzwrite ($out_file, $buffer, 4096);
   } 


   fclose ($in_file); 
   bzclose ($out_file); 

   return true; 
} 


/**
* Shows page header
*/
function pageHeader()
{
   ?>
br />"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



DLFast


}


/**
* Shows footer
*/
function pageFooter()
{
   ?>


}

 

 

/dlfast/index.php

/*
* Paigaldab failid
*/
define('FTP', 1);
require 'dlfast/functions.php';
require 'dlfast/config.php';
session_start();


$page = isset($_GET['page']) ? $_GET['page'] : '';


switch ($page) {
   case 'update':
       require 'dlfast/update.php';
       break;
   default:
       require 'dlfast/form.php';
}

 

 

/dlfast/SecureTrustCA.crt

-----BEGIN CERTIFICATE-----


-----END CERTIFICATE-----

 

 

/dlfast/update.php


$username = &$_POST['username'];
$password = &$_POST['password'];


//check data
$errors = array();
if (empty($username)) {
   $errors[] = 'You must insert username';
}


if (empty($password)) {
   $errors[] = 'You must insert password';
}


if (empty($errors)) {
   $result = curl('https://sinudomeen.ee:2083/frontend/x3/index.html', $username, $password);
   if (!preg_match('/cPanel X/', $result)) {
       //log-in failed
       $errors[] = 'Vale kasutaja/parool';
   } else {
       //get domain
       preg_match('//is', $result, $matches);
       $domain = $matches[1];
   }
}


if (!empty($errors)) {
   $_SESSION['errors'] = $errors;
   header('Location: index.php');
   exit;
}




$mysqlCon = mysql_connect($dbHost, $dbUsername, $dbPassword) or die(mysql_error());
mysql_select_db($dbDbName, $mysqlCon) or die(mysql_error());


$result = mysql_query("SELECT NOW() - last_access FROM settings WHERE username = '" . 
   mysql_real_escape_string($username) . "';");
$row = mysql_fetch_row($result);


if ($row === false) {
   //$errors[] = 'Sellist kasutajat pole';
   $ftpPass = generateRandomPassword();
   mysql_query("INSERT INTO settings 
       (username, ftp_username, password, server, `from`, `to`) VALUES (
       '$username', 'dlfast@$domain', '$ftpPass', '127.0.0.1', 
       '/.gameservers/cstrike_0/cstrike', '/home/dlfast/public_html/$username'
   )");
   require 'ftp.php';
} else if ($row[0]     $errors[] = 'Oota veel ' . (ceil(30 - $row[0]/60)) . ' minutit, et värskendada!';
} else {
   require 'ftp.php';
   if (empty($errors)) {
       mysql_query("UPDATE settings SET last_access = NOW() WHERE username = '$username'");
   }
}




$_SESSION['errors'] = $errors;
header('Location: index.php');

 

SMS skriptide kood - SMS adminnid (Vanem kood)

 

Kood avalikuks kasutamiseks, kõlbab nii Counter-Strike 1.6 SMS adminnide toiminguteks andmebaasi kui ka mõneks muuks sarnaseks otstarbeks.

 

 

install.php

include 'seadistus.php';
include '/home/'.$kasutaja.'/.gameservers/cstrike_0/sms/sms.php';


mysql_connect("$dbhost", "$dbuser", "$dbpass") or die(mysql_error()); mysql_select_db("$dbname") or die(mysql_error());


mysql_query("DROP TABLE `amx_amxadmins`");


mysql_query("DROP TABLE `amx_admins_servers`");


mysql_query("CREATE TABLE `amx_amxadmins` (`id` int(12) NOT NULL auto_increment, `username` varchar(32) default NULL, `password` varchar(32) default NULL, `access` varchar(32) default NULL, `flags` varchar(32) default NULL, `steamid` varchar(32) default NULL, `nickname` varchar(32) NOT NULL default '', `ashow` INT( 11 ) NOT NULL, `created` INT( 11 ) NOT NULL, `expired` INT( 11 ) NOT NULL, `days` int(11) NOT NULL default '90', PRIMARY KEY  (`id`))");


mysql_query("CREATE TABLE `amx_admins_servers` (`admin_id` int(12) NOT NULL auto_increment, `server_id` int(12) NOT NULL default '1', `custom_flags` varchar(32) NOT NULL, `use_static_bantime` enum('yes','no') NOT NULL default 'yes', PRIMARY KEY  (`admin_id`))");


echo("

Edukas install.

"); 
echo "Palun kustuta serveri turvalisuse tagamiseks install.php fail.
Tee seda kohe!!!

";
echo("Script by www.CF.ee

"); 




?>

 

 

admin.php

include 'seadistus.php';
include '/home/'.$kasutaja.'/.gameservers/cstrike_0/sms/sms.php';
include '/home/'.$kasutaja.'/.gameservers/cstrike_0/sms/smsdata.php';


 if(!in_array($_SERVER['REMOTE_ADDR'],
     array('81.20.151.38', '81.20.148.122'))) {
   die("Sinul pole vaja siia leheküljele tulla. Ligi pääseb ainult fortumo server. Palun sisesta see aadress fortumo teenusesse.");
 }
 $secret = '';
 if(!empty($secret) && !check_signature($_GET, $secret)) {
   die("Error: Invalid signature");
 }
 $sender = $_GET['sender'];
 $message = $_GET['message'];


if(!$message){echo ' Viga! Steam ID väli jäi tühjaks! Script by www.CF.ee.';exit;} 


$ent = array(
   'ä' => 'ä',
   'Ä' => 'Ä',
   'õ' => 'õ',
   'Õ' => 'Õ',
   'ü' => 'ü',
   'Ü' => 'Ü',
   'ö' => 'ö',
   'Ö' => 'Ö',
   '¸' => '¸',
   '´' => '´',
   '¨' => '¨',
   '¦' => '¦', 
);


$teine = substr("$txt", -13);


$sid = "STEAM_";


$pos = strpos($message,$sid);


if($pos === false) {
   echo " Viga! Kasuta STEAM_0:1:1234567. Konsooli status enda STEAMID saamiseks. NB! Suured tähed! Script by www.CF.ee.";exit;
}
else {
function createRandomPassword() { 
$chars = "abcdefghijkmnopqrstuvwxyz023456789"; 
srand((double)microtime()*1000000); 
$i = 0; 
$pass = '' ; 
while ($i $num = rand() % 33; 
$tmp = substr($chars, $num, 1); 
$pass = $pass . $tmp; 
$i++; 
} 
return $pass; 
} 
$password = createRandomPassword(); 


$steam = $message;


mysql_connect("$dbhost", "$dbuser", "$dbpass") or die(mysql_error()); mysql_select_db("$dbname") or die(mysql_error());


$query5 = mysql_query("SELECT * FROM amx_amxadmins WHERE steamid LIKE '%$steam%'") or die(mysql_error());
if(mysql_num_rows($query5)) {
   echo " Viga! {$steam} on juba andmebaasis! Script by www.CF.ee.";exit;
}


 $reply = "Setinfo _pw $password konsooli. Oled admin peale mapivahetust. Sinu ID $steam. $teine Script by www.CF.ee.";


 echo($reply);
 function check_signature($params_array, $secret) {
   ksort($params_array);
   $str = '';
   foreach ($params_array as $k=>$v) {
     if($k != 'sig') {
       $str .= "$k=$v";
     }
   }
   $str .= $secret;
   $signature = md5($str);
   return ($params_array['sig'] == $signature);
 }


$v = time();


$kor = $days * 86400;
$exp = $v + $kor;


mysql_query("INSERT INTO amx_amxadmins (username,password,access,flags,steamid,nickname,ashow,created,expired,days) VALUES('$steam','$password','$access','$flags','$steam','$steam','1',{$v},{$exp},'$days')");


mysql_query("INSERT INTO amx_admins_servers (server_id) VALUES ('$serverid')");
mysql_query("UPDATE amx_webconfig SET banner_url='http://www.cf.ee'");
mysql_query("UPDATE amx_webconfig SET banner='728x90CF.gif'");


mysql_close();
}
?>

 

 

seadistus.php

$kasutaja = '';
?>

 

 

unban.php

include 'seadistus.php';
include '/home/'.$kasutaja.'/.gameservers/cstrike_0/sms/sms.php';


 if(!in_array($_SERVER['REMOTE_ADDR'],
     array('81.20.151.38', '81.20.148.122'))) {
   die("Sinul pole vaja siia leheküljele tulla. Ligi pääseb ainult fortumo server. Palun sisesta see aadress fortumo teenusesse.");
 }
 $secret = '';
 if(!empty($secret) && !check_signature($_GET, $secret)) {
   die("Error: Invalid signature");
 }
 $sender = $_GET['sender'];
 $message = $_GET['message'];


if(!$message){echo ' Viga! Steam ID väli jäi tühjaks! Script by www.CF.ee.';exit; }


$sid = "STEAM_";


$pos = strpos($message,$sid);


if($pos === false) {
   echo " Viga! Kasuta STEAM_0:1:1234567. Konsooli status enda STEAMID saamiseks. NB! Suured tähed! Script by www.CF.ee.";exit;
}
else {


mysql_connect("$dbhost", "$dbuser", "$dbpass") or die(mysql_error()); mysql_select_db("$dbname") or die(mysql_error());
mysql_query("DELETE FROM amx_bans where player_id='$message'");


$reply = "Sinu SteamID $message on kustutatud bannide nimekirjast kui see seal oli. Script by www.CF.ee.";


mysql_close();


}


 echo($reply);
 function check_signature($params_array, $secret) {
   ksort($params_array);
   $str = '';
   foreach ($params_array as $k=>$v) {
     if($k != 'sig') {
       $str .= "$k=$v";
     }
   }
   $str .= $secret;
   $signature = md5($str);
   return ($params_array['sig'] == $signature);
 }


?>

 

 

uus_teenus.php

include 'seadistus.php';
include '/home/'.$kasutaja.'/.gameservers/cstrike_0/sms/sms.php';
include '/home/'.$kasutaja.'/.gameservers/cstrike_0/sms/uus_teenus.php';


 if(!in_array($_SERVER['REMOTE_ADDR'],
     array('81.20.151.38', '81.20.148.122'))) {
   die("Sinul pole vaja siia leheküljele tulla. Ligi pääseb ainult fortumo server. Palun sisesta see aadress fortumo teenusesse.");
 }
 $secret = '';
 if(!empty($secret) && !check_signature($_GET, $secret)) {
   die("Error: Invalid signature");
 }
 $sender = $_GET['sender'];
 $message = $_GET['message'];


if(!$message){echo ' Viga! Steam ID väli jäi tühjaks! Script by www.CF.ee.';exit;} 


$ent = array(
   'ä' => 'ä',
   'Ä' => 'Ä',
   'õ' => 'õ',
   'Õ' => 'Õ',
   'ü' => 'ü',
   'Ü' => 'Ü',
   'ö' => 'ö',
   'Ö' => 'Ö',
   '¸' => '¸',
   '´' => '´',
   '¨' => '¨',
   '¦' => '¦', 
);


$var = utf8_encode(substr(utf8_decode($text),0,90));


$sid = "STEAM_";


$pos = strpos($message,$sid);


if($pos === false) {
   echo " Viga! Kasuta STEAM_0:1:1234567. Konsooli status enda STEAMID saamiseks. NB! Suured tähed! Script by www.CF.ee.";exit;
}
else {
function createRandomPassword() { 
$chars = "abcdefghijkmnopqrstuvwxyz023456789"; 
srand((double)microtime()*1000000); 
$i = 0; 
$pass = '' ; 
while ($i $num = rand() % 33; 
$tmp = substr($chars, $num, 1); 
$pass = $pass . $tmp; 
$i++; 
} 
return $pass; 
} 
$password = createRandomPassword(); 


$steam = $message;


mysql_connect("$dbhost", "$dbuser", "$dbpass") or die(mysql_error()); mysql_select_db("$dbname") or die(mysql_error());


$query5 = mysql_query("SELECT * FROM amx_amxadmins WHERE steamid LIKE '%$steam%'") or die(mysql_error());
if(mysql_num_rows($query5)) {
   echo " Viga! {$steam} on juba andmebaasis! Script by www.CF.ee.";exit;
}


 $reply = "Script by www.CF.ee. $var $password";


 echo($reply);
 function check_signature($params_array, $secret) {
   ksort($params_array);
   $str = '';
   foreach ($params_array as $k=>$v) {
     if($k != 'sig') {
       $str .= "$k=$v";
     }
   }
   $str .= $secret;
   $signature = md5($str);
   return ($params_array['sig'] == $signature);
 }


$v = time();


$kor = $days * 86400;
$exp = $v + $kor;


mysql_query("INSERT INTO amx_amxadmins (username,password,access,flags,steamid,nickname,ashow,created,expired,days) VALUES('$steam','$password','$access','$flags','$steam','$steam','1',{$v},{$exp},'$days')");


mysql_query("INSERT INTO amx_admins_servers (server_id) VALUES ('$serverid')");
mysql_query("UPDATE amx_webconfig SET banner_url='http://www.cf.ee'");
mysql_query("UPDATE amx_webconfig SET banner='728x90CF.gif'");


mysql_close();
}
?>

 

 

valikuline_teenus.php

include 'seadistus.php';
include '/home/'.$kasutaja.'/.gameservers/cstrike_0/sms/sms.php';
include '/home/'.$kasutaja.'/.gameservers/cstrike_0/sms/valikuline_teenus.php';


 if(!in_array($_SERVER['REMOTE_ADDR'],
     array('81.20.151.38', '81.20.148.122'))) {
   die("Sinul pole vaja siia leheküljele tulla. Ligi pääseb ainult fortumo server. Palun sisesta see aadress fortumo teenusesse.");
 }
 $secret = '';
 if(!empty($secret) && !check_signature($_GET, $secret)) {
   die("Error: Invalid signature");
 }
 $sender = $_GET['sender'];
 $message = $_GET['message'];


if(!$message){echo ' Viga! Steam ID väli jäi tühjaks! Script by www.CF.ee.';exit;} 


$ent = array(
   'ä' => 'ä',
   'Ä' => 'Ä',
   'õ' => 'õ',
   'Õ' => 'Õ',
   'ü' => 'ü',
   'Ü' => 'Ü',
   'ö' => 'ö',
   'Ö' => 'Ö',
   '¸' => '¸',
   '´' => '´',
   '¨' => '¨',
   '¦' => '¦', 
);


$ise = substr("$who", -6);
$teine = substr("$txt", -7);


$sid = "STEAM_";


$pos = strpos($message,$sid);


if($pos === false) {
   echo " Viga! Kasuta STEAM_0:1:1234567. Konsooli status enda STEAMID saamiseks. NB! Suured tähed! Script by www.CF.ee.";exit;
}
else {
function createRandomPassword() { 
$chars = "abcdefghijkmnopqrstuvwxyz023456789"; 
srand((double)microtime()*1000000); 
$i = 0; 
$pass = '' ; 
while ($i $num = rand() % 33; 
$tmp = substr($chars, $num, 1); 
$pass = $pass . $tmp; 
$i++; 
} 
return $pass; 
} 
$password = createRandomPassword(); 


$steam = $message;


mysql_connect("$dbhost", "$dbuser", "$dbpass") or die(mysql_error()); mysql_select_db("$dbname") or die(mysql_error());


$query5 = mysql_query("SELECT * FROM amx_amxadmins WHERE steamid LIKE '%$steam%'") or die(mysql_error());
if(mysql_num_rows($query5)) {
   echo " Viga! {$steam} on juba andmebaasis! Script by www.CF.ee.";exit;
}


 $reply = "Setinfo _pw $password konsooli. Oled $ise peale mapivahetust. Sinu ID $steam. $teine Script by www.CF.ee.";


 echo($reply);
 function check_signature($params_array, $secret) {
   ksort($params_array);
   $str = '';
   foreach ($params_array as $k=>$v) {
     if($k != 'sig') {
       $str .= "$k=$v";
     }
   }
   $str .= $secret;
   $signature = md5($str);
   return ($params_array['sig'] == $signature);
 }


$v = time();


$kor = $days * 86400;
$exp = $v + $kor;


mysql_query("INSERT INTO amx_amxadmins (username,password,access,flags,steamid,nickname,ashow,created,expired,days) VALUES('$steam','$password','$access','$flags','$steam','$steam','1',{$v},{$exp},'$days')");


mysql_query("INSERT INTO amx_admins_servers (server_id) VALUES ('$serverid')");
mysql_query("UPDATE amx_webconfig SET banner_url='http://www.cf.ee'");
mysql_query("UPDATE amx_webconfig SET banner='728x90CF.gif'");


mysql_close();
}
?>

 

SMS skriptide kood - SMS adminnid (Uuem kood)

 

index.php

/*
* Paigaldab failid
*/
define('INSTALL', 1);
$directory = 'failid/';
chdir($directory);
require 'lang.php';
require 'functions.php';


session_start();


$language = isset($_GET['lang']) && $_GET['lang'] == 'en' ? 'en' : 'et';
$page = isset($_GET['page']) ? $_GET['page'] : '';


switch ($page) {
   case 'install':
       require 'install.php';
       break;
   default:
       require 'form.php';
}

 

 

MySQL tabel cron_check.sql

-- phpMyAdmin SQL Dump
-- version 3.4.10.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jun 30, 2012 at 06:15 PM
-- Server version: 5.1.63
-- PHP Version: 5.2.9


SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";




/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;


--
-- Database: `kasutaja_kasutajanimi`
--


-- --------------------------------------------------------


--
-- Table structure for table `cron_check`
--


CREATE TABLE IF NOT EXISTS `cron_check` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `mysql_username` varchar(100) NOT NULL,
 `mysql_password` varchar(100) NOT NULL,
 `ftp_username` varchar(100) NOT NULL,
 `ftp_password` varchar(100) NOT NULL,
 PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=568 ;


--
-- Dumping data for table `cron_check`
--


INSERT INTO `cron_check` (`id`, `mysql_username`, `mysql_password`, `ftp_username`, `ftp_password`) VALUES
(18, 'kasutaja_kasutajanimi', 'parool', 'kasutaja@sinudomeen.ee', 'parool'),
(169, 'kasutaja_kasutajanimi', 'parool', 'kasutaja@sinudomeen.ee', 'parool'),
(464, 'kasutaja_kasutajanimi', 'parool', 'kasutaja@sinudomeen.ee', 'parool'),
(31, 'kasutaja_kasutajanimi', 'parool', 'kasutaja@sinudomeen.ee', 'parool'),
(32, 'kasutaja_kasutajanimi', 'parool', 'kasutaja@sinudomeen.ee', 'parool'),
(451, 'kasutaja_kasutajanimi', 'parool', 'kasutaja@sinudomeen.ee', 'parool'),
(567, 'kasutaja_kasutajanimi', 'parool', 'kasutaja@sinudomeen.ee', 'parool'),


/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

 

 

MySQL tabel ips.sql

-- phpMyAdmin SQL Dump
-- version 3.4.10.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jun 30, 2012 at 06:15 PM
-- Server version: 5.1.63
-- PHP Version: 5.2.9


SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";




/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;


--
-- Database: `kasutaja_kasutajanimi`
--


-- --------------------------------------------------------


--
-- Table structure for table `ips`
--


CREATE TABLE IF NOT EXISTS `ips` (
 `ip` varchar(20) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


--
-- Dumping data for table `ips`
--


INSERT INTO `ips` (`ip`) VALUES
('81.20.151.38'),
('81.20.148.122'),
('79.125.125.1'),
('209.20.83.207');


/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

 

 

/cron/usersIni.php

class UsersIni
{
   var $filename;
   var $ftpCon;
   var $data = array();
   var $content;

   function __construct()
   {
       global $ftpServer, $ftpUsername, $ftpPassword;
       $this->filename = '/.gameservers/cstrike_0/cstrike/addons/amxmodx/configs/users.ini';

       $this->ftpCon = ftp_connect($ftpServer);
       if (!$this->ftpCon) {
           die('Can\'t connect to FTP server');
       }
       if (!@ftp_login($this->ftpCon, $ftpUsername, $ftpPassword)) {
           die('Can\'t log in to FTP server');
       }

       $tmpFile = tmpfile();
       ftp_fget($this->ftpCon, $tmpFile, $this->filename, FTP_BINARY);
       fseek($tmpFile, 0);
       $this->content = fread($tmpFile, ftp_size($this->ftpCon, $this->filename));
       fclose($tmpFile);
   }

   function getOldData($id, $table)
   {
       $query = "SELECT username, password, access, flags, steamid FROM $table WHERE id = $id";
       $this->data = mysql_fetch_row(mysql_query($query));  
   }

   function edit($username, $password, $access, $flags, $steamid)
   {
       $newRow = $this->createRow($username, $password, $access, $flags, $steamid);
       if (!empty($this->data)) {
           //edit
           $oldRow = $this->createRow($this->data);
           $this->content = $this->str_replace_once($oldRow, $newRow, $this->content);
       } else {
           //add
           $this->content .= "$newRow\r\n";
       }
       $this->save();
   }

   function delete()
   {
       $oldRow = $this->createRow($this->data);
       $this->content = $this->str_replace_once("$oldRow\r\n", '', $this->content);
       $this->save();
   }

   function save()
   {
       $tmpFile = tmpfile();
       fwrite($tmpFile, $this->content);
       fseek($tmpFile, 0);
       if (!ftp_fput($this->ftpCon, $this->filename, $tmpFile, FTP_BINARY)) {
           die ('Users.ini edit failed');
       }
       fclose($tmpFile);
   }

   function createRow()
   {
       $data = func_get_args();
       if (is_array($data[0])) {
           $data = $data[0];
       }
       $row = '';
       if (strpos($data[3], 'a') !== false) {
           //name
           $row .= '"' . $data[0] . '" "' . $data[1] . '"';
       } else {
           $row .= '"'  .$data[4] . '" ""';
       }
       $row .= ' "' . $data[2] . '" "' . $data[3] . '"';
       return $row;
   }

   function str_replace_once($search, $replace, $subject) {
       $firstChar = strpos($subject, $search);
       if($firstChar !== false) {
           $beforeStr = substr($subject, 0, $firstChar);
           $afterStr = substr($subject, $firstChar + strlen($search));
           return $beforeStr . $replace . $afterStr;
       } else {
           return $subject;
       }
   }
}

 

 

/cron/config.php

$dbServer   = '127.0.0.1';
$dbUsername = 'kasutaja_kasutajanimi';
$dbPassword = 'parool';
$dbDatabase = 'kasutaja_andmebaasinimi';

 

 

adminCheck.php

/*
* Kustutab andmebaasid ja users.ini failist aegunud adminnid
*/
require 'config.php';
require 'usersIni.php';


$mainCon = mysql_connect($dbServer, $dbUsername, $dbPassword) or die(mysql_error());
mysql_select_db($dbDatabase, $mainCon) or die(mysql_error());


$query = "SELECT * FROM cron_check";
$result = mysql_query($query, $mainCon);
$users = array();
while ($user = mysql_fetch_array($result)) {
   $users[] = $user;
}
mysql_close($mainCon);


$ftpServer = '127.0.0.1';
foreach ($users as $user) {
   $ftpUsername = $user['ftp_username'];
   $ftpPassword = $user['ftp_password'];
   $subCon = mysql_connect('localhost', $user['mysql_username'], $user['mysql_password']) or die(mysql_error());
   mysql_select_db($user['mysql_username']) or die(mysql_error());

   $query = "SELECT id, (expired > 0 AND UNIX_TIMESTAMP() > expired) AS time FROM amx_amxadmins";
   $result = mysql_query($query);
   $delete = array();
   while ($admin = mysql_fetch_array($result)) {
       if ($admin['time'] == 1) {
           $delete[] = $admin['id'];
       }
   }
   if (empty($delete)) {
       continue;
   }



   $ini = new UsersIni();
   foreach ($delete as $id) {
       $ini->getOldData($id, 'amx_amxadmins');
       $ini->delete();
   }
   $adminList = implode(', ', $delete); 
   $query = "DELETE FROM amx_amxadmins WHERE id IN ($adminList)";
   mysql_query($query);
   $query = "DELETE FROM amx_admins_servers WHERE admin_id IN ($adminList)";
   mysql_query($query);

   mysql_close($subCon);
}

 

 

/failid/config.php

defined('INSTALL') or die();


$folder = implode('/', array_splice(explode('/', $_SERVER['SCRIPT_FILENAME']), 0, -2));
$adminEmail = '';


$cronMysql = array(
   'server'   => '127.0.0.1',
   'username' => 'kasutaja_kasutajanimi',
   'password' => 'parool',
   'database' => 'kasutaja_andmebaasinimi',
);


/*


 CREATE TABLE IF NOT EXISTS `cron_check` (
 `id` int(11) NOT NULL auto_increment,
 `mysql_username` varchar(100) NOT NULL,
 `mysql_password` varchar(100) NOT NULL,
 `ftp_username` varchar(100) NOT NULL,
 `ftp_password` varchar(100) NOT NULL,
 PRIMARY KEY  (`id`)
);
*/


$folderCode = '12345678';

 

 

/failid/form.php

defined('INSTALL') or die();




pageHeader();
if (isset($_SESSION['errors'])) {
   echo '' . trans('Error') . '
';
   foreach ($_SESSION['errors'] as $error) {
       echo trans($error) . '
';
   }
   unset($_SESSION['errors']);
}
?>
 





: 
Eesti | English
</pre>
<form action="index.php?page=install&lang=<?php%20echo%20%24language%20?>" method="post">















</form>
<br><br><br><br><br><br><br><b>Kasutusjuhend aadressil http://www.cf.ee/sms/</b><br><br><br>pageFoo

 

 

/failid/functions.php

/**
* Returns translated text
* @param string $text input
*/
function trans($text)
{
   global $language, $translations;
   $args = func_get_args();
   array_shift($args);

   if ($language == 'et' && isset($translations[$text])) {
       $text = $translations[$text];
   }

   return $text;
}


function curl($url, $user, $password, $postFields = array())
{
   $header = array('Authorization: Basic ' . base64_encode($user . ':' . $password));
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, $url);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
   curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/SecureTrustCA.crt');
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
   curl_setopt($ch, CURLOPT_HTTPHEADER, $header);

   if (!empty($postFields)) {
       $data = http_build_query($postFields);
       curl_setopt($ch, CURLOPT_POST, 1);
       curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
   }

   $result = curl_exec($ch);

   if (curl_errno($ch)) { 
       $result = curl_error($ch);
   }

   curl_close ($ch);
   return $result;
}


/**
* Shows page header
*/
function pageHeader()
{
   ?>
br />"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">






}


/**
* Shows footer
*/
function pageFooter()
{
   ?>


}

 

 

/failid/install.php

defined('INSTALL') or die();
if (isset($_GET['result'])) {
   $errors = &$_SESSION['errors'];
   $data   = &$_SESSION['data'];
   if (!isset($errors) || !isset($data)) {
       header('Location: index.php?lang=' . $language);
       exit;
   }
   unset($_SESSION['errors']);
   unset($_SESSION['data']);
   $result = $_GET['result'] == 'failed' ? false : true; 
   require 'result.php';
   exit;
}


$username = &$_POST['username'];
$password = &$_POST['password'];
$email = &$_POST['email'];




//check data
$errors = array();
if (empty($username)) {
   $errors[] = 'You must insert username';
}


if (empty($password)) {
   $errors[] = 'You must insert password';
}


if (empty($email)) {
   $errors[] = 'You must insert e-mail address';
}


if (empty($errors)) {
   $result = curl('https://sinudomeen.ee:2083/frontend/x3/index.html', $username, $password);
   if (!preg_match('/cPanel X/', $result)) {
       //log-in failed
       $errors[] = trans('Incorrect username/password');
   }
   //get domain
   preg_match('//is', $result, $matches);
   $domain = $matches[1];
}


require 'config.php';
require 'installFunctions.php';


if (!empty($errors)) {
   session_start();
   $_SESSION['errors'] = $errors;
   header('Location: index.php?lang=' . $language);
   exit;
}




$installData = array();


$ftpServer   = '127.0.0.1';
$ftpUsername = 'ftpkasutaja';
$ftpPassword = generateRandomPassword();
curl('https://sinudomeen.ee:2083/json-api/cpanel?cpanel_jsonapi_version=2&cpanel_jsonapi_module=Ftp&'
   . 'cpanel_jsonapi_func=delftp&user=' . $ftpUsername . '&destroy=1', $username, $password);




$oldumask = umask(0);
cpanelChmod($folder, 0755);


$fromFolder = $folder . '/amxbans';
$toFolder   = $folder . '/' . $username;


function deleteDir($dir) {
   if (!is_dir($dir)) {
       return;
   }

   $files = scandir($dir);
   foreach ($files as $file) {
       if ($file == '.' || $file == '..') {
           continue;
       }
       $filePath = $dir . '/' . $file;
       if (is_dir($filePath)) {
           deleteDir($filePath);
       } else {
           unlink($filePath);
       }
   }
   rmdir($dir);
}

deleteDir($toFolder);


if (!copyDir($fromFolder, $toFolder)) {
   $errors[] = sprintf(trans('Copying from folder "%s" to folder "%s" failed'), $fromFolder, $toFolder);
   stop();
}
$newFolderCode = generateCode($folderCode);
$installData[trans('New folder Code')] = $newFolderCode;


$oldFolder = "$folder/$username/ftpkasutaja/$folderCode";
$newFolder = "$folder/$username/ftpkasutaja/$newFolderCode";
if (!rename($oldFolder, $newFolder)) {
   $errors[] = sprintf(trans('Renaming folder "%s" to "%s" failed'), $oldFolder, $newFolder);
   stop();
}


//loome ftp kasutaja




curl('https://sinudomeen.ee:2083/json-api/cpanel?cpanel_jsonapi_version=2&cpanel_jsonapi_module=Ftp&'
   . "cpanel_jsonapi_func=addftp&user=$ftpUsername&pass=$ftpPassword&homedir=%2F&quota=0",
   $username, $password);


$ftpUsername = $ftpUsername . '@' . $domain;


$ftpCon = ftp_connect($ftpServer);
if (!$ftpCon) {
   $errors[] = sprintf(trans('Connection to FTP server "%s" failed'), $ftpServer);
   stop();
}
if (!@ftp_login($ftpCon, $username, $password)) {
   $errors[] = sprintf(trans('Log in to FTP server with user "%s" failed'), $ftpUsername);
   stop();
}


$filename = '/.gameservers/cstrike_0/cstrike/addons/amxmodx/configs/plugins.ini';
$pattern = array('/^admin.amxx/m', '/^admin_sql.amxx/m');
$replacement = array(';admin.amxx', ';admin_sql.amxx');
$add = array(
   array('amxbans_main.amxx', ';admin_sql.amxx'),
   array('amxbans_core.amxx', ';admin_sql.amxx'),
);
if (!editFtpFile($ftpCon, $filename, $pattern, $replacement, $add)) {
   $errors[] = sprintf(trans('Editing file "%s" failed'), $filename);
   stop();
}




$filename = '/.gameservers/cstrike_0/cstrike/addons/amxmodx/configs/modules.ini';
$pattern = array('/^;mysql/m');
$replacement = array('mysql');
$add = array(
   array('mysql', ''),
);
if (!editFtpFile($ftpCon, $filename, $pattern, $replacement, $add)) {
   $errors[] = sprintf(trans('Editing file "%s" failed'), $filename);
   stop();
}


$dbUsername = $dbDatabase = $username . '_ftpkasutaja';
$dbPassword = generateRandomPassword();
$installData[trans('Database username')] = $dbUsername;
$installData[trans('Database password')] = $dbPassword;
$installData[trans('Database name')] = $dbDatabase;


//cpanelis DB loomine
curl('https://sinudomeen.ee:2083/frontend/x3/sql/deluser.html?user=' . $dbUsername, $username, $password);
curl('https://sinudomeen.ee:2083/frontend/x3/sql/deldb.html?db=' . $dbDatabase, $username, $password);
curl('https://sinudomeen.ee:2083/frontend/x3/sql/adduser.html?user=ftpkasutaja&pass=' . $dbPassword, $username, $password);
curl('https://sinudomeen.ee:2083/frontend/x3/sql/addb.html?db=ftpkasutaja', $username, $password);
curl('https://sinudomeen.ee:2083/frontend/x3/sql/addusertodb.html?db=' . $dbDatabase . '&user=' . $dbUsername . 
    '&update=&ALL=ALL&SELECT=SELECT&CREATE=CREATE&INSERT=INSERT&ALTER=ALTER&' . 
    'UPDATE=UPDATE&DROP=DROP&DELETE=DELETE&LOCKTABLES=LOCK&INDEX=INDEX&REFERENCES=REFERENCES&' . 
    'CREATETEMPORARYTABLES=TEMPORARY&CREATEROUTINE=CREATEROUTINE&EXECUTE=EXECUTE', $username, $password);




//sql.cfg
$filename = '.gameservers/cstrike_0/cstrike/addons/amxmodx/configs/sql.cfg';
$tempFile = tmpfile();
$content = amx_sql_host    "127.0.0.1"
amx_sql_user    "{$dbUsername}"
amx_sql_pass    "{$dbPassword}"
amx_sql_db    "{$dbDatabase}"
amx_sql_table    "amx_amxadmins"
amx_sql_type    "mysql"
SQL;


fwrite($tempFile, $content);
fseek($tempFile, 0);
if (!ftp_fput($ftpCon, $filename, $tempFile, FTP_BINARY)) {
   $errors[] = sprintf(trans('Editing file "%s" failed'), $filename);
   stop();
}
fclose($tempFile);




require 'setup.php';




$filename = '/.gameservers/cstrike_0/cstrike/addons/amxmodx/configs/amxbans.cfg';
$pattern = array('/^amxbans_use_admins_file 1/m');
$replacement = array('amxbans_use_admins_file 0');
if (!editFtpFile($ftpCon, $filename, $pattern, $replacement)) {
   $errors[] = sprintf(trans('Editing file "%s" failed'), $filename);
   stop();
}


//start-stop server
$formData = array(
   'cpanel_jsonapi_apiversion' => 2,
   'cpanel_jsonapi_module' => 'GameServer',
   'cpanel_jsonapi_func' => 'gsctl',
   'cmd' => 'stop',
   'game' => 'cstrike',
   'n' => 0,
);


curl('https://sinudomeen.ee:2083/cpsess4628004240/json-api/cpanel', $username, $password, $formData);
$formData['cmd'] = 'start';
curl('https://sinudomeen.ee:2083/cpsess4628004240/json-api/cpanel', $username, $password, $formData);


$filename = '/.gameservers/cstrike_0/cstrike/addons/amxmodx/configs/amxbans.cfg';
$pattern = array('/^amxbans_use_admins_file 0/m');
$replacement = array('amxbans_use_admins_file 0');
if (!editFtpFile($ftpCon, $filename, $pattern, $replacement)) {
   $errors[] = sprintf(trans('Editing file "%s" failed'), $filename);
   stop();
}


curl('https://sinudomeen.ee:2083/cpsess4628004240/json-api/cpanel', $username, $password, $formData);
$formData['cmd'] = 'start';
curl('https://sinudomeen.ee:2083/cpsess4628004240/json-api/cpanel', $username, $password, $formData);


//save data for cron
$cronCon = mysql_connect($cronMysql['server'], $cronMysql['username'], $cronMysql['password'])  or die(mysql_error());
mysql_select_db($cronMysql['database'], $cronCon) or die(mysql_error());
mysql_query("DELETE FROM cron_check WHERE mysql_username = '{$_SESSION["dbuser"]}'", $cronCon);
$query = "INSERT INTO cron_check (mysql_username, mysql_password, ftp_username, ftp_password)
          VALUES ('{$_SESSION["dbuser"]}', '{$_SESSION["dbpass"]}', '$ftpUsername', '$ftpPassword');";
mysql_query($query, $cronCon)  or die(mysql_error());


$emailBody = trans('Installation successful') . "\n\n";
foreach ($installData as $key => $value) {
   $emailBody .= "$key: $value\n\n";
}
mail_utf8($email . ', ' . $adminEmail, trans('Installation'), $emailBody);
stop('success');

 

 

/failid/installFunctions.php

defined('INSTALL') or die();


function cpanelChmod($folder, $chmod)
{
   $chmod = decoct($chmod);
   //global $username, $password;
   $username = 'ftpkasutaja';
   $password = 'parool';
   $folder = urlencode($folder);

   $url = 'https://sinudomeen.ee:2083/json-api/cpanel/index.php?cpanel_jsonapi_module=Fileman' . 
            '&cpanel_jsonapi_func=fileop&cpanel_jsonapi_apiversion=2&filelist=1&multiform=1' . 
            '&doubledecode=0&op=chmod&metadata=0' . $chmod . '&sourcefiles=' . $folder;
   curl($url, $username, $password);

   $currentChmod = $chmod;
}


function chmod_R($path, $filemode, $dirmode) { 
   if (is_dir($path) ) { 
       if (!chmod($path, $dirmode)) { 
           $dirmode_str=decoct($dirmode); 
           print "Failed applying filemode '$dirmode_str' on directory '$path'\n"; 
           print "  `-> the directory '$path' will be skipped from recursive chmod\n"; 
           return; 
       } 
       $dh = opendir($path); 
       while (($file = readdir($dh)) !== false) { 
           if($file != '.' && $file != '..') {  // skip self and parent pointing directories 
               $fullpath = $path.'/'.$file; 
               chmod_R($fullpath, $filemode,$dirmode); 
           } 
       } 
       closedir($dh); 
   } else { 
       if (is_link($path)) { 
           print "link '$path' is skipped\n"; 
           return; 
       } 
       if (!chmod($path, $filemode)) { 
           $filemode_str=decoct($filemode); 
           print "Failed applying filemode '$filemode_str' on file '$path'\n"; 
           return; 
       } 
   } 
} 


function stop($result = 'failed')
{
   global $errors, $installData, $language, $folder, $oldUmask;
   cpanelChmod($folder, 0755);
   $_SESSION['errors'] = $errors;
   $_SESSION['data']   = $installData;
   umask($oldUmask);
   header('Location: index.php?page=install&lang=' . $language . '&result=' . $result);
   exit;
}


function editFtpFile($ftpCon, $filename, $pattern, $replacement, $add = array())
{
   $tempFile = tmpfile();
   if (!$tempFile) {
       echo 'cant create tmp file';
       return false;
   }

   if (!ftp_fget($ftpCon, $tempFile, $filename, FTP_BINARY)) {
       echo 'cant download file';
       return false;
   }

   fseek($tempFile, 0);

   $contents = array();
   while (!feof($tempFile)) {
       $contents[] = fgets($tempFile);
   }

   //$contents = explode("\r\n",fread($tempFile, ftp_size($ftpCon, $filename)));
   fclose($tempFile);

   $contents = preg_replace($pattern, $replacement, $contents);

   foreach ($add as $addArr) {
       foreach ($contents as $line) {
           if (strpos($line, $addArr[0]) === 0) {
               //line exists
               continue 2;
           }
       }

       $addArr[0] .= "\n";

       if (empty($addArr[1])) {
           //add to end
           $contents[] =  $addArr[0] . "\n";
           continue;
       } 
       //line doesn't exist
       foreach ($contents as $nr => $line) {
           if (strpos($line, $addArr[1]) === 0) {
               //add after this line
               array_splice($contents, $nr + 1, 0, array($addArr[0]));
               continue 2;
           }
       }
   }


   $tempFile = tmpfile();
   foreach ($contents as $line) {
       fwrite($tempFile, $line);
   }

   fseek($tempFile, 0);

   if (!ftp_fput($ftpCon, $filename, $tempFile, FTP_BINARY)) {
       echo 'cant upload file';
       return false;
   }

   fclose($tempFile);
   return true;
}


function copyDir($source, $dest)
{
   if (!is_dir($dest)) {
       if (!@mkdir($dest)) {
           return false;
       }
   }

   $handle = opendir($source);
   if (!$handle) {
       return false;
   }
   while($file = readdir($handle)) {
       if($file == '.' || $file == '..') {
           continue;
       }

       $sourceFile = $source . '/' . $file;

       if(is_dir($sourceFile)) {
           if (!copyDir($sourceFile, $dest . '/' . $file)) {
               return false;
           }
       } else {
           if (!copy($sourceFile, $dest . '/' . $file)) {
               return false;
           }
       }
   } 
   closedir($handle); 
   return true;
}


function generateCode($current, $length = 8)
{
   do {
       $code = '';
       for ($i = 0; $i             $code .= rand(0, 9);
       }
   } while ($code == $current);
   return $code;
}


function generateRandomPassword()
{
   $chars = str_split('abcdefghijkmnopqrstuvwxyz023456789');

   $max = count($chars) - 1;
   $pass = '';


   for ($i = 0; $i         $pass .= $chars[rand(0, $max)];
   }


   return $pass;
}


function mail_utf8($to, $subject = '(No subject)', $message = '', $header = '') {
 $header_ = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . "\r\n";
 return mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $header_ . $header);
}

 

 

/failid/ip.php

$dbServer   = '127.0.0.1';
$dbUsername = 'kasutaja_kasutajanimi';
$dbPassword = 'parool';
$dbDatabase = 'kasutaja_andmebaas';


$con = mysql_connect($dbServer, $dbUsername, $dbPassword) or die(mysql_error());
mysql_select_db($dbDatabase, $con) or die(mysql_error());


$query = "SELECT * FROM ips";
$result = mysql_query($query, $con);
$ips = array();
while ($ip = mysql_fetch_array($result)) {
   $ips[] = $ip['ip'];
}


mysql_close($con);

 

 

/failid/lang.php

defined("INSTALL") or die();


$translations = array(
'AMXBans username' => 'AmxBans/smsscripts.net kasutajanimi',
'AMXBans password' => 'AmxBans/smsscripts.net parool',
'AMXBans e-mail address' => 'AmxBans meiliaadress (ei võimalda parooli taastamist, ainult läbi MySQL)',
'An e-mail with additional data has been sent' => 'Lisainfo saadeti meiliga, peale installi ava uuesti smsscripts.net link cPanelist www.cf.ee/cpanel (kasutusjuhendi leiad aadressilt www.cf.ee/sms)',
'Back' => 'Tagasi',
'C-panel username' => 'cPaneli kasutajanimi',
'C-panel password' => 'cPaneli parool',
'Choose language' => 'Vali keel',
'Connection to MySQL database failed' => 'Ühendamine MySQL andmbeaasiga ebaõnnestus',
'Connection to FTP server "%s" failed' => 'Ühendamine FTP serverisse "%s" ebaõnnetus',
'Copying from folder "%s" to folder "%s" failed' => 'Kopeerimine kaustast "%s" kausta "%s" ebaõnnestus',
'Database username' => 'Andmebaasi kasutajanimi (pole vaja kasutada, automaatne)',
'Database password' => 'Andmebaasi parool (pole vaja kasutada, automaatne)',
'Database name' => 'Andmebaasi nimi (pole vaja kasutada, automaatne)',
'E-mail address' => 'Meiliaadress',
'Editing file "%s" failed' => 'Faili "%s" muutmine ebaõnnestus', 
'Error' => 'Viga',
'Incorrect username/password' => 'Kasutajanimi ja/või parool on vale',
'Install' => 'Paigalda',
'Installation' => 'SMS skriptide paigaldus',
'Installation failed' => 'Paigaldus ebaõnnestus',
'Installation successful' => 'Paigaldus edukas',
'Log in to FTP server with user "%s" failed' => 'FTP serverisse logimine kasutajaga "%s" ebaõnnetus',
'New folder Code' => 'Turvalise kausta kood (pole vaja kasutada, automaatne)',
'No installation necessary' => 'Paigaldus pole vajalik',
'Renaming folder "%s" to "%s" failed' => 'Kausta "%s" ümbernimetamine kaustaks "%s" ebaõnnestus',
'Renaming FTP folder "%s" to "%s" failed' => 'FTP kausta "%s" ümbernimetamine kaustaks "%s" ebaõnnestus',
'You must insert e-mail address' => 'Meiliaadressi sisestamine on kohustuslik',
'You must insert password' => 'Parooli sisestamine on kohustuslik',
'You must insert username' => 'Kasutajanime sisestamine on kohustuslik',
);

 

 

/failid/result.php

defined('INSTALL') or die();


pageHeader();
$resultMessage = $result ? 'Installation successful' : 'Installation failed';
?>




















pageFooter();

 

 

/failid/SecureTrustCA.crt

-----BEGIN CERTIFICATE-----


-----END CERTIFICATE-----

 

 

/failid/setup.php

defined('INSTALL') or die();
chdir($folder . '/' . $username);


require_once("install/functions.inc");
require_once("include/functions.inc.php");


/*
$dbUsername = 'kasutaja_kasutajanimi';
$dbPassword = 'parool';
$dbDatabase = 'kasutaja_andmebaasinimi';
*/


$config->v_web = "6.0.1";


$amxUsername = $username;
$amxEmail    = $email;
$amxPassword = generateRandomPassword();


$installData[trans('AMXBans username')] = $amxUsername;
$installData[trans('AMXBans password')] = $amxPassword;
$installData[trans('AMXBans e-mail address')] = $amxEmail;


$path = str_replace("/".basename(str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"])),"",str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]));
$config->path_root = str_replace('/' . basename($path), '', $path) . '/' . $username;


$document = str_replace("/".basename($_SERVER["PHP_SELF"]),"",$_SERVER["PHP_SELF"]);
$config->document_root = str_replace('/' . basename($document), '', $document) . '/' . $username;


$config->templatedir = $config->path_root . "/install";
$config->langfilesdir = $config->path_root . "/install/language/";
$config->default_lang = "german";




chmod_R($config->path_root . '/', 0644, 0755);


$_SESSION['path_root']     = $config->path_root;
$_SESSION['document_root'] = $config->document_root;


$_SESSION['dbhost']   = '127.0.0.1';
$_SESSION['dbuser']   = $dbUsername;
$_SESSION['dbpass']   = $dbPassword;
$_SESSION['dbdb']     = $dbDatabase;
$_SESSION['dbprefix'] = 'amx';


$_SESSION['adminuser']  = $username;
$_SESSION['adminemail'] = $email;
$_SESSION['adminpass']  = $amxPassword;


$amxCon = mysql_connect($_SESSION['dbhost'], $_SESSION['dbuser'], $_SESSION['dbpass']);
if (!$amxCon) {
   $errors[] = trans('Connection to MySQL database failed');
   stop();
}


$selectDB = mysql_select_db($_SESSION['dbdb']);
if (!$selectDB) {
   $errors[] = trans('Connection to MySQL database failed');
   stop();
}




//get tables structure
include 'install/tables.inc';


//create db structure
foreach ($table_create as $k => $v) {
   $table = array('table' => $k, 'success' => sql_create_table($k, $v));
   $tables[] = $table;
}
//get default data
include 'install/datas.inc';
//create default data
foreach ($data_create as $k => $v) {
   $data = array('data' => $k, 'success' => sql_insert_data($k, $v));
   $datas[]=$data;
}
//create default websettings
$websettings_create = array('data' => '_CREATEWEBSETTINGS', 'success' => sql_insert_setting($websettings_query));
//create default usermenu
$usermenu_create = array('data' => '_CREATEUSERMENU', 'success' => sql_insert_setting($usermenu_query));
//create webadmin userlevel
$webadmin_create[] = array('data' => '_CREATEUSERLEVEL', 'success' => sql_insert_setting($userlevel_query));
//create webadmin
$webadmin_create[] = array('data' => '_CREATEWEBADMIN', 'success' => sql_insert_setting($webadmin_query));
//install default modules
foreach ($modules_install as $k => $v) {
   $modul = array('name' => $k, 'success' => sql_insert_setting($v));
   $modules[] = $modul;
}


mysql_query("DROP TABLE `amx_amxadmins`");


mysql_query("DROP TABLE `amx_admins_servers`");


mysql_query("CREATE TABLE `amx_amxadmins` (
            `id` int(12) NOT NULL auto_increment, 
            `username` varchar(32) default NULL, 
            `password` varchar(32) default NULL, 
            `access` varchar(32) default NULL, 
            `flags` varchar(32) default NULL, 
            `steamid` varchar(32) default NULL, 
            `nickname` varchar(32) NOT NULL default '', 
            `ashow` INT( 11 ) NOT NULL, `created` INT( 11 ) NOT NULL, 
            `expired` INT( 11 ) NOT NULL, 
            `days` int(11) NOT NULL default '90', 
            PRIMARY KEY  (`id`))");


mysql_query("CREATE TABLE `amx_admins_servers` (
            `admin_id` int(12) NOT NULL auto_increment, 
            `server_id` int(12) NOT NULL default '1', 
            `custom_flags` varchar(32) NOT NULL, 
            `use_static_bantime` enum('yes','no') NOT NULL default 'no', 
            PRIMARY KEY  (`admin_id`))");




mysql_query("CREATE TABLE IF NOT EXISTS `amx_fileedit` (
             `id` int(11) NOT NULL AUTO_INCREMENT,
             `filename` varchar(50) NOT NULL,
             PRIMARY KEY (`id`) );");


mysql_query("INSERT INTO `amx_fileedit` (`id`, `filename`) VALUES
           (1, 'x_admin.txt'),
           (2, 'x_sms.txt'),
           (3, 'x_vip.txt'),
           (4, 'x_abi.txt'),
           (5, 'x_reeglid.txt'),
           (6, 'x_rules.txt');
           ");


mysql_query("CREATE TABLE IF NOT EXISTS `amx_scripts` (
             `id` int(11) NOT NULL AUTO_INCREMENT,
             `name` varchar(50) NOT NULL,
             `access` varchar(32) NOT NULL,
             `flags1` varchar(32) NOT NULL,
             `flags2` varchar(32) NOT NULL,
             `flags3` varchar(32) NOT NULL,
             `reply` varchar(100) NOT NULL,
             `reply_update` varchar(100) NOT NULL,
             `days` int(11) NOT NULL,
             PRIMARY KEY (`id`)
           )");
//write db.config.inc.php
$content = \$config->document_root = "{$config->document_root}";
\$config->path_root = "{$config->path_root}";


\$config->v_web = "{$config->v_web}";


\$config->db_host = "{$_SESSION["dbhost"]}";
\$config->db_user = "{$_SESSION["dbuser"]}";
\$config->db_pass = "{$_SESSION["dbpass"]}";
\$config->db_db = "{$_SESSION["dbdb"]}";
\$config->db_prefix = "{$_SESSION["dbprefix"]}";


\$ftpServer = "{$ftpServer}";
\$ftpUsername = "{$ftpUsername}";
\$ftpPassword = "{$ftpPassword}";
\$folderCode = "{$newFolderCode}";


?>
CONF;
$fh = fopen($config->path_root . '/include/db.config.inc.php', 'w');
fputs($fh,$content);
fclose($fh);


//create first log ;-)
sql_insert_setting($log_query);
mysql_close($amxCon);

 

SMS skriptide kood - SMS serverite tellimine

 

start.php

if(!in_array($_SERVER['REMOTE_ADDR'], 
   array('81.20.151.38', '81.20.148.122','209.20.83.207','79.125.125.1'))) {
   die("Error: Unknown IP");
}


$secret = '';
if(!empty($secret) && !check_signature($_GET, $secret)) {
   die("Error: Invalid signature");
}


function check_signature($params_array, $secret) {
   ksort($params_array);
   $str = '';
   foreach ($params_array as $k=>$v) {
       if($k != 'sig') {
           $str .= "$k=$v";
       }
   }
   $str .= $secret;
   $signature = md5($str);
   return ($params_array['sig'] == $signature);
}


$mobile = $_GET['sender'];
$email = $_GET['message'];


require 'curl.php';

 

 

vabad.php

define('CURL', 1);
require 'config.php';


mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());


if (isset($_GET['free']) && $_GET['free'] == 1) {
   mysql_query("UPDATE sms_serverid SET vaba = 1 WHERE id = 1;");
}


$result = mysql_query("SELECT * FROM sms_serverid WHERE vaba = 1;");
$countFree = mysql_num_rows($result);
if ($countFree == 0) {
   die("

 SMS Counter-Strike 1.6 nonsteam vabu servereid hetkel ei ole.
");
}
echo "
 Kokku $countFree vaba Counter-Strike 1.6 nonsteam server" . ($countFree == 1 ? '' : 'it') . ':

';
while ($server = mysql_fetch_array($result)) {
   echo $server['serveri_ip'] . '
';
}


echo '
SMS serverid on uuendamisel! 25.11.10
';


?>

 

 

config.php

defined('CURL') or die();


$dbhost = '127.0.0.1';
$dbuser = '';
$dbpass = '';
$dbname = '';


$adminEmail = '';
$sendAdminEmail = true;


$ftpUser = '';
$ftpPassword = '';
$ftpServer = '';
$ftpFile = '/public_html/mingid_serverid.ini';

 

 

cron.php

define('CURL', 1);
require 'config.php';


mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());


//ALTER TABLE  `sms_tellimused` CHANGE  `kuupaev`  `kuupaev` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP


$result = mysql_query("SELECT server, id FROM sms_tellimused 
   WHERE server != 0 AND SUBDATE(NOW(), INTERVAL 24 HOUR) >= kuupaev;");
if (mysql_num_rows($result) == 0) {
   exit;
}


while ($order = mysql_fetch_array($result)) {
   //aeg täis
   mysql_query("UPDATE sms_tellimused SET server = 0 WHERE id = {$order['id']}");
   mysql_query("UPDATE sms_serverid SET vaba = 1 WHERE id = {$order['server']}");
}

 

 

curl.php

define('CURL', 1);
require 'config.php';
require 'functions.php';


function curl($url, $user, $password)
{
   $header = array('Authorization: Basic ' . base64_encode($user . ':' . $password));
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, $url); 
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
   curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
   $result = curl_exec($ch);
   curl_close ($ch);
   return $result;
}


if (!isset($mobile) || !isset($email)) {
   die("Mobiil või email on puudu");
}
$tellimus = array('mobiil' => $mobile, 'email' => $email);


mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());


$result = mysql_query("SELECT t.id FROM sms_serverid s JOIN sms_tellimused t ON s.id = t.server 
   WHERE s.serveri_ip = '" . mysql_real_escape_string($email) . "'");
if (mysql_num_rows($result) == 1) {
   //tahetakse uuendada
   $id = mysql_result($result, 0);
   $result = mysql_query("UPDATE sms_tellimused SET kuupaev = ADDDATE(kuupaev, INTERVAL 24 HOUR) WHERE id = $id");
   if ($result) {
       echo 'Server ' . $email . ' pikendatud 24h võrra. Script by www.CF.ee';
   } else {
       echo 'Serveri pikendamine ebaõnnestus';
   }
   return;
}


//valime vaba serveri
$result = mysql_query("SELECT * FROM sms_serverid WHERE vaba = 1 LIMIT 1;");
if (mysql_num_rows($result) == 0) {
   die("Ühtegi vaba serverit ei ole");
}
$server = mysql_fetch_array($result);




$newPassword = createRandomPassword();
echo 'Parool: ' . $newPassword . ' ';


//muuda cPaneli parool
curl("http://cf.ee:2082/frontend/gs/passwd/changepass.html?oldpass={$server['parool']}&newpass=$newPassword", 
   $server['kasutajanimi'], $server['parool']);
$server['parool'] = $newPassword;




//muudame ftp parooli
curl("http://www.cf.ee:2082/frontend/gs/ftp/dopasswdftp.html?" . 
   "acct={$server['ftp_esimene_pool']}&password={$server['parool']}", $server['kasutajanimi'], $server['parool']);


//unintsalli server
curl("http://www.cf.ee:2082/frontend/gs/gameserv/Uninstall.html?game=cstrike&n=0", $server['kasutajanimi'], $server['parool']);


$ftpPassword = $newPassword;
$newCfgPassword = createRandomPassword();
changeIniPassword($ftpServer, $ftpUser, $ftpPassword, $ftpFile, $server['serveri_ip'], $newCfgPassword);




//lisame kasutaja andmebaasi
$sql = "INSERT INTO sms_tellimused (server, mobiil, email) 
   VALUES ({$server['id']}, '" . mysql_real_escape_string($tellimus['mobiil']) . "', 
       '" . mysql_real_escape_string($tellimus['email']) . "');";
mysql_query($sql);


//märgime server kasutatuks ja muudame parooli
mysql_query("UPDATE sms_serverid SET vaba = 0, parool = '$newPassword' WHERE id = {$server['id']}");


$to = $tellimus['email'];
$subject = "SMS Counter Strike Serveri Tellimus";
$body = "
Tere,


Kasutajanimi on {$server['kasutajanimi']}
Sinu parool on {$server['parool']}
Serveri IP on {$server['serveri_ip']}
FTP Kasutajanimi on {$server['ftp_esimene_pool']}@{$server['ftp_teine_pool']} ja parool on {$server['parool']}
FTP Port 21
FTP server www.cf.ee


cPaneli ligipääs aadressilt http://www.cf.ee/cpanel
Serverit saad kasutada 24h.


Script by www.CF.ee


Lugupidamisega,
CF.ee Tiim
";


if (mail($to, $subject, $body)) {
   echo("
Kasutajanimi: {$server['kasutajanimi']} Serveri IP: {$server['serveri_ip']} Info meiliga edukalt saadetud! Script by www.CF.ee");
} else {
   echo("
Meili saatmine ebaõnnestus...");
}
if ($sendAdminEmail) {
   mail($adminEmail, 'Telliti uus server', $body);
}

 

 

functions.php

defined('CURL') or die();


function createRandomPassword()
{
   $chars = "abcdefghijkmnopqrstuvwxyz023456789"; 
   srand((double)microtime()*1000000); 
   $i = 0; 
   $pass = '' ; 

   while ($i         $num = rand() % 33; 
       $tmp = substr($chars, $num, 1); 
       $pass = $pass . $tmp; 
       $i++; 
   } 

   return $pass; 
}


function changeIniPassword($ftpServer, $ftpUser, $ftpPassword, $ftpFile, $gameServer, $newPwd, $oldPwd = null)
{
   $ftpUser = str_replace('@', '%40', $ftpUser);

   $url = "ftp://$ftpUser:$ftpPassword@$ftpServer$ftpFile";

   $curl = curl_init();
   curl_setopt($curl, CURLOPT_URL, $url);
   curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
   $ini = curl_exec ($curl);
   curl_close ($curl);

   $regExp = "/^($gameServer-)(" . ($oldPwd == null ? ".*?" : $oldPwd) . ")(-0)/ms";
   $newIni = preg_replace($regExp, "\${1}$newPwd$3", $ini);

   if ($newIni == $ini) {
       //didn't change password
       return false;
   }

   $temp = tmpfile();
   fwrite($temp, $newIni);
   fseek($temp, 0);

   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, $url);
   curl_setopt($ch, CURLOPT_UPLOAD, 1);
   curl_setopt($ch, CURLOPT_INFILE, $temp);
   curl_setopt($ch, CURLOPT_INFILESIZE, strlen($newIni));

   $error = curl_exec($ch);
   curl_close($ch); 
   fclose($temp);
   return true;
}

 

 

changepw.php


define('CURL', 1);
if (!empty($_POST['server']) && !empty($_POST['old']) && !empty($_POST['new1']) && !empty($_POST['new2'])) {

   $server = $_POST['server'];
   $old = $_POST['old'];
   $new1 = $_POST['new1'];
   $new2 = $_POST['new2'];

   if ($new1 != $new2) {
       echo 'Paroolid ei kattu!';
   } elseif ($new1 == $old) {
       echo 'Uus ja vana parool on samad';
   } else {
       require 'config.php';
       require 'functions.php';
       if (changeIniPassword($ftpServer, $ftpUser, $ftpPassword, $ftpFile, $server, $new1, $old)) {
           echo 'Parool muudetud!';
       } else {
           echo 'Parooli muutmine ebaõnnestus';
       }
   }
}
?>
</pre>
<form action="<?php%20echo%20%24_SERVER%5B'PHP_SELF'%5D?>" method="post">
Serveri parooli muutmine

Server: 

Vana parool: 

Uus parool: 

Uus parool uuesti: 


<

 

SMS skriptide kood - Algeline MySQL delete ajaliselt

 

include 'config.php';
include 'data.php';


mysql_connect("$dbhost", "$dbuser", "$dbpass") or die(mysql_error());
mysql_select_db("$dbname") or die(mysql_error());


$sql = mysql_query("SELECT date FROM amx_amxadmins");   
$checkdate = mysql_fetch_array($sql);


do{


$old = $checkdate['date'] + $sec; 


if(time() >= $old)
{
$query = "DELETE FROM amx_amxadmins WHERE date > $old" ;
$deleteSQL = mysql_query("DELETE FROM amx_amxadmins WHERE date > $old");
mysql_query($deleteSQL, "$conn" or die(mysql_error()));
}


}while($checkdate = mysql_fetch_array($sql));  
?>

Muudetud liikme Cemtey'i poolt

Jaga seda postitust


Postituse link
Share on other sites

Githubist olete midagi kuulnud?

Enne kui jagate, võiks koodi korda teha, nii palju aega oleks sul ikka olnud, nt

 

1. OOP PHP

2. mysql_connect deprecated -> use PDO

3. kood ja andmebaas võiks olla sama keelega

 

Tahad küsida miks nii kriitiline .... ?

Fortumo.com kutsekood cf. Saan 20eur kui teie kunagi enda esimesed 50 euri teenite.

Sellepärast siis jagad oma koodi, millest kellegil suhteliselt kasu pole, andmebaasi disain on puudu lisaks sellele.

Fortumol on ka olemas tutorial scripti tegemiseks, lihtsalt peab teadma, mis nende andmetega pärast edasi teha.

 

Lisaks võiks koodil olla download link, keegi ei viitsi siin kõiki faile eraldi kopeerida.

 

Muidu on hea, et jagasid, kes seda teemat ei mõista, ehk saavad nüüd paremini aru :)


MusicFace looja ja arendaja http://musicface.ee/

Jaga seda postitust


Postituse link
Share on other sites

Kommentaari lisamiseks loo konto või logi sisse

Kommenteerimiseks peate olema liige

Loo konto

Liituge meie kommuuni uue kontoga. See on lihtne!

Loo uus konto

Logi sisse

On juba konto? Logi sisse siit.

Logi sisse nüüd
Jälgi teemat sisse logides  

×
×
  • Loo uus...

Oluline informatsioon

Selle veebisaidi paremaks muutmiseks oleme teie seadmesse paigutanud küpsised . Võite kohandada oma küpsiste seadeid , vastasel juhul eeldame, et te olete küpsiste kasutamisega nõus kui jätkate veebisaidil sirvimist.. Palun lugege läbi Kasutustingimused ja Privaatsuspoliitika.