Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- index.php
- <?php
- /* Examplescript for Grex's Godfather API was made by Grex http://sa-rl.de */
- require "functions.php";
- $user = 'Grex'; // The username will defined here // Hier wird der Username gesetzt
- $password = 'sa-rl.de'; // The password will defined here // Hier wird das Passwort gesetzt
- $functions = new functions();
- //-----------------------[Auslesen der Userdaten]------------- Read the userinformations
- $PlayerInfo = $functions->GetPlayerInfo($user); // Userdatas will be saved in this variable // Spielerdaten werden auf diese Variable gespeichert
- //-----------------------[Benutzernamen überprüfen]------------- // Check the username
- if(!$PlayerInfo) die('User nicht gefunden'); // Check if the user exists // Kontrolliert, ob der User auch tatsächlich vorhanden ist
- //-----------------------[Loggen der Anmeldung]------------- // Logging the login
- if(!$functions->accesslog($user,true)) die ('Es trat ein Fehler auf'); // Security check, if logging has been failed, cancel // Sicherheitskontrolle, falls Logging nicht funktioniert, bricht er ab
- //-----------------------[Verwendung der Userdaten]-------------
- echo $PlayerInfo['Money'] + $PlayerInfo['Bank']."<br>"; // Calculate the money from the case and bank together and print out // Rechnet Geld von Geldbörse und Bank zusammen, und gibt es direkt aus
- //-----------------------[Passwortvergleich]-------------
- if($functions->cryptpw($password) != $PlayerInfo['Key']) die('Falsches Passwort'); // Crpyts the password (Godfather like) and compares it // Verschlüsselt das Passwort (Godfather Verschlüsselung)und vergleicht es
- //-----------------------[Auslesen der Bizzdaten]------------- Read the bizzdatas
- if($PlayerInfo['Bizz'] >= 0 && $PlayerInfo['Bizz'] < 100) $PlayerBizzInfo = $functions->GetPlayerBizzInfo($user); // Using bizzfiles and data // Einlesen der Bizzdaten
- else if($PlayerInfo['Bizz'] >= 100 && $PlayerInfo['Bizz'] < 255) $PlayerBizzInfo = $functions->GetPlayerSBizzInfo($user); // Using sbizzfile and datas // Einlesen der SBizzdaten
- else echo 'Du hast kein Bizz oder SBizz'; // User has no bizz or sbizz to read datas from file // User besitzt weder ein Bizz noch ein SBizz
- //-----------------------[Verwendung der Bizzdaten]------------- Using the bizzdatas
- if(isset($PlayerBizzInfo)) echo "<br>".$PlayerBizzInfo['Extortion']."<br>"; // The extortion will be displayed // Mitteilinhaber wird angezeigt
- //-----------------------[Auslesen der Hausdaten]------------- Read the housedatas
- if($PlayerInfo['House'] != 255) $PlayerHouseInfo = $functions->GetPlayerHouseInfo($user); // If the player has a house, search for them in property.cfg
- // Wenn der Spieler ein Haus besitzt, wir danach in der property.cfg gesucht
- //-----------------------[Verwendung der Hausdaten]------------- // Using the housedatas
- If(isset($PlayerHouseInfo)) echo $PlayerHouseInfo['Takings']; // The "housecash" (don't know correct word :P) will be displayed // Der Betrag von der Hauskasse wird angezeigt
- //-----------------------[Ändern der Userdaten]------------- // Change the userinformations
- $PlayerInfo['AdminLevel'] = $PlayerInfo['Level']; // Sets the adminlevel to the userlevel (for banning - part 1) // Setzt das Spielerlevel auf das Adminlevel (zum Bannen - Teil 1)
- $PlayerInfo['Level'] = -999; // Sets the Level -999 (for banning - part 2) // Setzt das Spielerlevel auf -999 (zum Bannen - Teil 2)
- //-----------------------[Änderung verwirken]------------- // Forfeit the userinformations
- $functions->UpdatePlayerInfo($PlayerInfo,$user); // All changes must be forfeit, because you have only changed in temporary and aren't changed in the file
- //Alle Änderungen müssen wirksam gemacht werden, ansonst sind diese nur temorär gespeichert und sind nicht in der ini gespeichert
- ?>
- functions.php
- <?php
- /* Grex's Godfather API for PHP was made by Grex
- For developers who want use this API for releasing CP or others:
- Do not edit andything
- Do not say, it is your own (without my premission), write my Name (Grex) at your footer. If you do not use one, write me under the credits
- Do not selling it!, it's free for everyone
- For developers who want use this for his OWN project:
- You are allowed to edit anything where you want
- Do not say, it is your own, write my Name (Grex) at your footer. If you do not use one, write me under the credits
- Fullname: Gregor Ganglberger
- E-Mail: grexaut@gmail.com
- Project: San Andreas [Fun]RealLife - German | http://sa-rl.de
- */
- class functions
- {
- // Read out the userinformations
- function GetPlayerInfo($user)
- {
- require "config.php";
- $file="$GameDir/scriptfiles/$user.ini";
- if(!file_exists($file)) die("Error reading userfile");
- $data = parse_ini_file($file);
- return $data;
- }
- // Read out the bizzinformations
- function GetPlayerBizzInfo($user)
- {
- require "config.php";
- if(!$file=fopen("$GameDir/scriptfiles/bizz.cfg","r")) die("Error reading bizzfile");
- while (($data=fgetcsv($file,1024, "|")) !== FALSE)
- {
- if($data[1] == $user)
- {
- $datanew = array(
- "Owned" => $data[0],
- "Owner" => $data[1],
- "Message" => $data[2],
- "Extortion" => $data[3],
- "EntranceX" => $data[4],
- "EntranceY" => $data[5],
- "EntranceZ" => $data[6],
- "ExitX" => $data[7],
- "ExitY" => $data[8],
- "ExitZ" => $data[9],
- "LevelNeeded" => $data[10],
- "BuyPrice" => $data[11],
- "EntranceCost" => $data[12],
- "Till" => $data[13],
- "Locked" => $data[14],
- "Interior" => $data[15],
- "Products" => $data[16],
- "MaxProducts" => $data[17],
- "PriceProd" => $data[18]
- );
- return $datanew;
- }
- }
- }
- // Read out the sbizzinformations
- function GetPlayerSBizzInfo($user)
- {
- require "config.php";
- if(!$file=fopen("$GameDir/scriptfiles/sbizz.cfg","r")) die("Error reading bizzfile");
- while (($data=fgetcsv($file,1024, "|")) !== FALSE)
- {
- if($data[1] == $user)
- {
- $datanew = array(
- "Owned" => $data[0],
- "Owner" => $data[1],
- "Message" => $data[2],
- "Extortion" => $data[3],
- "EntranceX" => $data[4],
- "EntranceY" => $data[5],
- "EntranceZ" => $data[6],
- "LevelNeeded" => $data[7],
- "BuyPrice" => $data[8],
- "EntranceCost" => $data[9],
- "Till" => $data[10],
- "Locked" => $data[11],
- "Interior" => $data[12],
- "Products" => $data[13],
- "MaxProducts" => $data[14],
- "PriceProd" => $data[15]
- );
- return $datanew;
- }
- }
- }
- function GetPlayerHouseInfo($user)
- {
- require "config.php";
- if(!$file=fopen("$GameDir/scriptfiles/property.cfg","r")) die("Error reading bizzfile");
- while (($data=fgetcsv($file,1024, ",")) !== FALSE)
- {
- if($data[12] == $user)
- {
- $datanew = array(
- "Entrancex" => $data[0],
- "Entrancey" => $data[1],
- "Entrancez" => $data[2],
- "Exitx" => $data[3],
- "Exity" => $data[4],
- "Exitz" => $data[5],
- "Healthx" => $data[6],
- "Healthy" => $data[7],
- "Healthz" => $data[8],
- "Armourx" => $data[9],
- "Armoury" => $data[10],
- "Armourz" => $data[11],
- "Owner" => $data[12],
- "Discription" => $data[13],
- "Value" => $data[14],
- "Hel" => $data[15],
- "Arm" => $data[16],
- "Int" => $data[17],
- "Lock" => $data[18],
- "Owned" => $data[19],
- "Rooms" => $data[20],
- "Rent" => $data[21],
- "Rentabil" => $data[22],
- "Takings" => $data[23],
- "Vec" => $data[24],
- "Vcol1" => $data[25],
- "Vcol2" => $data[26],
- "Date" => $data[27],
- "Level" => $data[28]
- );
- return $datanew;
- }
- }
- }
- // Crypts the input password for comparing
- function cryptpw($password)
- {
- for($i=0; $i < strlen($password); $i++)
- {
- $temp = ord($password[$i]);
- $temp += (3^$i) * ($i % 15);
- if($temp > (0xff))
- {
- $temp -= 256;
- }
- $password[$i] = chr($temp);
- }
- return $password;
- }
- function GetVehicleName($vehicleid)
- {
- $carname = array("Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel",
- "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana", "Infernus",
- "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam",
- "Esperanto", "Taxi", "Washington", "Bobcat", "Whoopee", "BF Injection",
- "Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator", "Bus",
- "Rhino", "Barracks", "Hotknife", "Trailer", "Previon", "Coach", "Cabbie",
- "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral",
- "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder",
- "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair", "Berkley's RC Van",
- "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale",
- "Oceanic","Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy",
- "Hermes", "Sabre", "Rustler", "ZR-350", "Walton", "Regina", "Comet", "BMX",
- "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper",
- "Rancher", "FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking",
- "Blista Compact", "Police Maverick", "Boxvillde", "Benson", "Mesa", "RC Goblin",
- "Hotring Racer A", "Hotring Racer B", "Bloodring Banger", "Rancher", "Super GT",
- "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster", "Stunt",
- "Tanker", "Roadtrain", "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra",
- "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune",
- "Cadrona", "FBI Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer",
- "Remington", "Slamvan", "Blade", "Freight", "Streak", "Vortex", "Vincent",
- "Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder", "Primo",
- "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite",
- "Windsor", "Monster", "Monster", "Uranus", "Jester", "Sultan", "Stratium",
- "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito",
- "Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper",
- "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400",
- "News Van", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club",
- "Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car",
- "Police Car", "Police Car", "Police Ranger", "Picador", "S.W.A.T", "Alpha",
- "Phoenix", "Glendale", "Sadler", "Luggage", "Luggage", "Stairs", "Boxville",
- "Tiller", "Utility Trailer");
- return $carname[$vehicleid-400];
- }
- // Logs who has where logged into his account
- function accesslog($user,$access)
- {
- require "config.php";
- if(!$file=fopen("$LogDir/access.log","a+")) return false;
- fwrite($file,mktime().";".$_SERVER['REMOTE_ADDR'].";".$user.";".$access."\n");
- fclose($file);
- return true;
- }
- // Writes the userinformation
- function UpdatePlayerInfo($assoc_array,$user)
- {
- require "config.php";
- $content = '';
- foreach ($assoc_array as $key => $data) $content .= "$key=$data\n";
- if (!$file = fopen("$GameDir/scriptfiles/$user.ini", 'w')) return false;
- if (!fwrite($file, $content)) {
- return false;
- }
- fclose($file);
- return true;
- }
- }
- ?>
- config.php
- <?php
- // Set the directory of the SAMP folder // Geben Sie den Pfad des Servers an
- $GameDir = "C:\server\SAMP";
- // Set the directory where the logfiles from the UCP will be save // Geben Sie den Pfad wo die Logfiles vom UCP gespeichert werden sollen an
- $LogDir = "C:\log\samp";
- //
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement