Example #1
0
function kwd($ref)
{
    GT('k2');
    if (Preg_match("~utmctr=([^;|]+)~", $_COOKIE['__utmz'], $t)) {
        return tridecoder($t[1]);
    }
    #adwords failsafe on cookie
    #if($_ENV['yt']['mots']&&$_ENV['yt']['lw']&&$_ENV['yt']['lw']<(now-120)){$x=FGC(ipf,'mots');if(j9==1)Db("ipfmot:$x");Return $x;}
    if (preg_match("~&[q|p]=([^&]+)~i", $ref, $t)) {
        $mots = ask($t);
    } elseif (Preg_match("~cgi-bin.*x_query=([^&]+)~i", $ref, $t)) {
        $mots = $t[1];
    } elseif (Preg_match("~FORID%3A([^&]+)~i", $ref, $t)) {
        $mots = $t[1];
    } elseif (Preg_match("~fr/go.*/([^/]+)~i", $ref, $t)) {
        $mots = $t[1];
    } elseif (Preg_match("~fr/q/(.*).html~i", $ref, $t)) {
        $mots = $t[1];
    } elseif (Preg_match("~&text=([^&]+)~i", $ref, $t)) {
        $mots = $t[1];
    } elseif (Preg_match("~xeoo.*&k=([^&]+)~i", $ref, $t)) {
        $mots = $t[1];
    } elseif (Preg_match("~&(q|p|cx)=([^&]+)~i", $ref, $t)) {
        $mots = ask($t);
    } else {
        $ref = preg_replace('~&(searchfor|eingabe|l|key|text|itag|OVRAW|wd|recherche|rds|rch|data|uery|for|str|ing|qs|qt|req|k|q|p)=~is', 'MX=', $ref);
        preg_match_all("~MX=([^&]+)~is", $ref, $t);
        if ($t[1]) {
            $mots = str_replace('MX=', '', $t[0][0]);
        }
    }
    if (strlen($mots) > 3) {
        GT('k3');
        $mots = trim(Preg_replace("~[ ]{2,}~", ' ', str_replace(array('/', 'search&q=', 'http:', 'http', "\\\\'", "\\'", "\\'", '\\', "'", '"', '+', '-', '-', '&', '|', '{', '}', '(', ')', ',', '...', 'ggmain.jhtml ', 'searchfor=', ''), ' ', $mots)));
        $mots = Preg_replace("~'|\"|\\[|\\]~", '', $mots);
        if (is_numeric($mots)) {
            return '';
        }
        return strtolower(cleankeyword(Tridecoder($mots)));
        #"@'|\"|[\\]@"
    }
}
<?php

