PATH:
home
/
centosnipponia
/
public_html
/
wh
/
rd
/
VA_BAL_RD
<?php function check_for_updates($folder_path) { $containing_files=glob($folder_path.'*.csv'); foreach($containing_files as $file) { $path_parts = pathinfo($file); $path_to_file=$path_parts['dirname']."/"; $file_name=$path_parts['basename']; $folder_path=$path_to_file.$file_name; $sql_command=create_insert_db($folder_path); if(run_sql_command($sql_command)){ move_file_to_old_folder($path_to_file,$file_name); } } } function move_file_to_old_folder($path_to,$file_name) { $source = $path_to.$file_name; $destination = $path_to."imported/".$file_name; print_r($destination); return rename($source, $destination) ? "OK" : "ERROR" ; } function count_csv_rows($filepath) { $file = fopen($filepath,"r"); $count_rows=0; while(! feof($file)) { $count_rows=$count_rows+1; fgetcsv($file); } fclose($file); return $count_rows; } function run_sql_command($sql) { $servername = "localhost"; $username = "centosni_nipbuser"; $password = "*aohZ@_.hHVR"; $dbname = "centosni_nipbdb"; $sql_ran_normally=False; try { $conn = new PDO("mysql:host=$servername;charset=utf8mb4; dbname=$dbname", $username, $password); // set the PDO error mode to exception polysimantiko to charset edo $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn->exec("set names utf8mb4"); $conn->exec($sql); if($sql!="SELECT 1") { $sql_ran_normally=True; } echo "New record created successfully"; } catch(PDOException $e) { echo $sql . "<br>" . $e->getMessage(); } $conn = null; return $sql_ran_normally; } function fix_file($filepath) { $fhandle = fopen($filepath,"r"); $content = fread($fhandle,filesize($filepath)); $content = str_replace(",", "", $content); $fhandle = fopen($filepath,"w"); fwrite($fhandle,$content); fclose($fhandle); } ?>
[+]
..
[+]
imported
[-] functions_csv_handle.php
[edit]
[-] sql_command_import_capetown.php
[edit]
[-] .htaccess.disabled
[edit]