Advertisement
Underworld1337

Untitled

Sep 26th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.22 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.  
  104.                     if($this->mod_store['status'] == 2 && $this->mod_store['upgrade_finished'] != 0){
  105.                         if($time >= $this->mod_store['upgrade_finished']){
  106.                             $this->mod_store['level'] = $this->mod_store['level']+1;
  107.                             $this->mod_store['status'] = 1;
  108.                             $this->mod_store['upgrade_finished'] = 0;
  109.                             $data = implode("|", $this->mod_store);
  110.                             $type = "storagemod";
  111.                             $qry = $this->con->prepare("UPDATE skylab SET {$type} = :data WHERE UserID = :uID");
  112.                             $qry->bindParam(':uID', $this->uid, PDO::PARAM_INT);
  113.                             $qry->bindParam(':data', $data, PDO::PARAM_STR);
  114.                             $qry->execute();
  115.                         }
  116.                     }
  117.                    
  118.                     if($this->mod_solar['status'] == 2 && $this->mod_solar['upgrade_finished'] != 0){
  119.                         if($time >= $this->mod_solar['upgrade_finished']){
  120.                             $this->mod_solar['level'] = $this->mod_solar['level']+1;
  121.                             $this->mod_solar['status'] = 1;
  122.                             $this->mod_solar['upgrade_finished'] = 0;
  123.                             $data = implode("|", $this->mod_solar);
  124.                             $type = "solarmod";
  125.                             $qry = $this->con->prepare("UPDATE skylab SET {$type} = :data WHERE UserID = :uID");
  126.                             $qry->bindParam(':uID', $this->uid, PDO::PARAM_INT);
  127.                             $qry->bindParam(':data', $data, PDO::PARAM_STR);
  128.                             $qry->execute();
  129.                         }
  130.                     }
  131.                    
  132.                     if($this->collector_prometium['status'] == 2 && $this->collector_prometium['upgrade_finished'] != 0){
  133.                         if($time >= $this->collector_prometium['upgrade_finished']){
  134.                             $this->collector_prometium['level'] = $this->collector_prometium['level']+1;
  135.                             $this->collector_prometium['status'] = 1;
  136.                             $this->collector_prometium['upgrade_finished'] = 0;
  137.                             $data = implode("|", $this->collector_prometium);
  138.                             $type = "prometiumcol";
  139.                             $qry = $this->con->prepare("UPDATE skylab SET {$type} = :data WHERE UserID = :uID");
  140.                             $qry->bindParam(':uID', $this->uid, PDO::PARAM_INT);
  141.                             $qry->bindParam(':data', $data, PDO::PARAM_STR);
  142.                             $qry->execute();
  143.                         }
  144.                     }
  145.                    
  146.                     if($this->collector_endurium['status'] == 2 && $this->collector_endurium['upgrade_finished'] != 0){
  147.                         if($time >= $this->collector_endurium['upgrade_finished']){
  148.                             $this->collector_endurium['level'] = $this->collector_endurium['level']+1;
  149.                             $this->collector_endurium['status'] = 1;
  150.                             $this->collector_endurium['upgrade_finished'] = 0;
  151.                             $data = implode("|", $this->collector_endurium);
  152.                             $type = "enduriumcol";
  153.                             $qry = $this->con->prepare("UPDATE skylab SET {$type} = :data WHERE UserID = :uID");
  154.                             $qry->bindParam(':uID', $this->uid, PDO::PARAM_INT);
  155.                             $qry->bindParam(':data', $data, PDO::PARAM_STR);
  156.                             $qry->execute();
  157.                         }
  158.                     }
  159.                    
  160.                     if($this->collector_terbium['status'] == 2 && $this->collector_terbium['upgrade_finished'] != 0){
  161.                         if($time >= $this->collector_terbium['upgrade_finished']){
  162.                             $this->collector_terbium['level'] = $this->collector_terbium['level']+1;
  163.                             $this->collector_terbium['status'] = 1;
  164.                             $this->collector_terbium['upgrade_finished'] = 0;
  165.                             $data = implode("|", $this->collector_terbium);
  166.                             $type = "terbiumcol";
  167.                             $qry = $this->con->prepare("UPDATE skylab SET {$type} = :data WHERE UserID = :uID");
  168.                             $qry->bindParam(':uID', $this->uid, PDO::PARAM_INT);
  169.                             $qry->bindParam(':data', $data, PDO::PARAM_STR);
  170.                             $qry->execute();
  171.                         }
  172.                     }
  173.                    
  174.                     if($this->refine_prometid['status'] == 2 && $this->refine_prometid['upgrade_finished'] != 0){
  175.                         if($time >= $this->refine_prometid['upgrade_finished']){
  176.                             $this->refine_prometid['level'] = $this->refine_prometid['level']+1;
  177.                             $this->refine_prometid['status'] = 1;
  178.                             $this->refine_prometid['upgrade_finished'] = 0;
  179.                             $data = implode("|", $this->refine_prometid);
  180.                             $type = "prometidref";
  181.                             $qry = $this->con->prepare("UPDATE skylab SET {$type} = :data WHERE UserID = :uID");
  182.                             $qry->bindParam(':uID', $this->uid, PDO::PARAM_INT);
  183.                             $qry->bindParam(':data', $data, PDO::PARAM_STR);
  184.                             $qry->execute();
  185.                         }
  186.                     }
  187.                    
  188.                     if($this->refine_duranium['status'] == 2 && $this->refine_duranium['upgrade_finished'] != 0){
  189.                         if($time >= $this->refine_duranium['upgrade_finished']){
  190.                             $this->refine_duranium['level'] = $this->refine_duranium['level']+1;
  191.                             $this->refine_duranium['status'] = 1;
  192.                             $this->refine_duranium['upgrade_finished'] = 0;
  193.                             $data = implode("|", $this->refine_duranium);
  194.                             $type = "duraniumref";
  195.                             $qry = $this->con->prepare("UPDATE skylab SET {$type} = :data WHERE UserID = :uID");
  196.                             $qry->bindParam(':uID', $this->uid, PDO::PARAM_INT);
  197.                             $qry->bindParam(':data', $data, PDO::PARAM_STR);
  198.                             $qry->execute();
  199.                         }
  200.                     }
  201.                    
  202.                     if($this->refine_promerium['status'] == 2 && $this->refine_promerium['upgrade_finished'] != 0){
  203.                         if($time >= $this->refine_promerium['upgrade_finished']){
  204.                             $this->refine_promerium['level'] = $this->refine_promerium['level']+1;
  205.                             $this->refine_promerium['status'] = 1;
  206.                             $this->refine_promerium['upgrade_finished'] = 0;
  207.                             $data = implode("|", $this->refine_promerium);
  208.                             $type = "promeriumref";
  209.                             $qry = $this->con->prepare("UPDATE skylab SET {$type} = :data WHERE UserID = :uID");
  210.                             $qry->bindParam(':uID', $this->uid, PDO::PARAM_INT);
  211.                             $qry->bindParam(':data', $data, PDO::PARAM_STR);
  212.                             $qry->execute();
  213.                         }
  214.                     }
  215.                    
  216.                     if($this->refine_seprom['status'] == 2 && $this->refine_seprom['upgrade_finished'] != 0){
  217.                         if($time >= $this->refine_seprom['upgrade_finished']){
  218.                             $this->refine_seprom['level'] = $this->refine_seprom['level']+1;
  219.                             $this->refine_seprom['status'] = 1;
  220.                             $this->refine_seprom['upgrade_finished'] = 0;
  221.                             $data = implode("|", $this->refine_seprom);
  222.                             $type = "sepromref";
  223.                             $qry = $this->con->prepare("UPDATE skylab SET {$type} = :data WHERE UserID = :uID");
  224.                             $qry->bindParam(':uID', $this->uid, PDO::PARAM_INT);
  225.                             $qry->bindParam(':data', $data, PDO::PARAM_STR);
  226.                             $qry->execute();
  227.                         }
  228.                     }
  229.                    
  230.                     if($this->generator_xeno['status'] == 2 && $this->generator_xeno['upgrade_finished'] != 0){
  231.                         if($time >= $this->generator_xeno['upgrade_finished']){
  232.                             $this->generator_xeno['level'] = $this->generator_xeno['level']+1;
  233.                             $this->generator_xeno['status'] = 1;
  234.                             $this->generator_xeno['upgrade_finished'] = 0;
  235.                             $data = implode("|", $this->generator_xeno);
  236.                             $type = "xenogen";
  237.                             $qry = $this->con->prepare("UPDATE skylab SET {$type} = :data WHERE UserID = :uID");
  238.                             $qry->bindParam(':uID', $this->uid, PDO::PARAM_INT);
  239.                             $qry->bindParam(':data', $data, PDO::PARAM_STR);
  240.                             $qry->execute();
  241.                         }
  242.                     }
  243.                     return TRUE;
  244.                 }
  245.             } else {
  246.                 $time = new DateTime();
  247.                 $time = $time->getTimestamp();
  248.  
  249.                 // level|status|finished-timestamp
  250.                 $qrys = $this->con->prepare("INSERT INTO `skylab`
  251.                                             (`LabID`, `UserID`, `lastvisit`, `basicmod`, `solarmod`, `storagemod`,
  252.                                             `prometiumcol`, `enduriumcol`, `terbiumcol`, `prometidref`, `duraniumref`,
  253.                                             `promeriumref`, `xenogen`, `sepromref`)
  254.                                             VALUES
  255.                                             (: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')");
  256.                 $qrys->bindParam(':uID', $this->uid, PDO::PARAM_INT);
  257.                 $qrys->bindParam(':lv', $time, PDO::PARAM_INT);
  258.                 $qrys->execute();
  259.                 $qryr = $this->con->prepare("INSERT INTO `skylab_ressources`
  260.                                             (`LabID`, `prometium`, `endurium`, `terbium`, `prometid`, `duranium`, `xenomit`, `promerium`, `seprom`)
  261.                                             VALUES
  262.                                             (:uID, 50000, 50000, 50000, 0, 0, 0, 0, 0)");
  263.                 $qryr->bindParam(':uID', $this->uid, PDO::PARAM_INT);
  264.                 $qryr->execute();
  265.                 self::initSkylab();
  266.             }
  267.         }  
  268.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement