public static function check() { $result = ""; $theList = array("/topic/"); $error = false; foreach ($theList as $cur) { if (isWriteable(dirname(__FILE__) . $cur)) { $result .= $cur . ' - <span style="color:green">Writable</span><br />'; } else { $result .= $cur . ' - <span style="color:red">Readonly</span><br />'; $error = true; } } if ($error) { $result .= '<span id="error"></span>'; } return $result; }
function admin_language_showpage() { global $main_smarty, $the_template; include_once 'config.php'; include_once mnminclude . 'html1.php'; include_once mnminclude . 'link.php'; include_once mnminclude . 'tags.php'; include_once mnminclude . 'smartyvariables.php'; $main_smarty = do_sidebar($main_smarty); force_authentication(); $canIhaveAccess = 0; $canIhaveAccess = $canIhaveAccess + checklevel('god'); if ($canIhaveAccess == 1) { if ($_REQUEST['var_id'] != "") { $lines = file('./languages/lang_' . pligg_language . '.conf'); $filename = './languages/lang_' . pligg_language . '.conf'; if ($handle = fopen($filename, 'w')) { foreach ($lines as $line_num => $line) { if (substr($line, 0, 2) != "//") { if (strlen(trim($line)) > 2) { $x = strpos($line, "="); if (trim(substr($line, 0, $x)) == str_replace('emptytext_', '', $_REQUEST["var_id"])) { $y = trim(substr($line, $x + 1, 10000)); $y = str_replace('"', '', $y); $line = trim(substr($line, 0, $x)) . ' = "' . $_REQUEST["var_value"] . '"' . "\n"; $returnVal = $_REQUEST["var_value"]; } } } if (fwrite($handle, $line)) { } else { echo "<b>Could not write to '{$filename}' file</b>"; } } fclose($handle); //header('Location: admin_modifylanguage.php'); } else { echo "<b>Could not open '{$filename}' file for writing</b>"; } echo $returnVal; die; } $canContinue = 1; $canContinue = isWriteable($canContinue, './languages/lang_' . pligg_language . '.conf', 0777, './languages/lang_' . pligg_language . '.conf'); if (!$canContinue) { echo 'File is not writeable. Please CHMOD /languages/lang_' . pligg_language . '.conf to 777 and refresh this page.<br /><br /><br />'; die; } $lines = file('./languages/lang_' . pligg_language . '.conf'); $section = "x"; $lastsection = ""; $tabA = " "; if (isset($_GET["mode"])) { if ($_GET["mode"] == "edit") { $outputHtml[] = "<form>"; $outputHtml[] = "<table class='listing'>"; $outputHtml[] = "Editing <b>" . $_GET["edit"] . "</b><br /><br />"; foreach ($lines as $line_num => $line) { if (substr($line, 0, 2) != "//") { if (strlen(trim($line)) > 2) { $x = strpos($line, "="); if (trim(substr($line, 0, $x)) == $_GET["edit"]) { $y = trim(substr($line, $x + 1, 10000)); $y = str_replace('"', "", $y); $outputHtml[] = "Current Value: " . $y . "<br />"; $outputHtml[] = '<input type = "hidden" name = "edit" value = "' . $_GET["edit"] . '">'; $outputHtml[] = '<input type = "hidden" name = "mode" value = "save">'; $outputHtml[] = '<input name = "newvalue" value = "' . $y . '" size=75><br />'; $outputHtml[] = '<input type = "submit" name = "save" value = "save" class = "log2">'; } } } } } if ($_GET["mode"] == "save") { $outputHtml[] = "saving <b>" . $_GET["edit"] . "</b><br />"; $filename = './languages/lang_' . pligg_language . '.conf'; if ($handle = fopen($filename, 'w')) { foreach ($lines as $line_num => $line) { if (substr($line, 0, 2) != "//") { if (strlen(trim($line)) > 2) { $x = strpos($line, "="); if (trim(substr($line, 0, $x)) == $_GET["edit"]) { $y = trim(substr($line, $x + 1, 10000)); $y = str_replace('"', '', $y); $line = trim(substr($line, 0, $x)) . ' = "' . $_GET["newvalue"] . '"' . "\n"; } } } if (fwrite($handle, $line)) { } else { $outputHtml[] = "<b>Could not write to '{$filename}' file</b>"; } } fclose($handle); header('Location: admin_modifylanguage.php'); } else { $outputHtml[] = "<b>Could not open '{$filename}' file for writing</b>"; } } } else { $outputHtml = array(); $outputHtml[] = "<form>"; $outputHtml[] = '<table id="mytable" class="listing">'; foreach ($lines as $line_num => $line) { if (substr($line, 0, 2) == "//") { $x = strpos($line, "<LANG>"); if ($x === false) { } else { $y = strpos($line, "</LANG>"); $lang = substr($line, $x + 6, $y); } $x = strpos($line, "<TITLE>"); if ($x === false) { } else { $y = strpos($line, "</TITLE>"); $outputHtml[] = "<tr><td bgcolor = BFBFBF><b>Title:</b>" . substr($line, $x + 7, $y) . "</td></tr>"; } $x = strpos($line, "<SECTION>"); if ($x > 0) { $y = strpos($line, '</SECTION>'); $section = substr($line, $x + 9, $y - $x); if ($section != $lastsection) { $lastsection = $section; $outputHtml[] = '<tr id="row_ASDFGHJK"><td></td></tr>'; $outputHtml[] = '<tr id="row_ASDFGHJK"><td></td></tr>'; $outputHtml[] = '<tr id="row_ASDFGHJK"><td></td></tr>'; $outputHtml[] = '<tr id="row_ASDFGHJK"><th><b>Section</b>: ' . $section . '</th></tr>'; } } $x = strpos($line, "<VERSION>"); if ($x === false) { } else { $y = strpos($line, "</VERSION>"); $version = substr($line, $x + 9, $y); } $x = strpos($line, "<ADDED>"); if ($x === false) { } else { $y = strpos($line, "</ADDED>"); $added = substr($line, $x + 7, $y) * 1; } } else { if (strlen(trim($line)) > 2) { $x = strpos($line, "="); $outputHtml[] = '<tr id = "row_' . str_replace('"', '', trim(substr($line, $x + 1, 10000))) . '"><td><br />'; $grey = "grey1"; $outputHtml[] = "<b>" . $tabA . trim(substr($line, 0, $x)); $outputHtml[] = "</b><br />"; $outputHtml[] = "" . $tabA . $tabA; $outputHtml[] = 'Value: <span class="emptytext" id="emptytext_' . trim(substr($line, 0, $x)) . '">' . str_replace('"', '', trim(substr($line, $x + 1, 10000))) . '</span>'; $outputHtml[] = "</td></tr>"; $editinplace_init[] = "EditInPlaceAL.makeEditable({ id: 'emptytext_" . trim(substr($line, 0, $x)) . "', on_blur: 'cancel'});"; } } } } $outputHtml[] = "</table>"; $outputHtml[] = "</form>"; $main_smarty->assign('outputHtml', $outputHtml); // breadcrumbs $navwhere['text1'] = $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel'); $navwhere['link1'] = getmyurl('admin', ''); $navwhere['text2'] = "Modify Language"; $navwhere['link2'] = my_pligg_base . "/module.php?module=admin_language"; $main_smarty->assign('navbar_where', $navwhere); $main_smarty->assign('posttitle', " | " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel')); // breadcrumbs //Method for identifying modules rather than pagename define('modulename', 'admin_language'); $main_smarty->assign('modulename', modulename); define('pagename', 'admin_modifylanguage'); $main_smarty->assign('pagename', pagename); $main_smarty->assign('editinplace_init', $editinplace_init); $main_smarty->assign('tpl_center', admin_language_tpl_path . 'admin_language_main'); $main_smarty->display($template_dir . '/admin/admin.tpl'); } else { echo "Access denied"; } }
/** * Actually uploads the file, and act on it according to the set processing class variables * * This function copies the uploaded file to the given location, eventually performing actions on it. * Typically, you can call {@link process} several times for the same file, * for instance to create a resized image and a thumbnail of the same file. * The original uploaded file remains intact in its temporary location, so you can use {@link process} several times. * You will be able to delete the uploaded file with {@link clean} when you have finished all your {@link process} calls. * * According to the processing class variables set in the calling file, the file can be renamed, * and if it is an image, can be resized or converted. * * When the processing is completed, and the file copied to its new location, the * processing class variables will be reset to their default value. * This allows you to set new properties, and perform another {@link process} on the same uploaded file * * It will set {@link processed} (and {@link error} is an error occurred) * * @access public * @param string $server_path Path location of the uploaded file, with an ending slash */ function process($server_path) { set_time_limit(30); global $site; $this->error = ''; $this->processed = true; if (substr($server_path, -1, 1) != '/') { $server_path = $server_path . '/'; } $this->log .= '<b>' . _("process file to") . ' ' . $server_path . '</b><br />'; // checks file size and mine type if ($this->file_exists) { if ($this->file_src_size > $this->file_max_size) { $this->processed = false; $this->error = _("File too big"); } else { $this->log .= '- ' . _("file size OK") . '<br />'; } // turn dangerous scripts into text files if ($this->no_script) { if ((substr($this->file_src_mime, 0, 5) == 'text/' || strpos($this->file_src_mime, 'javascript') !== false) && substr($this->file_src_name, -4) != '.txt' || preg_match('/\\.(php|pl|py|cgi|asp)$/i', $this->file_src_name) || empty($this->file_src_name_ext)) { $this->file_src_mime = 'text/plain'; $this->log .= '- ' . _("script") . ' ' . $this->file_src_name . ' ' . _("renamed as") . ' ' . $this->file_src_name . '.txt!<br />'; $this->file_src_name_ext .= empty($this->file_src_name_ext) ? 'txt' : '.txt'; } } // checks MIME type with mime_magic if ($this->mime_magic_check && function_exists('mime_content_type')) { $detected_mime = mime_content_type($this->file_src_pathname); if ($this->file_src_mime != $detected_mime) { $this->log .= '- ' . _("MIME type detected as") . ' ' . $detected_mime . ' ' . _("but given as") . ' ' . $this->file_src_mime . '!<br />'; $this->file_src_mime = $detected_mime; } } if (!empty($this->file_src_mime) && !array_key_exists($this->file_src_mime, array_flip($this->allowed))) { $this->processed = false; $this->error = _("Incorrect type of file"); } else { $this->log .= '- ' . _("file mime OK") . ' : ' . $this->file_src_mime . '<br />'; } } else { $this->error = _("File not uploaded. Can't carry on a process"); $this->processed = false; } if ($this->processed) { $this->file_dst_path = $server_path; // repopulate dst variables from src $this->file_dst_name = $this->file_src_name; $this->file_dst_name_body = $this->file_src_name_body; $this->file_dst_name_ext = $this->file_src_name_ext; if ($this->file_new_name_body != '') { // rename file body $this->file_dst_name_body = $this->file_new_name_body; $this->log .= '- ' . _("new file name body") . ' : ' . $this->file_new_name_body . '<br />'; } if ($this->file_new_name_ext != '') { // rename file ext $this->file_dst_name_ext = $this->file_new_name_ext; $this->log .= '- ' . _("new file name ext") . ' : ' . $this->file_new_name_ext . '<br />'; } if ($this->file_name_body_add != '') { // append a bit to the name $this->file_dst_name_body = $this->file_dst_name_body . $this->file_name_body_add; $this->log .= '- ' . _("file name body add") . ' : ' . $this->file_name_body_add . '<br />'; } if ($this->file_safe_name) { // formats the name $this->file_dst_name_body = str_replace(array(' ', '-'), array('_', '_'), $this->file_dst_name_body); $this->file_dst_name_body = ereg_replace('[^A-Za-z0-9_]', '_', $this->file_dst_name_body); $this->log .= '- ' . _("file name safe format") . '<br />'; } $this->log .= '- ' . _("destination variables") . '<br />'; $this->log .= ' file_dst_path : ' . $this->file_dst_path . '<br />'; $this->log .= ' file_dst_name_body : ' . $this->file_dst_name_body . '<br />'; $this->log .= ' file_dst_name_ext : ' . $this->file_dst_name_ext . '<br />'; // do we do some image manipulation? $image_manipulation = $this->image_resize || $this->image_convert != '' || is_numeric($this->image_brightness) || is_numeric($this->image_contrast) || is_numeric($this->image_threshold) || !empty($this->image_tint_color) || !empty($this->image_overlay_color) || !empty($this->image_text) || $this->image_greyscale || $this->image_negative || !empty($this->image_watermark) || is_numeric($this->image_rotate) || is_numeric($this->jpeg_size) || !empty($this->image_flip) || !empty($this->image_crop) || !empty($this->image_border) || $this->image_frame > 0 || $this->image_bevel > 0; if ($image_manipulation) { if ($this->image_convert == '') { $this->file_dst_name = $this->file_dst_name_body . (!empty($this->file_dst_name_ext) ? '.' . $this->file_dst_name_ext : ''); $this->log .= '- ' . _("image operation, keep extension") . '<br />'; } else { $this->file_dst_name = $this->file_dst_name_body . '.' . $this->image_convert; $this->log .= '- ' . _("image operation, change extension for conversion type") . '<br />'; } } else { $this->file_dst_name = $this->file_dst_name_body . (!empty($this->file_dst_name_ext) ? '.' . $this->file_dst_name_ext : ''); $this->log .= '- ' . _("no image operation, keep extension") . '<br />'; } if (!$this->file_auto_rename) { $this->log .= '- ' . _("no auto_rename if same filename exists") . '<br />'; $this->file_dst_pathname = $this->file_dst_path . $this->file_dst_name; } else { $this->log .= '- ' . _("checking for auto_rename") . '<br />'; $this->file_dst_pathname = $this->file_dst_path . $this->file_dst_name; $body = $this->file_dst_name_body; $cpt = 1; while (file_exists($this->file_dst_pathname)) { $this->file_dst_name_body = $body . '_' . $cpt; $this->file_dst_name = $this->file_dst_name_body . (!empty($this->file_dst_name_ext) ? '.' . $this->file_dst_name_ext : ''); $cpt++; $this->file_dst_pathname = $this->file_dst_path . $this->file_dst_name; } if ($cpt > 1) { $this->log .= ' ' . _("auto_rename to") . ' ' . $this->file_dst_name . '<br />'; } } $this->log .= '- ' . _("destination file details") . '<br />'; $this->log .= ' file_dst_name : ' . $this->file_dst_name . '<br />'; $this->log .= ' file_dst_pathname : ' . $this->file_dst_pathname . '<br />'; if ($this->file_overwrite) { $this->log .= '- ' . _("no overwrite checking") . '<br />'; } else { if (file_exists($this->file_dst_pathname)) { $this->processed = false; $this->error = $this->file_dst_name . ' ' . _("already exists. Please change the file name"); } else { $this->log .= '- ' . $this->file_dst_name . ' ' . _("doesn't exist already") . '<br />'; } } } else { $this->processed = false; } if (!$this->no_upload_check && !is_uploaded_file($this->file_src_pathname)) { $this->processed = false; $this->error = _("No correct source file. Can't carry on a process"); } if ($this->processed && !file_exists($this->file_src_pathname)) { $this->processed = false; $this->error = _("No source file. Can't carry on a process"); } // checks if the destination directory is writeable, and attempt to make it writeable if ($this->processed && !isReadable($this->file_src_pathname)) { $this->processed = false; if (is_readable($this->file_src_pathname)) { $this->error = _("Source file is not readable. open_basedir restriction in place?"); } else { $this->error = _("Source file is not readable. Can't carry on a process"); } } // checks if the destination directory exists, and attempt to create it if ($this->processed && !file_exists($this->file_dst_path)) { if ($this->dir_auto_create) { $this->log .= '- ' . $this->file_dst_path . ' ' . _("doesn't exist. Attempting creation:"); if (!function_exists('recursiveMkdir')) { function recursiveMkdir($strPath, $mode = 0777) { return is_dir($strPath) or recursiveMkdir(dirname($strPath), $mode) and mkdir($strPath, $mode); } } if (!recursiveMkdir($this->file_dst_path, $this->dir_chmod)) { $this->log .= ' ' . _("failed") . '<br />'; $this->processed = false; $this->error = _("Destination directory can't be created. Can't carry on a process"); } else { $this->log .= ' ' . _("success") . '<br />'; } } else { $this->error = _("Destination directory doesn't exist. Can't carry on a process"); } } if ($this->processed && !is_dir($this->file_dst_path)) { $this->processed = false; $this->error = _("Destination path is not a directory. Can't carry on a process"); } // checks if the destination directory is writeable, and attempt to make it writeable if ($this->processed && !isWriteable($this->file_dst_pathname)) { if ($this->dir_auto_chmod) { $this->log .= '- ' . $this->file_dst_path . ' ' . _("is not writeable. Attempting chmod:"); if (!chmod($this->file_dst_path, $this->dir_chmod)) { $this->log .= ' ' . _("failed") . '<br />'; $this->processed = false; $this->error = _("Destination directory can't be made writeable. Can't carry on a process"); } else { $this->log .= ' ' . _("success") . '<br />'; if (!isWriteable($this->file_dst_pathname)) { // we re-check $this->processed = false; $this->error = _("Destination directory is still not writeable. Can't carry on a process"); } } } else { $this->processed = false; $this->error = _("Destination path is not a writeable. Can't carry on a process"); } } if ($this->processed) { if ($image_manipulation) { $this->log .= '- ' . _("image resizing or conversion wanted") . '<br />'; if ($this->gd_version()) { switch ($this->file_src_mime) { case 'image/pjpeg': case 'image/jpeg': case 'image/jpg': if (!function_exists('imagecreatefromjpeg')) { $this->processed = false; $this->error = _("No create from JPEG support"); } else { $image_src = imagecreatefromjpeg($this->file_src_pathname); if (!$image_src) { $this->processed = false; $this->error = _("No JPEG read support"); } else { $this->log .= '- ' . _("source image is JPEG") . '<br />'; } } break; case 'image/png': if (!function_exists('imagecreatefrompng')) { $this->processed = false; $this->error = _("No create from PNG support"); } else { $image_src = imagecreatefrompng($this->file_src_pathname); if (!$image_src) { $this->processed = false; $this->error = _("No PNG read support"); } else { $this->log .= '- ' . _("source image is PNG") . '<br />'; } } break; case 'image/gif': if (!function_exists('imagecreatefromgif')) { $this->processed = false; $this->error = _("No create from GIF support"); } else { $image_src = imagecreatefromgif($this->file_src_pathname); if (!$image_src) { $this->processed = false; $this->error = _("No GIF read support"); } else { $this->log .= '- ' . _("source image is GIF") . '<br />'; } } break; default: $this->processed = false; $this->error = _("Can't read image source. not an image?"); } } else { $this->processed = false; $this->error = _("GD doesn't seem to be present"); } if ($this->processed && $image_src) { $this->image_src_x = imagesx($image_src); $this->image_src_y = imagesy($image_src); $this->image_dst_x = $this->image_src_x; $this->image_dst_y = $this->image_src_y; $gd_version = $this->gd_version(); if ($this->image_resize) { $this->log .= '- ' . _("resizing...") . '<br />'; if ($this->image_ratio_x) { $this->log .= ' ' . _("calculate x size") . '<br />'; $this->image_dst_x = round($this->image_src_x * $this->image_y / $this->image_src_y); $this->image_dst_y = $this->image_y; } else { if ($this->image_ratio_y) { $this->log .= ' ' . _("calculate y size") . '<br />'; $this->image_dst_x = $this->image_x; $this->image_dst_y = round($this->image_src_y * $this->image_x / $this->image_src_x); } else { if ($this->image_ratio || $this->image_ratio_no_zoom_in || $this->image_ratio_no_zoom_out) { $this->log .= ' ' . _("check x/y sizes") . '<br />'; if (!$this->image_ratio_no_zoom_in && !$this->image_ratio_no_zoom_out || $this->image_ratio_no_zoom_in && ($this->image_src_x > $this->image_x || $this->image_src_y > $this->image_y) || $this->image_ratio_no_zoom_out && $this->image_src_x < $this->image_x && $this->image_src_y < $this->image_y) { $this->image_dst_x = $this->image_x; $this->image_dst_y = $this->image_y; if ($this->image_src_x / $this->image_x > $this->image_src_y / $this->image_y) { $this->image_dst_x = $this->image_x; $this->image_dst_y = intval($this->image_src_y * ($this->image_x / $this->image_src_x)); } else { $this->image_dst_y = $this->image_y; $this->image_dst_x = intval($this->image_src_x * ($this->image_y / $this->image_src_y)); } } else { $this->log .= ' ' . _("doesn't calculate x/y sizes") . '<br />'; $this->image_dst_x = $this->image_src_x; $this->image_dst_y = $this->image_src_y; } } else { $this->log .= ' ' . _("use plain sizes") . '<br />'; $this->image_dst_x = $this->image_x; $this->image_dst_y = $this->image_y; } } } if ($this->preserve_transparency && $this->file_src_mime != 'image/gif' && $this->file_src_mime != 'image/png') { $this->preserve_transparency = false; } if ($gd_version >= 2 && !$this->preserve_transparency) { $image_dst = imagecreatetruecolor($this->image_dst_x, $this->image_dst_y); } else { $image_dst = imagecreate($this->image_dst_x, $this->image_dst_y); } if ($this->preserve_transparency) { $this->log .= '- ' . _("preserve transparency") . '<br />'; $transparent_color = imagecolortransparent($image_src); imagepalettecopy($image_dst, $image_src); imagefill($image_dst, 0, 0, $transparent_color); imagecolortransparent($image_dst, $transparent_color); } if ($gd_version >= 2 && !$this->preserve_transparency) { $res = imagecopyresampled($image_dst, $image_src, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, $this->image_src_x, $this->image_src_y); } else { $res = imagecopyresized($image_dst, $image_src, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, $this->image_src_x, $this->image_src_y); } $this->log .= ' ' . _("resized image object created") . '<br />'; $this->log .= ' image_src_x y : ' . $this->image_src_x . ' x ' . $this->image_src_y . '<br />'; $this->log .= ' image_dst_x y : ' . $this->image_dst_x . ' x ' . $this->image_dst_y . '<br />'; } else { // we only convert, so we link the dst image to the src image $image_dst =& $image_src; } // we have to set image_convert if it is not already if (empty($this->image_convert)) { $this->log .= ' ' . _("setting destination file type to") . ' ' . $this->file_src_name_ext . '<br />'; $this->image_convert = strtolower($this->file_src_name_ext); } // crop image if ($gd_version >= 2 && !empty($this->image_crop)) { if (is_array($this->image_crop)) { $vars = $this->image_crop; $this->log .= '- ' . _("crop image") . ' : ' . implode(' ', $this->image_crop) . '<br />'; } else { $this->log .= '- ' . _("crop image") . ' : ' . $this->image_crop . '<br />'; $vars = explode(' ', $this->image_crop); } if (sizeof($vars) == 4) { $ct = $vars[0]; $cr = $vars[1]; $cb = $vars[2]; $cl = $vars[3]; } else { if (sizeof($vars) == 2) { $ct = $vars[0]; $cr = $vars[1]; $cb = $vars[0]; $cl = $vars[1]; } else { $ct = $vars[0]; $cr = $vars[0]; $cb = $vars[0]; $cl = $vars[0]; } } if (strpos($ct, '%') > 0) { $ct = $this->image_dst_y * (str_replace('%', '', $ct) / 100); } if (strpos($cr, '%') > 0) { $cr = $this->image_dst_x * (str_replace('%', '', $cr) / 100); } if (strpos($cb, '%') > 0) { $cb = $this->image_dst_y * (str_replace('%', '', $cb) / 100); } if (strpos($cl, '%') > 0) { $cl = $this->image_dst_x * (str_replace('%', '', $cl) / 100); } if (strpos($ct, 'px') > 0) { $ct = str_replace('px', '', $ct); } if (strpos($cr, 'px') > 0) { $cr = str_replace('px', '', $cr); } if (strpos($cb, 'px') > 0) { $cb = str_replace('px', '', $cb); } if (strpos($cl, 'px') > 0) { $cl = str_replace('px', '', $cl); } $ct = (int) $ct; $cr = (int) $cr; $cb = (int) $cb; $cl = (int) $cl; $this->image_dst_x = $this->image_dst_x - $cl - $cr; $this->image_dst_y = $this->image_dst_y - $ct - $cb; if ($this->image_dst_x < 1) { $this->image_dst_x = 1; } if ($this->image_dst_y < 1) { $this->image_dst_y = 1; } $tmp = imagecreatetruecolor($this->image_dst_x, $this->image_dst_y); imagecopy($tmp, $image_dst, 0, 0, $cl, $ct, $this->image_dst_x, $this->image_dst_y); // we transfert tmp into image_dst imagedestroy($image_dst); $image_dst = imagecreatetruecolor($this->image_dst_x, $this->image_dst_y); imagecopy($image_dst, $tmp, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y); imagedestroy($tmp); } // flip image if ($gd_version >= 2 && !empty($this->image_flip)) { $this->image_flip = strtolower($this->image_flip); $this->log .= '- ' . _("flip image") . ' : ' . $this->image_flip . '<br />'; $tmp = imagecreatetruecolor($this->image_dst_x, $this->image_dst_y); for ($x = 0; $x < $this->image_dst_x; $x++) { for ($y = 0; $y < $this->image_dst_y; $y++) { if (strpos($this->image_flip, 'v') !== false) { imagecopy($tmp, $image_dst, $this->image_dst_x - $x - 1, $y, $x, $y, 1, 1); } else { imagecopy($tmp, $image_dst, $x, $this->image_dst_y - $y - 1, $x, $y, 1, 1); } } } // we transfert tmp into image_dst imagedestroy($image_dst); $image_dst = imagecreatetruecolor($this->image_dst_x, $this->image_dst_y); imagecopy($image_dst, $tmp, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y); imagedestroy($tmp); } // rotate image if ($gd_version >= 2 && is_numeric($this->image_rotate)) { if (!in_array($this->image_rotate, array(0, 90, 180, 270))) { $this->image_rotate = 0; } if ($this->image_rotate != 0) { if ($this->image_rotate == 90 || $this->image_rotate == 270) { $tmp = imagecreatetruecolor($this->image_dst_y, $this->image_dst_x); } else { $tmp = imagecreatetruecolor($this->image_dst_x, $this->image_dst_y); } $this->log .= '- ' . _("rotate image") . ' : ' . $this->image_rotate . '<br />'; for ($x = 0; $x < $this->image_dst_x; $x++) { for ($y = 0; $y < $this->image_dst_y; $y++) { if ($this->image_rotate == 90) { imagecopy($tmp, $image_dst, $y, $x, $x, $this->image_dst_y - $y - 1, 1, 1); } else { if ($this->image_rotate == 180) { imagecopy($tmp, $image_dst, $x, $y, $this->image_dst_x - $x - 1, $this->image_dst_y - $y - 1, 1, 1); } else { if ($this->image_rotate == 270) { imagecopy($tmp, $image_dst, $y, $x, $this->image_dst_x - $x - 1, $y, 1, 1); } else { imagecopy($tmp, $image_dst, $x, $y, $x, $y, 1, 1); } } } } } if ($this->image_rotate == 90 || $this->image_rotate == 270) { $t = $this->image_dst_y; $this->image_dst_y = $this->image_dst_x; $this->image_dst_x = $t; } // we transfert tmp into image_dst imagedestroy($image_dst); $image_dst = imagecreatetruecolor($this->image_dst_x, $this->image_dst_y); imagecopy($image_dst, $tmp, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y); imagedestroy($tmp); } } // add color overlay if ($gd_version >= 2 && (is_numeric($this->image_overlay_percent) && !empty($this->image_overlay_color))) { $this->log .= '- ' . _("apply color overlay") . '<br />'; sscanf($this->image_overlay_color, "#%2x%2x%2x", $red, $green, $blue); $filter = imagecreatetruecolor($this->image_dst_x, $this->image_dst_y); $color = imagecolorallocate($filter, $red, $green, $blue); imagefilledrectangle($filter, 0, 0, $this->image_dst_x, $this->image_dst_y, $color); imagecopymerge($image_dst, $filter, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, $this->image_overlay_percent); imagedestroy($filter); } // add brightness, contrast and tint, turns to greyscale and inverts colors if ($gd_version >= 2 && ($this->image_negative || $this->image_greyscale || is_numeric($this->image_threshold) || is_numeric($this->image_brightness) || is_numeric($this->image_contrast) || !empty($this->image_tint_color))) { $this->log .= '- ' . _("apply tint, light, contrast correction, negative, greyscale and threshold") . '<br />'; if (!empty($this->image_tint_color)) { sscanf($this->image_tint_color, "#%2x%2x%2x", $red, $green, $blue); } $background = imagecolorallocatealpha($image_dst, 255, 255, 255, 0); imagefill($image_dst, 0, 0, $background); imagealphablending($image_dst, TRUE); for ($y = 0; $y < $this->image_dst_y; $y++) { for ($x = 0; $x < $this->image_dst_x; $x++) { if ($this->image_greyscale) { $rgb = imagecolorat($image_dst, $x, $y); $pixel = imagecolorsforindex($image_dst, $rgb); $r = $g = $b = round(0.2125 * $pixel['red'] + 0.7154 * $pixel['green'] + 0.0721 * $pixel['blue']); $a = $pixel['alpha']; $pixelcolor = imagecolorallocatealpha($image_dst, $r, $g, $b, $a); imagesetpixel($image_dst, $x, $y, $pixelcolor); } if (is_numeric($this->image_threshold)) { $rgb = imagecolorat($image_dst, $x, $y); $pixel = imagecolorsforindex($image_dst, $rgb); $c = round($pixel['red'] + $pixel['green'] + $pixel['blue']) / 3 - 127; $r = $g = $b = $c > $this->image_threshold ? 255 : 0; $a = $pixel['alpha']; $pixelcolor = imagecolorallocatealpha($image_dst, $r, $g, $b, $a); imagesetpixel($image_dst, $x, $y, $pixelcolor); } if (is_numeric($this->image_brightness)) { $rgb = imagecolorat($image_dst, $x, $y); $pixel = imagecolorsforindex($image_dst, $rgb); $r = max(min(round($pixel['red'] + $this->image_brightness * 2), 255), 0); $g = max(min(round($pixel['green'] + $this->image_brightness * 2), 255), 0); $b = max(min(round($pixel['blue'] + $this->image_brightness * 2), 255), 0); $a = $pixel['alpha']; $pixelcolor = imagecolorallocatealpha($image_dst, $r, $g, $b, $a); imagesetpixel($image_dst, $x, $y, $pixelcolor); } if (is_numeric($this->image_contrast)) { $rgb = imagecolorat($image_dst, $x, $y); $pixel = imagecolorsforindex($image_dst, $rgb); $r = max(min(round(($this->image_contrast + 128) * $pixel['red'] / 128), 255), 0); $g = max(min(round(($this->image_contrast + 128) * $pixel['green'] / 128), 255), 0); $b = max(min(round(($this->image_contrast + 128) * $pixel['blue'] / 128), 255), 0); $a = $pixel['alpha']; $pixelcolor = imagecolorallocatealpha($image_dst, $r, $g, $b, $a); imagesetpixel($image_dst, $x, $y, $pixelcolor); } if (!empty($this->image_tint_color)) { $rgb = imagecolorat($image_dst, $x, $y); $pixel = imagecolorsforindex($image_dst, $rgb); $r = min(round($red * $pixel['red'] / 169), 255); $g = min(round($green * $pixel['green'] / 169), 255); $b = min(round($blue * $pixel['blue'] / 169), 255); $a = $pixel['alpha']; $pixelcolor = imagecolorallocatealpha($image_dst, $r, $g, $b, $a); imagesetpixel($image_dst, $x, $y, $pixelcolor); } if (!empty($this->image_negative)) { $rgb = imagecolorat($image_dst, $x, $y); $pixel = imagecolorsforindex($image_dst, $rgb); $r = round(255 - $pixel['red']); $g = round(255 - $pixel['green']); $b = round(255 - $pixel['blue']); $a = $pixel['alpha']; $pixelcolor = imagecolorallocatealpha($image_dst, $r, $g, $b, $a); imagesetpixel($image_dst, $x, $y, $pixelcolor); } } } } // adds a border if ($gd_version >= 2 && !empty($this->image_border)) { if (is_array($this->image_border)) { $vars = $this->image_border; $this->log .= '- ' . _("add border") . ' : ' . implode(' ', $this->image_border) . '<br />'; } else { $this->log .= '- ' . _("add border") . ' : ' . $this->image_border . '<br />'; $vars = explode(' ', $this->image_border); } if (sizeof($vars) == 4) { $ct = $vars[0]; $cr = $vars[1]; $cb = $vars[2]; $cl = $vars[3]; } else { if (sizeof($vars) == 2) { $ct = $vars[0]; $cr = $vars[1]; $cb = $vars[0]; $cl = $vars[1]; } else { $ct = $vars[0]; $cr = $vars[0]; $cb = $vars[0]; $cl = $vars[0]; } } if (strpos($ct, '%') > 0) { $ct = $this->image_dst_y * (str_replace('%', '', $ct) / 100); } if (strpos($cr, '%') > 0) { $cr = $this->image_dst_x * (str_replace('%', '', $cr) / 100); } if (strpos($cb, '%') > 0) { $cb = $this->image_dst_y * (str_replace('%', '', $cb) / 100); } if (strpos($cl, '%') > 0) { $cl = $this->image_dst_x * (str_replace('%', '', $cl) / 100); } if (strpos($ct, 'px') > 0) { $ct = str_replace('px', '', $ct); } if (strpos($cr, 'px') > 0) { $cr = str_replace('px', '', $cr); } if (strpos($cb, 'px') > 0) { $cb = str_replace('px', '', $cb); } if (strpos($cl, 'px') > 0) { $cl = str_replace('px', '', $cl); } $ct = (int) $ct; $cr = (int) $cr; $cb = (int) $cb; $cl = (int) $cl; $this->image_dst_x = $this->image_dst_x + $cl + $cr; $this->image_dst_y = $this->image_dst_y + $ct + $cb; if (!empty($this->image_border_color)) { sscanf($this->image_border_color, "#%2x%2x%2x", $red, $green, $blue); } $tmp = imagecreatetruecolor($this->image_dst_x, $this->image_dst_y); $background = imagecolorallocatealpha($tmp, $red, $green, $blue, 0); imagefill($tmp, 0, 0, $background); imagecopy($tmp, $image_dst, $cl, $ct, 0, 0, $this->image_dst_x - $cr - $cl, $this->image_dst_y - $cb - $ct); // we transfert tmp into image_dst imagedestroy($image_dst); $image_dst = imagecreatetruecolor($this->image_dst_x, $this->image_dst_y); imagecopy($image_dst, $tmp, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y); imagedestroy($tmp); } // add frame border if (is_numeric($this->image_frame)) { if (is_array($this->image_frame_colors)) { $vars = $this->image_frame_colors; $this->log .= '- ' . _("add frame") . ' : ' . implode(' ', $this->image_frame_colors) . '<br />'; } else { $this->log .= '- ' . _("add frame") . ' : ' . $this->image_frame_colors . '<br />'; $vars = explode(' ', $this->image_frame_colors); } $nb = sizeof($vars); $this->image_dst_x = $this->image_dst_x + $nb * 2; $this->image_dst_y = $this->image_dst_y + $nb * 2; $tmp = imagecreatetruecolor($this->image_dst_x, $this->image_dst_y); imagecopy($tmp, $image_dst, $nb, $nb, 0, 0, $this->image_dst_x - $nb * 2, $this->image_dst_y - $nb * 2); for ($i = 0; $i < $nb; $i++) { sscanf($vars[$i], "#%2x%2x%2x", $red, $green, $blue); $c = imagecolorallocate($tmp, $red, $green, $blue); if ($this->image_frame == 1) { imageline($tmp, $i, $i, $this->image_dst_x - $i - 1, $i, $c); imageline($tmp, $this->image_dst_x - $i - 1, $this->image_dst_y - $i - 1, $this->image_dst_x - $i - 1, $i, $c); imageline($tmp, $this->image_dst_x - $i - 1, $this->image_dst_y - $i - 1, $i, $this->image_dst_y - $i - 1, $c); imageline($tmp, $i, $i, $i, $this->image_dst_y - $i - 1, $c); } else { imageline($tmp, $i, $i, $this->image_dst_x - $i - 1, $i, $c); imageline($tmp, $this->image_dst_x - $nb + $i, $this->image_dst_y - $nb + $i, $this->image_dst_x - $nb + $i, $nb - $i, $c); imageline($tmp, $this->image_dst_x - $nb + $i, $this->image_dst_y - $nb + $i, $nb - $i, $this->image_dst_y - $nb + $i, $c); imageline($tmp, $i, $i, $i, $this->image_dst_y - $i - 1, $c); } } // we transfert tmp into image_dst imagedestroy($image_dst); $image_dst = imagecreatetruecolor($this->image_dst_x, $this->image_dst_y); imagecopy($image_dst, $tmp, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y); imagedestroy($tmp); } // add bevel border if ($this->image_bevel > 0) { if (empty($this->image_bevel_color1)) { $this->image_bevel_color1 = '#FFFFFF'; } if (empty($this->image_bevel_color2)) { $this->image_bevel_color2 = '#000000'; } sscanf($this->image_bevel_color1, "#%2x%2x%2x", $red1, $green1, $blue1); sscanf($this->image_bevel_color2, "#%2x%2x%2x", $red2, $green2, $blue2); imagealphablending($image_dst, true); for ($i = 0; $i < $this->image_bevel; $i++) { $alpha = round($i / $this->image_bevel * 127); $c1 = imagecolorallocatealpha($image_dst, $red1, $green1, $blue1, $alpha); $c2 = imagecolorallocatealpha($image_dst, $red2, $green2, $blue2, $alpha); imageline($image_dst, $i, $i, $this->image_dst_x - $i - 1, $i, $c1); imageline($image_dst, $this->image_dst_x - $i - 1, $this->image_dst_y - $i, $this->image_dst_x - $i - 1, $i, $c2); imageline($image_dst, $this->image_dst_x - $i - 1, $this->image_dst_y - $i - 1, $i, $this->image_dst_y - $i - 1, $c2); imageline($image_dst, $i, $i, $i, $this->image_dst_y - $i - 1, $c1); } } // add watermark image if ($this->image_watermark != '' && file_exists($site->absolute_path . $this->image_watermark)) { $this->log .= '- ' . _("add watermark") . '<br />'; $this->image_watermark_position = strtolower($this->image_watermark_position); $watermark_info = getimagesize($this->image_watermark); $watermark_type = array_key_exists(2, $watermark_info) ? $watermark_info[2] : NULL; // 1 = GIF, 2 = JPG, 3 = PNG $watermark_checked = false; if ($watermark_type == 1) { if (!function_exists('imagecreatefromgif')) { $this->error = _("No create from GIF support, can't read watermark"); } else { $filter = imagecreatefromgif($this->image_watermark); if (!$filter) { $this->error = _("No GIF read support, can't create watermark"); } else { $this->log .= ' ' . _("watermark source image is GIF") . '<br />'; $watermark_checked = true; } } } else { if ($watermark_type == 2) { if (!function_exists('imagecreatefromjpeg')) { $this->error = _("No create from JPG support, can't read watermark"); } else { $filter = imagecreatefromjpeg($this->image_watermark); if (!$filter) { $this->error = _("No JPG read support, can't create watermark"); } else { $this->log .= ' ' . _("watermark source image is JPG") . '<br />'; $watermark_checked = true; } } } else { if ($watermark_type == 3) { if (!function_exists('imagecreatefrompng')) { $this->error = _("No create from PNG support, can't read watermark"); } else { $filter = imagecreatefrompng($this->image_watermark); if (!$filter) { $this->error = _("No PNG read support, can't create watermark"); } else { $this->log .= ' ' . _("watermark source image is PNG") . '<br />'; $watermark_checked = true; } } } } } if ($watermark_checked) { $watermark_width = imagesx($filter); $watermark_height = imagesy($filter); $watermark_x = 0; $watermark_y = 0; if (is_numeric($this->image_watermark_x)) { if ($this->image_watermark_x < 0) { $watermark_x = $this->image_dst_x - $watermark_width + $this->image_watermark_x; } else { $watermark_x = $this->image_watermark_x; } } else { if (strpos($this->image_watermark_position, 'r') !== false) { $watermark_x = $this->image_dst_x - $watermark_width; } else { if (strpos($this->image_watermark_position, 'l') !== false) { $watermark_x = 0; } else { $watermark_x = ($this->image_dst_x - $watermark_width) / 2; } } } if (is_numeric($this->image_watermark_y)) { if ($this->image_watermark_y < 0) { $watermark_y = $this->image_dst_y - $watermark_height + $this->image_watermark_y; } else { $watermark_y = $this->image_watermark_y; } } else { if (strpos($this->image_watermark_position, 'b') !== false) { $watermark_y = $this->image_dst_y - $watermark_height; } else { if (strpos($this->image_watermark_position, 't') !== false) { $watermark_y = 0; } else { $watermark_y = ($this->image_dst_y - $watermark_height) / 2; } } } imagecopyresampled($image_dst, $filter, $watermark_x, $watermark_y, 0, 0, $watermark_width, $watermark_height, $watermark_width, $watermark_height); } else { $this->error = _("Watermark image is of unknown type"); } } // add text if (!empty($this->image_text)) { $this->log .= '- ' . _("add text") . '<br />'; if (!is_numeric($this->image_text_padding)) { $this->image_text_padding = 0; } if (!is_numeric($this->image_text_padding_x)) { $this->image_text_padding_x = $this->image_text_padding; } if (!is_numeric($this->image_text_padding_y)) { $this->image_text_padding_y = $this->image_text_padding; } $this->image_text_position = strtolower($this->image_text_position); $this->image_text_direction = strtolower($this->image_text_direction); if ($this->image_text_direction == 'v') { $text_height = ImageFontWidth($this->image_text_font) * strlen($this->image_text) + 2 * $this->image_text_padding_y; $text_width = ImageFontHeight($this->image_text_font) + 2 * $this->image_text_padding_x; } else { $text_width = ImageFontWidth($this->image_text_font) * strlen($this->image_text) + 2 * $this->image_text_padding_x; $text_height = ImageFontHeight($this->image_text_font) + 2 * $this->image_text_padding_y; } $text_x = 0; $text_y = 0; if (is_numeric($this->image_text_x)) { if ($this->image_text_x < 0) { $text_x = $this->image_dst_x - $text_width + $this->image_text_x; } else { $text_x = $this->image_text_x; } } else { if (strpos($this->image_text_position, 'r') !== false) { $text_x = $this->image_dst_x - $text_width; } else { if (strpos($this->image_text_position, 'l') !== false) { $text_x = 0; } else { $text_x = ($this->image_dst_x - $text_width) / 2; } } } if (is_numeric($this->image_text_y)) { if ($this->image_text_y < 0) { $text_y = $this->image_dst_y - $text_height + $this->image_text_y; } else { $text_y = $this->image_text_y; } } else { if (strpos($this->image_text_position, 'b') !== false) { $text_y = $this->image_dst_y - $text_height; } else { if (strpos($this->image_text_position, 't') !== false) { $text_y = 0; } else { $text_y = ($this->image_dst_y - $text_height) / 2; } } } // add a background, maybe transparent if (!empty($this->image_text_background)) { sscanf($this->image_text_background, "#%2x%2x%2x", $red, $green, $blue); if ($gd_version >= 2 && is_numeric($this->image_text_background_percent) && $this->image_text_background_percent >= 0 && $this->image_text_background_percent <= 100) { $filter = imagecreatetruecolor($text_width, $text_height); $background_color = imagecolorallocate($filter, $red, $green, $blue); imagefilledrectangle($filter, 0, 0, $text_width, $text_height, $background_color); imagecopymerge($image_dst, $filter, $text_x, $text_y, 0, 0, $text_width, $text_height, $this->image_text_background_percent); imagedestroy($filter); } else { $background_color = imageColorAllocate($image_dst, $red, $green, $blue); imagefilledrectangle($image_dst, $text_x, $text_y, $text_x + $text_width, $text_y + $text_height, $background_color); } } $text_x += $this->image_text_padding_x; $text_y += $this->image_text_padding_y; sscanf($this->image_text_color, "#%2x%2x%2x", $red, $green, $blue); // add the text, maybe transparent if ($gd_version >= 2 && is_numeric($this->image_text_percent) && $this->image_text_percent >= 0 && $this->image_text_percent <= 100) { $t_width = $text_width - 2 * $this->image_text_padding_x; $t_height = $text_height - 2 * $this->image_text_padding_y; if ($t_width < 0) { $t_width = 0; } if ($t_height < 0) { $t_height = 0; } $filter = imagecreatetruecolor($t_width, $t_height); $color = imagecolorallocate($filter, 0, 0, 0); $text_color = imageColorAllocate($filter, $red, $green, $blue); imagecolortransparent($filter, $color); if ($this->image_text_direction == 'v') { imagestringup($filter, $this->image_text_font, 0, $text_height - 2 * $this->image_text_padding_y, $this->image_text, $text_color); } else { imagestring($filter, $this->image_text_font, 0, 0, $this->image_text, $text_color); } imagecopymerge($image_dst, $filter, $text_x, $text_y, 0, 0, $t_width, $t_height, $this->image_text_percent); imagedestroy($filter); } else { $text_color = imageColorAllocate($image_dst, $red, $green, $blue); if ($this->image_text_direction == 'v') { imagestringup($image_dst, $this->image_text_font, $text_x, $text_y + $text_height - 2 * $this->image_text_padding_y, $this->image_text, $text_color); } else { imagestring($image_dst, $this->image_text_font, $text_x, $text_y, $this->image_text, $text_color); } } } if (is_numeric($this->jpeg_size) && $this->jpeg_size > 0 && ($this->image_convert == 'jpeg' || $this->image_convert == 'jpg')) { // based on: JPEGReducer class version 1, 25 November 2004, Author: Huda M ElMatsani, justhuda at netscape dot net $this->log .= '- ' . _("JPEG desired file size") . ' : ' . $this->jpeg_size . '<br />'; //calculate size of each image. 75%, 50%, and 25% quality ob_start(); imagejpeg($image_dst, '', 75); $buffer = ob_get_contents(); ob_end_clean(); $size75 = strlen($buffer); ob_start(); imagejpeg($image_dst, '', 50); $buffer = ob_get_contents(); ob_end_clean(); $size50 = strlen($buffer); ob_start(); imagejpeg($image_dst, '', 25); $buffer = ob_get_contents(); ob_end_clean(); $size25 = strlen($buffer); //calculate gradient of size reduction by quality $mgrad1 = 25 / ($size50 - $size25); $mgrad2 = 25 / ($size75 - $size50); $mgrad3 = 50 / ($size75 - $size25); $mgrad = ($mgrad1 + $mgrad2 + $mgrad3) / 3; //result of approx. quality factor for expected size $q_factor = round($mgrad * ($this->jpeg_size - $size50) + 50); if ($q_factor < 1) { $this->jpeg_quality = 1; } elseif ($q_factor > 100) { $this->jpeg_quality = 100; } else { $this->jpeg_quality = $q_factor; } $this->log .= ' ' . _("JPEG quality factor set to") . ' ' . $this->jpeg_quality . '<br />'; } // outputs image $this->log .= '- ' . _("converting..") . '<br />'; switch ($this->image_convert) { case 'jpeg': case 'jpg': $result = imagejpeg($image_dst, $this->file_dst_pathname, $this->jpeg_quality); if (!$result) { $this->processed = false; $this->error = _("No JPEG create support"); } else { $this->log .= ' ' . _("JPEG image created") . '<br />'; } break; case 'png': $result = imagepng($image_dst, $this->file_dst_pathname); if (!$result) { $this->processed = false; $this->error = _("No PNG create support"); } else { $this->log .= ' ' . _("PNG image created") . '<br />'; } break; case 'gif': $result = imagegif($image_dst, $this->file_dst_pathname); if (!$result) { $this->processed = false; $this->error = _("No GIF create support"); } else { $this->log .= ' ' . _("GIF image created") . '<br />'; } break; default: $this->processed = false; $this->error = _("No convertion type defined"); } if (is_resource($image_src)) { imagedestroy($image_src); } if (is_resource($image_dst)) { imagedestroy($image_dst); } $this->log .= ' ' . _("image objects destroyed") . '<br />'; } } else { $this->log .= '- ' . _("no image processing wanted") . '<br />'; if (!$this->no_upload_check) { $result = is_uploaded_file($this->file_src_pathname); } else { $result = TRUE; } if ($result) { $result = file_exists($this->file_src_pathname); if ($result) { $result = copy($this->file_src_pathname, $this->file_dst_pathname); if (!$result) { $this->processed = false; $this->error = _("Error copying file on the server. Copy failed"); } } else { $this->processed = false; $this->error = _("Error copying file on the server. Missing source file"); } } else { $this->processed = false; $this->error = _("Error copying file on the server. Incorrect source file"); } //$result = move_uploaded_file($this->file_src_pathname, $this->file_dst_pathname); //if (!$result) { // $this->processed = false; // $this->error = _("Error copying file on the server"); //} } } if ($this->processed) { $this->log .= '- <b>' . _("process OK") . '</b><br />'; } // we reinit all the var // no we don't $this->init(); }
} } else { echo "error"; } break; case "u_update": $header['Referer'] = "http://" . $req->GetServer("HTTP_HOST"); $header['ms_sign'] = $setting['web']['sign']; $update_info = GetRemoteContent($setting['gen']['update'] . "?m=u_update&v=" . $ms_version['ver'] . "&cs=" . $setting['gen']['charset'], $header); if (!empty($update_info)) { $update_info = preg_replace("/(^|[\r\n]+)([\\w]{0,6})[\r\n]+/", "", $update_info); $update_info = base64_decode($update_info); $update_info = unserialize($update_info); $list = array(); for ($i = 0, $m = count($update_info['file']); $i < $m; $i++) { if (isWriteable(ROOT_PATH . "/" . $update_info['file'][$i])) { if (empty($update_info['content'][$i])) { MultiDel(ROOT_PATH . "/" . $update_info['file'][$i]); } elseif ($update_info['content'][$i] == ".") { MakeDir(ROOT_PATH . "/" . $update_info['file'][$i]); } else { WriteFile(ROOT_PATH . "/" . $update_info['file'][$i], $update_info['content'][$i], "wb"); } } else { if (!empty($update_info['content'][$i])) { $list[] = $i; } } } $link = ""; $m = count($list);
<li>本软件及所附带的文件是作为不提供任何明确的或隐含的赔偿或担保的形式提供的;</li> <li>用户出于自愿而使用本软件,您必须了解使用本软件的风险,在尚未购买产品技术服务之前,我们不承诺提供任何形式的技术支持、使用担保,也不承担任何因使用本软件而产生问题的相关责任;</li> <li>RUI(zhangenrui.cn)不对使用本软件构建的网站中的文章或信息承担责任。</li> </ul> <p class="nt" style="padding-bottom:20px;">电子文本形式的授权协议如同双方书面签署的协议一样,具有完全的和等同的法律效力。您一旦开始安装 RUIBlog 即被视为完全理解并接受本协议的各项条款,在享有上述条款授予的权力的同时,受到相关的约束和限制。协议许可范围以外的行为,将直接违反本授权协议并构成侵权,我们有权随时终止授权,责令停止损害,并保留追究相关责任的权力。</p> </div> <div class="ch_next"> <p style="margin-top:15px; float:left;"><input type="checkbox" id="checkAgreement" value="1" /> 我同意以上条款。</p> <input type="button" id="agreementNext" value="继续" class="submit" style="float:right;margin-top:15px;" /> </div> <?php } elseif ($step == '1') { $dirarray = array('backupdata', 'install', 'Public/config', 'Public', 'Uploads'); $writeable = array(); foreach ($dirarray as $key => $dir) { if (isWriteable($dir)) { $writeable[$key] = $dir . getResult(1, 0); } else { $writeable[$key] = $dir . getResult(0, 0); $quit = true; } } ?> <div id="content"> <h1>系统环境检测</h1> <dl class="l1 nt"> <dt>操作系统:</dt> <dd><?php echo PHP_OS; getResult(1, 1); ?>
</tr> </table> <h2 class="title">目录、文件权限检查</h2> <table class="tb" style="margin:20px 0 20px 55px;width:90%;"> <tr> <th>目录文件</th> <th class="padleft">所需状态</th> <th class="padleft">当前状态</th> </tr> <?php $theList = array("include/config.php", "include/", "images/", "template/", "plugin/", "files/", "cache/"); foreach ($theList as $cur) { echo "<tr>\n"; echo "<td>{$cur}</td><td class=\"pdleft1\">可写</td>"; if (isWriteable(ROOT_PATH . "/" . $cur)) { echo '<td class="w pdleft1">可写</td>'; } else { echo '<td class="nw pdleft1">不可写<span id="error"></span></td>'; } echo "\n</tr>\n"; } ?> </table> <h2 class="title">函数依赖性检查</h2> <table class="tb" style="margin:20px 0 20px 55px;width:90%;"> <tr> <th>函数名称</th> <th class="padleft">建议</th> <th class="padleft">检查结果</th>
// check mySQL $good = getModuleSetting('mysql', 'MySQL Support') == 'enabled' ? 1 : 0; $canContinue = $canContinue && $good; CMessage('MySQL support exists - Check 2: ', $good); // GD2 Support $good = getModuleSetting('gd', 'GD Support') == 'enabled' ? 1 : 0; $canContinue = $canContinue && $good; CMessage('GD2 support exists: ', $good); // files is writable? clearstatcache(); $canContinue = isWriteable($canContinue, '' . ROOT_PATH . 'include/config.php', 0777, '/include/config.php/'); $canContinue = isWriteable($canContinue, '' . ROOT_PATH . 'torrents/', 0777, '/torrents/'); $canContinue = isWriteable($canContinue, '' . ROOT_PATH . 'cache/', 0777, '/cache/'); $canContinue = isWriteable($canContinue, '' . ROOT_PATH . 'chat.php', 0777, 'chat.php/'); $canContinue = isWriteable($canContinue, '' . ROOT_PATH . 'addons/guest.dat', 0777, 'addons/guest.dat'); $canContinue = isWriteable($canContinue, '' . ROOT_PATH . 'badwords.txt', 0777, 'badwords.txt'); if (is_writable('' . ROOT_PATH . 'INCLUDE/CONFIG.PHP')) { $good = true; $fname = '' . ROOT_PATH . 'INCLUDE/TEST'; if (is_writable($fname)) { $fp = fopen($fname, 'w'); fwrite($fp, ""); fclose($fp); } $fname = '' . ROOT_PATH . 'include/test_rename.txt'; $fp = fopen($fname, "a"); $good = fwrite($fp, "TEST STRING"); fclose($fp); $canContinue = $canContinue && $good; CMessage('File writing functions exists:', $good); $new_name = '' . ROOT_PATH . 'include/ren_test.txt';
function admin_language_showpage() { global $main_smarty, $the_template; include_once 'config.php'; include_once mnminclude . 'html1.php'; include_once mnminclude . 'link.php'; include_once mnminclude . 'tags.php'; include_once mnminclude . 'smartyvariables.php'; $main_smarty = do_sidebar($main_smarty); force_authentication(); $canIhaveAccess = 0; $canIhaveAccess = $canIhaveAccess + checklevel('god'); if ($canIhaveAccess == 1) { if ($_REQUEST['var_id'] != "") { $lines = file('./languages/lang_' . pligg_language . '.conf'); $filename = './languages/lang_' . pligg_language . '.conf'; if ($handle = fopen($filename, 'w')) { foreach ($lines as $line_num => $line) { if (substr($line, 0, 2) != "//") { if (strlen(trim($line)) > 2) { $x = strpos($line, "="); if (trim(substr($line, 0, $x)) == str_replace('emptytext_', '', $_REQUEST["var_id"])) { $y = trim(substr($line, $x + 1, 10000)); $y = str_replace('"', '', $y); $line = trim(substr($line, 0, $x)) . ' = "' . $_REQUEST["var_value"] . '"' . "\n"; $returnVal = $_REQUEST["var_value"]; } } } if (fwrite($handle, $line)) { } else { echo "<b>Could not write to '{$filename}' file</b>"; } } fclose($handle); //header('Location: admin_modifylanguage.php'); } else { echo "<b>Could not open '{$filename}' file for writing</b>"; } echo $returnVal; die; } $canContinue = 1; $canContinue = isWriteable($canContinue, './languages/lang_' . pligg_language . '.conf', 0777, './languages/lang_' . pligg_language . '.conf'); if (!$canContinue) { echo 'File is not writeable. Please CHMOD /languages/lang_' . pligg_language . '.conf to 777 and refresh this page.<br /><br /><br />'; die; } $lines = file('./languages/lang_' . pligg_language . '.conf'); $section = "x"; $lastsection = ""; $tabA = " "; if (isset($_GET["mode"])) { if ($_GET["mode"] == "edit") { $outputHtml[] = "<form>"; $outputHtml[] = "<table class='listing'>"; $outputHtml[] = "Editing <b>" . sanitize($_GET["edit"], 1) . "</b><br /><br />"; foreach ($lines as $line_num => $line) { if (substr($line, 0, 2) != "//") { if (strlen(trim($line)) > 2) { $x = strpos($line, "="); if (trim(substr($line, 0, $x)) == $_GET["edit"]) { $y = trim(substr($line, $x + 1, 10000)); $y = str_replace('"', "", $y); $outputHtml[] = "Current Value: " . $y . "<br />"; $outputHtml[] = '<input type = "hidden" name = "edit" value = "' . $_GET["edit"] . '">'; $outputHtml[] = '<input type = "hidden" name = "mode" value = "save">'; $outputHtml[] = '<input name = "newvalue" value = "' . $y . '" size=75><br />'; $outputHtml[] = '<input type = "submit" name = "save" value = "save" class = "log2">'; } } } } } if ($_GET["mode"] == "save") { //print_r($_GET); //print "New: ".js_urldecode($_GET["newvalue"]); $_GET["newvalue"] = js_urldecode($_GET["newvalue"]); $outputHtml[] = "saving <b>" . $_GET["edit"] . "</b><br />"; $filename = './languages/lang_' . pligg_language . '.conf'; if ($handle = fopen($filename, 'w')) { foreach ($lines as $line_num => $line) { if (substr($line, 0, 2) != "//") { if (strlen(trim($line)) > 2) { $x = strpos($line, "="); if (trim(substr($line, 0, $x)) == $_GET["edit"]) { $y = trim(substr($line, $x + 1, 10000)); $y = str_replace('"', '', $y); $line = trim(substr($line, 0, $x)) . ' = "' . addslashes($_GET["newvalue"]) . '"' . "\n"; } } } if (fwrite($handle, $line)) { } else { $outputHtml[] = "<b>Could not write to '{$filename}' file</b>"; } } fclose($handle); exit; // header('Location: admin_modifylanguage.php'); } else { $outputHtml[] = "<b>Could not open '{$filename}' file for writing</b>"; } } } else { $outputHtml = array(); $outputHtml[] = '<table id="mytable" class="listing">'; foreach ($lines as $line_num => $line) { if (substr($line, 0, 2) == "//") { $x = strpos($line, "<LANG>"); if ($x === false) { } else { $y = strpos($line, "</LANG>"); $lang = substr($line, $x + 6, $y); } $x = strpos($line, "<TITLE>"); if ($x === false) { } else { $y = strpos($line, "</TITLE>"); $outputHtml[] = "<tr><td bgcolor = BFBFBF><b>Title:</b>" . substr($line, $x + 7, $y) . "</td></tr>"; } $x = strpos($line, "<SECTION>"); if ($x > 0) { $y = strpos($line, '</SECTION>'); $section = substr($line, $x + 9, $y - $x); if ($section != $lastsection) { $lastsection = $section; $outputHtml[] = '<tr id="row_ASDFGHJK"><td></td></tr>'; $outputHtml[] = '<tr id="row_ASDFGHJK"><td></td></tr>'; $outputHtml[] = '<tr id="row_ASDFGHJK"><td></td></tr>'; $outputHtml[] = '<tr id="row_ASDFGHJK"><th><b>Section</b>: ' . $section . '</th></tr>'; } } $x = strpos($line, "<VERSION>"); if ($x === false) { } else { $y = strpos($line, "</VERSION>"); $version = substr($line, $x + 9, $y); } $x = strpos($line, "<ADDED>"); if ($x === false) { } else { $y = strpos($line, "</ADDED>"); $added = substr($line, $x + 7, $y) * 1; } } else { if (strlen(trim($line)) > 2) { $x = strpos($line, "="); $outputHtml[] = '<tr id = "row_' . str_replace('"', '', trim(substr($line, $x + 1, 10000))) . '"><td><form onsubmit="return false"><fieldset>'; $grey = "grey1"; $outputHtml[] = "<b>" . $tabA . trim(substr($line, 0, $x)); $outputHtml[] = "</b><br />"; $outputHtml[] = "" . $tabA . $tabA; $ID = trim(substr($line, 0, $x)); $VALUE = htmlspecialchars(trim(substr(stripslashes($line), $x + 1, 10000), " \t\n\r\"\\'")); // $VALUE = htmlspecialchars(str_replace('"', '', trim(substr($line, $x + 1, 10000)))); if (function_exists("iconv") && detect_encoding($VALUE) != 'utf-8') { $VALUE = iconv('', 'UTF-8//IGNORE', $VALUE); } $outputHtml[] = "Value: <span class=\"emptytext\" id=\"editme{$ID}\" onclick=\"show_edit('{$ID}')\">{$VALUE}</span>"; $outputHtml[] = "<span id=\"showme{$ID}\" style=\"display:none;\">"; $outputHtml[] = "<input type=\"text\" name=\"var_value\" value=\"{$VALUE}\">"; $outputHtml[] = "<br><div style='margin:5px 0 0 75px;'><input type=\"submit\" value=\"Save\" onclick=\"save_changes('{$ID}',this.form)\">"; $outputHtml[] = "<input type=\"reset\" value=\"Cancel\" onclick=\"hide_edit('{$ID}')\"></span></div><br>"; $outputHtml[] = "</fieldset></form>"; $outputHtml[] = "</td></tr>"; } } } } $outputHtml[] = "</table>"; $main_smarty->assign('outputHtml', $outputHtml); // breadcrumbs $navwhere['text1'] = $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel'); $navwhere['link1'] = getmyurl('admin', ''); $navwhere['text2'] = "Modify Language"; $navwhere['link2'] = my_pligg_base . "/module.php?module=admin_language"; $main_smarty->assign('navbar_where', $navwhere); $main_smarty->assign('posttitle', " | " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel')); // breadcrumbs //Method for identifying modules rather than pagename define('modulename', 'admin_language'); $main_smarty->assign('modulename', modulename); define('pagename', 'admin_modifylanguage'); $main_smarty->assign('pagename', pagename); $main_smarty->assign('editinplace_init', $editinplace_init); $main_smarty->assign('tpl_center', admin_language_tpl_path . 'admin_language_main'); $main_smarty->display($template_dir . '/admin/admin.tpl'); } else { header("Location: " . getmyurl('login', $_SERVER['REQUEST_URI'])); } }
$update_info = unserialize($update_info); $strFind = array("{db_name}", "{pre}", "{charset}"); $strReplace = array($setting['db']['name'], $setting['db']['pre'], $setting['db']['charset']); for ($i = 0, $m = count($update_info['sql']); $i < $m; $i++) { $db->Query(str_replace($strFind, $strReplace, $update_info['sql'][$i])); } if ($m > 0) { $result['info'] = sprintf($setting['language']['admin_update_sql'], $m); } else { $result['info'] = ""; } $plugin_path = ROOT_PATH . "/plugin/" . $idx; $list = array(); for ($i = 0, $m = count($update_info['file']); $i < $m; $i++) { MakeDir(dirname($plugin_path . "/" . $update_info['file'][$i])); if (isWriteable($plugin_path . "/" . $update_info['file'][$i])) { if (empty($update_info['content'][$i])) { @unlink($plugin_path . "/" . $update_info['file'][$i]); } elseif ($update_info['content'][$i] == ".") { MakeDir($plugin_path . "/" . $update_info['file'][$i]); } else { WriteFile($plugin_path . "/" . $update_info['file'][$i], $update_info['content'][$i], "wb"); } } else { $list[] = $i; } } $result['link'] = ""; $m = count($list); if ($m > 0) { require ROOT_PATH . "/source/class/myzip.class.php";
} if (!function_exists('imagecreatefromjpeg')) { echo '<b><font color="red">Problem:</font></b> GD is not installed. <br />'; echo 'Solution: Please view "Installation" section <a href = "http://php.net/ref.image" target="_blank">here</a>.<hr />'; } if ($URLMethod == 2 && !file_exists('./pligg/.htaccess')) { echo '<b><font color="red">Problem:</font></b> You have URLMethod set to "2" but ".htaccess" does not exist!<br />'; echo "Solution: Rename .htaccess.default to .htaccess<HR />"; } if ($my_base_url == '') { echo '<b><font color="red">Problem:</font></b> my_base_url is not set.<br />'; echo 'Solution: Please correct this using the <a href = "admin_config.php?page=Location%20Installed">admin panel</a><hr />'; } $canContinue = DoesExist($canContinue, './templates_c', 0777, 'templates_c'); $canContinue = DoesExist($canContinue, './cache', 0777, 'cache'); $canContinue = isWriteable($canContinue, './libs/dbconnect.php', 0777, '/libs/dbconnect.php'); $canContinue = DoesExist($canContinue, './libs/options.php', 0777, '/libs/options.php'); function DoesExist($canContinue, $file, $mode, $desc) { @chmod($file, $mode); $good = file_exists($file) ? 1 : 0; Message($desc . ' exists?: ', $good); return $canContinue && $good; } function isWriteable($canContinue, $file, $mode, $desc) { @chmod($file, $mode); $good = is_writable($file) ? 1 : 0; Message($desc . ' is writable: ', $good); return $canContinue && $good; }
echo '<html>'; $main_smarty->display($the_template . '/head.tpl'); echo '<body><div id="wrap"><div id="header">'; $main_smarty->display($the_template . '/header.tpl'); echo '</div><div id="content-wrap"><div id="sidebar">'; $main_smarty->display($the_template . '/sidebar.tpl'); echo '</div><div id="contentbox"><div id="breadcrumb"><a href="' . $my_pligg_base . '/">' . $server_name . '</a> » <a href="' . $my_pligg_base . '/admin_index.php">Admin Panel</a> » Modify Language</div>'; echo '<div id="inside"><div id="contents"><fieldset><legend>Modify Language</legend><br />'; */ // ------------------------------------------------------------------------------------- force_authentication(); $canIhaveAccess = 0; $canIhaveAccess = $canIhaveAccess + checklevel('god'); if ($canIhaveAccess == 1) { $canContinue = 1; $canContinue = isWriteable($canContinue, './libs/lang.conf', 0777, './libs/lang.conf'); if (!$canContinue) { echo 'File is not writeable. Please CHMOD /libs/lang.conf to 777 and refresh this page.<br /><br /><br />'; die; } $version = file('./libs/lang.conf.version'); $myversion = $version[0] * 1; $lines = file('./libs/lang.conf'); $section = "x"; $lastsection = ""; $tabA = " "; if (isset($_GET["mode"])) { if ($_GET["mode"] == "edit") { $outputHtml[] = "<form>"; $outputHtml[] = "<table class='listing'>"; $outputHtml[] = "Editing <b>" . $_GET["edit"] . "</b><br /><br />";