Advertisement
D0cEvil

PHP - Connect to MySQL (Lab2)

Jan 4th, 2023
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.16 KB | Cybersecurity | 0 0
  1. <?php
  2.  
  3. $srvname="localhost";
  4. $username="root";
  5. $passwd="P@ssw0rd";
  6. $dbname="testdb";
  7.  
  8. //Массив с именами файлов таблиц ACL, совпадают с именами таблиц в БД
  9.  
  10. $acl_tables = array(1 => 'acl_esx_rules','acl_exim_rules','acl_ftp_rules','acl_loader_rules','acl_motorsich_6116_rules','acl_motorsich_oracle_rules','acl_motorsich_rdp_rules','acl_pib_rules','acl_printera_rules','acl_prohod_rules','acl_sharepoint_user_rules','acl_spfserv_rules','acl_squid_rules','acl_tender_rules','acl_terminet_rules');
  11.  
  12.  
  13.     mysql_connect($srvname, $username, $passwd) or die (mysql_error ());
  14.     mysql_select_db($dbname) or die(mysql_error());
  15.    
  16.     echo "Using DB ".$dbname. "<br />";
  17.  
  18.     for ($i = 1; $i <= count($acl_tables); $i++)
  19.     {
  20.         echo "Create table ".$acl_tables[$i]."<br /> ";
  21.         $trunk = "CREATE TABLE `testdb`.$acl_tables[$i] ( `id` INT NOT NULL AUTO_INCREMENT , `ip_addr` VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , `username` VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB";
  22.         mysql_query($trunk) or die(mysql_error());
  23.     }
  24.  
  25. mysql_close();
  26.  
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement