Advertisement
Underworld1337

Untitled

Sep 26th, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.55 KB | None | 0 0
  1.     public function initSkylab()
  2.     {
  3.         $qry = $this->con->prepare("SELECT * FROM skylab WHERE UserID = :uID");
  4.         $qry->bindParam(':uID', $this->uid, PDO::PARAM_INT);
  5.         if ($qry->execute()) {
  6.             if ($qry->rowCount () != 0) {
  7.                 $result = $qry->fetchAll(PDO::FETCH_ASSOC);
  8.  
  9.                 $time = new DateTime();
  10.                 $time = $time->getTimestamp();
  11.  
  12.                 //todo finish transports here
  13.                
  14.                 $basicmod_arr = explode("|", $result[0]['basicmod']);
  15.                 $this->mod_basic['level'] = $basicmod_arr[0];
  16.                 $this->mod_basic['status'] = $basicmod_arr[1];
  17.                 $this->mod_basic['upgrade_finished'] = $basicmod_arr[2];
  18.                
  19.                 $storagemod_arr = explode("|", $result[0]['storagemod']);
  20.                 $this->mod_store['level'] = $storagemod_arr[0];
  21.                 $this->mod_store['status'] = $storagemod_arr[1];
  22.                 $this->mod_store['upgrade_finished'] = $storagemod_arr[2];
  23.                
  24.                 $solarmod_arr = explode("|", $result[0]['solarmod']);
  25.                 $this->mod_solar['level'] = $solarmod_arr[0];
  26.                 $this->mod_solar['status'] = $solarmod_arr[1];
  27.                 $this->mod_solar['upgrade_finished'] = $solarmod_arr[2];
  28.  
  29.                 $prometiumcol_arr = explode("|", $result[0]['prometiumcol']);
  30.                 $this->collector_prometium['level'] = $prometiumcol_arr[0];
  31.                 $this->collector_prometium['status'] = $prometiumcol_arr[1];
  32.                 $this->collector_prometium['upgrade_finished'] = $prometiumcol_arr[2];
  33.                
  34.                 $enduriumcol_arr = explode("|", $result[0]['enduriumcol']);
  35.                 $this->collector_endurium['level'] = $enduriumcol_arr[0];
  36.                 $this->collector_endurium['status'] = $enduriumcol_arr[1];
  37.                 $this->collector_endurium['upgrade_finished'] = $enduriumcol_arr[2];
  38.                
  39.                 $terbiumcol_arr = explode("|", $result[0]['terbiumcol']);
  40.                 $this->collector_terbium['level'] = $terbiumcol_arr[0];
  41.                 $this->collector_terbium['status'] = $terbiumcol_arr[1];
  42.                 $this->collector_terbium['upgrade_finished'] = $terbiumcol_arr[2];
  43.                
  44.                 $prometidref_arr = explode("|", $result[0]['prometidref']);
  45.                 $this->refine_prometid['level'] = $prometidref_arr[0];
  46.                 $this->refine_prometid['status'] = $prometidref_arr[1];
  47.                 $this->refine_prometid['upgrade_finished'] = $prometidref_arr[2];
  48.                
  49.                 $duraniumref_arr = explode("|", $result[0]['duraniumref']);
  50.                 $this->refine_duranium['level'] = $duraniumref_arr[0];
  51.                 $this->refine_duranium['status'] = $duraniumref_arr[1];
  52.                 $this->refine_duranium['upgrade_finished'] = $duraniumref_arr[2];
  53.                
  54.                 $promeriumref_arr = explode("|", $result[0]['promeriumref']);
  55.                 $this->refine_promerium['level'] = $promeriumref_arr[0];
  56.                 $this->refine_promerium['status'] = $promeriumref_arr[1];
  57.                 $this->refine_promerium['upgrade_finished'] = $promeriumref_arr[2];
  58.                
  59.                 $sepromref_arr = explode("|", $result[0]['sepromref']);
  60.                 $this->refine_seprom['level'] = $sepromref_arr[0];
  61.                 $this->refine_seprom['status'] = $sepromref_arr[1];
  62.                 $this->refine_seprom['upgrade_finished'] = $sepromref_arr[2];
  63.                
  64.                 $xenogen_arr = explode("|", $result[0]['xenogen']);
  65.                 $this->generator_xeno['level'] = $xenogen_arr[0];
  66.                 $this->generator_xeno['status'] = $xenogen_arr[1];
  67.                 $this->generator_xeno['upgrade_finished'] = $xenogen_arr[2];
  68.                
  69.  
  70.                 $qryr = $this->con->prepare("SELECT * FROM skylab_ressources WHERE LabID = :uID");
  71.                 $qryr->bindParam(':uID', $this->uid, PDO::PARAM_INT);
  72.                 if ($qryr->execute()) {
  73.                     $ress = $qryr->fetchAll(PDO::FETCH_ASSOC);
  74.                     $ress_array = array(
  75.                                     "prometium" => $ress[0]['prometium'],
  76.                                     "endurium" => $ress[0]['endurium'],
  77.                                     "terbium" => $ress[0]['terbium'],
  78.                                     "prometid" => $ress[0]['prometid'],
  79.                                     "duranium" => $ress[0]['duranium'],
  80.                                     "xenomit" => $ress[0]['xenomit'],
  81.                                     "promerium" => $ress[0]['promerium'],
  82.                                     "seprom" => $ress[0]['seprom']
  83.                                         );
  84.                     $this->ressources_array = $ress_array;
  85.                    
  86.                     // update ressources here
  87.                    
  88.                     // check the upgrades after update ressources
  89.                     //
  90.                     if($this->mod_basic['status'] == 2 && $this->mod_basic['upgrade_finished'] != 0){
  91.                         if($time >= $this->mod_basic['upgrade_finished']){
  92.                             $this->mod_basic['level'] = $this->mod_basic['level']+1;
  93.                             $this->mod_basic['status'] = 1;
  94.                             $this->mod_basic['upgrade_finished'] = 0;
  95.                             $data = implode("|", $this->mod_basic);
  96.                             $type = "basicmod";
  97.                             $qry = $this->con->prepare("UPDATE skylab SET {$type} = :data WHERE UserID = :uID");
  98.                             $qry->bindParam(':uID', $this->uid, PDO::PARAM_INT);
  99.                             $qry->bindParam(':data', $data, PDO::PARAM_STR);
  100.                             $qry->execute();
  101.                         }
  102.                     }
  103.                     return TRUE;
  104.                 }
  105.             } else {
  106.                 $time = new DateTime();
  107.                 $time = $time->getTimestamp();
  108.  
  109.                 // level|status|finished-timestamp
  110.                 $qrys = $this->con->prepare("INSERT INTO `skylab`
  111.                                             (`LabID`, `UserID`, `lastvisit`, `basicmod`, `solarmod`, `storagemod`,
  112.                                             `prometiumcol`, `enduriumcol`, `terbiumcol`, `prometidref`, `duraniumref`,
  113.                                             `promeriumref`, `xenogen`, `sepromref`)
  114.                                             VALUES
  115.                                             (:uID, :uID, :lv, '1|1|0', '1|1|0', '1|1|0', '1|1|0', '1|1|0', '1|1|0', '1|1|0', '1|1|0', '1|1|0', '1|1|0', '1|1|0')");
  116.                 $qrys->bindParam(':uID', $this->uid, PDO::PARAM_INT);
  117.                 $qrys->bindParam(':lv', $time, PDO::PARAM_INT);
  118.                 $qrys->execute();
  119.                 $qryr = $this->con->prepare("INSERT INTO `skylab_ressources`
  120.                                             (`LabID`, `prometium`, `endurium`, `terbium`, `prometid`, `duranium`, `xenomit`, `promerium`, `seprom`)
  121.                                             VALUES
  122.                                             (:uID, 50000, 50000, 50000, 0, 0, 0, 0, 0)");
  123.                 $qryr->bindParam(':uID', $this->uid, PDO::PARAM_INT);
  124.                 $qryr->execute();
  125.                 self::initSkylab();
  126.             }
  127.         }  
  128.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement