Есть код:
Код | class file {
public function FileOpen($path){ clearstatcache();#клеар кеш. if(!file_exists($path) || !is_file($path) || !is_readable($path) ) return false; if(filesize($path)<=0) return false; $fd = fopen($path, "rb"); $contents = fread ($fd, filesize($path)); fclose ($fd); return $contents; }
public function FileWrite($path, $contents , $unlock = false, $chmod = 0755){ if(file_exists($path)) chmod($path,$chmod); if($file = fopen($path, "w+")){ if($unlock!=false) $this->LockFile($file); fwrite($file, $contents); if($unlock!=false) $this->UnlockFile($file); fclose($file); chmod($path,$chmod); return true; } else return false; }
public function LockFile($f, $mode='w'){ switch ($mode){ case 'w': case 'W': return flock($f, LOCK_EX); break; case 'r': case 'R': return flock($f, LOCK_SH); break; default: die(sprintf('FATAL: invalid lock mode: %s in %s or method %s ' ,$mode , __FILE__ , __FUNCTION__ )); } }
public function UnlockFile($f){ return flock($f, LOCK_UN); }
}
|
но он почемуто при работе на денвере под вистой пудрит мозг..
отправляется аякс запрос на редактирования данных на страницу /cms/core/ajax.php Параметры ПОСТ comand showDialogEditTmpl component_name autlogin id_component 2 template new_tmpl title autlogin url_page /index.php
Файл /cms/core/ajax.php
Код | //Тут конфиг и автолойдер... include_once $_SERVER['DOCUMENT_ROOT'].'/core/config.php';
if (get_magic_quotes_gpc()) { $_GET = stripslashes_array($_GET); $_POST = stripslashes_array($_POST); $_COOKIE = stripslashes_array($_COOKIE); }
$core = new core();
$charset = new charset();
$file = new file(); //Тупой класс вот его вызываю.. для работы с файлами
//Получаем команду выполняем действие if(!empty($_POST['comand'])){ $comand = $_POST['comand']; switch($comand){
//открыть деалог настройки компонента!!!
case 'showDialogConfig': $component_name = $_POST['component_name']; if(file_exists(core_root . "/components/".$component_name . "/dialog.php" )) include_once core_root . "/components/".$component_name . "/dialog.php"; break; case 'include_ajax_component': //Выполнения инструкций аякса конфига комопнента. $component_name = $_POST['component_name']; if(file_exists(core_root . "/components/".$component_name . "/ajax.php" )) { include_once core_root . "/components/".$component_name . "/ajax.php"; } break; //Деалог редактирования шаблона case 'showDialogEditTmpl': include_once getTemplateCore('actions/edit_template_component.php'); break; //Результат сохранения case 'saveNewTmplComponent': include_once getTemplateCore('actions/result_new_template_component.php'); break; //Результат сохранения редактирования шаблона. case 'save_edit_template': include_once getTemplateCore('actions/result_edit_template_component.php'); break;
}}
|
getTemplateCore возращяет частичный путь....
case 'showDialogEditTmpl': include_once getTemplateCore('actions/edit_template_component.php'); break;
Далие идем по порядку открываем файл ... где ругается actions/edit_template_component.php
Код | $url_page = $_POST['url_page']; $component_name = $_POST['component_name']; $idcomponent = intval($_POST['id_component']);
$nameTmpl = !empty($_POST['nameTmpl'])? $_POST['nameTmpl'] : 'new_tmpl'; $txtTmpl = !empty($_POST['txtTmpl'])? $_POST['txtTmpl'] : '';
$template = !empty($_POST['template'])? $_POST['template'] : ''; $template = !empty($_POST['template'])? $_POST['template'] : '';
$body = '';
///$file = new file();
if(is_dir(core_root . "/components/{$component_name}/templates/{$template}")) { $dirc = core_root . "/components/{$component_name}/templates/{$template}/template.php"; $body = $file->FileOpen($dirc); }
|
Результат http://savepic.org/1584298.htm
разкоменчиваю /// $file = new file();
Результат
http://savepic.org/1588394.htm
Почему include_once getTemplateCore('actions/edit_template_component.php'); не бепедается $file ? раньше до переноса проекта на персональный компьютер с хостинга все работало.
Намашине стоит апатч под вистой хоме базовый.
|