public function edit() { $article = new ArticleEntity($_GET['id']); echo BreadCrumbs::getInstance()->addCrumb(__('Articles'))->addCrumb($article->getTitle()); $article->setTags(ArticleTagRelationEntityRepository::getInstance()->setWhereArticleId($article->getId())->getPairs('tag_id')); echo $this->__add_edit_form($article)->setSubmitButton('Update'); UID::text2uidJS(true, array('title_' . LNG . '_' => 'uid'), 255, 1, 0); }
public static function getView() { global $start_microtime; $tt = microtime(1) - $start_microtime; $db_tt = 0; foreach (self::$db_queries as $db_query) { $db_tt += $db_query['time']; } $so_queris = count(self::$db_queries); $base_dir_l = strlen(rtrim(DIR_BASE, '/')); $inc_f = array(); foreach (get_included_files() as $v) { $inc_f[] = substr($v, $base_dir_l); } $def_c = get_defined_constants(true); $def_c = $def_c['user']; if (isset($def_c['CFG_DB_LOGIN'])) { $def_c['CFG_DB_LOGIN'] = '******'; } if (isset($def_c['CFG_DB_PASSWORD'])) { $def_c['CFG_DB_PASSWORD'] = '******'; } if (isset($def_c['CFG_DB_NAME'])) { $def_c['CFG_DB_NAME'] = '***'; } if (isset($def_c['CFG_DB_SERVER'])) { $def_c['CFG_DB_SERVER'] = '***'; } foreach ($def_c as $k => $v) { $def_c[$k] = $k . '=' . $v; } $data = array('total' => round($tt, 4), 'php' => round($tt - $db_tt, 4), 'db' => round($db_tt, 4), 'so_queries' => $so_queris, 'memory_peak' => round(memory_get_peak_usage() / 1024), 'memory_current' => round(memory_get_usage() / 1024), 'queries' => self::$db_queries, 'included_files' => $inc_f, 'defined_constants' => $def_c); // Generate unique UID $uid = UID::uid32(); while (Cacher::getInstance()->getDefaultCacher()->get('debug_panel_' . $uid)) { $uid = UID::uid32(); } Cacher::getInstance()->getDefaultCacher()->set('debug_panel' . $uid, $data, 3600); ?> <script> $.ajax({ url: '/-/<?php echo CFG_AJAX_ROUTE; ?> /debug_panel?uid=<?php echo $uid; ?> ', success: function (data) { $('body').append(data); } }); </script> <?php }
/** * Action for Downloading files as ZIP file */ public function _multiple_download() { ob_get_clean(); if (!$_REQUEST || !isset($_REQUEST['pathes'])) { return; } $paths = $_REQUEST['pathes']; $items_to_add = []; foreach ($paths as $v) { // Cut leading slash if (substr($v, 0, 1) == '/') { $v = substr($v, 1); } $items_to_add[] = $v; } FileSystem::mkDir(DIR_TEMP); $zip_path = DIR_TEMP_URL . UID::uid10() . '.zip'; $zip = new ZipArchive(); $zip->open(DIR_BASE . $zip_path, ZipArchive::CREATE | ZipArchive::OVERWRITE); // Add items to current archive foreach ($items_to_add as $v) { $full_path_from = DIR_BASE . $v; if (is_file($full_path_from)) { $zip->addFile($full_path_from, basename($v)); } elseif (is_dir($full_path_from)) { // Iterate all files in folder $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($full_path_from), 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($full_path_from) + 1); // Add current file to archive $zip->addFile($filePath, $relativePath); } } } } $zip->close(); App::add('Downloaded files as .zip file'); Messages::sendGreenAlert('Downloaded files as .zip file'); exit('' . $zip_path); }