function _default() { global $dir; if (!MRights::can("open")) { return $this->_noAuth("open"); } $syntax = MRequest::clean("syntax"); $uniq = getUnique(); $height = MRequest::int("height", 550); $sid = MRequest::int("sid", null); //$content = implode('', file($dir)); $content = ""; $encoding = MText::_("nofile"); if (MFile::is($dir) && MFile::isFile($dir)) { $content = MFile::readData($dir); $padding = $syntax == "text" ? "0px" : "0px"; $this->view->content('<form id="saveeditfile" method="post" action="' . MURL::_("xhredit", MURL::safePath($dir), "save", "sid=" . $sid) . '"> <input type="hidden" name="close" id="is_close" value="0"></input> <input type="hidden" name="syntax" value="' . htmlentities($syntax) . '"></input> <input type="hidden" name="height" value="' . htmlentities($height) . '"></input> <textarea id="mEditArea-' . $sid . '" name="content" style="width:100%; height:' . $height . 'px;margin:-4px;padding:' . $padding . ';">' . htmlentities($content) . '</textarea> <div class="toRight" style="margin-top:5px;"> <a href="" class="askButton" style="width:120px; text-align:center;" onclick="javascript: mCodeMirrorSubmit(\'' . $sid . '\'); mFormSubmit(_(\'saveeditfile\'));">' . MText::_("save") . '</a> <a href="" class="askButton" style="width:200px; text-align:center;" onclick="javascript: _(\'is_close\').value = 1; mCodeMirrorSubmit(\'' . $sid . '\'); mFormSubmit(_(\'saveeditfile\'));">' . MText::_("saveandclose") . '</a> <a href="" class="askButton" style="width:120px; text-align:center;" onclick="javascript: closePopup(\'Edit' . $sid . '\'); ">' . MText::_("cancel") . '</a> </div> </form> <span style="display:none;" class="mCodeMirrorData" syntax="' . $syntax . '" sid="' . $sid . '" height="' . $height . '"></span> '); //<script language="javascript" type="text/javascript" src="'.MURL::_("xhreditarea",null,null,"syntax=".$syntax."&sid=".$sid."&height=".urlencode($height) ).'" noCache="1"></script> } else { $this->view->content('<h2 style="color:red">' . $encoding . '</h2>'); } }
public function __construct() { $this->path = _FM_HOME_DIR . DS . "data" . DS . "roots.php"; $data = MDO::instance(); if (MFile::isFile($this->path)) { $data->load($this->path); } else { $data->set("counter", 0); $data->set("folders", array()); } $this->data = $data; }
public static function liveTests(){ // Set Sandbox to be writable if possible @MFile::chmod(_FM_SANDBOX, 755); if( ! MFile::isWritable(_FM_SANDBOX)){ self::$sandboxError = 1; return false; } $assets = _FM_SANDBOX .DS . "assets" ; $fileSample = _FM_SANDBOX .DS . "assets" . DS ."sample.txt"; $fileValidate = _FM_SANDBOX .DS . "assets" . DS ."validate.txt"; $destinationFolder = _FM_SANDBOX . DS . "dest"; // 1. isDir self::$params["live_is_dir"] = (int) @MFile::isDir($assets); // 2. isFile self::$params["live_is_file"] = (int) @MFile::isFile($fileSample); // 3. Create Dir MFile::createDir($destinationFolder, 0755); self::$params["live_create_dir"] = (int) ( @MFile::is($destinationFolder) && @MFile::isDir($destinationFolder)); // 4. Read $valid = MFile::readData($fileValidate); self::$params["live_read_file"] = (int) $valid == "valid"; // 5. Copy MFile::copy($fileValidate, $destinationFolder . DS . basename($fileValidate)); // MFile::copy($fileValidate, _FM_SANDBOX . DS . "reserved.txt"); self::$params["live_copy"] = (int) MFile::is($destinationFolder . DS . basename($fileValidate)); // 6. Rename $newValidate = $destinationFolder . DS . "deleteme.txt"; MFile::rename($destinationFolder . DS . basename($fileValidate), $newValidate); self::$params["live_rename"] = (int) MFile::is($newValidate); // 7. mode read @MFile::chmod($newValidate, 444); $mode = MFile::mode($newValidate); self::$params["live_mode"] = (int) (!! $mode); // 8. CHMOD MFile::chmod($newValidate, 666); self::$params["live_chmod"] = (int) ( $mode != MFile::mode($newValidate) ); // 9. Write (Create / Add File) MFile::writeData($newValidate,"new",true); $validnew = MFile::readData($newValidate); self::$params["live_write_file"] = (int) $validnew == "validnew"; // 10. Pack $archive = new PclZip(_FM_SANDBOX. DS . 'packed.zip'); $archive->add($destinationFolder,PCLZIP_OPT_REMOVE_PATH, $destinationFolder); self::$params["live_zip"] = (int) MFile::is(_FM_SANDBOX. DS . 'packed.zip'); // 11. Delete File MFile::remove($newValidate, 1); self::$params["live_delete_file"] = (int) ! MFile::is($newValidate); // 12. Delete Folder MFile::removeDir($destinationFolder); self::$params["live_delete_folder"] = (int) ! MFile::is($destinationFolder); // 13. UNZIP $archive = new PclZip(_FM_SANDBOX. DS . 'packed.zip'); $archive->extract(PCLZIP_OPT_PATH, _FM_SANDBOX); self::$params["live_unzip"] = (int) MFile::is(_FM_SANDBOX. DS . 'deleteme.txt'); // 14. Move MFile::createDir($destinationFolder, 0777); MFile::move(_FM_SANDBOX. DS . 'deleteme.txt', $destinationFolder); self::$params["live_move"] = (int) MFile::is($newValidate); // Purge MFile::remove(_FM_SANDBOX. DS . 'packed.zip', 1); MFile::removeDirAtAllCosts($destinationFolder); }
public function __construct($id = null) { $this->path = _FM_HOME_DIR . DS . "data" . DS . "rights" . DS; if (!isset(self::$tree)) { self::$tree = MPeer::getUserGroups($this); self::$user = MPeer::getUser(); } if ($id !== null && MFile::isFile($this->path . "rf" . $id . ".php")) { $this->load($id); } else { $this->createClean($id); } if ($id !== null && $id > -1) { $this->rootFolderId = (int) $id; } $this->calculate($id); }
public function load($fileName = null) { if ($fileName && $this->endsWith($fileName, ".php") && MFile::isFile($fileName)) { try { $fetch = @file_get_contents($fileName); if ($fetch) { $split = explode("/*SPLIT", $fetch); if (sizeof($split) == 2) { $data = str_replace("\n", "", trim($split[1])); @$this->unserialize($data); } } } catch (Exception $e) { return false; } return true; } else { return false; } }
public static function filesByType($dirName, $type) { if (!MFile::is($dirName) || !MFile::isDir($dirName)) { return null; } $isArray = gettype($type) == "array"; $array = array(); $dir = @opendir($dirName); while ($entry = @readdir($dir)) { if ($entry == '.' || $entry == '..') { continue; } if (MFile::isFile($dirName . DS . $entry)) { $info = MFile::info($dirName . DS . $entry); if ($isArray) { $typeMatching = in_array($info->extension, $type); } else { $typeMatching = $info->extension == $type; } if ($typeMatching) { $array[] = $info; } } } @closedir($dir); if (sizeof($array) > 0) { return $array; } else { return null; } }