function dc_admin_icon_url($img) { global $core; $core->auth->user_prefs->addWorkspace('interface'); $user_ui_iconset = @$core->auth->user_prefs->interface->iconset; if ($user_ui_iconset && $img) { $icon = false; if (preg_match('/^images\\/menu\\/(.+)$/', $img, $m) || preg_match('/^index\\.php\\?pf=(.+)$/', $img, $m)) { if ($m[1]) { $icon = path::real(dirname(__FILE__) . '/../../admin/images/iconset/' . $user_ui_iconset . '/' . $m[1], false); if ($icon !== false) { $allow_types = array('png', 'jpg', 'jpeg', 'gif'); if (is_file($icon) && is_readable($icon) && in_array(files::getExtension($icon), $allow_types)) { return DC_ADMIN_URL . 'images/iconset/' . $user_ui_iconset . '/' . $m[1]; } } } } } return $img; }
/** * Vérifie que la variable passée en paramètre est de type image * @param string $pImage nom de l'image * @param string $pName nom du label associé * @param string $pMessage message */ function imageTest($pImage, $pName, $pMessage = "", $i = "") { $extension = files::getExtension($pImage); if (!($extension == 'jpg' || $extension == 'gif' || $extension == 'png')) { $this->add($pImage, $pName, $pMessage, $this->style, $i); $this->nbError++; } }
protected function sortFilesHelper($a, $b) { if ($a == $b) { return 0; } $ext_a = files::getExtension($a); $ext_b = files::getExtension($b); return strcmp($ext_a . '.' . $a, $ext_b . '.' . $b); }
http::head(404, 'Not Found'); exit; } $allow_types = array('png', 'jpg', 'jpeg', 'gif', 'css', 'js', 'swf'); $pf = path::clean($_GET['pf']); $paths = array_reverse(explode(PATH_SEPARATOR, DC_PLUGINS_ROOT)); # Adding admin/res folder here to load some stuff $paths[] = dirname(__FILE__) . '/swf'; foreach ($paths as $m) { $PF = path::real($m . '/' . $pf); if ($PF !== false) { break; } } unset($paths); if ($PF === false || !is_file($PF) || !is_readable($PF)) { header('Content-Type: text/plain'); http::head(404, 'Not Found'); exit; } if (!in_array(files::getExtension($PF), $allow_types)) { header('Content-Type: text/plain'); http::head(404, 'Not Found'); exit; } http::$cache_max_age = 7200; http::cache(array_merge(array($PF), get_included_files())); header('Content-Type: ' . files::getMimeType($PF)); header('Content-Length: ' . filesize($PF)); readfile($PF); exit;
function mediaItemLine($f, $i, $query, $table = false) { global $core, $page_url, $popup, $select, $post_id, $plugin_id, $page_url_params; $fname = $f->basename; $file = $query ? $f->relname : $f->basename; $class = $table ? '' : 'media-item media-col-' . $i % 2; if ($f->d) { // Folder $link = $core->adminurl->get('admin.media', array_merge($page_url_params, array('d' => html::sanitizeURL($f->relname)))); if ($f->parent) { $fname = '..'; $class .= ' media-folder-up'; } else { $class .= ' media-folder'; } } else { // Item $params = new ArrayObject(array('id' => $f->media_id, 'plugin_id' => $plugin_id, 'popup' => $popup, 'select' => $select, 'post_id' => $post_id)); $core->callBehavior('adminMediaURLParams', $params); $params = (array) $params; $link = $core->adminurl->get('admin.media.item', $params); } $maxchars = 36; if (strlen($fname) > $maxchars) { $fname = substr($fname, 0, $maxchars - 4) . '...' . ($f->d ? '' : files::getExtension($fname)); } $act = ''; if (!$f->d) { if ($select > 0) { if ($select == 1) { // Single media selection button $act .= '<a href="' . $link . '"><img src="images/plus.png" alt="' . __('Select this file') . '" ' . 'title="' . __('Select this file') . '" /></a> '; } else { // Multiple media selection checkbox $act .= form::checkbox(array('medias[]', 'media_' . rawurlencode($file)), $file); } } else { // Item if ($post_id) { // Media attachment button $act .= '<a class="attach-media" title="' . __('Attach this file to entry') . '" href="' . $core->adminurl->get("admin.post.media", array('media_id' => $f->media_id, 'post_id' => $post_id, 'attach' => 1)) . '">' . '<img src="images/plus.png" alt="' . __('Attach this file to entry') . '"/>' . '</a>'; } if ($popup) { // Media insertion button $act .= '<a href="' . $link . '"><img src="images/plus.png" alt="' . __('Insert this file into entry') . '" ' . 'title="' . __('Insert this file into entry') . '" /></a> '; } } } if ($f->del) { // Deletion button or checkbox if (!$popup && !$f->d) { if ($select < 2) { // Already set for multiple media selection $act .= form::checkbox(array('medias[]', 'media_' . rawurlencode($file)), $file); } } else { $act .= '<a class="media-remove" ' . 'href="' . html::escapeURL($page_url) . '&plugin_id=' . $plugin_id . '&d=' . rawurlencode($GLOBALS['d']) . '&q=' . rawurlencode($GLOBALS['q']) . '&remove=' . rawurlencode($file) . '">' . '<img src="images/trash.png" alt="' . __('Delete') . '" title="' . __('delete') . '" /></a>'; } } // Render markup if (!$table) { $res = '<div class="' . $class . '"><p><a class="media-icon media-link" href="' . rawurldecode($link) . '">' . '<img src="' . $f->media_icon . '" alt="" />' . ($query ? $file : $fname) . '</a></p>'; $lst = ''; if (!$f->d) { $lst .= '<li>' . $f->media_title . '</li>' . '<li>' . $f->media_dtstr . ' - ' . files::size($f->size) . ' - ' . '<a href="' . $f->file_url . '">' . __('open') . '</a>' . '</li>'; } $lst .= $act != '' ? '<li class="media-action"> ' . $act . '</li>' : ''; // Show player if relevant $file_type = explode('/', $f->type); if ($file_type[0] == 'audio') { $lst .= '<li>' . dcMedia::audioPlayer($f->type, $f->file_url, $core->adminurl->get("admin.home", array('pf' => 'player_mp3.swf')), null, $core->blog->settings->system->media_flash_fallback) . '</li>'; } $res .= $lst != '' ? '<ul>' . $lst . '</ul>' : ''; $res .= '</div>'; } else { $res = '<tr class="' . $class . '">'; $res .= '<td class="media-action">' . $act . '</td>'; $res .= '<td class="maximal" scope="row"><a class="media-flag media-link" href="' . rawurldecode($link) . '">' . '<img src="' . $f->media_icon . '" alt="" />' . ($query ? $file : $fname) . '</a>' . '<br />' . ($f->d ? '' : $f->media_title) . '</td>'; $res .= '<td class="nowrap count">' . ($f->d ? '' : $f->media_dtstr) . '</td>'; $res .= '<td class="nowrap count">' . ($f->d ? '' : files::size($f->size) . ' - ' . '<a href="' . $f->file_url . '">' . __('open') . '</a>') . '</td>'; $res .= '</tr>'; } return $res; }