$DBVARS['site_subtitle'] = $_REQUEST['site_subtitle']; $DBVARS['site_thousands_sep'] = $_REQUEST['site_thousands_sep']; $DBVARS['site_dec_point'] = $_REQUEST['site_dec_point']; if (isset($_FILES['site_favicon']) && file_exists($_FILES['site_favicon']['tmp_name'])) { $tmpname = addslashes($_FILES['site_favicon']['tmp_name']); $newdir = USERBASE . '/f/skin_files'; if (!file_exists(USERBASE . '/f/skin_files')) { mkdir(USERBASE . '/f/skin_files'); } $files = glob($newdir . '/favicon-*'); foreach ($files as $f) { unlink($f); } $from = addslashes($_FILES['site_favicon']['tmp_name']); $to = addslashes($newdir . '/favicon.png'); CoreGraphics::resize($from, $to, 32, 32); } if (isset($_FILES['site_logo']) && file_exists($_FILES['site_logo']['tmp_name'])) { $tmpname = addslashes($_FILES['site_logo']['tmp_name']); $newdir = USERBASE . '/f/skin_files'; if (!file_exists($newdir)) { mkdir($newdir); } $files = glob($newdir . '/logo-*'); foreach ($files as $f) { unlink($f); } CoreGraphics::convert($_FILES['site_logo']['tmp_name'], $newdir . '/logo.png'); } $pageLengthLimit = $_REQUEST['site_page_length_limit']; if (!empty($pageLengthLimit) && is_numeric($pageLengthLimit)) {
/** * set the icon of a category * * @return array result of upload */ function Products_adminCategorySetIcon() { $cat_id = (int) $_REQUEST['cat_id']; $cat = ProductCategory::getInstance($cat_id); $dir = USERBASE . '/f/products/categories/' . $cat_id; @mkdir($dir, 0777, true); $tmpname = $_FILES['Filedata']['tmp_name']; list($width, $height) = getimagesize($tmpname); $thumbw = (int) $cat->vals['thumbsize_w']; $thumbh = (int) $cat->vals['thumbsize_h']; if ($width > $thumbw || $height > $thumbh) { CoreGraphics::resize($tmpname, $dir . '/icon.png', $thumbw, $thumbh); } else { move_uploaded_file($tmpname, $dir . '/icon.png'); } return array('ok' => 1); }
/** * return a logo HTML string if the admin uploaded one * * @param array $vars array of logo parameters (width, height) * * @return string */ function Template_logoDisplay($vars) { $vars = array_merge(array('width' => 64, 'height' => 64), $vars); $image_file_orig = USERBASE . '/f/skin_files/logo.png'; if (!file_exists($image_file_orig)) { return ''; } $x = (int) $vars['width']; $y = (int) $vars['height']; $geometry = $x . 'x' . $y; $image_file = USERBASE . '/f/skin_files/logo-' . $geometry . '.png'; if (!file_exists($image_file) || filectime($image_file) < filectime($image_file_orig)) { CoreGraphics::resize($image_file_orig, $image_file, $x, $y); } $size = getimagesize($image_file); return '<img class="logo" src="/i/blank.gif" style="' . 'background:url(/f/skin_files/logo-' . $geometry . '.png) no-repeat;' . 'width:' . $size[0] . 'px;height:' . $size[1] . 'px;" />'; }
/** * display an theme's screenshot * * @param string $file the screenshot * * @return null */ function ThemesApi_displayImage($file) { if (!file_exists($file) || !filesize($file)) { die(__('File %1 does not exist', array($file), 'core')); } $arr = getimagesize($file); if ($arr[0] > 240 || $arr[1] > 172) { $md5 = USERBASE . '/ww.cache/screenshots/' . md5($file) . '.png'; if (!file_exists($md5)) { @mkdir(USERBASE . '/ww.cache/screenshots'); CoreGraphics::resize($file, $md5, 240, 172); } $file = $md5; } /** * set headers and read file */ header('Content-type: image/png'); header('Content-Transfer-Encoding: Binary'); header('Content-length: ' . filesize($file)); readfile($file); }
/** * retrieve an image * * @return null */ function Core_getImg() { $w = isset($_REQUEST['w']) ? (int) $_REQUEST['w'] : 0; $h = isset($_REQUEST['h']) ? (int) $_REQUEST['h'] : 0; if (isset($_REQUEST['base64'])) { $f = base64_decode($_REQUEST['base64']); if (@fopen($f, 'r') != true) { header("HTTP/1.0 404 Not Found"); echo 'file does not exist'; Core_quit(); } } else { $f = USERBASE . '/f/' . $_REQUEST['_remainder']; if (!file_exists($f)) { header("HTTP/1.0 404 Not Found"); echo 'file does not exist'; Core_quit(); } } $ext = strtolower(preg_replace('/.*\\./', '', $f)); switch ($ext) { case 'jpg': case 'jpe': // { $ext = 'jpeg'; break; // } // } case 'png': case 'gif': case 'jpeg': // { break; // } // } default: // { echo 'unhandled image extension ' . $ext; Core_quit(); // } } if (strpos($f, '/.') != false) { return false; // hack attempt } if ($w || $h) { list($width, $height) = getimagesize($f); $resize = 0; if ($w && $width > $w) { $height *= $w / $width; $width = $w; $resize = 1; } if ($h && $height > $h) { $width *= $h / $height; $height = $h; $resize = 1; } if ($resize) { $width = (int) $width; $height = (int) $height; @mkdir(USERBASE . '/ww.cache/resized.images'); $c = USERBASE . '/ww.cache/resized.images/' . md5($f) . ',' . $width . 'x' . $height . '.png'; if (!file_exists($c) || filesize($c) == 0) { CoreGraphics::resize($f, $c, $width, $height); } $f = $c; $ext = 'png'; } } header('Content-type: image/' . $ext); header('Cache-Control: max-age=2592000, public'); header('Expires-Active: On'); header('Expires: Fri, 1 Jan 2500 01:01:01 GMT'); header('Pragma:'); header('Content-Length: ' . filesize($f)); readfile($f); Core_quit(); }