inital commit
This commit is contained in:
90
webroot/dbtohtml.php
Normal file
90
webroot/dbtohtml.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
ini_set('memory_limit', '200000000M');
|
||||
require './Staff/dbconfig.php';
|
||||
$file_path = "html_content";
|
||||
$file_path_html_code = "html_content/html_history_code/";
|
||||
processhtmlcodehistories($conn,$file_path_html_code);
|
||||
//processDataDocument($conn,$file_path);
|
||||
|
||||
//ALTER TABLE `data_documents` ADD `is_process` TINYINT(1) NOT NULL DEFAULT '0' COMMENT 'for temporary use' AFTER `modified_on`;
|
||||
|
||||
function processDataDocument($conn,$file_path){
|
||||
$file_path = __DIR__."/".$file_path;
|
||||
|
||||
if(!is_dir($file_path)){
|
||||
mkdir($file_path,0777,true);
|
||||
}
|
||||
|
||||
$sql = "select * from data_documents where is_process = 0 Limit 0,100";
|
||||
$result = mysqli_query($conn,$sql);
|
||||
//count
|
||||
while ($row = mysqli_fetch_assoc($result)){
|
||||
$member_id = $row['cmsuser_id'] ;
|
||||
$client_id = $row['client_id'] ;
|
||||
$dd_id = $row['id'] ;
|
||||
$new_path = $file_path."/".$member_id."/".$client_id;
|
||||
if(!is_dir($new_path)){
|
||||
mkdir($new_path,0777,true);
|
||||
}
|
||||
$path = $new_path.'/'.$dd_id;
|
||||
if(!empty($row['html_content']) && !file_exists($path.".html")){
|
||||
fileWrite($path,$row['html_content']);
|
||||
$sql1 = "UPDATE data_documents SET is_process=1 WHERE id=".$dd_id;
|
||||
if(mysqli_query($conn,$sql1)){
|
||||
echo "<p style='color:green'>Process success for Data Document ID = ".$dd_id."</p><br/>";
|
||||
}else{
|
||||
echo "<p style='color:red'>Process failed for Data Document ID = ".$dd_id."</p><br/>";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function processhtmlcodehistories($conn,$file_path){
|
||||
$file_path = __DIR__."/".$file_path;
|
||||
|
||||
if(!is_dir($file_path)){
|
||||
mkdir($file_path,0777,true);
|
||||
}
|
||||
|
||||
$sql = "select * from html_code_histories Limit 0,100";
|
||||
$result = mysqli_query($conn,$sql);
|
||||
//count
|
||||
while ($row = mysqli_fetch_assoc($result)){
|
||||
|
||||
$member_id = $row['member_id'] ;
|
||||
$client_id = $row['client_id'] ;
|
||||
$dd_id = $row['id'] ;
|
||||
$new_path = $file_path."/".$member_id."/".$client_id;
|
||||
if(!is_dir($new_path)){
|
||||
mkdir($new_path,0777,true);
|
||||
}
|
||||
$path = $new_path.'/'.$dd_id;
|
||||
if(!empty($row['code']) && !file_exists($path.".html")){
|
||||
fileWrite($path,$row['code']);
|
||||
$sql1 = "UPDATE data_documents SET is_process=1 WHERE id=".$dd_id;
|
||||
if(1){
|
||||
echo "<p style='color:green'>Process success for Data Document ID = ".$dd_id."</p><br/>";
|
||||
}else{
|
||||
echo "<p style='color:red'>Process failed for Data Document ID = ".$dd_id."</p><br/>";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function fileWrite($file_name,$content){
|
||||
//file_put_contents($file_name.".", $current);
|
||||
try {
|
||||
//$pattern = "/<script[^>]*>(?:(?!<\/script>)[^])*<\/script>/g";
|
||||
//$content = preg_replace($pattern, "", $content);
|
||||
$file = fopen($file_name.".html","wb");
|
||||
fwrite($file,utf8_encode($content));
|
||||
fclose($file);
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user