public function getModuleAttachments($module_name, $filter, $page, $size, $order) { $table_name = ucfirst($module_name) . 'Attachments'; $_model = D($table_name); if (!$order) { $order = 'id desc'; } $_model = $_model->where($filter)->order($order); if ($page && $size) { $_model->page($page, $size); } $res = $_model->select(); foreach ($res as $k => $v) { if ($module_name == 'user') { $res[$k]['related_name'] = '<a target="_blank" href="/user/detail/' . $v["user_id"] . '">' . M("UserRecommends")->where('id=' . $v['user_id'])->getField('name') . '</a>'; } if ($module_name == 'project') { $res[$k]['related_name'] = '<a target="_blank" href="/project/detail/' . $v["project_id"] . '">' . M("Projects")->where('id=' . $v['project_id'])->getField('title') . '</a>'; } $res[$k]['create_time'] = substr($res[$k]['create_time'], 0, 16); $res[$k]['size'] = formatBytes($res[$k]['size']); if ($v['create_user_id'] < 2000) { $res[$k]['create_user_name'] = M("Users")->where('id=' . $v['create_user_id'])->getField('realname'); } else { $res[$k]['create_user_name'] = M("UserInfo")->where('id=' . $v['create_user_id'])->getField('name'); } } return $res; }
function writeZIP($targetDir, $idC, $version) { global $log; $zipFile = "Wazzup_{$idC}" . "_" . $version . "_" . MIG_GAME . "_" . date("Ymd") . ".zip"; // genero nombre para el zip $i = 0; $existe = TRUE; while ($existe === TRUE) { if (file_exists(ZIP_DIR . "/{$zipFile}")) { $i++; //$zipFile = date("Ymd")."_Wazzup_".WAZZUP_WALLPAPER."_$i.zip"; $zipFile = "Wazzup_{$idC}" . "_" . $version . "_" . MIG_GAME . "_" . date("Ymd") . "_{$i}" . "_" . ".zip"; } else { $existe = FALSE; } } // zipeo y muevo a carpeta de "envios" $shellCmd = "cd " . $targetDir . "; zip -r ../../../../" . ZIP_DIR . "/{$zipFile} * "; // echo '<li>Creando ZIP con: ' . $shellCmd.'</li>'; $log .= exec($shellCmd); echo "<li> Zip " . ZIP_DIR . "/{$zipFile} generado exitosamente</li>"; $ds = filesize(ZIP_DIR . "/{$zipFile}"); $ds = formatBytes($ds); return array('size' => $ds, 'path' => ZIP_DIR . "/{$zipFile}"); }
function DrawUsersList() { global $connection, $config; echo "<div class='page-header'><h1>Gestione utenti dispense</h1></div>\n"; echo "<div class='btn-group'>\n <button type='button' class='btn btn-success' id='addnewuser'><span class='fa fa-plus'></span> Nuovo</button>\n <button type='button' class='btn btn-default' id='edituser'><span class='fa fa-edit'></span> Modifica</button>\n <button type='button' class='btn btn-default' id='enableuser'><span class='fa fa-check'></span> Abilita</button>\n <button type='button' class='btn btn-default' id='disableuser'><span class='fa fa-ban'></span> Disabilita</button>\n <button type='button' class='btn btn-danger' id='deletemultiuser'><span class='fa fa-remove'></span> Elimina</button>\n </div>\n <br><br>\n <table class='table table-hover'>\n <thead><tr>\n <th>Utente</th>\n <th>Nome completo</th>\n <th>Stato</th>\n <th>Email</th>\n <th>Spazio usato</th>\n <th>Spazio massimo</th>\n </tr></thead>"; $request = "SELECT * FROM teachers_users ORDER BY user ASC"; $result = $connection->query($request); while ($line = $result->fetch_assoc()) { //Draw table row $name = $line["user"]; $fullname = $line["name"]; $mail = $line["email"]; if ($line["active"] == 1) { $status = "<span class='fa fa-check'></span> Attivo"; } else { $status = "<span class='fa fa-ban'></span> Disabilitato"; } $max_space = formatBytes($line["max_user_space"] * 1073741824); $space_percent = intval(getFolderSize("../" . $config->plugin_notes_engine_fpath . "/" . $name) / ($line["max_user_space"] * 1073741824) * 100); $space_used = "<div class='progress' style='min-width: 175px;'><div class='progress-bar' role='progressbar' aria-valuenow='{$space_percent}' aria-valuemin='0' aria-valuemax='100' style='width: {$space_percent}%; min-width: 20px;'>{$space_percent}%</div></div>"; if ($space_percent > 90) { $class = "class='danger'"; } elseif ($space_percent > 80) { $class = "class='warning'"; } else { $class = ""; } echo "<tr {$class}>\n <td><input type='checkbox' id='select-{$name}' value='{$name}'> <a href='index.php?module=notes-engine&arg={$name}'>{$name}</a></td>\n <td>{$fullname}</td>\n <td>{$status}</td>\n <td>{$mail}</td>\n <td>{$space_used}</td>\n <td>{$max_space}</td>\n </tr>"; } echo "</table></div>"; }
function displayRuns($resultSet, $title = "") { echo "<div class=\"runTitle\">{$title}</div>\n"; echo "<table id=\"box-table-a\" class=\"tablesorter\" summary=\"Stats\"><thead><tr><th>Timestamp</th><th>Cpu</th><th>Wall Time</th><th>Peak Memory Usage</th><th>URL</th><th>Simplified URL</th></tr></thead>"; echo "<tbody>\n"; while ($row = XHProfRuns_DefaultXHPROFGUI::getNextAssoc($resultSet)) { $c_url = urlencode($row['c_url']); $url = urlencode($row['url']); $html['url'] = htmlentities($row['url'], ENT_QUOTES, 'UTF-8'); $html['c_url'] = htmlentities($row['c_url'], ENT_QUOTES, 'UTF-8'); $date = date('M d H:i:s', (int) $row['timestamp']); $row['cpu'] = printSeconds($row['cpu']); $row['wt'] = printSeconds($row['wt']); $row['pmu'] = formatBytes($row['pmu']); echo "\t<tr><td><a href=\"?run={$row['id']}\">{$date}</a><br /><span class=\"runid\">(ID: {$row['id']})</span></td><td>{$row['cpu']}</td><td>{$row['wt']}</td><td>{$row['pmu']}</td><td><a href=\"?geturl={$url}\">{$html['url']}</a></td><td><a href=\"?getcurl={$c_url}\">{$html['c_url']}</a></td></tr>\n"; } echo "</tbody>\n"; echo "</table>\n"; echo <<<SORTTABLE <script type="text/javascript"> \$(document).ready(function() { \$("#box-table-a").tablesorter( {sortList: []} ); } ); </script> SORTTABLE; }
function scriptReturn($return, $buffer = false, $json = true) { global $initime; if ($buffer) { // start and end user output so this can happen without the user waiting ob_end_clean(); header("Connection: close"); ignore_user_abort(); // optional ob_start(); } if ($json) { $return['memory_usage'] = formatBytes(memory_get_usage()); $return['memory_peak_usage'] = formatBytes(memory_get_peak_usage()); $return['script_run_time'] = round((microtime(true) - $initime) * 1000); header('Content-Type: application/json'); echo json_encode($return, JSON_NUMERIC_CHECK); } else { header('Content-Type: text/html'); echo htmlArray($return); } if ($buffer) { $size = ob_get_length(); header("Content-Length: {$size}"); ob_end_flush(); // Strange behaviour, will not work flush(); // Unless both are called ! } }
function displayFiles($path) { echo "<table class='table table-hover file-list'>\n <thead><th>Nome</th><th>Dimensione</th><th>Ultima modifica</th></thead>"; $file_array = array_diff(scandir("../" . $path), array('..', '.', '.DS_Store')); foreach ($file_array as $file) { $url = "../" . $path . "/" . $file; if (is_dir($url)) { $name = $file; $folder_path = $path . "/" . $file; $size = formatBytes(getFolderSize($url), 1); $date = date("d/m/Y", stat($url)['mtime']); echo "<tr><td><span class='fa-stack fa-2x'><i class='fa fa-folder'></i></span> <a href='#' data-path=\"{$folder_path}\" class='file-list-folder'>{$name}</a>"; echo "<button type='button' class='btn btn-link pull-right lmb remove-folder tooltipped' data-toggle='tooltip' title='Elimina' data-path=\"{$folder_path}\"><i class='fa fa-remove'></i></button>"; echo "<button type='button' class='btn btn-link pull-right lmb edit-folder tooltipped' data-toggle='tooltip' title='Rinomina' data-path=\"{$folder_path}\"><i class='fa fa-edit'></i></button>"; echo "</td><td><span class='text-muted'>{$size}</span></td><td><span class='text-muted'>{$date}</span></td></tr>"; } else { $finfo = finfo_open(FILEINFO_MIME_TYPE); $content_type = finfo_file($finfo, $url); $file_icon = getFileTypeIcon($content_type, $file); $size = formatBytes(filesize($url), 1); $date = date("d/m/Y", filemtime($url)); $preview = canPreview($content_type); if ($preview == "no") { echo "<tr><td><span class='fa-stack fa-2x'><i class='fa {$file_icon}'></i></span> <a href=\"{$url}\" class='file-list' target='_blank'>{$file}</a>"; } else { echo "<tr><td><span class='fa-stack fa-2x'><i class='fa {$file_icon}'></i></span> <a href='#' data-path=\"{$url}\" data-preview_mode='{$preview}' class='file-list-previewable'>{$file}</a>"; } echo "<button type='button' class='btn btn-link pull-right lmb remove-file tooltipped' data-toggle='tooltip' title='Elimina' data-path=\"{$url}\"><i class='fa fa-remove'></i></button>"; echo "</td><td><span class='text-muted'>{$size}</span></td><td><span class='text-muted'>{$date}</span></td></tr>"; } } echo "</table>"; }
protected function execute(InputInterface $input, OutputInterface $output) { // get all thumbnails $dir = Asset\Image\Thumbnail\Config::getWorkingDir(); $thumbnails = array(); $files = scandir($dir); foreach ($files as $file) { if (strpos($file, ".xml")) { $thumbnails[] = str_replace(".xml", "", $file); } } $allowedThumbs = array(); if ($input->getOption("thumbnails")) { $allowedThumbs = explode(",", $input->getOption("thumbnails")); } // get only images $conditions = array("type = 'image'"); if ($input->getOption("parent")) { $parent = Asset::getById($input->getOption("parent")); if ($parent instanceof Asset\Folder) { $conditions[] = "path LIKE '" . $parent->getFullPath() . "/%'"; } else { $this->writeError($input->getOption("parent") . " is not a valid asset folder ID!"); exit; } } $list = new Asset\Listing(); $list->setCondition(implode(" AND ", $conditions)); $total = $list->getTotalCount(); $perLoop = 10; for ($i = 0; $i < ceil($total / $perLoop); $i++) { $list->setLimit($perLoop); $list->setOffset($i * $perLoop); $images = $list->load(); foreach ($images as $image) { foreach ($thumbnails as $thumbnail) { if (empty($allowedThumbs) && !$input->getOption("system") || in_array($thumbnail, $allowedThumbs)) { if ($input->getOption("force")) { $image->clearThumbnail($thumbnail); } $this->output->writeln("generating thumbnail for image: " . $image->getFullpath() . " | " . $image->getId() . " | Thumbnail: " . $thumbnail . " : " . formatBytes(memory_get_usage())); $this->output->writeln("generated thumbnail: " . $image->getThumbnail($thumbnail)); } } if ($input->getOption("system")) { $thumbnail = Asset\Image\Thumbnail\Config::getPreviewConfig(); if ($input->getOption("force")) { $image->clearThumbnail($thumbnail->getName()); } $this->output->writeln("generating thumbnail for image: " . $image->getFullpath() . " | " . $image->getId() . " | Thumbnail: System Preview (tree) : " . formatBytes(memory_get_usage())); $this->output->writeln("generated thumbnail: " . $image->getThumbnail($thumbnail)); } } \Pimcore::collectGarbage(); } }
/** * @param $directory * @param $files */ function writeHTMLFiles($directory, $files) { echo "Processing " . $directory . "\n"; $excludeFiles = [".DS_Store", "sign.time", "index.html", "."]; $contents = <<<END <html> <body> <table> <tr> <th align='left'>Filename</th> <th align='right'>Last modified</th> <th align='right' style='padding-left: 100px'>Size</th> </tr> END; foreach ($files as $file) { // if ($file === "index.html") { // continue; // } // if ($file === ".") { // continue; // } if (in_array($file, $excludeFiles) == true) { continue; } if ($file === "..") { $contents .= "<tr><td colspan='3'>"; $contents .= "<a href='..'>Parent Directory</a>"; $contents .= "</td></tr>"; } else { $contents .= "<tr><td>"; $filename = $directory . '/' . $file; $file = htmlentities($file); $contents .= "<a href='{$file}'>{$file}</a>"; $contents .= "</td><td>"; $contents .= date("j-M-Y H:i", filemtime($filename)); $contents .= "</td><td align='right'>"; if (is_dir($filename) == false) { $contents .= formatBytes(filesize($filename)); } $contents .= "</td></tr>"; } } $contents .= <<<END </table> </body> </html> END; file_put_contents($directory . "/index.html", $contents); }
protected function execute(InputInterface $input, OutputInterface $output) { // disable versioning Version::disable(); // get all thumbnails $thumbnails = []; $list = new Asset\Video\Thumbnail\Config\Listing(); $items = $list->load(); foreach ($items as $item) { $thumbnails[] = $item->getName(); } $allowedThumbs = array(); if ($input->getOption("thumbnails")) { $allowedThumbs = explode(",", $input->getOption("thumbnails")); } // get only images $conditions = array("type = 'video'"); if ($input->getOption("parent")) { $parent = Asset::getById($input->getOption("parent")); if ($parent instanceof Asset\Folder) { $conditions[] = "path LIKE '" . $parent->getFullPath() . "/%'"; } else { $this->writeError($input->getOption("parent") . " is not a valid asset folder ID!"); exit; } } $list = new Asset\Listing(); $list->setCondition(implode(" AND ", $conditions)); $total = $list->getTotalCount(); $perLoop = 10; for ($i = 0; $i < ceil($total / $perLoop); $i++) { $list->setLimit($perLoop); $list->setOffset($i * $perLoop); $videos = $list->load(); foreach ($videos as $video) { foreach ($thumbnails as $thumbnail) { if (empty($allowedThumbs) && !$input->getOption("system") || in_array($thumbnail, $allowedThumbs)) { $this->output->writeln("generating thumbnail for video: " . $video->getFullpath() . " | " . $video->getId() . " | Thumbnail: " . $thumbnail . " : " . formatBytes(memory_get_usage())); $video->getThumbnail($thumbnail); $this->waitTillFinished($video->getId(), $thumbnail); } } if ($input->getOption("system")) { $this->output->writeln("generating thumbnail for video: " . $video->getFullpath() . " | " . $video->getId() . " | Thumbnail: System Preview : " . formatBytes(memory_get_usage())); $thumbnail = Asset\Video\Thumbnail\Config::getPreviewConfig(); $video->getThumbnail($thumbnail); $this->waitTillFinished($video->getId(), $thumbnail); } } } }
/** * From ajax */ public function savePhoto() { $response = ['code' => 0, 'message' => trans('photo.error', ['size' => formatBytes()]), 'url' => '']; if (\Request::hasFile('image')) { if (!$this->photoRepository->imagesMetSizes(\Input::file('image'))) { return json_encode($response); } $user = $this->userRepository->changeAvatar(\Input::file('image')); if ($user) { $response['code'] = 1; $response['url'] = $user->present()->getAvatar(100); } } return json_encode($response); }
/** * Ajax serving */ public function uploadBg() { $error = json_encode(['response' => 0, 'message' => trans('photo.error', ['size' => formatBytes()])]); if (\Request::hasFile('image')) { if (!$this->photoRepository->imagesMetSizes(\Input::file('image'))) { return $error; } if ($image = $this->userRepository->changeDesignBg(\Input::file('image'), \Input::get('val.bg_image'))) { return json_encode(['response' => 1, 'image' => \Image::url($image), 'imagePath' => $image]); } else { return $error; } } return $error; }
protected function execute(InputInterface $input, OutputInterface $output) { $files = rscandir(PIMCORE_TEMPORARY_DIRECTORY . "/image-thumbnails/"); $savedBytesTotal = 0; foreach ($files as $file) { if (file_exists($file)) { $originalFilesize = filesize($file); \Pimcore\Image\Optimizer::optimize($file); $savedBytes = $originalFilesize - filesize($file); $savedBytesTotal += $savedBytes; $this->output->writeln("Optimized image: " . $file . " saved " . formatBytes($savedBytes)); } } $this->output->writeln("Finished!"); $this->output->writeln("Saved " . formatBytes($savedBytesTotal) . " in total"); }
function show_database() { $db_size = 0; echo "<h3>Status:</h3>"; $result = mysql_query("SHOW TABLE STATUS"); if ($result) { while ($row = mysql_fetch_array($result)) { $db_size += $row['Index_length']; $db_size += $row['Data_length']; } echo "<p>The Grinder Server database '" . htmlentities(database_get_name(), ENT_QUOTES) . "' is currently " . htmlentities(formatBytes($db_size), ENT_QUOTES) . " in size.</p>"; mysql_free_result($result); } echo "<h3>Purge Database:</h3>"; echo "<p>Purge all crashes and nodes from the database.</p>"; echo "<div id='purge_db_button'>Purge</div>"; }
public function changePhoto() { $id = \Input::get('id'); $game = $this->gameRepository->get($id); $response = ['code' => 0, 'message' => trans('photo.error', ['size' => formatBytes()]), 'url' => '']; if (\Request::hasFile('image')) { if (!$this->photoRepository->imagesMetSizes(\Input::file('image'))) { return json_encode($response); } $image = $this->gameRepository->changePhoto(\Input::file('image'), $game); if ($image) { $response['code'] = 1; $response['url'] = \Image::url($image, 100); } } return json_encode($response); }
function listFiles($prefix) { date_default_timezone_set('UTC'); $location = "../download/product"; echo "<!-- listing files in {$location} with prefix {$prefix} -->"; if (false != ($dir = opendir($location))) { while (false != ($file = readdir($dir))) { if ($file != "." and $file != ".." and $file != "index.php") { $files[] = $location . "/" . $file; // put in array. } } closedir($dir); } else { $location = "../../download/product"; if (false != ($dir = opendir($location))) { while (false != ($file = readdir($dir))) { if ($file != "." and $file != ".." and $file != "index.php") { $files[] = $location . "/" . $file; // put in array. } } closedir($dir); } } rsort($files); $count = 0; foreach ($files as $file) { if ($count < 5) { $refname = basename($file); if (substr($refname, 0, strlen($prefix)) == $prefix) { $count = $count + 1; $stat = stat($file); $date = date('Y-m-d', $stat['mtime']); $size = formatBytes($stat['size']); echo "<tr class='clickable'>"; echo "<td class='text-center'>{$date}</td>"; echo "<td><a href='http://eclipse.baeyens.it/download/product/{$refname}' target='_blank'><i class='glyphicon glyphicon-cloud-download'></i> {$refname}</a></td>"; echo "<td class='text-right'>{$size}</td>"; echo "</tr>"; } } } }
/** * Ließt den Seiteninhalt der übergebenen ID aus der Datenbank aus */ function show($id) { global $mysql, $content; $id = intval($id); $qPage = $mysql->query("SELECT * FROM " . _PREFIX_ . "pages WHERE id='" . $id . "'"); $oPage = mysql_fetch_object($qPage); $content->pagetitle = $oPage->title; $pageContent = stripslashes(base64_decode($oPage->content)); if (0 < mysql_result($mysql->query("SELECT count(*) FROM " . _PREFIX_ . "rel_pf WHERE page='" . $id . "'"), 0)) { $qFile = $mysql->query("SELECT " . _PREFIX_ . "files.*\r\n\t\t\t\t\t\tFROM " . _PREFIX_ . "files, " . _PREFIX_ . "rel_pf\r\n\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t" . _PREFIX_ . "rel_pf.page = " . $id . "\r\n\t\t\t\t\t\tAND\r\n\t\t\t\t\t\t\t" . _PREFIX_ . "files.id = " . _PREFIX_ . "rel_pf.file\r\n\t\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\t\t" . _PREFIX_ . "files.name"); $token = @file_get_contents(dirname(__FILE__) . "/template/attachment.token.tpl"); $tpl = @file_get_contents(dirname(__FILE__) . "/template/attachment.tpl"); while ($o = mysql_fetch_object($qFile)) { $data .= str_replace(array("%link%", "%title%", "%description%", "%filesize%"), array(UPLOAD_DIR . $o->file, $o->name, $o->description, formatBytes(filesize(UPLOAD_DIR . $o->file))), $token); } } $returnVal = $pageContent . str_replace("%attachment%", $data, $tpl); return $returnVal; }
function status(&$curBytes, &$totalBytes) { $minfo = apc_sma_info(); $cinfo = apc_cache_info('user'); foreach ($minfo['block_lists'] as $c) { $blocks[] = count($c); } $curBytes = $minfo['seg_size'] - $minfo['avail_mem']; $totalBytes = $minfo['seg_size']; $return[] = array('name' => '子系统运行时间', 'value' => timeLength(time() - $cinfo['start_time'])); $return[] = array('name' => '可用内存', 'value' => formatBytes($minfo['avail_mem']) . ' / ' . formatBytes($minfo['seg_size'])); $return[] = array('name' => '内存使用方式', 'value' => $cinfo['memory_type']); $return[] = array('name' => '内存数据段', 'value' => $minfo['num_seg'] . '块 (' . implode(',', $blocks) . ')'); $return[] = array('name' => '缓存命中', 'value' => $cinfo['num_hits'] . '次'); $return[] = array('name' => '缓存未命中', 'value' => $cinfo['num_misses'] . '次'); $return[] = array('name' => '已缓存数据条数', 'value' => $cinfo['num_entries'] . '条'); $return[] = array('name' => '数据锁定方式', 'value' => $cinfo['locking_type']); return $return; }
function status(&$curBytes, &$totalBytes) { $info = $this->obj->getStats(); $curBytes = $info['bytes']; $totalBytes = $info['limit_maxbytes']; $return[] = array('name' => '子系统运行时间', 'value' => timeLength($info['uptime'])); $return[] = array('name' => '缓存服务器', 'value' => MEMCACHED_HOST . ':' . MEMCACHED_PORT . " (ver:{$info['version']})"); $return[] = array('name' => '数据读取', 'value' => $info['cmd_get'] . '次 ' . formatBytes($info['bytes_written'])); $return[] = array('name' => '数据写入', 'value' => $info['cmd_set'] . '次 ' . formatBytes($info['bytes_read'])); $return[] = array('name' => '缓存命中', 'value' => $info['get_hits'] . '次'); $return[] = array('name' => '缓存未命中', 'value' => $info['get_misses'] . '次'); $return[] = array('name' => '已缓存数据条数', 'value' => $info['curr_items'] . '条'); $return[] = array('name' => '进程数', 'value' => $info['threads']); $return[] = array('value' => $info['pid'], 'name' => '服务器进程ID'); $return[] = array('value' => $info['rusage_user'], 'name' => '该进程累计的用户时间(秒:微妙)'); $return[] = array('value' => $info['rusage_system'], 'name' => '该进程累计的系统时间(秒:微妙)'); $return[] = array('value' => $info['curr_items'], 'name' => '服务器当前存储的内容数量'); $return[] = array('value' => $info['total_items'], 'name' => '服务器启动以来存储过的内容总数'); // $return[] = array('value'=>$info['curr_connections'],'name'=>'连接数量'); // $return[] = array('value'=>$info['total_connections'],'name'=>'服务器运行以来接受的连接总数 '); // $return[] = array('value'=>$info['connection_structures'],'name'=>'服务器分配的连接结构的数量'); return $return; }
public function uploadCover() { $failed = json_encode(['status' => 'error', 'message' => trans('photo.error', ['size' => formatBytes()])]); if (!\Input::hasFile('image')) { return $failed; } $file = \Input::file('image'); if (!$this->photo->imagesMetSizes($file)) { return $failed; } $path = $file->getRealPath(); list($width, $height) = getimagesize($path); $result = json_encode(['status' => 'error', 'message' => 'Failed to process image, supported type jpg,jpeg,gif,png']); //let use direct upload like that $imageRepo = $this->photo->image; $image = $imageRepo->load($file)->setPath('temp/')->offCdn(); $image = $image->resize(1000, null, 'fill', 'any'); if ($image->hasError()) { return $result; } $image = $image->result(); $image = str_replace('%d', '1000', $image); if ($image) { list($width, $height) = getimagesize(base_path() . '/' . $image); //delete old images $user = \Auth::user(); if ($user->original_cover) { \Image::delete($user->original_cover); } if ($user->cover) { \Image::delete($user->cover); } $this->userRepository->updateCover($image, null, true); return json_encode(['status' => 'success', 'url' => \URL::to($image)]); } return $result; }
public function uploadCover() { $failed = json_encode(['status' => 'error', 'message' => trans('photo.error', ['size' => formatBytes()])]); if (!\Input::hasFile('img')) { return $failed; } $file = \Input::file('img'); if (!$this->photo->imagesMetSizes($file)) { return $failed; } $path = $file->getRealPath(); list($width, $height) = getimagesize($path); $result = json_encode(['status' => 'error', 'message' => 'Insufficient image width/Height, MinWidth : 200px and MinHeight : 100px']); if ($width < 200 or $height < 100) { return $result; } if ($width < 1000) { //let use direct upload like that $imageRepo = $this->photo->image; $image = $imageRepo->load($file)->setPath('temp/')->offCdn(); $image = $image->resize(1000, 500, 'fill', 'up'); //if ($image->hasError()) return $result; $image = $image->result(); $image = str_replace('%d', '1000', $image); } else { $image = $this->photo->upload($file, ['path' => 'temp/', 'width' => 1000, 'fit' => 'inside', 'scale' => 'down', 'cdn' => false]); if (!$image) { return $result; } $image = str_replace('_%d_', '_1000_', $image); } if ($image) { list($width, $height) = getimagesize(base_path() . '/' . $image); return json_encode(['status' => 'success', 'url' => \URL::to($image)]); } return $result; }
/** * @return string */ protected function getFormattedFilesize() { if ($this->zipArchive) { $this->zipArchive->close(); $this->zipArchive = null; } return formatBytes(filesize($this->getBackupFile())); }
/* Template Name: Download */ ?> <? ob_start(); ?> <?php $file_id = get_query_var('file_id'); $fname = get_query_var("file_name"); if (!empty($file_id) && !empty($fname)) { $file = getFileByFileID($file_id); foreach ($file as $fi) { $post_id = $fi->post_id; $file_name = $fi->file_name; $file_url = $fi->file; $file_des = $fi->file_des; $file_size = formatBytes($fi->file_size); $file_hits = $fi->file_hits; $file_date = $fi->file_date; $file_updated_date = $fi->file_updated_date; $file_last_downloaded_date = $fi->file_last_downloaded_date; $file_views = $fi->file_views; } $_SESSION['hits'] = $file_hits; if (!isset($_SESSION['file_views'][$file_id])) { $_SESSION['file_views'][$file_id] = $file_views + 1; updateFile(array('file_views' => $file_views + 1), array('file_id' => $file_id)); } } $link = getLinkByFileID($file_id); $hit = $_SESSION['hits'] + 1; updateFile(array('file_hits' => $hit, 'file_last_downloaded_date' => date("d-m-Y H:i:s")), array('file_id' => $file_id));
// echo "Success, wrote ($somecontent) to file ($filename)"; fclose($fp); // genero nombre para el zip $i = 0; $existe = TRUE; while ($existe === TRUE) { if (file_exists(ZIP_DIR . "/{$zipFile}")) { $i++; $zipFile = date("Ymd") . "_Wazzup_" . DRUTT_VIDEO . "_{$i}.zip"; } else { $existe = FALSE; } } // creo file para ftp if ($FTPProcess == "new") { createEmptyFile($tmpDir . "/create.start"); } else { if ($FTPProcess == "update") { createEmptyFile($tmpDir . "/edit.start"); } } // zipeo y muevo a carpeta de "envios" $shellCmd = "cd " . $tmpDir . "; zip ../../../" . ZIP_DIR . "/{$zipFile} * "; $log .= exec($shellCmd); $log .= "\tZip " . ZIP_DIR . "/{$zipFile} generado exitosamente\n"; // chequeo zip filesize $ds = filesize(ZIP_DIR . "/{$zipFile}"); $ds = formatBytes($ds); echo "generado <a href='" . ZIP_DIR . "/{$zipFile}'>" . ZIP_DIR . "/{$zipFile}</a> con {$total} contenidos, <b>{$ds}</b><br/>\n"; echo "<hr/><h3>Log:</h3>"; echo "<textarea cols=50 rows=10>{$log}</textarea>";
unset($lists['allactive']); if (isset($messagedata['excludelist']) && is_array($messagedata['excludelist']) && count($messagedata['excludelist'])) { $exclude = sprintf(' and listuser.listid not in (%s)', implode(',', $messagedata['excludelist'])); } else { $exclude = ''; } $htmlcnt = Sql_Fetch_Row_Query(sprintf('select count(distinct userid) from %s listuser,%s user where user.htmlemail and user.id = listuser.userid and listuser.listid in (%s) %s', $GLOBALS['tables']['listuser'], $GLOBALS['tables']['user'], implode(',', array_keys($lists)), $exclude), 1); $textcnt = Sql_Fetch_Row_Query(sprintf('select count(distinct userid) from %s listuser,%s user where !user.htmlemail and user.id = listuser.userid and listuser.listid in (%s) %s', $GLOBALS['tables']['listuser'], $GLOBALS['tables']['user'], implode(',', array_keys($lists)), $exclude), 1); if ($htmlcnt[0] || $textcnt[0]) { if (!isset($messagedata['textsize'])) { $messagedata['textsize'] = 0; } if (!isset($messagedata['htmlsize'])) { $messagedata['htmlsize'] = 0; } $send_content .= $GLOBALS['I18N']->get('Estimated size of mailout') . ': ' . formatBytes($htmlcnt[0] * $messagedata['htmlsize'] + $textcnt[0] * $messagedata['textsize']) . '<br/>'; ## remember this to see how well the estimate was Sql_Query(sprintf('replace into %s set name = "estimatedsize",id=%d,data = "%s"', $GLOBALS['tables']['messagedata'], $id, $htmlcnt[0] * $messagedata['htmlsize'] + $textcnt[0] * $messagedata['textsize'])); $send_content .= sprintf($GLOBALS['I18N']->get('About %d users to receive HTML and %s users to receive text version of email'), $htmlcnt[0], $textcnt[0]) . '<br/>'; Sql_Query(sprintf('replace into %s set name = "estimatedhtmlusers",id=%d,data = "%s"', $GLOBALS['tables']['messagedata'], $id, $htmlcnt[0])); Sql_Query(sprintf('replace into %s set name = "estimatedtextusers",id=%d,data = "%s"', $GLOBALS['tables']['messagedata'], $id, $textcnt[0])); } } } $send_content .= '</div>'; ## the button to actually send the campagin $send_content .= $placeinqueue; print '<div class="sendtabs_container">'; $tabs->setListClass('sendcampaign'); $tabs->setId('sendtabs'); # $tabs->addPrevNext();
<th>Msg #</th> <th>Active</th> <th>Action</th> </tr> </thead> <tbody> <?php $result = mysqli_query($link, "SELECT mailbox.username, name, CASE active WHEN 1 THEN 'Yes' ELSE 'No' END AS active, domain, quota, bytes, messages \nFROM mailbox, quota2 WHERE (mailbox.username = quota2.username) AND \n(domain IN (SELECT domain from domain_admins WHERE username='******') OR 'admin'='{$logged_in_role}')"); while ($row = mysqli_fetch_array($result)) { echo "<tr><td>", $row['username'], "</td><td>", $row['name'], "</td><td>", $row['domain'], "</td><td>"; if (formatBytes($row['quota'], 2) == "0") { echo "∞"; } else { echo formatBytes($row['quota'], 2); } echo "</td><td>", formatBytes($row['bytes'], 2), "</td><td>", $row['messages'], "</td><td>", $row['active'], "</td><td><a href=\"do.php?deletemailbox=", $row['username'], "\">delete</a> | <a href=\"do.php?editmailbox=", $row['username'], "\">edit</a>", "</td></tr>"; } ?> </tbody> </table> </div> </div> </div> </div> <div class="row"> <div class="col-md-14"> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title">Aliases</h3> <div class="pull-right"> <span class="clickable filter" data-toggle="tooltip" title="Toggle table filter" data-container="body">
/** * */ public static function processOptimizeQueue() { $ids = TmpStore::getIdsByTag("image-optimize-queue"); // id = path of image relative to PIMCORE_TEMPORARY_DIRECTORY foreach ($ids as $id) { $file = PIMCORE_TEMPORARY_DIRECTORY . "/" . $id; if (file_exists($file)) { $originalFilesize = filesize($file); \Pimcore\Image\Optimizer::optimize($file); \Logger::debug("Optimized image: " . $file . " saved " . formatBytes($originalFilesize - filesize($file))); } else { \Logger::debug("Skip optimizing of " . $file . " because it doesn't exist anymore"); } TmpStore::delete($id); } }
function wall_upload_post(&$a, $desktopmode = true) { logger("wall upload: starting new upload", LOGGER_DEBUG); $r_json = x($_GET, 'response') && $_GET['response'] == 'json'; if ($a->argc > 1) { if (!x($_FILES, 'media')) { $nick = $a->argv[1]; $r = q("SELECT `user`.*, `contact`.`id` FROM `user` INNER JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1", dbesc($nick)); if (!count($r)) { if ($r_json) { echo json_encode(['error' => t('Invalid request.')]); killme(); } return; } } else { $user_info = api_get_user($a); $r = q("SELECT `user`.*, `contact`.`id` FROM `user` INNER JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1", dbesc($user_info['screen_name'])); } } else { if ($r_json) { echo json_encode(['error' => t('Invalid request.')]); killme(); } return; } $can_post = false; $visitor = 0; $page_owner_uid = $r[0]['uid']; $default_cid = $r[0]['id']; $page_owner_nick = $r[0]['nickname']; $community_page = $r[0]['page-flags'] == PAGE_COMMUNITY ? true : false; if (local_user() && local_user() == $page_owner_uid) { $can_post = true; } else { if ($community_page && remote_user()) { $cid = 0; if (is_array($_SESSION['remote'])) { foreach ($_SESSION['remote'] as $v) { if ($v['uid'] == $page_owner_uid) { $cid = $v['cid']; break; } } } if ($cid) { $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1", intval($cid), intval($page_owner_uid)); if (count($r)) { $can_post = true; $visitor = $cid; } } } } if (!$can_post) { if ($r_json) { echo json_encode(['error' => t('Permission denied.')]); killme(); } notice(t('Permission denied.') . EOL); killme(); } if (!x($_FILES, 'userfile') && !x($_FILES, 'media')) { if ($r_json) { echo json_encode(['error' => t('Invalid request.')]); killme(); } killme(); } $src = ""; if (x($_FILES, 'userfile')) { $src = $_FILES['userfile']['tmp_name']; $filename = basename($_FILES['userfile']['name']); $filesize = intval($_FILES['userfile']['size']); $filetype = $_FILES['userfile']['type']; } elseif (x($_FILES, 'media')) { if (is_array($_FILES['media']['tmp_name'])) { $src = $_FILES['media']['tmp_name'][0]; } else { $src = $_FILES['media']['tmp_name']; } if (is_array($_FILES['media']['name'])) { $filename = basename($_FILES['media']['name'][0]); } else { $filename = basename($_FILES['media']['name']); } if (is_array($_FILES['media']['size'])) { $filesize = intval($_FILES['media']['size'][0]); } else { $filesize = intval($_FILES['media']['size']); } if (is_array($_FILES['media']['type'])) { $filetype = $_FILES['media']['type'][0]; } else { $filetype = $_FILES['media']['type']; } } if ($src == "") { if ($r_json) { echo json_encode(['error' => t('Invalid request.')]); killme(); } notice(t('Invalid request.') . EOL); killme(); } // This is a special treatment for picture upload from Twidere if ($filename == "octet-stream" and $filetype != "") { $filename = $filetype; $filetype = ""; } if ($filetype == "") { $filetype = guess_image_type($filename); } // If there is a temp name, then do a manual check // This is more reliable than the provided value $imagedata = getimagesize($src); if ($imagedata) { $filetype = $imagedata['mime']; } logger("File upload src: " . $src . " - filename: " . $filename . " - size: " . $filesize . " - type: " . $filetype, LOGGER_DEBUG); $maximagesize = get_config('system', 'maximagesize'); if ($maximagesize && $filesize > $maximagesize) { $msg = sprintf(t('Image exceeds size limit of %s'), formatBytes($maximagesize)); if ($r_json) { echo json_encode(['error' => $msg]); } else { echo $msg . EOL; } @unlink($src); killme(); } $r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ", intval($page_owner_uid)); $limit = service_class_fetch($page_owner_uid, 'photo_upload_limit'); if ($limit !== false && $r[0]['total'] + strlen($imagedata) > $limit) { $msg = upgrade_message(true); if ($r_json) { echo json_encode(['error' => $msg]); } else { echo $msg . EOL; } @unlink($src); killme(); } $imagedata = @file_get_contents($src); $ph = new Photo($imagedata, $filetype); if (!$ph->is_valid()) { $msg = t('Unable to process image.'); if ($r_json) { echo json_encode(['error' => $msg]); } else { echo $msg . EOL; } @unlink($src); killme(); } $ph->orient($src); @unlink($src); $max_length = get_config('system', 'max_image_length'); if (!$max_length) { $max_length = MAX_IMAGE_LENGTH; } if ($max_length > 0) { $ph->scaleImage($max_length); logger("File upload: Scaling picture to new size " . $max_length, LOGGER_DEBUG); } $width = $ph->getWidth(); $height = $ph->getHeight(); $hash = photo_new_resource(); $smallest = 0; $defperm = '<' . $default_cid . '>'; $r = $ph->store($page_owner_uid, $visitor, $hash, $filename, t('Wall Photos'), 0, 0, $defperm); if (!$r) { $msg = t('Image upload failed.'); if ($r_json) { echo json_encode(['error' => $msg]); } else { echo $msg . EOL; } killme(); } if ($width > 640 || $height > 640) { $ph->scaleImage(640); $r = $ph->store($page_owner_uid, $visitor, $hash, $filename, t('Wall Photos'), 1, 0, $defperm); if ($r) { $smallest = 1; } } if ($width > 320 || $height > 320) { $ph->scaleImage(320); $r = $ph->store($page_owner_uid, $visitor, $hash, $filename, t('Wall Photos'), 2, 0, $defperm); if ($r and $smallest == 0) { $smallest = 2; } } $basename = basename($filename); if (!$desktopmode) { $r = q("SELECT `id`, `datasize`, `width`, `height`, `type` FROM `photo` WHERE `resource-id` = '%s' ORDER BY `width` DESC LIMIT 1", $hash); if (!$r) { if ($r_json) { echo json_encode(['error' => '']); killme(); } return false; } $picture = array(); $picture["id"] = $r[0]["id"]; $picture["size"] = $r[0]["datasize"]; $picture["width"] = $r[0]["width"]; $picture["height"] = $r[0]["height"]; $picture["type"] = $r[0]["type"]; $picture["albumpage"] = $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash; $picture["picture"] = $a->get_baseurl() . "/photo/{$hash}-0." . $ph->getExt(); $picture["preview"] = $a->get_baseurl() . "/photo/{$hash}-{$smallest}." . $ph->getExt(); if ($r_json) { echo json_encode(['picture' => $picture]); killme(); } return $picture; } if ($r_json) { echo json_encode(['ok' => true]); killme(); } /* mod Waitman Gobble NO WARRANTY */ //if we get the signal then return the image url info in BBCODE, otherwise this outputs the info and bails (for the ajax image uploader on wall post) if ($_REQUEST['hush'] != 'yeah') { if (local_user() && (!feature_enabled(local_user(), 'richtext') || x($_REQUEST['nomce']))) { echo "\n\n" . '[url=' . $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . $a->get_baseurl() . "/photo/{$hash}-{$smallest}." . $ph->getExt() . "[/img][/url]\n\n"; } else { echo '<br /><br /><a href="' . $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '" ><img src="' . $a->get_baseurl() . "/photo/{$hash}-{$smallest}." . $ph->getExt() . "\" alt=\"{$basename}\" /></a><br /><br />"; } } else { $m = '[url=' . $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . $a->get_baseurl() . "/photo/{$hash}-{$smallest}." . $ph->getExt() . "[/img][/url]"; return $m; } /* mod Waitman Gobble NO WARRANTY */ killme(); // NOTREACHED }
// filesystem label $tblStorage->td($cfgPtr['fsmounts'][$mntNode]['label']); // mount point $tblStorage->td("{$cfgPtr['mountroot']}/{$mntNode}"); // size/usage/... $fsFree = ''; $fsUsed = ''; $fsTotal = ''; $usage = ''; if (isset($disksInfo[$fsInfo[0]]['parts'][$fsInfo[1]]['blocks-total'])) { $fsBlocksTotal = $disksInfo[$fsInfo[0]]['parts'][$fsInfo[1]]['blocks-total']; $fsBlocksUsed = $disksInfo[$fsInfo[0]]['parts'][$fsInfo[1]]['blocks-used']; // we have 1024 bytes blocks, not bytes. $fsFree = formatBytes($fsBlocksTotal * 1024 - $fsBlocksUsed * 1024); $fsUsed = formatBytes($fsBlocksUsed * 1024); $fsTotal = formatBytes($fsBlocksTotal * 1024); $usage = getAnalogBar(array('total' => $fsBlocksTotal, 'used' => $fsBlocksUsed)); } $tblStorage->td($fsFree); $tblStorage->td($fsUsed); $tblStorage->td($fsTotal); $tblStorage->td($usage); // attached services $tblStorage->td(''); } } else { $tblStorage->tr(); $tblStorage->td(_('No additional storage configured.'), 'colspan=8'); } // // report all system devices
<?php echo $form->labelEx($model, 'video_file'); ?> <?php echo $form->fileField($model, 'video_file'); ?> <div class="padding-bottom10"> <span class="label label-info"> <?php echo Yii::t('module_apartments', 'Supported file: {supportExt}.', array('{supportExt}' => $supportvideoext)); ?> </span> <br /> <span class="label label-info"> <?php echo Yii::t('module_apartments', 'videoMaxSite: {size}.', array('{size}' => formatBytes($supportvideomaxsize))); ?> </span> </div> <?php echo $form->error($model, 'video_file'); ?> </div> </div> </div> <?php } ?> <?php $this->renderPartial('__form', array('form' => $form, 'model' => $model));
if (is_dir($dir . '/' . $currentFile)) { $ret2 = countFilesProc($dir . '/' . $currentFile); $ret['files'] += $ret2['files']; $ret['size'] += $ret2['size']; } else { $ret['files']++; $ret['size'] += filesize($dir . '/' . $currentFile); } } } closedir($odir); return $ret; } $user = $_SESSION['user_id']; $proj_id = $_POST['proj_id']; $q = new myQuery("SELECT project.user_id as owner \n FROM project \n LEFT JOIN project_user ON (project.id=project_id)\n WHERE project_user.user_id='{$user}' AND project_id='{$proj_id}'"); if ($q->get_num_rows() > 0) { $return['filemtime'] = filemtime(IMAGEBASEDIR . $proj_id); if ($return['filemtime'] != $_POST['filemtime']) { $res = countFilesProc(IMAGEBASEDIR . $proj_id); if ($res) { $return['mysize'] = $q->get_one() == $user ? $res['size'] : 0; $return['files'] = $res['files'] | 0; $return['trash'] = $res['trash'] | 0; $return['tmp'] = $res['tmp'] | 0; $return['size'] = formatBytes($res['size']); } } } scriptReturn($return); exit;