Advertisement
Guest User

Untitled

a guest
Sep 16th, 2017
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 14.23 KB | None | 0 0
  1. <?php
  2.  
  3. require '../dibi/dibi.php';
  4. require '../php_scripts/config.php';
  5. require '../classes/Telnet.php';
  6. require '../php_scripts/functions.php';
  7.  
  8. function transferThisItemChar($r) {
  9.     global $mysqliC,$ii,$newCharGuid;
  10.     if(($r['slot']<=73 && $r['bag']==0)) {
  11.         // $mysqliC->query("SET AUTOCOMMIT=0");
  12.         $mysqliC->query("LOCK TABLES character_inventory READ, item_instance READ;");
  13.         $mysqliC->query("START TRANSACTION");
  14.         $query = $mysqliC->query("SELECT (MAX(item)+1) FROM character_inventory");
  15.         $guid = $query->fetch_row();
  16.         $p1 = $mysqliC->query("INSERT INTO character_inventory (guid,bag,slot,item) VALUES('".$newCharGuid."',".$r['bag'].",".$r['slot'].",".$guid[0].")");
  17.         $p2 = $mysqliC->query("INSERT INTO item_instance (guid,itemEntry,owner_guid,creatorGuid,giftCreatorGuid,count,duration,charges,flags,enchantments,randomPropertyId,durability,playedTime,text) VALUES (".$guid[0].",'".$ii[$r['item']]['itemEntry']."','".$newCharGuid."','0','0','".$ii[$r['item']]['count']."','".$ii[$r['item']]['duration']."','".$ii[$r['item']]['charges']."','".$ii[$r['item']]['flags']."','".$ii[$r['item']]['enchantments']."','".$ii[$r['item']]['randomPropertyId']."','".$ii[$r['item']]['durability']."','".$ii[$r['item']]['playedTime']."','".$ii[$r['item']]['text']."')");
  18.         if($r['bag']==0 && $r['slot']>=19 && $r['slot']<=22) { session_start(); $_SESSION['changes']['inventory'][$r['item']] = $guid[0]; } // bags in inventory
  19.         if($r['bag']==0 && $r['slot']>=67 && $r['slot']<=73) { session_start(); $_SESSION['changes']['bank'][$r['item']] = $guid[0]; } // bags in bank
  20.         if($p1 && $p2) {
  21.             $mysqliC->query("COMMIT");
  22.         } else {
  23.             $mysqliC->query("ROLLBACK");
  24.             transferThisItemChar($r);
  25.         }
  26.         $mysqliC->query("UNLOCK TABLES;");
  27.         unset($p1,$p2);
  28.     }
  29. }
  30.  
  31. function transferThisItemBank($r) {
  32.    
  33. }
  34.  
  35. $type = $_GET['t'];
  36. if(is_numeric($type)) {
  37.     switch($type) {
  38.         case 1:
  39.             {
  40.                 $username = $_GET['username'];
  41.                 $password = $_GET['password'];
  42.                 $hash = sha1(strtoupper($username).':'.strtoupper($password));
  43.                 $match = $dibiSW->query("SELECT id FROM account WHERE username = %s",$username," AND sha_pass_hash = %s",$hash)->fetchSingle();
  44.                 $banned = $dibiSW->query("SELECT bandate FROM account_banned WHERE id = %i", $match, " AND active = '1'")->fetchSingle();
  45.                 if(!$banned) {
  46.                     if($match) {
  47.                         $array = $dibiCT->query("SELECT name FROM characters WHERE online = '0' AND account = %s",$match)->fetchAll();
  48.                         echo '<form action="" method="post" enctype="application/x-www-form-urlencoded">';
  49.                         echo '<tr><td><input type="hidden" name="transf_wtc_account" value="'.$username.'"></td></tr>';
  50.                         echo '<table>';
  51.                         foreach($array as $value) {
  52.                             echo '<tr><td><input type="checkbox" name="'.$value['name'].'" id="'.$value['name'].'" /></td><td><label for="'.$value['name'].'">'.$value['name'].'</label></td></tr>';
  53.                         }  
  54.                         echo '<tr><td colspan="2"><hr /><br /></td></tr>';
  55.                         echo '<tr><td colspan="2">cata účet: <input type="text" id="transf_wtc_account_cata" name="transf_wtc_account_cata" value="" /><br /><br /></td></tr>';
  56.                         echo '<tr><td colspan="2">Tímto stvrzujete, že žádáte o převedení postav na cataclysm realm. Postavy Vám budou v tento okamžik odebrány z účtu, ponechány v záloze a v nejbližším možném termínu převedeny na cataclysm realm.</td></tr>';
  57.                         echo '<tr><td colspan="2"><input type="submit" name="submit_transfer_wtc_send" value="zažádat o převod postav" onclick="return transferSecoundCheck()"></td></tr>';
  58.                         echo '</table></form>';
  59.                     } else {
  60.                         echo '<br />chyba přístupu na účet';
  61.                     }
  62.                 } else {
  63.                     echo '<br />nelze převést charactery ze zabanovaného účtu';
  64.                 }
  65.                 break;
  66.             }
  67.         case 2:
  68.             {
  69.                 $id = $_GET['id'];
  70.                 $cata_char = $_GET['cc'];
  71.                 $faze = $_GET['faze'];
  72.                 if(is_numeric($id)) {
  73.                     $newCharGuid=$dibiC->query("SELECT guid FROM characters WHERE online = '0' AND name = %s", $cata_char)->fetchSingle();
  74.                     if($newCharGuid) {
  75.                         $array = dibi::query("SELECT * FROM web2_transfer_wtc WHERE id = %i",$id)->fetch();
  76.                         $character = $array['character'];
  77.                         $characters=$dibiCT->query("SELECT * FROM characters WHERE name = %s",$character)->fetch();
  78.                         switch($faze) {
  79.                             case 1:
  80.                             {
  81.                                 session_start();
  82.                                 $_SESSION['changes']=null;
  83.                                 $faze = $array['status'];
  84.                                 if($faze == 0) {
  85.                                     /*
  86.                                      * lets transfer begin
  87.                                      */
  88.                                     // step 1. money
  89.                                     $dibiC->query("UPDATE characters SET money = %i",$characters['money']," WHERE guid = %i",$newCharGuid);
  90.                                     // step 2. skilly -  fishing(356), archaeology(794),cooking(185),first aid(129)
  91.                                     $skills=$dibiCT->query("SELECT * FROM character_skills WHERE guid = %i",$characters['guid'])->fetchAll();
  92.                                     $onlyThisSkills = array('356','794','185','129','171','164','333','202','182','773','755','165','186','393','197','762');
  93.                                     foreach($skills as $r) {
  94.                                         if(in_array($r['skill'],$onlyThisSkills)) {
  95.                                             $dibiC->query("DELETE FROM character_skills WHERE guid = %i",$newCharGuid, " AND skill = %i",$r['skill']);
  96.                                             $r['guid']=$newCharGuid;
  97.                                             $dibiC->query("INSERT INTO character_skills ",$r);
  98.                                         }
  99.                                     }
  100.                                     // step 3. spelly
  101.                                     $notSpells=array('688','712','697','691');
  102.                                     $spells=$dibiCT->query("SELECT * FROM character_spell WHERE guid = %i",$characters['guid'])->fetchAll();
  103.                                     foreach($spells as $r) {
  104.                                         if(!in_array($r['spell'],$notSpells)) {
  105.                                             $dibiC->query("DELETE FROM character_spell WHERE guid = %i",$newCharGuid," AND spell = %i",$r['spell']);
  106.                                             $r['guid']=$newCharGuid;
  107.                                             $dibiC->query("INSERT INTO character_spell ",$r);
  108.                                         }
  109.                                     }
  110.                                     // step 4. reputation
  111.                                     $reputation=$dibiCT->query("SELECT * FROM character_reputation WHERE guid = %i",$characters['guid'])->fetchAll();
  112.                                     foreach($reputation as $r) {
  113.                                         $dibiC->query("DELETE FROM character_reputation WHERE guid = %i",$newCharGuid," AND faction = %i",$r['faction']);
  114.                                         $r['guid']=$newCharGuid;
  115.                                         $dibiC->query("INSERT INTO character_reputation ",$r);
  116.                                     }
  117.                                     dibi::query("UPDATE web2_transfer_wtc SET status = '1' WHERE id = %i",$id);
  118.                                 } else {
  119.                                     // TODO: notice - character has been transfered yet via phase 1
  120.                                 }
  121.                                 break;
  122.                             }
  123.                             case 2:
  124.                             {
  125.                                 $faze = $array['status'];
  126.                                 if($faze == 1) {
  127.                                     $notQuest=array('1599','1598');
  128.                                     $quests=$dibiCT->query("SELECT * FROM character_queststatus WHERE guid = %i",$characters['guid'])->fetchAll();
  129.                                     $questsRewarded=$dibiCT->query("SELECT * FROM character_queststatus_rewarded WHERE guid = %i",$characters['guid'])->fetchAll();
  130.                                     foreach($quest as $r) {
  131.                                         if(!in_array($r['quest'],$notQuest)) {
  132.                                             $r['guid']=$newCharGuid;
  133.                                             $dibiC->query("INSERT INTO character_queststatus ",$r);
  134.                                         }
  135.                                     }
  136.                                     foreach($questsRewarded as $r) {
  137.                                         if(!in_array($r['quest'],$notQuest)) {
  138.                                             $r['guid']=$newCharGuid;
  139.                                             $dibiC->query("INSERT INTO character_queststatus_rewarded ",$r);
  140.                                         }
  141.                                     }
  142.                                     dibi::query("UPDATE web2_transfer_wtc SET status = '2' WHERE id = %i",$id);
  143.                                 } else {
  144.                                     // TODO: notice - character has been transfered yet via phase 2
  145.                                 }
  146.                                 break; 
  147.                             }
  148.                             case 3:
  149.                             {
  150.                                 $faze = $array['status'];
  151.                                 // TODO: pro test zakomentovano if($faze == 2) {
  152.                                     // erase all items on new char
  153.                                     $delThis=$dibiC->query("SELECT item FROM character_inventory WHERE guid = %i",$newCharGuid)->fetchAll();
  154.                                     foreach($delThis as $r) { $del[]=$r['item']; }
  155.                                     $delThisIn=implode("','",$del);
  156.                                     $delThisIn="'".$delThisIn."'";
  157.                                    
  158.                                     $dibiC->query("DELETE FROM character_inventory WHERE guid = %i",$newCharGuid);
  159.                                     $dibiC->query("DELETE FROM item_instance WHERE guid IN (",$delThisIn,")");
  160.                                     $dibiC->query("DELETE FROM mail WHERE receiver = %i",$newCharGuid);
  161.                                     $dibiC->query("DELETE FROM mail_items WHERE receiver = %i",$newCharGuid);
  162.                                    
  163.                                     // step 5. itemy - nahrat pouze bagy a veci na charu, zapamatovat si ID bagu ( to stare + nove radej )
  164.                                     $items=$dibiCT->query("SELECT * FROM character_inventory WHERE guid = %i",$characters['guid'])->fetchAll();
  165.                                     foreach($items as $r) {
  166.                                         $temp[]=$r['item'];
  167.                                     }
  168.                                     $in=implode("','", $temp);
  169.                                     $in="'".$in."'";
  170.                                     $instances=$dibiCT->query("SELECT * FROM item_instance WHERE guid IN (",$in,")")->fetchAll();
  171.                                     foreach($instances as $r) {
  172.                                         $ii[$r['guid']] = $r;
  173.                                     }
  174.                                    
  175.                                     foreach($items as $r) {
  176.                                         transferThisItemChar($r);
  177.                                     }
  178.                                     unset($r);
  179.                                     /*foreach($changes as $k=>$r) {
  180.                                         $dibiC->query("UPDATE character_inventory SET bag = %i",$r," WHERE bag = %i",$k," AND guid = %i",$newCharGuid);
  181.                                     }*/
  182.                                                                    
  183.                                 // TODO: pro test zakomentovano } else {
  184.                                     // TODO: notice - character has been transfered yet via phase 2
  185.                                 // TODO: pro test zakomentovano }
  186.                                 break;     
  187.                             }
  188.                             case 4:
  189.                             {
  190.                                 $faze = $array['status'];
  191.                                 // TODO: pro test zakomentovano if($faze == 3) {
  192.                                     // step 5. itemy
  193.                                     /*$items=$dibiCT->query("SELECT * FROM character_inventory WHERE guid = %i",$characters['guid'])->fetchAll();
  194.                                     foreach($items as $r) {
  195.                                         $temp[]=$r['item'];
  196.                                     }
  197.                                     $in=implode("','", $temp);
  198.                                     $in="'".$in."'";
  199.                                     $instances=$dibiCT->query("SELECT * FROM item_instance WHERE guid IN (",$in,")")->fetchAll();
  200.                                     foreach($instances as $r) {
  201.                                         $ii[$r['guid']] = $r;
  202.                                     }
  203.                                    
  204.                                     foreach($items as $r) {
  205.                                         transferThisItemBank($r);
  206.                                     }
  207.                                     unset($r);
  208.                                     foreach($changes as $k=>$r) {
  209.                                         $dibiC->query("UPDATE character_inventory SET bag = %i",$r," WHERE bag = %i",$k," AND guid = %i",$newCharGuid);
  210.                                     }
  211.                                     */
  212.                                     session_start();
  213.                                     var_export($_SESSION);
  214.                                 // TODO: pro test zakomentovano }
  215.                                 break;
  216.                             }
  217.                         }
  218.                     } else {
  219.                         // TODO: notice - character is online or was not created
  220.                     }  
  221.                     // DEPRECIATED
  222.                     // 3444 port wotlk, 3443 port cata, 3445 port cata test
  223.                     /*
  224.                     $array = dibi::query("SELECT * FROM web2_transfer_wtc WHERE id = %i",$id)->fetch();
  225.                     $character = $array['character'];
  226.                     $account_cata = $array['account_cata'];
  227.                     $prevedeno = $array['status'];
  228.                     if(!$prevedeno) {
  229.                         send_ra_command($var['account']['gm']['username'], $var['account']['gm']['password'], '89.185.235.181', 3445, 'pdump write /home/kalgul/'.$character.'.sql '.$character);
  230.                         send_ra_command($var['account']['gm']['username'], $var['account']['gm']['password'], '89.185.235.181', 3443, 'pdump load /home/kalgul/'.$character.'.sql '.$account_cata);
  231.                     }
  232.                     */
  233.                 }
  234.                 break;
  235.             }
  236.        
  237.         case 3:
  238.             {
  239.                 $input = $_GET['i'];
  240.                 // $input = '2097152 249024 33554432 199280668 8704 0'; // koval
  241.                 $inputs = explode(' ',$input);
  242.                
  243.                 function idTitle($inGameOrder)
  244.                 {
  245.                 $idTitles = array('1'=>'1',
  246.                 '2'=>'2',
  247.                 '3'=>'3',
  248.                 '4'=>'4',
  249.                 '5'=>'5',  
  250.                 '6'=>'6',  
  251.                 '7'=>'7',  
  252.                 '8'=>'8',  
  253.                 '9'=>'9',  
  254.                 '10'=>'10',
  255.                 '11'=>'11',
  256.                 '12'=>'12',
  257.                 '13'=>'13',
  258.                 '14'=>'14',
  259.                 '15'=>'15',
  260.                 '16'=>'16',
  261.                 '17'=>'17',
  262.                 '18'=>'18',
  263.                 '19'=>'19',
  264.                 '20'=>'20',
  265.                 '21'=>'21',
  266.                 '22'=>'22',
  267.                 '23'=>'23',
  268.                 '24'=>'24',
  269.                 '25'=>'25',
  270.                 '26'=>'26',
  271.                 '27'=>'27',
  272.                 '28'=>'28',
  273.                 '29'=>'42',
  274.                 '30'=>'43',
  275.                 '31'=>'44',
  276.                 '32'=>'45',
  277.                 '33'=>'46',
  278.                 '34'=>'47',
  279.                 '35'=>'48',
  280.                 '36'=>'53',
  281.                 '37'=>'62',
  282.                 '38'=>'63',
  283.                 '39'=>'64',
  284.                 '40'=>'71',
  285.                 '41'=>'72',
  286.                 '43'=>'74',
  287.                 '44'=>'75',
  288.                 '45'=>'76',
  289.                 '46'=>'77',
  290.                 '47'=>'78',
  291.                 '48'=>'79',
  292.                 '49'=>'80',
  293.                 '42'=>'81',
  294.                 '50'=>'82',
  295.                 '51'=>'83',
  296.                 '52'=>'84',
  297.                 '53'=>'85',
  298.                 '54'=>'86',
  299.                 '55'=>'87',
  300.                 '57'=>'89',
  301.                 '58'=>'90',
  302.                 '59'=>'91',
  303.                 '60'=>'92',
  304.                 '61'=>'93',
  305.                 '62'=>'94',
  306.                 '63'=>'95',
  307.                 '64'=>'96',
  308.                 '65'=>'97',
  309.                 '66'=>'98',
  310.                 '67'=>'99',
  311.                 '68'=>'100',   
  312.                 '69'=>'101',   
  313.                 '70'=>'102',   
  314.                 '71'=>'103',   
  315.                 '72'=>'104',   
  316.                 '73'=>'105',   
  317.                 '74'=>'106',   
  318.                 '75'=>'107',   
  319.                 '76'=>'108',   
  320.                 '77'=>'109',   
  321.                 '78'=>'110',   
  322.                 '79'=>'111',   
  323.                 '80'=>'112',   
  324.                 '81'=>'113',   
  325.                 '82'=>'114',   
  326.                 '83'=>'115',   
  327.                 '84'=>'116',   
  328.                 '85'=>'117',   
  329.                 '86'=>'118',   
  330.                 '87'=>'119',   
  331.                 '88'=>'120',   
  332.                 '89'=>'121',   
  333.                 '90'=>'122',   
  334.                 '91'=>'123',   
  335.                 '92'=>'124',   
  336.                 '93'=>'125',   
  337.                 '94'=>'126',   
  338.                 '95'=>'127',   
  339.                 '96'=>'128',   
  340.                 '97'=>'129',   
  341.                 '98'=>'130',   
  342.                 '99'=>'131',   
  343.                 '100'=>'132',
  344.                 '101'=>'133',
  345.                 '102'=>'134',
  346.                 '103'=>'135',
  347.                 '104'=>'137',
  348.                 '105'=>'138',
  349.                 '106'=>'139',
  350.                 '107'=>'140',
  351.                 '108'=>'141',
  352.                 '109'=>'142',
  353.                 '110'=>'143',
  354.                 '111'=>'144',  
  355.                 '112'=>'145',  
  356.                 '113'=>'146',  
  357.                 '114'=>'147',  
  358.                 '115'=>'148',  
  359.                 '116'=>'149',  
  360.                 '117'=>'150',  
  361.                 '118'=>'151',  
  362.                 '119'=>'152',  
  363.                 '120'=>'153',  
  364.                 '121'=>'154',  
  365.                 '122'=>'155',  
  366.                 '123'=>'156',  
  367.                 '56'=>'157',   
  368.                 '124'=>'158',  
  369.                 '125'=>'159',  
  370.                 '126'=>'160',  
  371.                 '127'=>'161',  
  372.                 '128'=>'163',  
  373.                 '129'=>'164',  
  374.                 '130'=>'165',  
  375.                 '131'=>'166',  
  376.                 '132'=>'167',  
  377.                 '133'=>'168',  
  378.                 '134'=>'169',  
  379.                 '135'=>'170',  
  380.                 '136'=>'171',  
  381.                 '137'=>'172',  
  382.                 '138'=>'173',  
  383.                 '139'=>'174',  
  384.                 '140'=>'175',  
  385.                 '141'=>'176',  
  386.                 '142'=>'177'); 
  387.                
  388.                     return $idTitles[$inGameOrder];
  389.                 }
  390.                
  391.                 function zakoduj($idGameOrder)
  392.                 {
  393.                     $data['saveIndex'] = floor($idGameOrder/32);
  394.                     $data['flag'] = 1 << ($idGameOrder%32);
  395.                     return $data;
  396.                 }
  397.                
  398.                 function obsahuje($data)
  399.                 {
  400.                     global $inputs;
  401.                     if($data['flag'] == $inputs[$data['saveIndex']]) {
  402.                         return true;
  403.                     } else {
  404.                         $check = $data['flag'] & $inputs[$data['saveIndex']];
  405.                         if($check) {
  406.                             return true;
  407.                         }
  408.                     }
  409.                     return false;
  410.                 }
  411.                
  412.                 for($i=1;$i<=131;$i++) {
  413.                     $idGameOrders[$i] = $i;
  414.                 }
  415.                
  416.                 foreach($idGameOrders as $key=>$val) {
  417.                     $data = zakoduj($val);
  418.                     if(obsahuje($data)) {
  419.                         $idExistTitleOrder[] = $val;
  420.                     }
  421.                 }
  422.                
  423.                 foreach($idExistTitleOrder as $val) {
  424.                     echo '.title add '.idTitle($val).'<br />';
  425.                 }
  426.                 break;
  427.             }
  428.     }
  429. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement