示例#1
0
/**
 * Function strips url part from css link
 *
 * @param string $path
 * @param string $rootDir
 * @return string
 */
function stripUrl($path, $rootDir = '')
{
    $result = $path;
    if (is_string($path) && $path != '') {
        $start = strpos($path, '(') + 1;
        $length = strpos($path, ')') - $start;
        $rut = $rootDir . substr($path, $start, $length);
        $result = fullPath($rut, '/');
    }
    return $result;
}
示例#2
0
	function getItems($dir, $type, $valid) {		
		global $cfg;
		global $l;
		$path = fullPath($dir); // get full path like D:/www/.....     
		if ($handle = @opendir($path)) {
			$retstr = '';
			$files = array();
			$valids = (is_array($valid) ? implode('|', $valid) : $valid);			
			while (($file = readdir($handle)) !== false) {                                                            
				if (is_file($path . $file) && eregi('\.(' . $valids . ')$', $file, $matches)) {                                                                                   
					$files[$path . $file] = $matches[0];
				}
			}
			closedir($handle);                                               
			ksort($files);
			
			$radiocounter = 0;
			foreach ($files as $filename => $ext) {
				$noext = str_replace($ext, '', basename($filename));				
				if ($type == 'wm') { // watermark images
					$src = $cfg['scripts'] . 'phpThumb/phpThumb.php?src=' . $dir . basename($filename) . '&w=32;&h=32&zc=1&f=gif';
					$retstr .= '<div><input type="radio" name="wmf" value="' . $dir . basename($filename) . '" class="chkBox"' . ((++$radiocounter == 1) ? "checked=\"checked\"" : "") . ' /><img src="' . htmlentities($src, ENT_QUOTES) . '" alt="' . htmlentities($noext, ENT_QUOTES) . '" title="' . htmlentities($noext, ENT_QUOTES) . '" align="middle" /></div>' . "\n";
				} else if ($type == 'ms') { // mask images
					$src = $cfg['scripts'] . 'phpThumb/phpThumb.php?src=' . $dir . basename($filename) . '&w=32;&h=32&zc=1&q=85&f=jpeg';
					$retstr .= '<div><input type="radio" name="msf" value="' . $dir . basename($filename) . '" class="chkBox"' . ((++$radiocounter == 1) ? "checked=\"checked\"" : "") . ' /><img src="' . htmlentities($src, ENT_QUOTES) . '" alt="' . htmlentities($noext, ENT_QUOTES) . '" title="' . htmlentities($noext, ENT_QUOTES) . '" width="32" height="32" align="middle" /></div>' . "\n";
				} else if ($type == 'ft') { // true type fonts					
					$retstr .= '<option value="' . basename($filename) . '">' . htmlentities($noext, ENT_QUOTES) . '</option>' . "\n";	
    			};
			}
			return $retstr;
		} else {
			echo $l->m('er_027');
			return false;
		}	
	}
示例#3
0
function GetDepFilesHTML($manifestroot, $fname, &$filenames, &$dcx, $folder)
{
    $dcx->resetXpath();
    $nlist = $dcx->nodeList("//img/@src | //link/@href | //script/@src | //a[not(starts-with(@href,'#'))]/@href");
    $css_obj_array = array();
    foreach ($nlist as $nl) {
        $item = $folder . $nl->nodeValue;
        $path_parts = pathinfo($item);
        $fname = $path_parts['basename'];
        $ext = array_key_exists('extension', $path_parts) ? $path_parts['extension'] : '';
        if (!is_url($folder . $nl->nodeValue) && !is_url($nl->nodeValue)) {
            $path = $folder . $nl->nodeValue;
            $file = fullPath($path, "/");
            toNativePath($file);
            if (file_exists($manifestroot . DIRECTORY_SEPARATOR . $file)) {
                $filenames[$file] = $file;
            }
        }
        if ($ext == 'css') {
            $css = new cssparser();
            $css->Parse($dcx->filePath() . $nl->nodeValue);
            $css_obj_array[$item] = $css;
        }
    }
    $nlist = $dcx->nodeList("//*/@class");
    foreach ($nlist as $nl) {
        $item = $folder . $nl->nodeValue;
        foreach ($css_obj_array as $csskey => $cssobj) {
            $bimg = $cssobj->Get($item, "background-image");
            $limg = $cssobj->Get($item, "list-style-image");
            $npath = pathinfo($csskey);
            if (!empty($bimg) && $bimg != 'none') {
                $value = stripUrl($bimg, $npath['dirname'] . '/');
                $filenames[$value] = $value;
            } else {
                if (!empty($limg) && $limg != 'none') {
                    $value = stripUrl($limg, $npath['dirname'] . '/');
                    $filenames[$value] = $value;
                }
            }
        }
    }
    $elems_to_check = array("body", "p", "ul", "h4", "a", "th");
    $do_we_have_it = array();
    foreach ($elems_to_check as $elem) {
        $do_we_have_it[$elem] = $dcx->nodeList("//" . $elem)->length > 0;
    }
    foreach ($elems_to_check as $elem) {
        if ($do_we_have_it[$elem]) {
            foreach ($css_obj_array as $csskey => $cssobj) {
                $sb = $cssobj->Get($elem, "background-image");
                $sbl = $cssobj->Get($elem, "list-style-image");
                $npath = pathinfo($csskey);
                if (!empty($sb) && $sb != 'none') {
                    $value = stripUrl($sb, $npath['dirname'] . '/');
                    $filenames[$value] = $value;
                } else {
                    if (!empty($sbl) && $sbl != 'none') {
                        $value = stripUrl($sbl, $npath['dirname'] . '/');
                        $filenames[$value] = $value;
                    }
                }
            }
        }
    }
}
示例#4
0
function handlePath($path)
{
    $path = str_replace('/', '\\', $path);
    if (!strpos($path, ":")) {
        if (substr($path, 0, 1) != "\\") {
            //自定义当前目录
            if (isset($GLOBALS['ThisDirName'])) {
                $path = $GLOBALS['ThisDirName'] . "\\" . $path;
            } else {
                if (defined('WEBPATH')) {
                    $path = WEBPATH . "\\" . $path;
                } else {
                    $path = dirname(__FILE__) . "\\" . $path;
                }
            }
        } else {
            $path = $_SERVER['DOCUMENT_ROOT'] . "\\" . $path;
        }
    }
    $path = str_replace('/', '\\', $path);
    $path = str_replace('\\\\', '\\', $path);
    $path = fullPath($path);
    return $path;
}