Advertisement
Wayne08

functions.php

May 11th, 2011
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.83 KB | None | 0 0
  1. <?php
  2. /* Grex's Godfather API for PHP was made by Grex
  3.  
  4.     For developers who want use this API for releasing CP or others:
  5.         Do not edit andything
  6.         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
  7.         Do not selling it!, it's free for everyone
  8.        
  9.     For developers who want use this for his OWN project:
  10.         You are allowed to edit anything where you want
  11.         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
  12.        
  13.     Fullname: Gregor Ganglberger
  14.     E-Mail: grexaut@gmail.com
  15.     Project: San Andreas [Fun]RealLife - German | http://sa-rl.de
  16. */
  17.  
  18. class functions
  19. {
  20.     // Read out the userinformations
  21.     function GetPlayerInfo($user)
  22.     {
  23.         require "config.php";
  24.         $file="$GameDir/scriptfiles/Accounts/$user.ini";
  25.         if(!file_exists($file)) return false;
  26.         $data = parse_ini_file($file);
  27.         return $data;
  28.     }
  29.     // Read out the bizzinformations
  30.     function GetPlayerBizzInfo($user)
  31.     {
  32.         require "config.php";
  33.         if(!$file=fopen("$GameDir/scriptfiles/bizz.cfg","r")) die("Error reading bizzfile");
  34.         while (($data=fgetcsv($file,1024, "|")) !== FALSE)
  35.         {
  36.             if($data[1] == $user)
  37.             {
  38.                 $datanew = array(
  39.                     "Owned" => $data[0],
  40.                     "Owner" => $data[1],
  41.                     "Message" => $data[2],
  42.                     "Extortion" => $data[3],
  43.                     "EntranceX" => $data[4],
  44.                     "EntranceY" => $data[5],
  45.                     "EntranceZ" => $data[6],
  46.                     "ExitX" => $data[7],
  47.                     "ExitY" => $data[8],
  48.                     "ExitZ" => $data[9],
  49.                     "LevelNeeded" => $data[10],
  50.                     "BuyPrice" => $data[11],
  51.                     "EntranceCost" => $data[12],
  52.                     "Till" => $data[13],
  53.                     "Locked" => $data[14],
  54.                     "Interior" => $data[15],
  55.                     "Products" => $data[16],
  56.                     "MaxProducts" => $data[17],
  57.                     "PriceProd" => $data[18]
  58.                 );
  59.                 return $datanew;
  60.             }
  61.         }
  62.     }
  63.     // Read out the sbizzinformations
  64.     function GetPlayerSBizzInfo($user)
  65.     {
  66.         require "config.php";
  67.         if(!$file=fopen("$GameDir/scriptfiles/sbizz.cfg","r")) die("Error reading bizzfile");
  68.         while (($data=fgetcsv($file,1024, "|")) !== FALSE)
  69.         {
  70.             if($data[1] == $user)
  71.             {
  72.                 $datanew = array(
  73.                     "Owned" => $data[0],
  74.                     "Owner" => $data[1],
  75.                     "Message" => $data[2],
  76.                     "Extortion" => $data[3],
  77.                     "EntranceX" => $data[4],
  78.                     "EntranceY" => $data[5],
  79.                     "EntranceZ" => $data[6],
  80.                     "LevelNeeded" => $data[7],
  81.                     "BuyPrice" => $data[8],
  82.                     "EntranceCost" => $data[9],
  83.                     "Till" => $data[10],
  84.                     "Locked" => $data[11],
  85.                     "Interior" => $data[12],
  86.                     "Products" => $data[13],
  87.                     "MaxProducts" => $data[14],
  88.                     "PriceProd" => $data[15]
  89.                 );
  90.                 return $datanew;
  91.             }
  92.         }
  93.     }
  94.     function GetPlayerHouseInfo($user)
  95.     {
  96.         require "config.php";
  97.         if(!$file=fopen("$GameDir/scriptfiles/property.cfg","r")) die("Error reading bizzfile");
  98.         while (($data=fgetcsv($file,1024, ",")) !== FALSE)
  99.         {
  100.             if($data[12] == $user)
  101.             {
  102.                 $datanew = array(
  103.                     "Entrancex" => $data[0],
  104.                     "Entrancey" => $data[1],
  105.                     "Entrancez" => $data[2],
  106.                     "Exitx" => $data[3],
  107.                     "Exity" => $data[4],
  108.                     "Exitz" => $data[5],
  109.                     "Healthx" => $data[6],
  110.                     "Healthy" => $data[7],
  111.                     "Healthz" => $data[8],
  112.                     "Armourx" => $data[9],
  113.                     "Armoury" => $data[10],
  114.                     "Armourz" => $data[11],
  115.                     "Owner" => $data[12],
  116.                     "Discription" => $data[13],
  117.                     "Value" => $data[14],
  118.                     "Hel" => $data[15],
  119.                     "Arm" => $data[16],
  120.                     "Int" => $data[17],
  121.                     "Lock" => $data[18],
  122.                     "Owned" => $data[19],
  123.                     "Rooms" => $data[20],
  124.                     "Rent" => $data[21],
  125.                     "Rentabil" => $data[22],
  126.                     "Takings" => $data[23],
  127.                     "Vec" => $data[24],
  128.                     "Vcol1" => $data[25],
  129.                     "Vcol2" => $data[26],
  130.                     "Date" => $data[27],
  131.                     "Level" => $data[28]
  132.                 );
  133.                 return $datanew;
  134.             }
  135.         }
  136.     }
  137.     // Crypts the input password for comparing
  138.     function cryptpw($password)
  139.     {
  140.         for($i=0; $i < strlen($password); $i++)
  141.         {
  142.             $temp = ord($password[$i]);
  143.             $temp += (3^$i) * ($i % 15);
  144.             if($temp > (0xff))
  145.             {
  146.                 $temp -= 256;
  147.             }
  148.             $password[$i] = chr($temp);
  149.         }  
  150.         return $password;
  151.     }
  152.     function GetVehicleName($vehicleid)
  153.     {
  154.         $carname = array("Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel",
  155.         "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana", "Infernus",
  156.         "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam",
  157.         "Esperanto", "Taxi", "Washington", "Bobcat", "Whoopee", "BF Injection",
  158.         "Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator", "Bus",
  159.         "Rhino", "Barracks", "Hotknife", "Trailer", "Previon", "Coach", "Cabbie",
  160.         "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral",
  161.         "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder",
  162.         "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair", "Berkley's RC Van",
  163.         "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale",
  164.         "Oceanic","Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy",
  165.         "Hermes", "Sabre", "Rustler", "ZR-350", "Walton", "Regina", "Comet", "BMX",
  166.         "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper",
  167.         "Rancher", "FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking",
  168.         "Blista Compact", "Police Maverick", "Boxvillde", "Benson", "Mesa", "RC Goblin",
  169.         "Hotring Racer A", "Hotring Racer B", "Bloodring Banger", "Rancher", "Super GT",
  170.         "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster", "Stunt",
  171.         "Tanker", "Roadtrain", "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra",
  172.         "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune",
  173.         "Cadrona", "FBI Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer",
  174.         "Remington", "Slamvan", "Blade", "Freight", "Streak", "Vortex", "Vincent",
  175.         "Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder", "Primo",
  176.         "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite",
  177.         "Windsor", "Monster", "Monster", "Uranus", "Jester", "Sultan", "Stratium",
  178.         "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito",
  179.         "Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper",
  180.         "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400",
  181.         "News Van", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club",
  182.         "Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car",
  183.         "Police Car", "Police Car", "Police Ranger", "Picador", "S.W.A.T", "Alpha",
  184.         "Phoenix", "Glendale", "Sadler", "Luggage", "Luggage", "Stairs", "Boxville",
  185.         "Tiller", "Utility Trailer");
  186.         return $carname[$vehicleid-400];
  187.     }
  188.     // Logs who has where logged into his account
  189.     function accesslog($user,$access)
  190.     {
  191.         require "config.php";
  192.         if(!$file=fopen("$LogDir/access.log","a+")) return false;
  193.         fwrite($file,mktime().";".$_SERVER['REMOTE_ADDR'].";".$user.";".$access."\n");
  194.         fclose($file);
  195.         return true;
  196.     }
  197.     // Writes the userinformation
  198.     function UpdatePlayerInfo($assoc_array,$user)
  199.     {
  200.         require "config.php";
  201.         $content = '';
  202.         foreach ($assoc_array as $key => $data) $content .= "$key=$data\n";
  203.         if (!$file = fopen("$GameDir/scriptfiles/$user.ini", 'w')) return false;
  204.         if (!fwrite($file, $content)) {
  205.             return false;
  206.         }
  207.         fclose($file);
  208.         return true;
  209.     }
  210. }
  211. class fractions
  212. {
  213.     function ReadOrg()
  214.     {
  215.         while($user = readdir(opendir("$GameDir/Accounts/scriptfiles/")))
  216.         {
  217.             if(substr($user, -3) == 'ini')
  218.             {
  219.                 $file = fopen("$GameDir/scriptfiles/Accounts/$user","r");
  220.                 $user = substr($user,0,-4);
  221.                 $functions = new functions();
  222.                 $PlayerInfo = $functions->GetPlayerInfo($user);
  223.                 if($PlayerInfo['Leader'] > 0) return $PlayerOrg[$user][true][$PlayerInfo['Leader']];
  224.                 else if($PlayerInfo['Member'] > 0) return $PlayerOrg[$user][false][$PlayerInfo['Member']];
  225.             }
  226.            
  227.         }
  228.         closedir($dir_handle);
  229.     }
  230. }
  231. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement