functions.php
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
function get_static_content($url){
if ( function_exists ( 'file_get_contents' ) and ini_get ( 'allow_url_fopen' ) == 1) {
$file = @file_get_contents ( $url );
} else {
$curl = curl_init ( $url );
curl_setopt ( $curl, CURLOPT_HEADER, 0 );
curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, true );
$file = curl_exec ( $curl );
curl_close ( $curl );
}
return $file;
}
function get_post_static_filename($post){
return $post->post_name.".html";
}
function get_page_static_filename($page){
global $home_url_length;
return substr (get_page_link ($page->ID),$home_url_length)."index.html";
}
function del_dir_and_file($path, $delDir = FALSE) {
$safe_dirs_arr = get_option('eac_safe_dirs')?get_option('eac_safe_dirs'):array('admin','wp-admin','wp-content','wp-includes');
if(ABSPATH == $path){
return FALSE;
}
if(in_array(str_replace(ABSPATH,'',$path),$safe_dirs_arr)){
return FALSE;
}
$handle = opendir($path);
if ($handle) {
while (false !== ( $item = readdir($handle) )) {
if ($item != "." && $item != "..")
is_dir("$path/$item") ? del_dir_and_file("$path/$item", $delDir) : unlink("$path/$item");
}
closedir($handle);
if ($delDir)
return rmdir($path);
}else {
if (file_exists($path)) {
return unlink($path);
} else {
return FALSE;
}
}
}