/** * Recursively copy a folder and its contents * http://aidan.dotgeek.org/lib/?file=function.copyr.php * * @author Aidan Lister <*****@*****.**> * @version 1.0.1 * @param string $source Source path * @param string $dest Destination path * @return bool Returns TRUE on success, FALSE on failure */ function copyDir($source, $dest) { clearstatcache(); // Simple copy for a file if (is_file($source)) { return File::copy($source, $dest); } // Make destination directory if (!File::isDir($dest)) { File::createDir($dest); } // Loop through the folder $dir = dir($source); while (false !== ($entry = $dir->read())) { // Skip pointers if ($entry == '.' || $entry == '..') { continue; } // Deep copy directories if ($dest !== "{$source}/{$entry}") { MyFile::copyDir("{$source}/{$entry}", "{$dest}/{$entry}"); } } // Clean up $dir->close(); return true; }
/** * Returns true if the template is a valid template set */ function validate() { // first of all, check that the folder exists if (!File::isDir($this->_fullName)) { return ERROR_TEMPLATE_NOT_INSIDE_FOLDER; } // now check that all the basic files are available foreach ($this->_basicFiles as $basicFile) { if (!File::isReadable($this->_fullName . $basicFile)) { return ERROR_MISSING_BASE_FILES; } } return true; }
function getTemplateSubFolders($folder) { $templateSubFolders = array(); $files = Glob::myGlob($folder, "*"); foreach ($files as $file) { if (File::isDir($file)) { $tmp['name'] = basename($file); if ($tmp['name'] != "backups") { array_push($templateSubFolders, $tmp); } } } return $templateSubFolders; }
function getTemplateFiles($folder) { $templateFiles = array(); $files = Glob::myGlob($folder, "*"); foreach ($files as $file) { if (!File::isDir($file)) { $tmp['name'] = basename($file); $tmp['size'] = filesize($file); $tmp['isEditable'] = $this->isValidExtension($tmp['name']); $tmp['isImage'] = $this->isImage($tmp['name']); $tmp['url'] = $file; array_push($templateFiles, $tmp); } } return $templateFiles; }
$this->message .= "articles_text table updated successfully!<br/>"; return true; } function perform() { $updaters = array("updateArticleCategories", "updateArticleComments", "updateBlogs", "updateAlbums", "updateResources", "updateArticleText"); // loop through each one of the methods to take care of updating one of the tables foreach ($updaters as $method) { $result = $this->{$method}(); if (!$result) { $this->_view = new WizardView("update3"); $this->_view->setErrorMessage($this->message); return false; } } // everything went fine so we can show the final page! $this->_view = new WizardView("update4"); $this->_view->setValue("message", $this->message); return true; } } // check if the "./tmp" folder is writable by us, otherwise // throw an error before the user gets countless errors // from Smarty if (!File::isWritable(TEMP_FOLDER) || !File::isDir(TEMP_FOLDER)) { print "<span style=\"color:red; font-size: 14px;\">Error</span><br/><br/>This wizard needs the " . TEMP_FOLDER . " folder to be writable by the web server user.<br/><br/>Please correct that and try again."; die; } //// main part //// $controller = new Controller($_actionMap, "nextStep"); $controller->process(HttpVars::getRequest());
function view() { $this->Form->setAttribute('action', extension_filemanager::baseURL() . 'properties/?file=' . $_GET['file']); $file = new File(DOCROOT . $this->_FileManager->getStartLocation() . $_GET['file']); $FileManager =& $this->_Parent->ExtensionManager->create('filemanager'); $formHasErrors = is_array($this->_errors) && !empty($this->_errors); if ($formHasErrors) { $this->pageAlert('An error occurred while processing this form. <a href="#error">See below for details.</a>', AdministrationPage::PAGE_ALERT_ERROR); } if (isset($_GET['result'])) { switch ($_GET['result']) { case 'saved': $this->pageAlert(__('%s updated successfully', array($file->isDir() ? 'Folder' : 'File')), Alert::SUCCESS); break; } } $this->setPageType('form'); $path = extension_filemanager::baseURL() . 'browse/'; $breadcrumb = ''; $pathelements = explode('/', $_GET['file']); foreach ($pathelements as $element) { if ($element != '') { $path .= $element . '/'; $breadcrumb .= ' / ' . ($element == end($pathelements) ? $element : Widget::Anchor($element, $path)->generate()); } } $this->appendSubheading(trim($FileManager->getStartLocationLink(), '/') . $breadcrumb); $fields = array(); $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings'); $fieldset->appendChild(new XMLElement('legend', 'Essentials')); $div = new XMLElement('div'); $div->setAttribute('class', 'group'); $label = Widget::Label('Name'); $label->appendChild(Widget::Input('fields[name]', General::sanitize($file->name()))); if (isset($this->_errors['name'])) { $div->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['name'])); } else { $div->appendChild($label); } $label = Widget::Label('Permissions'); $label->appendChild(Widget::Input('fields[permissions]', General::sanitize($file->permissions()))); if (isset($this->_errors['permissions'])) { $div->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['permissions'])); } else { $div->appendChild($label); } $fieldset->appendChild($div); $this->Form->appendChild($fieldset); if (!$file->isDir() && in_array(File::fileType($file->name()), array(File::CODE, File::DOC))) { $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings'); $fieldset->appendChild(new XMLElement('legend', 'Editor')); $label = Widget::Label('Contents'); $label->appendChild(Widget::Textarea('fields[contents]', '25', '50', General::sanitize($file->contents()), array('class' => 'code'))); if (isset($this->_errors['contents'])) { $fieldset->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['contents'])); } else { $fieldset->appendChild($label); } $this->Form->appendChild($fieldset); } if (!$file->isDir() && File::fileType($file->name()) == File::IMAGE) { $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings'); $fieldset->appendChild(new XMLElement('legend', 'Preview')); $img = new XMLElement('img'); $img->setAttribute('src', URL . $FileManager->getStartLocation() . $_GET['file']); $img->setAttribute('alt', $file->name()); $fieldset->appendChild($img); $this->Form->appendChild($fieldset); } $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); if (is_writeable(DOCROOT . $this->_FileManager->getStartLocation() . $_GET['file'])) { $div->appendChild(Widget::Input('action[save]', 'Save Changes', 'submit', array('accesskey' => 's'))); $button = new XMLElement('button', 'Delete'); $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'confirm delete', 'title' => 'Delete this ' . ($file->isDir() ? 'Folder' : 'File'))); $div->appendChild($button); } else { $notice = new XMLElement('p', 'The server does not have permission to edit this file.'); $notice->setAttribute('class', 'inactive'); $div->appendChild($notice); } $this->Form->appendChild($div); }
/** * @private * Factored out from above... */ function _getTemplateFileInfo($templateName, $layout, $blogInfo) { // build the file name if ($blogInfo == null) { $templateFileName = $layout . '/' . $templateName . '.template'; $templateFolder = TemplateSetStorage::getBaseTemplateFolder(); } else { // // might be the case that the template is not local but global, so // by default, global templates will always have preference over // local templates. If the template is global, then // $baseTemplateFolder = TemplateSetStorage::getBaseTemplateFolder(); $globalTemplateFolder = $baseTemplateFolder . '/' . $layout; $localTemplateFolder = $baseTemplateFolder . '/' . BLOG_BASE_TEMPLATE_FOLDER . $blogInfo->getId() . '/' . $layout; //print("local = $localTemplateFolder - global = $globalTemplateFolder<br/>"); $templateFileName = $layout . '/' . $templateName . '.template'; if (!File::isDir($globalTemplateFolder)) { //$templateFileName = $layout."/".$templateName.".template"; $templateFolder = $baseTemplateFolder . '/' . BLOG_BASE_TEMPLATE_FOLDER . $blogInfo->getId(); } else { $templateFolder = $baseTemplateFolder . '/'; } } $result['templateFileName'] = $templateFileName; $result['templateFolder'] = $templateFolder; return $result; }
<?php apd_set_pprof_trace(); require_once '../../lib/base/boot.php'; $f = new File(__FILE__); var_dump($f->isDir()); var_dump($f->isFile()); $f->copyTo('/tmp/test'); #$t = getrusage(); #$t = doubleval($t['ru_utime.tv_sec']*1000) + doubleval($t['ru_utime.tv_usec']/1000000); #printf("User time: %f", $t);
function download($id) { $conditions = array('conditions' => array('Halaman.lesson_id' => $id), 'order' => array('Halaman.order' => 'ASC')); $isi = $this->Halaman->find('all', $conditions); $lesson = $this->Halaman->Lesson->read(null, $id); $this->kosongin(WWW_ROOT . DS . 'wow_book/files/*'); $servername = $_SERVER['SERVER_NAME']; foreach ($isi as $item) { $source = $this->getContents($item['Halaman']['content'], 'http://' . $servername . '/skope/app/webroot/', '"'); $count = $item['Halaman']['order']; $count = 0; foreach ($source as $row) { //echo $count.' '.$row."</br>"; $row = str_replace("%20", " ", $row); mkdir(dirname(WWW_ROOT . "wow_book/files/" . $row), 0777, true); copy(WWW_ROOT . $row, WWW_ROOT . "wow_book/files/" . $row); $count++; } $source2 = $this->getContents($item['Halaman']['content'], 'src="/skope/files/image_mikroskop/', '"'); foreach ($source2 as $row2) { //echo $count.' '.$row."</br>"; $row2 = trim(str_replace("%20", " ", $row2)); mkdir(dirname(WWW_ROOT . "wow_book/files/image_mikroskop/" . $row2), 0777, true); copy(WWW_ROOT . "files/image_mikroskop/" . $row2, WWW_ROOT . "wow_book/files/image_mikroskop/" . $row2); } $source3 = $this->getContents($item['Halaman']['content'], 'src="/skope/files/video_mikroskop/', '"'); foreach ($source3 as $row2) { //echo $count.' '.$row."</br>"; $row2 = trim(str_replace("%20", " ", $row2)); mkdir(dirname(WWW_ROOT . "wow_book/files/video_mikroskop/" . $row2), 0777, true); copy(WWW_ROOT . "files/video_mikroskop/" . $row2, WWW_ROOT . "wow_book/files/video_mikroskop/" . $row2); } //var_dump($source); } $isifeature = '<!doctype html> <!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]--> <head> <meta charset="utf-8"> <style> .js #features { margin-left: -12000px; width: 100%; } </style> <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame Remove this if you use the .htaccess --> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <!-- Mobile viewport optimized: j.mp/bplateviewport --> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> <meta name="description" content=""> <title>SKOPE</title> <!-- Bootstrap core CSS --> <!-- CSS : implied media="all" --> <link href="css/style.css" rel="stylesheet"> <link href="wow_book.css" rel="stylesheet"> <link href="css/preview.css" rel="stylesheet"> <link href="css/nanoscroller.css" rel="stylesheet"> <link href="css/component_lesson.css" rel="stylesheet"> <script type="text/javascript" src="js/jquery-2.1.4.min.js"></script> </head> <body> <div id="container"> <div id="main"> <img id="click_to_open" src="images/click_to_open.png" alt="click to open" /> <div id="features">'; $isifeature .= '<div class="feaature bk-book book-1 bk-bookdefault viewlesson"> <div class="bk-front"> <div class="bk-cover"> <h2> <span>' . $lesson['Lesson']['author'] . '</span> <span style="text-transform:uppercase;">' . $lesson['Lesson']['title'] . '</span><br/> <span style="font-size:0.5em;font-family:arial,helvetica;text-transform:lowercase;">' . $lesson['Lesson']['description'] . '</span> </h2> </div> <div class="bk-cover-back"></div> </div> </div> <div class="feature"> <div class="contenttextbook nano"> <div class="nano-content"> <div class="contentareablock titlearea"> <span>' . $lesson['Lesson']['author'] . '</span> <h1 style="text-transform:uppercase;font-size:43px;">' . $lesson['Lesson']['title'] . '</h1> <span style="font-size:1em;font-family:arial,helvetica;text-transform:lowercase;">' . $lesson['Lesson']['description'] . '</span> <p>Kelas : ' . $lesson['Lesson']['grade_id'] . ' <br/>Pelajaran : ' . $lesson['Pelajaran']['nama'] . '</p> <br/> <p style="font-weight:bold;">---- KELOMPOK ----</p> <p>' . nl2br($lesson['Lesson']['kelompok']) . '</p> </div> </div> </div> </div> <div class="feature"> <div class="contenttextbook nano"> <div class="nano-content"> <div class="contentareablock titlearea"> </div> </div> </div> </div>'; foreach ($isi as $item) { //$this->getContents($item['Halaman']['content'],'http://localhost/skope/app/webroot/','"') $item['Halaman']['content'] = str_replace("http://" . $servername . "/skope/app/webroot/", "files/", $item['Halaman']['content']); $item['Halaman']['content'] = str_replace("/skope/files/image_mikroskop/", "files/image_mikroskop/", $item['Halaman']['content']); $item['Halaman']['content'] = str_replace("/skope/files/video_mikroskop/", "files/video_mikroskop/", $item['Halaman']['content']); $isifeature .= '<div class="echo"> <div class="contenttextbook nano"> <div class="nano-content"> <div class="contentareablock"> <h2 style="font-size:37px;">' . $item['Halaman']['deskripsi_halaman'] . '</h2> ' . $item['Halaman']['content'] . ' </div> </div> </div> </div>'; } $isifeature .= '</div><nav class="navigasiwow"> <ul> <li><a id="first" href="#" title="goto first page" >First page</a></li> <li><a id="back" href="#" title="go back one page" >Back</a></li> <li><a id="next" href="#" title="go foward one page">Next</a></li> <li><a id="last" href="#" title="goto last page" >last page</a></li> <li><a id="zoomin" href="#" title="zoom in" >Zoom In</a></li> <li><a id="zoomout" href="#" title="zoom out" >Zoom Out</a></li> <li><a id="slideshow" href="#" title="start slideshow" >Slide Show</a></li> <li><a id="flipsound" href="#" title="flip sound on/off" >Flip sound</a></li> </ul> </nav> </div> <!--! end of #container --> <footer> </footer> </div> <script type="text/javascript" src="wow_book.min.js"></script> <script type="text/javascript" src="js/jquery.nanoscroller.min.js"></script> <style> .makecenter{ position: absolute; display: inline-block; right: 0; width: 61px; padding: 5px 10px; } .makecenter > a { color: #000; background-color: transparent; border: 1px solid; margin: 2px; } </style> <script type="text/javascript" src="wow_conf.js"></script> <script type="text/javascript" src="js/plugins.js"></script> <script type="text/javascript" src="js/script.js"></script> </body> </html>'; //var_dump($isifeature);exit(); $path = WWW_ROOT . DS . 'wow_book/index.html'; $file = new File($path, true, 0777); $file->open('w', true); $file->write($isifeature); $file->close(); // Get real path for our folder $rootPath = realpath(WWW_ROOT . DS . 'wow_book'); // Initialize archive object $zip = new ZipArchive(); $zip->open('file.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE); // Create recursive directory iterator /** @var SplFileInfo[] $files */ $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($rootPath), RecursiveIteratorIterator::LEAVES_ONLY); foreach ($files as $name => $file) { // Skip directories (they would be added automatically) if (!$file->isDir()) { // Get real and relative path for current file $filePath = $file->getRealPath(); $relativePath = substr($filePath, strlen($rootPath) + 1); // Add current file to archive $zip->addFile($filePath, $relativePath); } } // Zip archive will be created only after closing object $zip->close(); $this->layout = 'default_blank'; }
/** * @public */ function checkMediumSizePreviewsStorageFolder($ownerId) { $previewsFolder = GalleryResourceStorage::getMediumSizePreviewsFolder($ownerId); if ($previewsFolder[strlen($previewsFolder) - 1] == "/") { $previewsFolder = substr($previewsFolder, 0, strlen($previewsFolder) - 1); } if (!File::isDir($previewsFolder)) { // folder does not exist, so we should try to create it if (!File::createDir($previewsFolder, 0755)) { throw new Exception("Could not create user storage folder for medium size previews: " . $previewsFolder); //die(); return false; } } if (!File::isReadable($previewsFolder)) { throw new Exception($previewsFolder . " user previews storage folder exists but it is not readable!"); //die(); return false; } return true; }
/** * refreshes the list of folders from disk */ function getPluginListFromFolder() { $pluginList = array(); $pluginFiles = Glob::glob($this->_pluginDir, "*"); if (!is_array($pluginFiles)) { return $pluginList; } foreach ($pluginFiles as $pluginFile) { if (File::isDir($pluginFile)) { // build up the name of the file $pluginId = array_pop(explode("/", $pluginFile)); $pluginFileName = "plugin" . $pluginId . ".class.php"; $pluginFullPath = PLOG_CLASS_PATH . "{$pluginFile}/{$pluginFileName}"; // and try to include it if (File::isReadable($pluginFile . "/" . $pluginFileName)) { $pluginList[] = $pluginId; } } } return $pluginList; }
private function getFolders() { $folders = array(); // If we're running in advanced directory mode, get information about the folders if ($_SESSION['directoryMode'] == 'ADVANCED') { $path = File::getUserSandboxPath(); // If we're not at the user's top-level folder, show the parent folder if ($_SESSION['cwd'] != $_SESSION['userPath']) { $folders[] = '..'; } foreach (scandir($path) as $file) { if (File::isDir($file) && $file != '.' && $file != '..') { $folders[] = $file; } } } return $folders; }
/** * Creates the blog-specific folder where templates are stored. * If the folder is not there, it will be created. If it is already there, * then nothing will happen. * * @param blogId The identifier of the blog. */ function createBlogTemplateFolder($blogId) { // make sure that the blog-specific folder exists $templateFolder = $this->getBaseTemplateFolder(); $blogTemplateFolder = "{$templateFolder}/blog_" . $blogId; if (!File::isDir($blogTemplateFolder)) { File::createDir($blogTemplateFolder); } return $blogTemplateFolder; }
function download($id) { $conditions = array('conditions' => array('Halaman.lesson_id' => $id), 'order' => array('Halaman.order' => 'ASC')); $isi = $this->Halaman->find('all', $conditions); $lesson = $this->Halaman->Lesson->read(null, $id); $this->kosongin(WWW_ROOT . DS . 'wow_book/files/*'); $servername = $_SERVER['SERVER_NAME']; //echo $_SERVER['DOCUMENT_ROOT']; $url = $_SERVER['REQUEST_URI']; //returns the current URL $parts = explode('/', $url); foreach ($isi as $item) { $source = $this->getContents($item['Halaman']['content'], 'http://' . $servername . '/' . $parts[1] . '/app/webroot/', '"'); $count = $item['Halaman']['order']; $count = 0; foreach ($source as $row) { //echo $count.' '.$row."</br>"; $row = str_replace("%20", " ", $row); mkdir(dirname(WWW_ROOT . "wow_book/files/" . $row), 0777, true); copy(WWW_ROOT . $row, WWW_ROOT . "wow_book/files/" . $row); $count++; } $source2 = $this->getContents($item['Halaman']['content'], 'src="/' . $parts[1] . '/source/SKOPE/image_mikroskop/', '"'); foreach ($source2 as $row2) { //echo $count.' '.$row."</br>"; $row2 = trim(str_replace("%20", " ", $row2)); mkdir(dirname(WWW_ROOT . "wow_book/files/image_mikroskop/" . $row2), 0777, true); copy(WWW_ROOT . "source/SKOPE/image_mikroskop/" . $row2, WWW_ROOT . "wow_book/files/image_mikroskop/" . $row2); } $source3 = $this->getContents($item['Halaman']['content'], 'src="/' . $parts[1] . '/source/SKOPE/video_mikroskop/', '"'); foreach ($source3 as $row2) { //echo $count.' '.$row."</br>"; $row2 = trim(str_replace("%20", " ", $row2)); mkdir(dirname(WWW_ROOT . "wow_book/files/video_mikroskop/" . $row2), 0777, true); copy(WWW_ROOT . "source/SKOPE/video_mikroskop/" . $row2, WWW_ROOT . "wow_book/files/video_mikroskop/" . $row2); } //var_dump($source); } $isifeature = ' <!doctype html> <!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ --> <!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]--> <!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]--> <!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]--> <!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]--> <!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]--> <head> <script>(function(H){H.className=H.className.replace(/\\bno-js\\b/,"js")})(document.documentElement)</script> <meta charset="utf-8"> <style> .js #features { margin-left: -12000px; width: 100%; } #videocontent{ width: 100%; } </style> <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame Remove this if you use the .htaccess --> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <!-- Mobile viewport optimized: j.mp/bplateviewport --> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> <meta name="description" content=""> <link rel="icon" type="image/png" href="favicon.ico"/> <title>SKOPE</title> <!-- Bootstrap core CSS --> <link href="/skope_kaltim/css/bootstrap.min.css" rel="stylesheet"> <!-- CSS : implied media="all" --> <link rel="stylesheet" type="text/css" href="css/style.css" /> <link rel="stylesheet" type="text/css" href="wow_book.css" /> <link rel="stylesheet" type="text/css" href="css/preview.css" /> <link rel="stylesheet" type="text/css" href="css/nanoscroller.css" /> <link rel="stylesheet" type="text/css" href="css/component_lesson.css" /> <script type="text/javascript" src="js/modernizr.custom.39460.js"></script> <script type="text/javascript" src="js/jquery-2.1.4.min.js"></script> <script type="text/javascript" src="js/jwplayer.js"></script><script type="text/javascript">jwplayer.key="J0+IRhB3+LyO0fw2I+2qT2Df8HVdPabwmJVeDWFFoplmVxFF5uw6ZlnPNXo="; </script> </head> <body> <div id="videocontent"> <div id="example_video_1"> </div> </div> <div id="penelitiancontent"> <div class="container-fluid"> </div> <div id="container"> <div id="main"> <img id="click_to_open" src="images/click_to_open.png" alt="click to open" /> <div id="features">'; $isifeature .= '<div class="feaature bk-book book-1 bk-bookdefault viewlesson"> <div class="bk-front"> <div class="bk-cover ' . $lesson['Lesson']['color'] . '"> <h2> <span>' . $lesson['Lesson']['author'] . '</span> <span style="text-transform:uppercase;">' . $lesson['Lesson']['title'] . '</span><br/> <span style="font-size:0.5em;font-family:arial,helvetica;">' . $lesson['Lesson']['description'] . '</span> </h2> </div> <div class="bk-cover-back"></div> </div> </div> <div class="feature"> <div class="contenttextbook nano"> <div class="nano-content"> <div class="contentareablock titlearea"> <!--<span>' . $lesson['Lesson']['author'] . '</span>--> <h1 style="text-transform:uppercase;font-size:43px;">' . $lesson['Lesson']['title'] . '</h1> <span style="font-size:1em;font-family:arial,helvetica;margin-top:10px;display:block;">' . $lesson['Lesson']['description'] . '</span> <p style="margin-top:150px;display:block;font-weight:bold;font-size:1.1em;">' . $lesson['Pelajaran']['nama'] . ' - ' . $lesson['Grade']['details'] . '</p> <br/> <p style="font-weight:normal;margin-top:20px;display:block;">dibuat oleh: </p> <p style="margin-top:7px;display:block;"> ' . $lesson['Lesson']['author'] . ' <br/>' . nl2br($lesson['Lesson']['kelompok']) . '</p> </div> </div> </div> </div> <div class="feature"> <div class="contenttextbook nano"> <div class="nano-content"> <div class="contentareablock titlearea"> <img src="images/smicro/poweredby.png"> </div> </div> </div> </div>'; foreach ($isi as $item) { //$this->getContents($item['Halaman']['content'],'http://localhost/skope/app/webroot/','"') $item['Halaman']['content'] = str_replace("http://" . $servername . "/" . $parts[1] . "/app/webroot/", "files/", $item['Halaman']['content']); $item['Halaman']['content'] = str_replace("/" . $parts[1] . "/source/SKOPE/image_mikroskop/", "files/image_mikroskop/", $item['Halaman']['content']); $item['Halaman']['content'] = str_replace("/" . $parts[1] . "/source/SKOPE/video_mikroskop/", "files/video_mikroskop/", $item['Halaman']['content']); $isifeature .= '<div class="feature"> <div class="contenttextbook nano"> <div class="nano-content"> <div class="contentareablock"> <h2 style="font-size:33px;background-color:#66CAE8;color:#fff;padding:10px;margin-left:-10px;">' . $item['Halaman']['deskripsi_halaman'] . '</h2> ' . $item['Halaman']['content'] . ' </div> </div> </div> </div>'; } $countpages = count($isi); if ($countpages % 2 == 0) { $isifeature .= '<div class="feature"> <div class="bk-front"> <div class="bk-cover ' . $lesson['Lesson']['color'] . '"> <img style="margin-top:120px;" src="images/smicro/backcover.png"> </div> <div class="bk-cover-back"></div> </div> </div>'; } elseif ($countpages == 0) { $isifeature .= '<div class="feature"> <div class="contenttextbook nano"> <div class="nano-content"> <div class="contentareablock titlearea"> </div> </div> </div> </div> <div class="feature"> <div class="bk-front"> <div class="bk-cover ' . $lesson['Lesson']['color'] . '"> <img style="margin-top:120px;" src="images/smicro/backcover.png"> </div> <div class="bk-cover-back"></div> </div> </div>'; } else { $isifeature .= '<div class="feature"> <div class="contenttextbook nano"> <div class="nano-content"> <div class="contentareablock titlearea"> </div> </div> </div> </div> <div class="feature"> <div class="bk-front"> <div class="bk-cover ' . $lesson['Lesson']['color'] . '"> <img style="margin-top:120px;" src="<?php echo $this->webroot;?>art/smicro/backcover.png"> </div> <div class="bk-cover-back"></div> </div> </div>'; } $isifeature .= '</div><!--! end of #feature --></div><nav class="navigasiwow"> <ul> <li><a id="first" href="#" title="goto first page" >First page</a></li> <li><a id="back" href="#" title="go back one page" >Back</a></li> <li><a id="next" href="#" title="go foward one page">Next</a></li> <li><a id="last" href="#" title="goto last page" >last page</a></li> <li><a id="zoomin" href="#" title="zoom in" >Zoom In</a></li> <li><a id="zoomout" href="#" title="zoom out" >Zoom Out</a></li> <li><a id="slideshow" href="#" title="start slideshow" >Slide Show</a></li> <li><a id="flipsound" href="#" title="flip sound on/off" >Flip sound</a></li> </ul> </nav> </div> <!--! end of #container --> <footer> </footer> </div> <script type="text/javascript" src="wow_book.min.js"></script> <script type="text/javascript" src="js/jquery.nanoscroller.min.js"></script> <style> .makecenter{ position: absolute; display: inline-block; right: 0; width: 61px; padding: 5px 10px; } .makecenter > a { color: #000; background-color: transparent; border: 1px solid; margin: 2px; } </style> <script type="text/javascript"> $(document).ready(function() { $(".nano").nanoScroller(); $("#features").wowBook({ height : 550 ,width : 950 ,centeredWhenClosed : true ,hardcovers : true ,turnPageDuration : 1000 ,numberedPages : [1,-2] ,controls : { zoomIn : "#zoomin", zoomOut : "#zoomout", next : "#next", back : "#back", first : "#first", last : "#last", slideShow : "#slideshow", flipSound : "#flipsound" } }).css({"display":"none", "margin":"auto"}).fadeIn(1000); $("#cover").click(function(){ $.wowBook("#features").advance(); }); }); </script> <script type="text/javascript" src="js/plugins.js"></script> <script type="text/javascript" src="js/script.js"></script> <script src="js/bootstrap.min.js"></script> <!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> <script type="text/javascript"> var heightWindow = $( window ).height(); jwplayer("example_video_1").setup({ file: "opening/opening_skope.flv", image: "opening/cover_opening_skope.png", width: "100%", height:heightWindow, aspectratio: "12:5", autostart:true, onComplete: function() { alert("done"); $("#videocontent").fadeOut(); $("#penelitiancontent").fadeIn(); } }); jwplayer("example_video_1").onComplete(function() { $("#videocontent").fadeOut(); }); </script> </body> </html>'; //var_dump($isifeature);exit(); $path = WWW_ROOT . DS . 'wow_book/index.html'; $file = new File($path, true, 0777); $file->open('w', true); $file->write($isifeature); $file->close(); // Get real path for our folder $rootPath = realpath(WWW_ROOT . DS . 'wow_book'); // Initialize archive object $zip = new ZipArchive(); $zip->open('file.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE); // Create recursive directory iterator /** @var SplFileInfo[] $files */ $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($rootPath), RecursiveIteratorIterator::LEAVES_ONLY); foreach ($files as $name => $file) { // Skip directories (they would be added automatically) if (!$file->isDir()) { // Get real and relative path for current file $filePath = $file->getRealPath(); $relativePath = substr($filePath, strlen($rootPath) + 1); // Add current file to archive $zip->addFile($filePath, $relativePath); } } // Zip archive will be created only after closing object $zip->close(); //$pathbatch=WWW_ROOT.DS.'compiler.bat'; //system("cmd /c ".$pathbatch); $this->layout = 'default_blank'; }
/** * removes a directory, optinally in a recursive fashion * * @param dirName * @param recursive Whether to recurse through all subdirectories that * are within the given one and remove them. * @param onlyFiles If the recursive mode is enabled, setting this to 'true' will * force the method to only remove files but not folders. The directory will not be * removed but all the files included it in (and all subdirectories) will be. * @return True if successful or false otherwise * @static */ function deleteDir($dirName, $recursive = false, $onlyFiles = false) { // if the directory can't be read, then quit with an error if (!File::isReadable($dirName) || !File::exists($dirName)) { return false; } // if it's not a file, let's get out of here and transfer flow // to the right place... if (!File::isDir($dirName)) { return File::delete($dirName); } // Glob::myGlob is easier to use than Glob::glob, specially when // we're relying on the native version... This improved version // will automatically ignore things like "." and ".." for us, // making it much easier! $files = Glob::myGlob($dirName, "*"); foreach ($files as $file) { if (File::isDir($file)) { // perform a recursive call if we were allowed to do so if ($recursive) { File::deleteDir($file, $recursive, $onlyFiles); } } // File::delete can remove empty folders as well as files if (File::isReadable($file)) { File::delete($file); } } // finally, remove the top-level folder but only in case we // are supposed to! if (!$onlyFiles) { File::delete($dirName); } return true; }
/** * Cleans all the temporary folders used by this class during * its execution. * * @param $folder The name of the temporary folder used * @return Returns true */ function cleanUp($folder) { if (!File::isDir($folder)) { return true; } // recursively delete the folder File::deleteDir($folder, true); return true; }
/** * Synchronize the file system with the database * * @return string The path to the synchronization log file * * @throws \Exception If a parent ID entry is missing */ public static function syncFiles() { // Try to raise the limits (see #7035) @ini_set('memory_limit', -1); @ini_set('max_execution_time', 0); $objDatabase = \Database::getInstance(); // Lock the files table $objDatabase->lockTables(array('tl_files')); // Reset the "found" flag $objDatabase->query("UPDATE tl_files SET found=''"); // Get a filtered list of all files $objFiles = new \RecursiveIteratorIterator(new \Dbafs\Filter(new \RecursiveDirectoryIterator(TL_ROOT . '/' . \Config::get('uploadPath'), \FilesystemIterator::UNIX_PATHS | \FilesystemIterator::FOLLOW_SYMLINKS | \FilesystemIterator::SKIP_DOTS)), \RecursiveIteratorIterator::SELF_FIRST); $strLog = 'system/tmp/' . md5(uniqid(mt_rand(), true)); // Open the log file $objLog = new \File($strLog, true); $objLog->truncate(); $arrModels = array(); // Create or update the database entries foreach ($objFiles as $objFile) { $strRelpath = str_replace(TL_ROOT . '/', '', $objFile->getPathname()); // Get all subfiles in a single query if ($objFile->isDir()) { $objSubfiles = \FilesModel::findMultipleFilesByFolder($strRelpath); if ($objSubfiles !== null) { while ($objSubfiles->next()) { $arrModels[$objSubfiles->path] = $objSubfiles->current(); } } } // Get the model if (isset($arrModels[$strRelpath])) { $objModel = $arrModels[$strRelpath]; } else { $objModel = \FilesModel::findByPath($strRelpath); } if ($objModel === null) { // Add a log entry $objLog->append("[Added] {$strRelpath}"); // Get the parent folder $strParent = dirname($strRelpath); // Get the parent ID if ($strParent == \Config::get('uploadPath')) { $strPid = null; } else { $objParent = \FilesModel::findByPath($strParent); if ($objParent === null) { throw new \Exception("No parent entry for {$strParent}"); } $strPid = $objParent->uuid; } // Create the file or folder if (is_file(TL_ROOT . '/' . $strRelpath)) { $objFile = new \File($strRelpath, true); $objModel = new \FilesModel(); $objModel->pid = $strPid; $objModel->tstamp = time(); $objModel->name = $objFile->name; $objModel->type = 'file'; $objModel->path = $objFile->path; $objModel->extension = $objFile->extension; $objModel->found = 2; $objModel->hash = $objFile->hash; $objModel->uuid = $objDatabase->getUuid(); $objModel->save(); } else { $objFolder = new \Folder($strRelpath); $objModel = new \FilesModel(); $objModel->pid = $strPid; $objModel->tstamp = time(); $objModel->name = $objFolder->name; $objModel->type = 'folder'; $objModel->path = $objFolder->path; $objModel->extension = ''; $objModel->found = 2; $objModel->hash = $objFolder->hash; $objModel->uuid = $objDatabase->getUuid(); $objModel->save(); } } else { // Check whether the MD5 hash has changed $objResource = $objFile->isDir() ? new \Folder($strRelpath) : new \File($strRelpath); $strType = $objModel->hash != $objResource->hash ? 'Changed' : 'Unchanged'; // Add a log entry $objLog->append("[{$strType}] {$strRelpath}"); // Update the record $objModel->found = 1; $objModel->hash = $objResource->hash; $objModel->save(); } } // Check for left-over entries in the DB $objFiles = \FilesModel::findByFound(''); if ($objFiles !== null) { $arrMapped = array(); $arrPidUpdate = array(); while ($objFiles->next()) { $objFound = \FilesModel::findBy(array('hash=?', 'found=2'), $objFiles->hash); if ($objFound !== null) { // Check for matching file names if the result is ambiguous (see #5644) if ($objFound->count() > 1) { while ($objFound->next()) { if ($objFound->name == $objFiles->name) { $objFound = $objFound->current(); break; } } } // If another file has been mapped already, delete the entry (see #6008) if (in_array($objFound->path, $arrMapped)) { $objLog->append("[Deleted] {$objFiles->path}"); $objFiles->delete(); continue; } $arrMapped[] = $objFound->path; // Store the PID change if ($objFiles->type == 'folder') { $arrPidUpdate[$objFound->uuid] = $objFiles->uuid; } // Add a log entry BEFORE changing the object $objLog->append("[Moved] {$objFiles->path} to {$objFound->path}"); // Update the original entry $objFiles->pid = $objFound->pid; $objFiles->tstamp = $objFound->tstamp; $objFiles->name = $objFound->name; $objFiles->type = $objFound->type; $objFiles->path = $objFound->path; $objFiles->found = 1; // Delete the newer (duplicate) entry $objFound->delete(); // Then save the modified original entry (prevents duplicate key errors) $objFiles->save(); } else { // Add a log entry BEFORE changing the object $objLog->append("[Deleted] {$objFiles->path}"); // Delete the entry if the resource has gone $objFiles->delete(); } } // Update the PID of the child records if (!empty($arrPidUpdate)) { foreach ($arrPidUpdate as $from => $to) { $objChildren = \FilesModel::findByPid($from); if ($objChildren !== null) { while ($objChildren->next()) { $objChildren->pid = $to; $objChildren->save(); } } } } } // Close the log file $objLog->close(); // Reset the found flag $objDatabase->query("UPDATE tl_files SET found=1 WHERE found=2"); // Unlock the tables $objDatabase->unlockTables(); // Return the path to the log file return $strLog; }
/** @ignore */ public static function __test() { $file = new File(__FILE__); assert($file->exists()); assert($file->isFile()); assert(!$file->isDir()); assert($file->isReadable()); }