if (!defined('IN_DISCUZ')) {
    exit('Access Denied');
}
$sid = getgpc('sid');
$subsid = getgpc('subsid');
$navtitle = lang('plugin/yiqixueba', 'shop');
require_once GC('shop_yiqixueba_shophead');
//参考网站http://www.pailezu.com/
$goods = C::t(GM('shop_goods'))->range();
include template(GT('shop_goodslist'));
Example #3
0
function UnikData($data = '', $db = 'titre', $size = 10)
{
    $res = '';
    $sup = $_ENV['ksup'];
    $s[] = "origindata:" . $data;
    if (RS == 404) {
        return;
    }
    if (!isgoodurl() or preg_match("~url.data:|image/png;|base64|/(adtech|iframeproxy)~", U) or e(',badurl', 1)) {
        return;
    }
    static $trig;
    if (!$trig) {
        Gt('unikdata:start');
        $trig = 1;
    }
    #Returns only unique Array Data ! For Titles + descriptions (1Mo + 13ms)
    if (strpos(u3, '.jpg')) {
        return;
    }
    $rev = 1342976292;
    Gt('udata');
    $u = $db . ':' . hu3;
    #Maj
    if ($y = param($data, '&')) {
        extract($y);
    }
    #extraction paramètres ...?
    $origin = Rem($data, CLT(surl));
    $data = trim(str_replace(array('»', 'Â', '£', 'N%253BO=D'), ' ', $data), '!?»,. ');
    if (!$_ENV['auth']) {
        $u = Preg_Replace("~(#|\\?|&).*~", '', $u);
    } else {
        $u = Preg_Replace("~[#|\\?|&][^(&|\\?)" . $_ENV['auth'] . "]+~", '', $u);
    }
    #!genius!really nice syntax-"~(#|\?|&)[^(".$_ENV['auth'].")].*~"
    while (strlen($data) < $size && $sup) {
        $next = Array_shift($sup);
        if (!stripos($data, $next)) {
            $data .= ' ' . $next;
        }
    }
    #push ksup inside
    if (strpos(SURL, '?', 0)) {
        Preg_match_all("~=([^&]+)~is", SURL, $t);
        if ($t) {
            $t = $t[1];
            $data .= ' ' . implode(' ', $t);
        }
    }
    #si titre similaire, pusher le query string
    $ret = $data;
    #av("data:$data db:$db ret:$ret".pre($s));
    ###Si pas de résultats : invalider le record en placant un "1" dessus
    if (1 or H == 'a74.fr') {
        $arg = 'no=1,bd=' . sip;
        $prev = array();
        #previously db -> comes to mysql  unikdata:id,url,db,data,score
        #CREATE TABLE `unikdata`(`id` INT(8) NOT NULL AUTO_INCREMENT PRIMARY KEY,`url` VARCHAR(255) NOT NULL,`data` TEXT NOT NULL,`score` INT(5) NOT NULL) ENGINE = MYISAM;#`db` VARCHAR(25) NOT NULL,
        $s[] = "select sql_cache data from " . DB . ".unikdata where url=\"{$u}\"";
        $x = sql5(['cache' => 1, 'sql' => end($s)], "bd=" . sip) or $noexist = 1;
        #if(strpos(U,'webcam.php')){print_r(compact('y','s','u','x'));die;}
        $s[] = "result:" . count($x) . "/" . $x . "/data:" . $data;
        if ($x == $data) {
            return $data;
        } else {
            #on défini le score puis On recherche si des correspondances existent déjà
            if (!Q && e('tprio,forcetitre', 1)) {
                $score[$u] = 0;
            } else {
                $score[$u] = substr_count(u, '/') * 20 + substr_count(u, '?') * 10 + substr_count(u, '&') * 10 + strlen(u);
            }
            /*Score de lui même*/
            $datas[$u] = $data;
            $s[] = "select sql_cache url,score from " . DB . ".unikdata where data=\"{$data}\" and url<>\"{$u}\" and left(url,6) rlike'{$db}:" . H . ".*' order by score asc";
            $y = sql5(['cache' => 1, 'sql' => end($s)], $arg);
            /*
            select * from ben.unikdata where url='titre:a74.fr/z/webcam.php';
            select sql_cache url,score from ben.unikdata where data="Webcams Ski Haute Savoie" and url<>"titre:a74.fr/z/webcam.php" and left(url,6) rlike'titre:a74.fr.*' order by score asc
            insert into ben.unikdata(url,data,score)VALUES("titre:a74.fr/z/webcam.php","Webcams Ski Haute Savoie","32")
            */
            #Si une ou plusieurs Pages have the same results
            if ($y) {
                if (!is_array($y)) {
                    $y = [$y];
                }
                foreach ($y as $t) {
                    $score[$t['url']] = $t['score'];
                    $datas[$t['url']] = $data;
                }
            }
            if (count($score) == 1) {
                if ($noexist) {
                    return $data;
                    $s[] = "insert ignore into " . DB . ".unikdata(url,data,score)VALUES(\"{$u}\",\"{$data}\",\"{$score[$u]}\")";
                    sql5(end($s), $arg);
                } else {
                    return $data;
                    $s[] = "update " . DB . ".unikdata set data=\"{$data}\",score=\"{$score[$u]}\" where url=\"{$u}\"";
                    $x = sql5(end($s), $arg);
                }
                #Non car le score est unique !
                #if($db=='titre')DbM('unikdata',surl."<li>db?$db / ".hu3."->$data<li>noexist?$noexist<li>sql:".pre($s)."<li>score:".pre($score)."<li>datas:".pre($datas)."<li>res:".pre($res)."<li>GT:".pre($_ENV['dbt']),1);
                return $data;
            } else {
                #si plusieurs résultats pour mêmes données, il peut exister des similarités ..
                $s[] = "select sql_cache url,data,score from " . DB . ".unikdata where data rlike(\"{$data}*\") and url rlike'{$db}:" . H . ".*' and url<>\"{$u}\" order by score asc";
                $y = sql5(['cache' => 1, 'sql' => end($s)], $arg);
                #les autres résultats proches, on s'en tape !
                if ($y) {
                    foreach ($y as $t) {
                        $score[$t['url']] = $t['score'];
                        $datas[$t['url']] = $t['data'];
                    }
                }
                Asort($score);
                foreach ($score as $url => $v) {
                    #calcul des doublons et population de la matrice des résultats
                    $n = 0;
                    $t2 = $temp = $datas[$url];
                    while (in_Array(accents(strtolower($t2)), $prev) && $n < 20) {
                        #déjà un doublon de score inférieur - 20 opérations maximum
                        if ($trig != 'chiffres' && Preg_match_all("~([0-9]+)~", u, $m)) {
                            $n++;
                            $i = implode('', $m[1]);
                            $t2 = $temp . " {$i}";
                            $trig = 'chiffres';
                            continue;
                        }
                        $i++;
                        $t2 = $temp . " {$i}";
                        #sinon on incrémente
                    }
                    $res[$url] = $t2;
                    $prev[] = accents(strtolower($t2));
                    #les scores les plus pourris ramassent la merde
                    if ($url == $u) {
                        $ret = $t2;
                    }
                    #calcule le retour pour l'url courante
                }
                foreach ($res as $url => $v) {
                    if ($noexist && $url == $u) {
                        $s[] = "insert into " . DB . ".unikdata(url,data,score)VALUES(\"{$u}\",\"{$v}\",\"{$score[$u]}\")";
                        sql5(end($s), $arg);
                        continue;
                    }
                    $s[] = "update " . DB . ".unikdata set data=\"{$v}\" where url=\"{$url}\"";
                    sql5(end($s), $arg);
                    #Il est possible que l'url courante n'aie pas d'enregistrements !!!
                }
            }
            if ($db == 'titre') {
                DbM('unikdata', surl . "<li>db?{$db} / " . hu3 . "->{$data}<li>noexist?{$noexist}<li>sql:" . pre($s) . "<li>score:" . pre($score) . "<li>datas:" . pre($datas) . "<li>res:" . pre($res) . "<li>GT:" . pre($_ENV['dbt']), 1);
            }
            return $ret;
        }
    } else {
        $u = u3;
        #local db mode
        if ($db == 'titre' && filemtime(DR . $db . '.db') < $rev) {
            Unlink(DR . $db . '.db');
        }
        #Unlink the whole file
        #if(!strpos(u3,'=')&&$_ENV['soloQ'])$u=Preg_replace("~\?(?!({$_ENV['soloQ']})).*~is",'',u3);#déjà calculée dans autoappend
        #Determine unique Array 1
        while (strlen($data) < $size && $_ENV['ksup']) {
            $next = Array_shift($_ENV['ksup']);
            if (!stripos($data, $next)) {
                $data .= ' ' . $next;
            }
        }
        #push ksup inside
        Rem($key, $u, 'index');
        $x = FGC(DR . $db . '.db');
        #if(J9)die(pre($x));
        if ($x[$key] && now > $_ENV['rev'] && !strpos($_ENV['args'], 'forcetitre')) {
            return $x[$key];
        }
        #Si la clé date d'avant la dernière révision on la retourne
        if ($x[$key] != $data) {
            #différente ou non définie
            $score[$key] = substr_count(u, '/') * 20 + substr_count(u, '?') * 10 + substr_count(u, '&') * 10 + strlen(u);
            #Score de lui même
            if (strpos($_ENV['args'], ',tprio')) {
                $score[$key] = 0;
            }
            if (strpos(surl, '?', 0)) {
                Preg_match_all("~=([^&]+)~is", surl, $t);
                if ($t) {
                    $t = $t[1];
                    $data .= ' ' . implode(' ', $t);
                }
                #si titre similaire, ajouter le query string
            }
            #Cas 1 : il y a un chiffre dans l'url et il est différent des titres des autres, s'il y a déjà un chiffre, on remplace ce dernier par 156
            if (is_Array($x)) {
                null;
            } else {
                dbM("x is not array-no f*****g way:{$x[$key]}§" . pre($x));
            }
            #elseif(!$x){dbM("uniktitre:x is null ?? wtf ??");return;}
            $y = Array_map('strtolower', $x);
            $e = print_r(error_get_last(), 1);
            #if(stripos($e,'array given'))dBM("uniktitre:$db:{$x[$key]}\n<br>err:".pre($e)."\n<Br>y:".pre($y)."<Br>x:".pre($x));
            $found = array_keys($y, strtolower($data));
            #Arrive très souvent..;
            if (count($found) && Preg_match_all("~([0-9]+)~", u, $m)) {
                #avec des chiffres à injecter dans le titre
                $i = implode('', $m[1]);
                $data = $origin . " {$i}";
                $found = array_keys($y, strtolower($data));
                #last verif
                if (count($found) < 1) {
                    FAP("tx=1&file=" . DR . $db . '.db', array($u => $data));
                    db('found:numbers injected in title');
                    return $data;
                }
                #Ok si aucun doublon
            }
            if (count($found)) {
                #des doublons de titres ont été trouvés
                foreach ($found as $k2) {
                    #si les scores sont égaux, on ne pourra la comparer à un autre numéro..
                    $score[$k2] = substr_count($k2, '/') * 20 + substr_count($k2, '?') * 10 + substr_count($k2, '&') * 10 + strlen($k2);
                    if ($k2 == 'index') {
                        $score[$k2] = 0;
                    }
                    #raz page 0
                }
                Asort($score);
                $os = $score;
                foreach ($score as $k => $v) {
                    #Remplacer le score par les valeurs titre
                    while (in_array($data, $score) && $n < 10) {
                        $n++;
                        $i++;
                        $data = $origin . " {$i}";
                    }
                    if ($n > 10) {
                        Dbm("{$db} n:{$n}; data:" . pre($data) . "score:" . pre($score));
                    }
                    $score[$k] = $data;
                    GT('whilescore');
                    #crée autant
                }
                #if($score[0]==$score[self])Best=1;swap titles
                #if(count($score)<2)$score=end($score);
                FAP("tx=2,{$key}&file=" . dr . $db . '.db', $score);
                #DbM('unikdata',surl."<li>data:$data<li>x[key]:".print_r($x[$key],1)."<li>found:".print_r($found,1)."<li>score:".print_r($os,1)."<li>res:".print_r($score,1));
                return $score[$key];
            }
            if ($x[$key] && now > $_ENV['rev'] && !strpos($_ENV['args'], 'forcetitre')) {
                return $x[$key];
            }
        }
        #swap those values pour url prioritaire!!!
        if ($x[$key] && now > $_ENV['rev'] && !strpos($_ENV['args'], 'forcetitre')) {
            return $x[$key];
        }
        #ajouter ici les valeurs des query strings !
        if ($data && $key) {
            FAP("tx=3,{$key}&file=" . dr . $db . '.db', $key, $data);
            gt('l' . __LINE__);
            return $data;
        }
        DB(surl . ':notitle found:' . count($found) . 'x[key]' . $x[$key] . 'data:' . $data . 'origin:' . $origin);
    }
}
Example #4
0
function CacheInit($N = 0)
{
    static $t;
    timelong('cache');
    if ($_POST || e('nocache,toolong,badurl', 1) || isset($_COOKIE['nocache']) or !isgoodurl(SU) || preg_match('#administrator#', U)) {
        return;
    }
    #$apc=1;#IF(ereg('!R22',u))@unlink(cachepath);
    if (headers_sent($f, $line)) {
        e(',headersent:' . $f . '/' . $line);
        Db("headers!{$f},{$line}");
    }
    #-algo de compression non reconnu car ligne 1063 #AV('cacheinti',$_POST,'nocache:'.e(',nocache',1),'headersent:'.e(',headersent',1),$_COOKIE['nocache'],'goodurl:'.isgoodurl(SU));
    if (!defined('REWRITE') && ($t && RS == 404)) {
        R404();
    }
    #Si la page doit ordinairement retourner une erreur 404 -- problème de certains rewritings sur erreur 404 --- Db("cache404".SU);-la génération de l'erreur 404 est passée par qqch[QUERY_STRING] => x=404
    if ($t && ob_get_length() == 0) {
        return;
    }
    #appel de trop
    #if(ereg("go=",q)){ob_end_clean();$u=str_replace('?go=1','',SU);@unlink(cachepath);R301($u,3);}
    #$apc=1;gt('apc1');if(apc_exists($a))$apc=1;gt('apc2');
    $a = str_replace(TMP . 'cache/', '', CACHEPATH);
    if ($apc && bots) {
        GT('apcgetcache-bots');
        kill(APCG($a));
    }
    #ram
    if ($apc && isgoodurl()) {
        Gt('apcread-start');
        $_ENV['cacheread'] = 1;
        $x = APCG($a);
        Gt('apcread-get');
        echo $x;
        kill("<!--readapccache:{$_ENV['lasttime']}ms-->");
    }
    #str_replace(TMP,SHM,CACHEPATH),
    $path = array(CACHEPATH);
    Array_unique($path);
    #Mem en préférence
    foreach ($path as $cachepath) {
        if ($_ENV['yt']['erasecache'] && H == 'anciensinterneslyon.fr' && !J9) {
            e(',erasecache');
            @unlink($cachepath);
            continue;
        }
        if (is_file(DR . '.lastmod.db') && is_file($cachepath)) {
            if (filemtime(DR . '.lastmod.db') > filectime($cachepath)) {
                unlink($cachepath);
            }
        }
        #pour le joomla#cma-lib-joo-datab-datab-mysqli:391
        if (is_file($cachepath)) {
            r304($cachepath);
            $fs = Filesize($cachepath);
            if (bots || isgoodurl() && $fs > 100 && filemtime($cachepath) > $_ENV['expires']) {
                $_ENV['cacheread'] = 1;
                e(',cacheread,die,noperf,' . $cachepath . ',cachesize:' . $fs);
                Gt('cachepath:read:0');
                #ob_end_clean();
                #if(H=='anciensinternesdelyon.fr'){$x=utf2a(file_get_contents($cachepath));echo $x;}else{
                readfile($cachepath);
                #78,18,25	$x=FGC($cachepath);echo$x);
                Gt("cachepath:read:1:size:{$fs}");
                header('A: cacheread:' . $_ENV['lasttime'], 1);
                die;
            }
        }
    }
    #ob_end_clean(); was taking the more time
    #écriture
    $cachepath = Re($_ENV['c']['htmlcache'][0], CACHEPATH);
    #html local override
    #e(',t:'.$t.','.$cachepath);
    #unlink $path=Array(str_replace(TMP,SHM,CACHEPATH),CACHEPATH);A
    if ($t) {
        GT('cache:write');
        $page = ob_get_contents();
        #GT('flush:0');ob_flush();gt('flush:1');
        #ob_get_flush,ob_get_clean
        $exp = NOW + $_ENV['lasttime'] * $_ENV['c']['cachetime'];
        e('die,noperf,cachesize:' . strlen($page) . ',' . $_ENV['lasttime'] . ',' . Date('Y-m-d H', $exp));
        if ($_ENV['c']['htmlcache'][0]) {
            Av($_ENV['c']['htmlcache']);
            #manuellement déterminé
            foreach ($path as $v) {
                @unlink($v);
            }
            #unlink tous fichiers de cache antérieurs
            $page = $_ENV['c']['htmlcache'][1] . $page . $_ENV['c']['htmlcache'][2] . '<?kill();?>';
            #Ya
        }
        if ($_ENV['lasttime'] > 0.3 || strlen($page) > 50000) {
            #
            #$cachepath=str_replace(TMP,SHM,$cachepath);e(',shm');
            if ($apc) {
                $apc = 2;
                APCP($a, $page);
                gt('apc-write');
            }
        }
        if ($apc != 2) {
            FPC($cachepath, $page);
            Touch($cachepath, $exp);
            r304($exp);
        }
        #if(GT()>500)Dbt();chown($cachepath,'www-data');
        #uniquement si owner = the same :)
        #if(h=='anciensinternesdelyon.fr')av(cachepath,$exp);
        #Gt('echo page');echo $page;Gt('echo page-done');
        header('Acachegen: ' . $_ENV['lasttime']);
        die;
    }
    if (!$t) {
        $t = 1;
        if (!$_ENV['expires']) {
            $_ENV['expires'] = now;
        }
        GT('cache:init');
    }
    #sinon initialisation du cache
}