Jump to content
php.lv forumi

TheQn

Reģistrētie lietotāji
  • Posts

    15
  • Joined

  • Last visited

Posts posted by TheQn

  1. kods ir 100% pareizi uzrakstits, es pats nesaprotu kur kluda, es vel meginaju error_reporting(E_ALL) un error_reporting(8191) kludas koda neradas.

    <pre id="line1">string(18) "C:\AppServ\www/css" </pre>

    var_dump($types); null uzrada

    <pre id="line1">string(20) "reset.css,global.css" vis pareizi</pre>

  2. si koda dala urzrada Here!

    elseif ($type == 'css' && substr($path, -4) !== '.css')
    {
       	$file .= '.css';
       	echo "Here";
    }
    

     

    si koda dala neko neuzrada

    if ($type === 'css')
    {
    $contents = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $contents);
     $contents = str_replace(array("\r", "\n", "\t", '  ', '   '), '', $contents);
       	$contents = str_replace('{ ','{', $contents);
       	$contents = str_replace(' }','}', $contents);
       	$contents = str_replace('; ',';', $contents);
       	$contents = str_replace(', ',',', $contents);
       	$contents = str_replace(' {','{', $contents);
       	$contents = str_replace('} ','}', $contents);
       	$contents = str_replace(': ',':', $contents);
       	$contents = str_replace(' ,',',', $contents);
       	$contents = str_replace(' ;',';', $contents);
       	echo "here";
    }
    

     

    lieku echo kur ir apstrada ar css faili.

     

    taisiju vel ta var_dump($cssdir);, var_dump($files);, var_dump($file); vispar neko neuzrada.

  3. vo ko uzrada access

    ip - - [11/Aug/2011:14:18:32 +0300] "GET /css/reset.css,global.css HTTP/1.1" 404 20

    ip - - [11/Aug/2011:14:18:47 +0300] "GET /css/reset.css,global.css HTTP/1.1" 404 20

    ip - - [11/Aug/2011:14:18:50 +0300] "GET /css/reset.css,global.css HTTP/1.1" 404 20

    bet nezinu kapec rada 404 ja es ieliku pareizu celu lids css folderim pasa combine.php, un .htaccess bet kludu nevaru atrast.

  4. Sis combine scripts comprese css,js failus tikai vienu reizi, un nem no cache folderi kam lietotajam piemeram cache-fwqfqw432423423f4f2f4.js.gzip nu nelade katram lietotajom compress css strada tika ta <link rel="stylesheet" type="text/css" href="/engine/combine.php?type=css&files=reset,global" /> nezinu kapec vins negrib stradat caur .htaccess sada veida RewriteRule ^css/(.*\.css)$ /engine/combine.php?type=css&files=$1

    jo es taisu savu cms man vajag tikai so combine.php lai stradatu.

     

    man liekas ta problema ir combine.php scripta jo es nevaru atrast so kludu scripta. busu pateicigs kurs atradis kludu un izlabos.

  5. kr4 nesaprotu kur kluda combine.php negrib .css faili apvienoties viena faila, bet .js apvienojas viena faila un compressojas, kur var but kluda.

    combine.php

    <?php
    header("Vary: Accept-Encoding");
    error_reporting(0);
    $cache = true;
    $cachedir = dirname(__FILE__) . '/cache';
    $cssdir = dirname(__FILE__) . '../../css/';
    $jsdir = dirname(__FILE__) . '../../javascript/';
    if (!isset($_GET['files']) or strlen($_GET['files']) == 0) {
    header('Status: 404 Not Found');
    exit();
    }
    if (!file_exists($cachedir)) {
    mkdir($cachedir);
    }
    $type = $_GET['type'];
    switch ($type) {
    case 'css':
       	$base = realpath($cssdir);
       	break;
    case 'javascript':
       	$base = realpath($jsdir);
       	break;
    default:
       	header("HTTP/1.0 503 Not Implemented");
       	exit;
    };
    $files = explode(',', $_GET['files']);
    $types = array_fill(0, sizeof($files), $type);
    function addExtension($file, $type)
    {
    if ($type == 'javascript' && substr($file, -3) !== '.js')
    {
       	$file .= '.js';
    }
    elseif ($type == 'css' && substr($path, -4) !== '.css')
    {
       	$file .= '.css';
    }
    return $file;
    }
    $files = array_map('addExtension', $files, $types);
    $lastmodified = 0;
    foreach ($files as $file) {
    $path = realpath($base.'/'.$file);
    if (!file_exists($path)) {
       	header("HTTP/1.0 404 Not Found");
       	exit;
    }
    $lastmodified = max($lastmodified, filemtime($path));
    }
    $md5 = md5($_GET['files']);
    $hash = $lastmodified . '-' . $md5;
    header("ETag: \"" . $hash . "\"");
    if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) ==
    '"' . $hash . '"') {
    header("HTTP/1.0 304 Not Modified");
    header('Content-Length: 0');
    exit;
    }
    else
    {
    $gzip = strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip');
    $deflate = strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate');
    $encoding = $gzip ? 'gzip' : ($deflate ? 'deflate' : 'none');
    if (!strstr($_SERVER['HTTP_USER_AGENT'], 'Opera') && preg_match('/^Mozilla\/4\.0 \(compatible; MSIE ([0-9]\.[0-9])/i',
       	$_SERVER['HTTP_USER_AGENT'], $matches)) {
       	$version = floatval($matches[1]);
       	if ($version < 6)
           	$encoding = 'none';
       	if ($version == 6 && !strstr($_SERVER['HTTP_USER_AGENT'], 'EV1'))
           	$encoding = 'none';
    }
    
    if ($cache)
    {
       	$cachefile = 'cache-' . $md5 . '.' . (($type === 'css') ? 'css' : 'js') . (($encoding !=
           	'none') ? '.' . $encoding : '');
       	if (file_exists($cachedir . '/' . $cachefile) && $lastmodified < filemtime($cachedir . '/' . $cachefile))
       	{
           	if ($encoding != 'none') {
               	header("Content-Encoding: " . $encoding);
           	}
           	header("Content-Type: text/" . $type);
           	header("Content-Length: " . filesize($cachedir . '/' . $cachefile));
           	readfile($cachedir . '/' . $cachefile);
           	exit;
       	}
    }
    $contents = '';
    foreach ($files as $file) {
       	$path = realpath($base.'/'.$file);
       	$contents .= file_get_contents($path);
    }
    if ($type === 'css')
    {
    $contents = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $contents);
     $contents = str_replace(array("\r", "\n", "\t", '  ', '   '), '', $contents);
    }
    else
    {
       	require ('classes/jsmin.php');
       	$contents = JSMin::minify($contents);
    }
    header("Content-Type: text/" . $type);
    if (isset($encoding) && $encoding != 'none')
    {
       	$contents = gzencode($contents, 9, $gzip ? FORCE_GZIP : FORCE_DEFLATE);
       	header("Content-Encoding: " . $encoding);
       	header('Content-Length: ' . strlen($contents));
       	echo $contents;
    }
    else
    {
       	header('Content-Length: ' . strlen($contents));
       	echo $contents;
    }
    if ($cache)
       	file_put_contents($cachedir . '/' . $cachefile, $contents);
    }
    ?>
    

     

    .htaccess

    
    
    RewriteEngine On
    RewriteRule ^css/(.*\.css)$ /engine/combine.php?type=css&files=$1
    RewriteRule ^javascript/(.*\.js)$ /engine/combine.php?type=javascript&files=$1

     

     

    Index.php

    <link rel="stylesheet" type="text/css" href="css/reset.css,global.css" />
    <script type="text/javascript"> (function() {
    var ssync = document.createElement('script');
    ssync.type = 'text/javascript';
    ssync.async = true;
    ssync.src = 'javascript/jquery.js,common.js';
    var xsync = document.getElementsByTagName('script')[0];
    xsync.parentNode.insertBefore(ssync,xsync); } )();
    </script>
    
    

  6. Val ne nestrada.

    man visi fails bans.php atrodas

    engine/includes/bans.php

     

    izvadu uz main lapu ar so scriptu

    <?php
    if($go == '')
    {
    include ENGINE_DIR . '/includes/news.php';
    }
    else
    {
    include ENGINE_DIR . '/includes/'.$go.'.php';
    }
    echo "\n";
    ?>
    
    

  7. Vis strada nepamaniju ka tur ir global $lang; :D

     

    un vel viens jautajums ne par temu

     

    kak ar rewrite taisit

     

    /?go=bans&details=1 uz so /bans/details/1 un so

    /?go=bans&page=1 uz so /bans/page/1

     

    es taisiju ta RewriteRule ^bans/details/([0-9]*)$ ?go=bans&details=$1 [L]

    un RewriteRule ^bans/page/([0-9]*)$ ?go=bans&page=$1 [L] un nestrada..

     

    Un tad var Topic Close!

  8. Nezunu kapec negrib valodu no lang faila uz <title> <?php echo $title; ?></title>

     

    bet uz

     

    <body>

    <?php echo $lang['home']; ?>

    </body>

     

    vis izvada, a bet title negrib.

     

    Index.php

    <?php
    @session_start();
    define('ROOT_DIR', dirname(__FILE__));
    define('ENGINE_DIR', ROOT_DIR . "/engine");
    
    require_once ROOT_DIR . '/config.php';
    require_once ROOT_DIR . '/main_things.php';
    
    $title = title($_GET['go']);
    ?>
    <title> <?php echo $title; ?></title>
    

    main_things.php

    <?php
    
    function title($arg)
    {
       switch($arg)
       {
           case "":
               $title = $lang['home'];
           break;
           case "forum":
               $title = $lang['forum'];
           break;
       }
       return $title;
    }
    
    ?>
    <?php
    
    require_once ENGINE_DIR . '/modules/language.php';
    
    ?>
    

     

    modules/language.php

     

    <?php
    
    $referer = $_SERVER['HTTP_REFERER'];
    
    $languages = array('english' => 'english','latvian' => 'latvian','russian' => 'russian');
    
    if(isset($_GET['lang']))
    {
       $language = $_GET['lang'];
       setcookie('lang', $language, time()+(3600*24*365), "/");
       header("Location: $referer");
    }
    
    elseif(isset($_COOKIE['lang']))
    {
       $language = $_COOKIE['lang'];
    }
    else
    {
       $language = "russian";
    }
    if(!(in_array($language,array_keys($languages))))
    {
       die("Sorry, but this language does not exists!");
    }
    
    require_once ENGINE_DIR . "/languages/{$language}.php";
    
    ?>
    

     

    russian.php

    <?php
    
    $lang = array(
    'home' => 'Главная',
    'forum' => 'Форум'
    );
    
    ?>
    

×
×
  • Create New...