Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6 2.23 KB | None | 0 0
  1. ### Randomly add items to Bazaar merchant each restart
  2. ### Stores items in merchantlist_temp
  3. ### Reads items from Bazaar.txt list
  4. ##################################################################################
  5. ##################################################################################
  6.  
  7. #::: Variables
  8. $merchant1 = 500000;
  9.  
  10. #::: Script Body
  11. #::: Read database name, user and password from eqemu config file
  12. read_eqemu_config_xml();
  13. get_mysql_path();
  14.  
  15. #::: Clear previous entries from merchantlist_temp table
  16.  
  17. sub read_eqemu_config_xml {
  18.     open (CONFIG, "eqemu_config.xml");
  19.     while (<CONFIG>){
  20.         chomp;
  21.         $o = $_;
  22.        
  23.         if($o=~/\<\!--/i){
  24.             next;
  25.         }
  26.        
  27.         if($o=~/database/i && $o=~/\<\//i){
  28.             $in_database_tag = 0;
  29.         }
  30.         if($o=~/database/i){
  31.             print "IN DATABASE TAG\n" if $debug;
  32.             $in_database_tag = 1;
  33.         }
  34.         if ($o=~/<longname>/i){
  35.             ($long_name) = $o =~ /<longname>(.*)<\/longname>/;
  36.             print "Long Name: '" . $long_name . "'/n" if $debug;
  37.         }
  38.         if($in_database_tag == 1){
  39.             @left = split (">", $o);
  40.             @right = split ("<", $left[1]);
  41.             $tag_data = trim($right[0]);
  42.            
  43.             if($0=~/<username>/i && $in_database_tag){
  44.                 $user = $tag_data;
  45.                 print "Database User: '" . $user . "'\n" if $debug;
  46.             }
  47.             if($o=~/<password>/i && $in_database_tag){
  48.                 $pass = $tag_data;
  49.                 print "Database Pass: '" . $pass . "'\n" if $debug;
  50.             }
  51.             if($o=~/<db>/i){
  52.                 $db = $tag_data;
  53.                 print "Database Name: '" . $db . "'\n" if $debug;
  54.             }
  55.             if($o=~/<host>/i){
  56.                 $host = $tag_data;
  57.                 print "Database Host: '" . $host . "'\n" if $debug;
  58.             }
  59.         }
  60.     }
  61.     close(CONFIG);
  62. }
  63.  
  64. sub get_mysql_path {
  65.     $has_mysql_path = `echo %PATH%`;
  66.     if($has_mysql_path=~/MySQL|MariaDB/i){
  67.         @mysql = split(';', $has_mysql_path);
  68.         foreach my $v (@mysql){
  69.             if($v=~/MySQL|MariaDB/i){
  70.                 $v =~s/\n//g;
  71.                 $path = trim($v) . "/mysql";
  72.                 last;
  73.             }
  74.         }
  75.     }
  76.    
  77.     #::: Path not found, error and exit
  78.     if($path eq ""){
  79.         print "[Error:Bazaar.pl] MySQL path not found, please add the path for automatic merchant script to continue... \n\n";
  80.         exit;
  81.     }  
  82. }
  83.  
  84. sub get_mysql_result {
  85.     my $run_query = $_[0];
  86.     if(!$db){ return; }
  87.     return `"$path" --host $host --user $user --password="$pass" $db -N -B -e "$run_query"`;
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement