Example #1
0
    verbose("cacheControl = {$cacheControl}");
    $img->addHTTPHeader("Cache-Control", $cacheControl);
}
$dummyDir = getConfig('dummy_dir', $cachePath . "/" . $dummyFilename);
if ($dummyImage === true) {
    is_writable($dummyDir) or verbose("dummy dir not writable = {$dummyDir}");
    $img->setSaveFolder($dummyDir)->setSource($dummyFilename, $dummyDir)->setOptions(array('newWidth' => $newWidth, 'newHeight' => $newHeight, 'bgColor' => $bgColor))->setJpegQuality($quality)->setPngCompression($compress)->createDummyImage()->generateFilename(null, false)->save(null, null, false);
    $srcImage = $img->getTarget();
    $imagePath = null;
    verbose("src (updated) = {$srcImage}");
}
$srgbDirName = "/srgb";
$srgbDir = realpath(getConfig('srgb_dir', $cachePath . $srgbDirName));
$srgbDefault = getConfig('srgb_default', false);
$srgbColorProfile = getConfig('srgb_colorprofile', __DIR__ . '/../icc/sRGB_IEC61966-2-1_black_scaled.icc');
$srgb = getDefined('srgb', true, null);
if ($srgb || $srgbDefault) {
    if (!is_writable($srgbDir)) {
        if (is_writable($cachePath)) {
            mkdir($srgbDir);
        }
    }
    $filename = $img->convert2sRGBColorSpace($srcImage, $imagePath, $srgbDir, $srgbColorProfile, $useCache);
    if ($filename) {
        $srcImage = $img->getTarget();
        $imagePath = null;
        verbose("srgb conversion and saved to cache = {$srcImage}");
    } else {
        verbose("srgb not op");
    }
}
Example #2
0
verbose("dpr = {$dpr}");
/**
 * convolve - image convolution as in http://php.net/manual/en/function.imageconvolution.php
 */
$convolve = get('convolve', null);
$convolutionConstant = getConfig('convolution_constant', array());
// Check if the convolve is matching an existing constant
if ($convolve && isset($convolutionConstant)) {
    $img->addConvolveExpressions($convolutionConstant);
    verbose("convolve constant = " . print_r($convolutionConstant, 1));
}
verbose("convolve = " . print_r($convolve, 1));
/**
 * no-upscale, nu - Do not upscale smaller image to larger dimension.
 */
$upscale = getDefined(array('no-upscale', 'nu'), false, true);
verbose("upscale = {$upscale}");
/**
 * Get details for post processing
 */
$postProcessing = getConfig('postprocessing', array('png_filter' => false, 'png_filter_cmd' => '/usr/local/bin/optipng -q', 'png_deflate' => false, 'png_deflate_cmd' => '/usr/local/bin/pngout -q', 'jpeg_optimize' => false, 'jpeg_optimize_cmd' => '/usr/local/bin/jpegtran -copy none -optimize'));
/**
 * alias - Save resulting image to another alias name.
 * Password always apply, must be defined.
 */
