[384] | 1 | <?php |
---|
| 2 | function xp_permission_check($mydirname , $mydirpath) { |
---|
| 3 | global $ret ; // TODO :-D |
---|
| 4 | // permission check |
---|
| 5 | |
---|
| 6 | $error = false; |
---|
| 7 | if( defined( 'XOOPS_CUBE_LEGACY' ) ) { |
---|
| 8 | $GLOBALS["err_log"][] = "********************************* Error Log ********************************<br />"; |
---|
| 9 | } else { |
---|
| 10 | $GLOBALS["err_log"][] = '<h4 style="border-bottom: 1px dashed rgb(0, 0, 0); text-align: left; margin-bottom: 0px;">Error Log</h4>'; |
---|
| 11 | } |
---|
| 12 | |
---|
| 13 | if (!file_exists($mydirpath . '/wp-settings.php')){ |
---|
| 14 | $GLOBALS["err_log"][] = '<span style="color:#ff0000;">WordPress is not built in.</span><br />'; |
---|
| 15 | $error = true; |
---|
| 16 | } |
---|
| 17 | $check_files = array('/templates/', '/wp-content/'); |
---|
| 18 | foreach ($check_files as $check) { |
---|
| 19 | $check_file = $mydirpath . $check; |
---|
| 20 | if (!is_dir($check_file)) { |
---|
| 21 | if ( file_exists($check_file) ) { |
---|
| 22 | @chmod($check_file, 0666); |
---|
| 23 | if (! is_writeable($check_file)) { |
---|
| 24 | $GLOBALS["err_log"][] = "<span style=\"color:#ff0000;\">Permission Error $check_file is not writeable</span><br />"; |
---|
| 25 | $error = true; |
---|
| 26 | } |
---|
| 27 | } |
---|
| 28 | } else { |
---|
| 29 | @chmod($check_file, 0777); |
---|
| 30 | if (! is_writeable($check_file)) { |
---|
| 31 | $GLOBALS["err_log"][] = "<span style=\"color:#ff0000;\">Permission Error $check_file directory is not writeable</span><br />"; |
---|
| 32 | $error = true; |
---|
| 33 | } else { |
---|
| 34 | // Windows parmission check |
---|
| 35 | $src_file = __FILE__ ; |
---|
| 36 | $newfile = $check_file . 'write_check.txt'; |
---|
| 37 | if (!copy($src_file, $newfile)) { |
---|
| 38 | $GLOBALS["err_log"][] = "<span style=\"color:#ff0000;\">Permission Error $check_file directory is not writeable</span><br />"; |
---|
| 39 | $error = true; |
---|
| 40 | } else { |
---|
| 41 | unlink($newfile); |
---|
| 42 | } |
---|
| 43 | } |
---|
| 44 | } |
---|
| 45 | } |
---|
| 46 | if($error) return false; |
---|
| 47 | |
---|
| 48 | return true; |
---|
| 49 | } |
---|
| 50 | ?> |
---|