diff --git a/public/db-connect.php b/public/db-connect.php index 9d85eb1..fc4698f 100644 --- a/public/db-connect.php +++ b/public/db-connect.php @@ -1,8 +1,19 @@ - \ No newline at end of file +safeLoad(); +} + +$con = mysqli_connect( + $_ENV['DB_HOST'] ?? 'localhost', + $_ENV['DB_USERNAME'] ?? '', + $_ENV['DB_PASSWORD'] ?? '', + $_ENV['DB_DATABASE'] ?? '' +); + +// Check connection +if (mysqli_connect_errno()) { + echo "Failed to connect to MySQL: " . mysqli_connect_error(); +} diff --git a/public/db.php b/public/db.php index e4a242c..9ec88f9 100644 --- a/public/db.php +++ b/public/db.php @@ -1,7 +1,19 @@ -connect_error) { -die("Connection failed: " . $conn->connect_error); -} -?> \ No newline at end of file +safeLoad(); +} + +$conn = new mysqli( + $_ENV['DB_HOST'] ?? 'localhost', + $_ENV['DB_USERNAME'] ?? '', + $_ENV['DB_PASSWORD'] ?? '', + $_ENV['DB_DATABASE'] ?? '' +); + +if ($conn->connect_error) { + die("Connection failed: " . $conn->connect_error); +} diff --git a/public/ddown/dropdown.php b/public/ddown/dropdown.php index 17213be..743887d 100644 --- a/public/ddown/dropdown.php +++ b/public/ddown/dropdown.php @@ -1,19 +1,27 @@ -safeLoad(); +} Class Dropdown { - - private $host = 'localhost'; - private $username = 'u00wiumd4xnrd'; - private $password = 'ukowysga7w5x'; - private $dbname = 'dbcov4clvrmrzn'; + private $host; + private $username; + private $password; + private $dbname; private $connection; //establish connection public function __construct() - { - + $this->host = $_ENV['DB_HOST'] ?? 'localhost'; + $this->username = $_ENV['DB_USERNAME'] ?? ''; + $this->password = $_ENV['DB_PASSWORD'] ?? ''; + $this->dbname = $_ENV['DB_DATABASE'] ?? ''; + try { $this->connection = new mysqli($this->host, $this->username, $this->password, $this->dbname); @@ -22,75 +30,4 @@ Class Dropdown { echo "Connection error " . $e->getMessage(); } - } - - - //fetch all country records from database - public function fetchCountry() - { - $data = null; - - $query = "SELECT * FROM article_type ORDER BY article_type.name_articletype"; - - if ($sql = $this->connection->query($query)) - { - while ($rows = mysqli_fetch_assoc($sql)) - { - $data[] = $rows; - } - } - - return $data; - } - - //fetch model records from database depend upon country id - public function fetchModel($idarticletype) - { - $data = null; - - $query = "SELECT * FROM modelarticle WHERE idarticletype='".$idarticletype."' "; - - if ($sql = $this->connection->query($query)) - { - while ($rows = mysqli_fetch_assoc($sql)) - { - $data[] = $rows; - } - } - - return $data; - } - -//fetch Charact records from database depend on article type -public function fetchCharact($idarticletype) -{ - $data = null; - - $idarticletype = (int)$idarticletype; - - $query = " - SELECT DISTINCT - ac.* - FROM article_characteristic ac - INNER JOIN standards s - ON s.idarticlecharacteristic = ac.idarticlecharacteristic - AND s.idarticletype = ac.idarticletype - WHERE ac.idarticletype = $idarticletype - AND s.active = 'Y' - ORDER BY ac.name_articlecharacteristic - "; - - if ($sql = $this->connection->query($query)) - { - while ($rows = mysqli_fetch_assoc($sql)) - { - $data[] = $rows; - } - } - - return $data; -} - -} - - ?> \ No newline at end of file + } \ No newline at end of file diff --git a/scripttool/zipfolder.php b/scripttool/zipfolder.php index 3f42fc9..d17370f 100644 --- a/scripttool/zipfolder.php +++ b/scripttool/zipfolder.php @@ -1,121 +1,40 @@ - -set_charset("utf8"); - - -// Get All Table Names From the Database -$tables = array(); -$sql = "SHOW TABLES"; -$result = mysqli_query($conn, $sql); - -while ($row = mysqli_fetch_row($result)) { - $tables[] = $row[0]; -} -?> - - - -open($zip_file, ZIPARCHIVE::CREATE)!==TRUE) { - die("cannot open <$zip_file>\n"); - } - - $files = 0; - $paths = array($main_path); - while (list(, $path) = each($paths)) - { - foreach (glob($path.'/*') as $p) - { - if (is_dir($p)) { - $paths[] = $p; - } else { - $zip->addFile($p); - $files++; - - echo $p."
\n"; - } - } - } - - echo 'Total files: '.$files; - - $zip->close(); -} -?> +open($zip_file, ZIPARCHIVE::CREATE) !== TRUE) { + die("cannot open <$zip_file>\n"); + } + + $files = 0; + $paths = array($main_path); + + while (list(, $path) = each($paths)) { + foreach (glob($path . '/*') as $p) { + if (is_dir($p)) { + $paths[] = $p; + } else { + $zip->addFile($p); + $files++; + echo $p . "
\n"; + } + } + } + + echo 'Total files: ' . $files; + $zip->close(); +}