$alias = get('alias', null);
$aliasPath = getConfig('alias_path', null);
$validAliasname = getConfig('valid_aliasname', '#^[a-z0-9A-Z-_]+$#');
$aliasTarget = null;
if ($alias && $aliasPath && $passwordMatch) {
    $aliasTarget = $aliasPath . $alias;
Example #3
0
 /**
  * Compare Language File against script and find unused LANs
  * @param object $lanfile
  * @param object $script
  * @return string|boolean FALSE on error
  */
 function unused($lanfile, $script, $reverse = false)
 {
     $mes = e107::getMessage();
     $frm = e107::getForm();
     unset($_SESSION['language-tools-unused']);
     //	$mes->addInfo("LAN=".$lanfile."<br />Script = ".$script);
     if ($reverse == true) {
         $exclude = array("e_LANGUAGE", "e_LANGUAGEDIR", "e_LAN", "e_LANLIST", "e_LANCODE", "LANGUAGES_DIRECTORY");
         $data = file_get_contents($script);
         if (preg_match_all("/([\\w_]*LAN[\\w_]*)/", $data, $match)) {
             // print_a($match);
             $foundLans = array();
             foreach ($match[1] as $val) {
                 if (!in_array($val, $exclude)) {
                     $foundLans[] = $val;
                 }
             }
             sort($foundLans);
             $foundLans = array_unique($foundLans);
             $lanDefines = implode("\n", $foundLans);
         }
         $mes->addDebug("Script: " . $script);
         $tmp = explode(",", $lanfile);
         foreach ($tmp as $scr) {
             if (!file_exists($scr)) {
                 $mes->addError(LANG_LAN_121 . " " . $scr);
                 continue;
             }
             $compare[$scr] = file_get_contents($scr);
             $mes->addDebug("LanFile: " . $scr);
         }
         $lanfile = $script;
     } else {
         $lanDefines = file_get_contents($lanfile);
         $mes->addDebug("LanFile: " . $lanfile);
         $tmp = explode(",", $script);
         foreach ($tmp as $scr) {
             if (!file_exists($scr)) {
                 $mes->addError(LANG_LAN_121 . " " . $scr);
                 continue;
             }
             $compare[$scr] = file_get_contents($scr);
             $mes->addDebug("Script: " . $scr);
         }
     }
     //	print_a($compare);
     //	print_a($lanDefines);
     if (!$compare) {
         $mes->addError(LANG_LAN_121 . " " . $script);
     }
     if (!$lanDefines) {
         $mes->addError(LANG_LAN_121 . " " . $lanfile);
     }
     $srch = array("<?php", "<?", "?>");
     $lanDefines = str_replace($srch, "", $lanDefines);
     $lanDefines = explode("\n", $lanDefines);
     if ($lanDefines) {
         $text = $frm->open('language-unused');
         $text .= "<table class='table adminlist table-striped table-bordered'>\n\t\t\t<colgroup>\n\t\t\t\t<col style='width:20%' />\n\t\t\t\t<col style='auto' />\n\t\t\t\t<col style='auto' />\n\t\t\t</colgroup>\n\t\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th>" . str_replace(e_LANGUAGEDIR, "", $lanfile) . "</th><th>Value</th>";
         foreach ($compare as $k => $val) {
             $text .= "<th>" . str_replace("../", "", $k) . "</th>";
         }
         if ($reverse == true) {
             $text .= "<th>" . LANG_LAN_124 . "</th>";
         }
         $text .= "\n\t\t\t\t</tr>\n\t\t\t\t</thead>\n\t\t\t\t<tbody>";
         // 	for ($i=0; $i<count($lanDefines); $i++)
         //	{
         foreach ($lanDefines as $line) {
             if (trim($line) != "") {
                 $disabled = preg_match("#^//#i", $line) ? " " . LANG_LAN_125 : false;
                 if ($match = getDefined($line, $reverse)) {
                     $text .= $this->compareit($match['define'], $compare, $match['value'], $disabled, $reverse);
                 }
             }
         }
         $text .= "</tbody></table>";
         /*
         		if(count($_SESSION['language-tools-unused'])>0 && $reverse == false)
         		{
         			$text .= "<div class='buttons-bar center'>".$frm->admin_button('disabled-unused',LANG_LAN_126,'delete').
         			$frm->hidden('disable-unused-lanfile',$lanfile).
         			$frm->hidden('deprecatedLans',$script).
         
         			"</div>";
         		}
         */
         $text .= $frm->close();
         if ($reverse != true) {
             $mes->addInfo("<b>Search ENTIRE core before commenting out ANY LAN from ANY language file.</b>");
         }
         $ret['text'] = $mes->render() . $text;
         $ret['caption'] = "Errors: " . intval($this->errors);
         return $ret;
     } else {
         return FALSE;
     }
 }
Example #4
0
function compareit($needle, $haystack, $value = '', $disabled = FALSE)
{
    //	return "Need=".$needle."<br />hack=".$haystack."<br />val=".$val;
    //TODO Move this into a separate function (use a class for this whole script)
    $commonPhrases = file_get_contents(e_LANGUAGEDIR . "English/admin/lan_admin.php");
    $commonLines = explode("\n", $commonPhrases);
    $foundSimilar = FALSE;
    $foundCommon = FALSE;
    foreach ($commonLines as $line) {
        if ($match = getDefined($line)) {
            $id = $match['define'];
            $ar[$id] = $match['value'];
        }
    }
    // Check if a common phrases was used.
    foreach ($ar as $def => $common) {
        similar_text($value, $common, $p);
        if (strtoupper(trim($value)) == strtoupper($common)) {
            //$text .= "<div style='color:yellow'><b>$common</b></div>";
            $foundCommon = TRUE;
            break;
        } elseif ($p > 55) {
            $foundSimilar = TRUE;
            break;
        }
        $p = 0;
    }
    foreach ($haystack as $script) {
        $lines = explode("\n", $script);
        $text .= "<td>";
        $count = 1;
        foreach ($lines as $ln) {
            if (preg_match("/\\b" . $needle . "\\b/i", $ln)) {
                if ($disabled) {
                    $text .= ADMIN_WARNING_ICON;
                }
                $text .= " Line:<b>" . $count . "</b>  ";
                // "' Found";
                $found = TRUE;
            }
            $count++;
        }
        if (!$found) {
            $text .= "-";
        }
        $text .= "</td>";
    }
    $color = $found ? "" : "background-color:pink";
    if ($foundCommon && $found) {
        $color = "background-color:yellow";
        $disabled .= "<br /><i>" . $common . "</i> is a common phrase.<br />(Use <b>" . $def . "</b> instead.)";
        // return "<tr><td style='width:25%;'>".$needle .$disabled. "</td><td></td></tr>";
    } elseif ($foundSimilar && $found && substr($def, 0, 4) == "LAN_") {
        $color = "background-color:#E9EAF2";
        $disabled .= "  <a class='e-tip' href='#' title=\"" . $value . " :: " . $common . "\">" . round($p) . "% like " . $def . "</a> ";
        // $disabled .= " <a class='e-tip' href='#' title=\"".$common."\">" . $def."</a>"; //  $common;
    }
    if ($disabled == " (disabled)") {
        $color = "background-color:#DFFFDF";
    }
    return "<tr><td style='width:25%;{$color}'>" . $needle . $disabled . "</td>" . $text . "</tr>";
}