EngliSEA.php
by webproger on 2024-01-27
ᐥ⏍⎕⍞⊡ↆ↺⟲⨀▣⊙➔××ᐥ
<?php
include $_SERVER['DOCUMENT_ROOT'].'/i/i.php';
if($_GET['id']) {
    header("Location: /i.php?i=".$_GET['id']);
    exit();
}
$_GET['q'] = trim($_GET['q']);
$pr  = "http://qindex.info";
function qdigit($n) {
  if($n>9) {
    switch($n) {
      case 10: return 'A';
      case 11: return 'B';
      case 12: return 'C';
      case 13: return 'D';
      case 14: return 'E';
      case 15: return 'F';
    }
  } else return $n;
}
function qhxdcml($n) {
  if($n>15) {
    $q = floor($n/16);
    $h = qdigit($q);
    $r = $n % 16;
    $h.= qdigit($r);
  } else $h = '0'.qdigit($n);
  return $h;
}
function qrank($n,$m) {
    $r  = round(255-(255-105)/9*($n-1));
    $r  = qhxdcml($r);
    $o  = round(105/9*($n-1));
    $o  = qhxdcml($o);
    $o .= $o;
    $s  = "<span style='color:#".$r.$o.";'>";
    if($m) $s .= "›"; else $s .= "•";
    $s .= "</span>";
    return $s;
}

function qfoto($a) {
    global $pr;
    $b = qslt('uri','*','ix',$a['ui']);
    $u = $pr.'/i.php?x='.$a['ix'];
    $r = '/http\:\/\/qindex\.info\/v\.php(?:(?:\?|&)g=(?:[^&]+))?(?:(?:\?|&)t=([^&]+))?(?:(?:\?|&)v=([-0-9a-zA-Z_]+))?(?:(?:\?|&)i=([0-9.]+))?(?:(?:\?|&)j=([0-9.]+))?(?:(?:\?|&)s=([0-9]+))?(?:(?:\?|&)e=([0-9]+))?/';
    preg_match($r,$b['ui'],$m);
    if($a['tn']>1 OR ($a['tn2'] AND $a['tn']!=1)) {
        $f = floor($a['ui']/1000)+1;
        $g = "http://qindex.info/s/".$f."/".$a['ui'];
        if($a['tn']>1) $g .= "_".$a['ix'];
        $g .= ".png?";
        if($a['tn']>1) $g .= $a['tn']; else $g .= $a['tn2'];
        if($m[0]) {
            if(!$m[3]) $m[3] = 0;
            if(!$m[4]) $m[4] = 0;
            if(!$m[5]) $m[5] = 0;
            if($m[2] && $m[4]>0) {
                if($m[6]) {
                    if($_GET['i']=='ΕͷցlιЅΞΛ') {
                        echo "<td  id='td".$a['ix']."' class='db' style='padding:0px; vertical-align:top;' onclick=\"qfoto1('".qesc($a['tl'],5)."',".$a['ix'].",'".$m[2]."',".$m[3].",".$m[4].",".$m[5].",".$a['ts'].");\">";
                        echo "<img id='ig".$a['ix']."' src='".$g."' style='width:80px; visibility:hidden'>";
                        echo "</td>\n";
                    } else {
                        echo "<td  id='td".$a['ix']."' class='db' style='padding:0px; vertical-align:top; background-color:white;' onclick=\"qfoto2('".qesc($a['tl'],5)."',".$a['ix'].",'".$m[2]."',".$m[3].",".$m[4].",".$m[5].",".$a['ts'].");\">";
                        echo "<img id='ig".$a['ix']."' src='".$g."' style='width:80px;'>";
                        echo "</td>\n";
                    }
                }
            }
        }
    }
}

function qword($a) {
    global $pr;
    $b = qslt('uri','*','ix',$a['ui']);
    $u = $pr.'/i.php?x='.$a['ix'];
    $r = '/http\:\/\/qindex\.info\/v\.php(?:(?:\?|&)g=(?:[^&]+))?(?:(?:\?|&)t=([^&]+))?(?:(?:\?|&)v=([-0-9a-zA-Z_]+))?(?:(?:\?|&)i=([0-9.]+))?(?:(?:\?|&)j=([0-9.]+))?(?:(?:\?|&)s=([0-9]+))?(?:(?:\?|&)e=([0-9]+))?/';
    preg_match($r,$b['ui'],$m);
    if($m[0]) {
        if(!$m[3]) $m[3] = 0;
        if(!$m[4]) $m[4] = 0;
        if(!$m[5]) $m[5] = 0;
        if($m[2] && $m[4]>0) {
            if($m[6]) {
                echo "<tr>\n";
                echo "<td id='td1".$a['ix']."' class='db' onclick=\"fopn1('".qesc($a['tl'],5)."',".$a['ix'].",".$a['ts'].");\">⨀</td>\n";
                echo "<td colspan='2' id='td".$a['ix']."' class='db' onclick=\"fply3('".qesc($a['tl'],5)."',".$a['ix'].",'".$m[2]."',".$m[3].",".$m[4].",".$m[5].");\">";
                echo qalphabet(mb_substr($a['tl'],0,10,'UTF-8'));
                echo "</td>\n";
                echo "<td id='td2".$a['ix']."' class='db' onclick=\"fopn2('".qesc($a['tl'],5)."',".$a['ix'].",".$a['ui'].",".$a['ts'].");\">⊡</td>\n";
                echo "</tr>\n";
            }
        }
    }
}
$qlttrs = array();
function qalphabet($t) {
    global $qlttrs;
    if(!$qlttrs) $qlttrs = qtdr(65);
    $a = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    $n = '';
    $l = strlen($t);
    for($i=0; $i<$l; $i++) {
        $j = substr($t,$i,1);
        $k = strpos($a,$j);
        if($k===false) $n .= $j; else $n .= $qlttrs[$k];
    }
    return $n;
}
function qsearch($a) {
    global $pr;
    if($a['tp']=='p') {
        $b = qslt('uri','*','ix',$a['ui']);
        $u = '/f.php?i='.$a['ui'].'&p='.$a['ix'];
        if($_GET['q']) $r1 = '/'.$_GET['q'].'/i';
        $r2 = '/http\:\/\/qindex\.info\/v\.php(?:(?:\?|&)g=(?:[^&]+))?(?:(?:\?|&)t=([^&]+))?(?:(?:\?|&)v=([-0-9a-zA-Z_]+))?(?:(?:\?|&)i=([0-9.]+))?(?:(?:\?|&)j=([0-9.]+))?(?:(?:\?|&)s=([0-9]+))?(?:(?:\?|&)e=([0-9]+))?/';
        preg_match($r2,$b['ui'],$m);
        echo "\n\n<div class='c1'>";
        if($a['tn']>1 OR ($a['tn2'] AND $a['tn']!=1)) {
            $f = floor($a['ui']/1000)+1;
            $g = "http://qindex.info/s/".$f."/".$a['ui'];
            if($a['tn']>1) $g .= "_".$a['ix'];
            $g .= ".png?";
            if($a['tn']>1) $g .= $a['tn']; else $g .= $a['tn2'];
            if($_SESSION['s_login']=='EngliSea')
                 $v = '/EngliSEA.php?q='.rawurlencode($_GET['q']).'&g='.rawurlencode($g);
            else $v = $u;
            echo "\n<a class='c2' href='".$v."'><img class='c3' src='".$g."'></a>";
        }
        if(trim($_GET['q'])!=trim($a['tl'])) {
            if    ($m[6]==3)                             echo "\n<a href='/EngliSEA.php?q=".rawurlencode($a['tl'])."' target='_blank'>⨀⨀⨀</a>&nbsp;";
            elseif($m[6]==2)                             echo "\n<a href='/EngliSEA.php?q=".rawurlencode($a['tl'])."' target='_blank'>◎◎◎</a>&nbsp;";
            elseif($m[6]==1)                             echo "\n<a href='/EngliSEA.php?q=".rawurlencode($a['tl'])."' target='_blank'>○○○</a>&nbsp;";
            elseif(preg_match('/^[a-zA-Z]+$/',$a['tl'])) echo "\n<a href='/EngliSEA.php?q=".rawurlencode($a['tl'])."' target='_blank'>◌◌◌</a>&nbsp;";
            else echo qrank($a['r'])."&nbsp;";
        }   else echo qrank($a['r'])."&nbsp;";
        echo "<a href='".$u."' target='_blank' onclick='window.setTimeout(\"fud(".$a['ix'].");\",1);'>";
        $t = $a['tl'];
        if($_GET['q'] AND substr($_GET['q'],0,1)!='#') echo preg_replace($r1,'<b>$0</b>',$a['tl']);
        else echo $a['tl'];
        echo "</a>";
        if($m[0]) {
            if(!$m[3]) $m[3] = 0;
            if(!$m[4]) $m[4] = 0;
            if(!$m[5]) $m[5] = 0;
            if($m[2] && $m[4]>0) {
                $r3 = '/^Word%20Power%3A%20%20/';
                if($m[6]) {
                    echo " <span onclick=\"fply('".qesc($t,5)."',".$a['ix'].",'".$m[2]."',".$m[3].",".$m[4].",".$m[5].");\" style='cursor:pointer;'>⪢⪢</span>";
                }
            }
        }
        if(substr($_GET['q'],0,1)=='#') $a['sy'] = preg_replace($r1,'',$a['sy']);
        if($a['sy']) {
            echo "\n<br>";
            if($_GET['q']) echo "\n".preg_replace($r1,'<b>$0</b>',$a['sy']);
            else echo $a['sy'];
        }
        echo "\n<br>";
        $u = $pr.'/i.php?x='.$a['ix'];
        echo "\n<a class='lnk' href='".$u."' target='_blank'>".$u."</a>";
        echo "\n</div>";
    }
}
$_GET['q'] = trim($_GET['q']);
?><!DOCTYPE html>
<head><title><?php
        if($_GET['q']) echo $_GET['q'];
        elseif($_GET['v']=='ruth' OR $_GET['v']=='todd')   echo 'Word Power';
        elseif($_GET['v']=='paul' OR $_GET['v']=='nation') echo 'Essential Words';
        elseif($_GET['i'])   echo 'EngliSea - '.$_GET['i'];
        else echo 'EngliSea';
    ?></title>
    <meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>
    <meta name='description' content='<?php
        if($_GET['q']) echo $_GET['q'];
        elseif($_GET['v']=='ruth' OR $_GET['v']=='todd')   echo 'Hello Channel, Ruth Todd';
        elseif($_GET['v']=='paul' OR $_GET['v']=='nation') echo '4000 Essential English Words, Paul Nation';
        else echo 'EngliSEA = Listening + Dictionary';
        ?>'>
    <meta name='robots' content='index,follow'>
    <link rel='SHORTCUT ICON'  href='/s/1768b76a74ef55c1acd8b78a3b6ae389.png'>
    <meta name="twitter:card"  content="summary">
    <meta name="twitter:title" content="<?php
        if($_GET['q']) echo $_GET['q']; elseif($_GET['v']) echo '4000 Essential English Words'; else echo 'EngliSEA';
        ?>">
    <meta name="twitter:image" content="<?php
        if($_GET['g']) echo $_GET['g'];
        elseif($_GET['v']) echo 'http://qindex.info/g/vocabulary.png';
        else echo 'http://qindex.info/s/1768b76a74ef55c1acd8b78a3b6ae389.png';
        ?>">
    <link rel='stylesheet' href='/i/c.css'>
    <style type='text/css'>
        body { font-size:0.9em; }
        .bttn { width:32px; height:32px; border-radius:50%; opacity: 0.5; }
        .left { position: fixed; left:  15px; bottom: 10px; z-index: 1000; padding:0px; }
        .rght { position: fixed; right: 15px; bottom: 10px; z-index: 1000; padding:0px; }
        .lnk  { font-size:0.8em; }
        img.txt { height:18px; }
        .a1 {
            font-family:Courier new;
            font-size:1.5em;
            padding:0px 4px 0px 4px;
            border:solid 1px white;
            border-radius:50%;
            margin:8px;
            line-height:180%;
        }
        .a2 {
            font-family:Courier new;
            font-size:1.5em;
            padding:0px 4px 3px 4px;
            border:solid 1px silver;
            border-radius:50%;
            margin:8px;
            line-height:180%;
        }
        .bl {
            position: fixed;
            left:  15px;
            bottom: 10px;
            z-index: 1000;
            padding:0px;
        }
        .br {
            position: fixed;
            right:  15px;
            bottom: 10px;
            z-index: 1000;
            padding:0px;
        }
        .bi {
            width:32px;
            height:32px;
            border-radius:50%;
            opacity: 1;
            cursor: pointer;
        }
        .ci {
            font-size:18px;
            width:80px;
            border-width:0px 0px 1px 0px;
            border-bottom:1px solid forestgreen;
        }
        .cq {
            color: deepskyblue;
            font-size:16px;
            width:150px;
            border:0px;
        }
        .ct {
            padding:0px;
            border-bottom: 1px solid deepskyblue;
            text-align:left;
            vertical-align:bottom;
            background-color:white;
        }
        .cs {
            color:dodgerblue;
            background-color:white;
            border:1px solid deepskyblue;
            font-size:13px;
            padding:9px 10px 6px 10px;
            cursor:pointer;
        }
        .cd {
            border-top:1px solid whitesmoke;
            padding:0.25em 15px 0.25em 15px;
            color:gainsboro;
            text-align:center;
        }
        .c1 {
            padding:0px 15px 0px 15px;
            margin-top:1em;
        }
        .c2 {
            float:left;
            margin:0.3em 0.5em 0px 0px
        }
        .c3 {
            display:inline-block;
            width:80px;
        }
        .c4 {
            padding:0px 15px 0px 15px;
        }
        .c5 {
            text-align:center; vertical-align:middle;
        }
        .sm {
            height:30px;
            margin:0px;
            border:0px;
            padding:0px;
            display:block;
        }
        .in {
            height:60px;
            display:inline-block;
        }
        .db {
            font-size:20px;
            color:white;
            text-align:center;
            vertical-align:middle;
            background-color:DodgerBlue;
            cursor:pointer;
        }
    </style>
    <script src='/i/j.php'></script>
    <?php
    if(false) echo "<script src='/i/jqz.php'></script>";
    ?>
    <script src='http://qindex.info/EngliSEA.js'></script>
</head>

<body>
    <!-- start of input -->
    <form method='get' action='<?php echo $_SERVER['PHP_SELF']; ?>'>
    <table cellspacing='0' style='width:100%; position:fixed; left:0px; top:0px; background-color:white;'>
        <tr>
            <td style='padding:0px; text-align:left;'>
                <a href='/EngliSEA.php<?php if($_GET['v']) echo "?v=".$_GET['v']; ?>'>
                    <img src='/s/0799224d0c665696d27342f59e730add.png' style='height:32px; display:block;'>
                </a>
            </td>
            <td>
                <!-- 1. The <iframe> (and video player) will replace this <div> tag. -->
                <div id="player"></div>
                <script>
                    // 2. This code loads the IFrame Player API code asynchronously.
                    var tag = document.createElement('script');
              
                    tag.src = "https://www.youtube.com/iframe_api";
                    var firstScriptTag = document.getElementsByTagName('script')[0];
                    firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
              
                    // 3. This function creates an <iframe> (and YouTube player)
                    //    after the API code downloads.
                    var player;
                    function onYouTubeIframeAPIReady() {
                      player = new YT.Player('player', {
                        height: '1',
                        width: '1',
                        playerVars:{
                            'playsinline': 1
                        },
                        events: {
                          'onReady': onPlayerReady,
                          'onStateChange': onPlayerStateChange
                        }
                      });
                    }
                    // 4. The API will call this function when the video player is ready.
                    function onPlayerReady(event) {
                        player.playVideo();
                    }
                    // 5. The API calls this function when the player's state changes.
                    //    The function indicates that when playing a video (state=1),
                    //    the player should play for six seconds and then stop.
                    function onPlayerStateChange(event) {
                      if (event.data == YT.PlayerState.PLAYING) {
                        wt.style.visibility = 'hidden';
                      }
                    }
                    function stopVideo() {
                      player.stopVideo();
                    }
                    var viy,vst,ved,vvm;
                    function fud(i,j) {
                        var h = document.createElement("script");
                        var s = "http://qindex.info/i/pxr.php?mode=ud&i="+i;
                        if(j) s += "&j="+j;
                        h.setAttribute("src",s);
                        document.getElementsByTagName('head')[0].appendChild(h);
                    }
                    var c1 = new Array();
                    var c2 = new Array();
                    function fply(qs,ix,iy,st,ed,vm) {
                        window.setTimeout("fud("+ix+");",1);
                        document.getElementById('iq').value = qs;
                        wt.style.visibility = 'visible';
                        player.loadVideoById({'videoId':iy,'startSeconds':st,'endSeconds':ed});
                        if(vm) player.setVolume(vm); else player.setVolume(100);
                    }
                    var dc;
                    function qfoto1(qs,ix,iy,st,ed,vm,ts) {
                        if(c1.includes(ix)) {
                            document.getElementById('iq').value = qs;
                            if(c2.includes(ix)) {
                            } else {
                                document.getElementById('td'+ix).style.backgroundColor = 'white';
                                document.getElementById('ig'+ix).style.visibility = 'visible';
                                window.setTimeout("fud("+ix+","+tf+");",1);
                                c2.push(ix);
                            }
                        } else {
                            document.getElementById('td'+ix).style.backgroundColor = 'DeepSkyBlue';
                            document.getElementById('iq').value = '';
                            window.setTimeout("fud("+ix+");",1);
                            c1.push(ix);
                        }
                        wt.style.visibility = 'visible';
                        player.loadVideoById({'videoId':iy,'startSeconds':st,'endSeconds':ed});
                        if(vm) player.setVolume(vm); else player.setVolume(100);
                    }
                    function qfoto2(qs,ix,iy,st,ed,vm,ts) {
                        if(c1.includes(ix)) {
                            document.getElementById('iq').value = qs;
                            if(c2.includes(ix)) {
                            } else {
                                window.setTimeout("fud("+ix+","+tf+");",1);
                                c2.push(ix);
                            }
                        } else {
                            document.getElementById('iq').value = '';
                            window.setTimeout("fud("+ix+");",1);
                            c1.push(ix);
                        }
                        wt.style.visibility = 'visible';
                        player.loadVideoById({'videoId':iy,'startSeconds':st,'endSeconds':ed});
                        if(vm) player.setVolume(vm); else player.setVolume(100);
                    }
                    function fply3(qs,ix,iy,st,ed,vm) {
                        document.getElementById('td'+ix).style.backgroundColor = 'DeepSkyBlue';
                        if(c1.includes(ix)) {
                            document.getElementById('iq').value = qs;
                        } else {
                            document.getElementById('iq').value = qs;
                            window.setTimeout("fud("+ix+");",1);
                            c1.push(ix);
                        }
                        wt.style.visibility = 'visible';
                        player.loadVideoById({'videoId':iy,'startSeconds':st,'endSeconds':ed});
                        if(vm) player.setVolume(vm); else player.setVolume(100);
                    }
                    function fopn1(qs,ix,ts) {
                        document.getElementById('td1'+ix).style.backgroundColor = 'DeepSkyBlue';
                        document.getElementById('iq').value = qs;
                        if(c2.includes(ix)) {
                        } else {
                            window.setTimeout("fud("+ix+","+tw+");",1);
                            if(!c1.includes(ix)) c1.push(ix);
                            c2.push(ix);
                        }
                        window.open('/i.php?x='+ix);
                    }
                    function fopn2(qs,ix,iy,ts) {
                        document.getElementById('td2'+ix).style.backgroundColor = 'DeepSkyBlue';
                        document.getElementById('iq').value = qs;
                        if(c2.includes(ix)) {
                        } else {
                            window.setTimeout("fud("+ix+","+tw+");",1);
                            if(!c1.includes(ix)) c1.push(ix);
                            c2.push(ix);
                        }
                        window.open('/f.php?i='+iy+'&p='+ix);
                    }
                    
                    var wt = document.createElement("img");
                    wt.setAttribute("src",'http://qindex.info/g/wait.gif');
                    wt.style.visibility = 'hidden';
                    wt.style.position = 'fixed';
                    wt.style.width  = '100px';
                    wt.style.height = '100px';
                    w = jdm.clnt_wdth();
                    h = jdm.clnt_hght();
                    wt.style.left = (w-100)/2+'px';
                    wt.style.top  = (h-100)/2+'px';
                    wt.style.zIndex = '1000';
                    var b = document.getElementsByTagName("body")[0];
                    b.appendChild(wt);
                </script>
            </td>
            <td class='ct' style='padding:0px 5px 0px 5px; text-align:right;'>
                <input id='iq' type='search' name='q' value='<?php
                    if($_GET['q']) echo qesc($_GET['q'],1);
                    elseif($_GET['i']) echo '#'.qesc($_GET['i'],1);
                    ?>' class='cq' autocapitalize='off'>
            </td>
            <td class='ct'>
                <input type='image' src='/g/surf.png' class='sm'>
            </td>
        </tr>
    </table>
    </form><br>
    <!-- end of input -->

    
    <!-- start of pages -->
    <br><br>
    <?php
    $pool = array();
    $cs1 = "SELECT T1.*, T2.ui AS ui2, T2.tn AS tn2";
    $cs2 = " FROM qix AS T1";
    $cs2.= " JOIN uri AS T2";
    $cs2.= " ON T1.ui=T2.ix";
    $cs2.= " WHERE";
    $cs2.= "     T1.iy='EngliSea'";
    $cs2.= " AND T1.oc='o'";
    $cs2.= " AND T1.tp='p'";
    $cs2.= " AND T2.ui LIKE '%://qindex.info/v.php?%'";
    $cs1.= $cs2;
    if($_GET['q']) {
        if(substr($_GET['q'],0,1)=='#' OR preg_match('/→/',$_GET['q'])) {
            $q = $cs1;
            $q.= " AND T2.ui LIKE '%&e=%'";
            $cs3  = " AND (T1.tl REGEXP '(^| |\n)".qesc($_GET['q'],7)."($| |\n)'";
            $cs3 .= " OR   T1.sy REGEXP '(^| |\n)".qesc($_GET['q'],7)."($| |\n)')";
            $cs3 .= " ORDER BY T1.ts";
            $q .= $cs3;
            $r = mysql_query($q,$p_link);
            while($a=mysql_fetch_array($r)) array_push($pool,$a);
        } else {
            $a1 = array();
            $a2 = array();
            $a3 = array();
            $a4 = array();
            $a5 = array();
            if($p_mobile) $n = 6; else $n = 12;
            $q = $cs1;
            $q.= " AND (T1.tl REGEXP '(^|#|\"|\\'|_| )".qesc($_GET['q'],7)."' OR T1.sy REGEXP '(^|#|\"|\\'|_| |\n)".qesc($_GET['q'],7)."')";
            $q.= " ORDER BY T1.r";
            $r = mysql_query($q,$p_link);
            while($a=mysql_fetch_array($r)) {
                if(preg_match('/&e=3/',$a['ui2'])) {
                    if($a['tl']==$_GET['q']) {
                        array_unshift($a1,$a);
                    } else {
                        array_unshift($a4,$a);
                    }
                } elseif(preg_match('/&e=2/',$a['ui2'])) {
                    if($a['tl']==$_GET['q']) {
                        array_unshift($a2,$a);
                    } else {
                        array_unshift($a4,$a);
                    }
                } elseif(preg_match('/&e=1/',$a['ui2'])) {
                    if($a['tl']==$_GET['q']) {
                        array_push($a3,$a);
                    } else {
                        array_push($a4,$a);
                    }
                } else {
                        array_push($a5,$a);
                }
            }
            $pool = array_merge($a1,$a2,$a3,$a4,$a5);
        }
        if($_GET['q']=='#bookmark' OR $_GET['q']=='#TOEIC') {
            echo "<center><table cellspacing='6' style='color:white; font-size:20px;'>\n";
            $q = "SELECT COUNT(*) AS c";
            $q.= $cs2.$cs3;
            $r = mysql_query($q,$p_link);
            $a = mysql_fetch_array($r);
            echo "<center>".number_format($a['c'])." clips</center>";
            
            $n = 0;
            foreach($pool as $i) {
                $n++;
                qword($i);
                if($n>4) break;
            }
            
            $q = $cs1;
            $q.= " AND T2.ui LIKE '%&e=%' AND T2.tn>0";
            $r = mysql_query($q." ORDER BY T1.ts LIMIT 100,1",$p_link);
            $a = mysql_fetch_array($r);
            echo "<script>var tf = ".$a['ts'].";</script>";
    
            if($_GET['q']=='#bookmark')  $q.= " AND T1.sy REGEXP '(^| |\n)".qesc('#lyrics' ,7)."($| |\n)'";
            elseif($_GET['q']=='#TOEIC') $q.= " AND T1.sy REGEXP '(^| |\n)".qesc('#mystery',7)."($| |\n)'";
            $q.= " ORDER BY T1.ts";
            $q.= " LIMIT 4";
            $r = mysql_query($q,$p_link);
            $n = 1;
            for($i=0; $i<$n; $i++) {
                echo "<tr>\n";
                for($j=0; $j<4; $j++) {
                    $a = mysql_fetch_array($r);
                    qfoto($a);
                }
                echo "</tr>\n";
            }
            $q = $cs1;
            $q.= " AND T2.ui LIKE '%&e=%'";
            $r = mysql_query($q." ORDER BY T1.ts LIMIT 100,1",$p_link);
            $a = mysql_fetch_array($r);
            echo "<script>var tw = ".$a['ts'].";</script>";
            echo "</table></center>\n";
        } else {
            $n = 0;
            foreach($pool as $i) {
                $n++;
                qsearch($i);
                if($n>99) break;
            }
        }
        if(substr($_GET['q'],0,1)!='#' AND !preg_match('/→/',$_GET['q'])) {
            echo "\n<div class='c1'>Google";
            echo "\n ➔ <a href='https://www.google.com/search?q=".$_GET['q']."+meaning&oq=".$_GET['q']."+meaning' target='_blank'>Dictionary</a>";
            echo "\n ➔ <a href='https://www.google.com/search?q=".$_GET['q']."&tbm=isch' target='_blank'>Image</a>";
            echo "\n ➔ <a href='https://youglish.com/pronounce/" .$_GET['q']."/english/us?' target='_blank'>YouGlish</a>";
            echo "\n</div>";
        }
    } elseif($_GET['v']) {
        if($_GET['v']=='elementary' OR $_GET['v']=='middle' OR $_GET['v']=='high') {
            $a = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');
            if(!$_GET['a']) {
                $n = rand(0,count($a)-1);
                $_GET['a'] = $a[$n];
            }
            echo "\n<div class='c4'>";
            for($i=0; $i<count($a); $i++) {
                if($_GET['a']==$a[$i]) echo "<span class='a1'>".strtoupper($a[$i])."</span> ";
                else echo "<a class='a2' href='".$_SERVER['PHP_SELF']."?v=".$_GET['v']."&a=".$a[$i]."'>".strtoupper($a[$i])."</a> ";
            }
            echo "\n</div>";
            $q = "SELECT * FROM wrd WHERE wd LIKE '".$_GET['a']."%' AND gd=";
            if($_GET['v']=='elementary') $q .= '1';
            elseif($_GET['v']=='middle') $q .= '2';
            elseif($_GET['v']=='high')   $q .= '3';
            $r = mysql_query($q,$p_link);
            while($b=mysql_fetch_array($r)) {
                echo "\n<div class='c1'><a href='".$_SERVER['PHP_SELF']."?q=".$b['wd']."' target='_blank'>".$b['wd']."</a></div>";
            }
        } elseif($_GET['v']=='ruth' OR $_GET['v']=='paul' OR $_GET['v']=='listening') {
            $q = "SELECT COUNT(*) AS c";
            $q.= $cs2;
            //$q.= " AND T2.ui LIKE '%4000\%20Essential\%20English\%20Words%'";
            if($_GET['v']=='ruth')          $q.= " AND T2.ui LIKE '%1000%20English%20Vocabulary%20For%20Beginners%'";
            elseif($_GET['v']=='paul')      $q.= " AND T2.ui LIKE '%4000\%20Essential\%20English\%20Words%'";
            elseif($_GET['v']=='listening') $q.= " AND T2.ui LIKE '%&e=2%'";
            $r = mysql_query($q,$p_link);
            $a = mysql_fetch_array($r);
            echo "<center>".number_format($a['c'])." clips are registered.</center>";

            $q = $cs1;
            //$q.= " AND T2.ui LIKE '%4000\%20Essential\%20English\%20Words%'";
            if($_GET['v']=='ruth')          $q.= " AND T2.ui LIKE '%1000%20English%20Vocabulary%20For%20Beginners%'";
            elseif($_GET['v']=='paul')      $q.= " AND T2.ui LIKE '%4000\%20Essential\%20English\%20Words%'";
            elseif($_GET['v']=='listening') $q.= " AND T2.ui LIKE '%&e=2%'";
            $q.= " ORDER BY T2.ts DESC";
            $q.= " LIMIT 100";
            $r = mysql_query($q,$p_link);
            $i = 0;
            while($a=mysql_fetch_array($r)) {
                if(Q_accss($a['ix'])) {
                    $i++;
                    qsearch($a);
                    if($i>=2) break;
                }
            }
            $q = $cs1;
            //$q.= " AND T2.ui LIKE '%4000\%20Essential\%20English\%20Words%'";
            if($_GET['v']=='ruth')          $q.= " AND T2.ui LIKE '%1000%20English%20Vocabulary%20For%20Beginners%'";
            elseif($_GET['v']=='paul')      $q.= " AND T2.ui LIKE '%4000\%20Essential\%20English\%20Words%'";
            elseif($_GET['v']=='listening') $q.= " AND T2.ui LIKE '%&e=2%'";
            $q.= " ORDER BY T1.ts";
            $q.= " LIMIT 100";
            $r = mysql_query($q,$p_link);
            $i = 0;
            while($a=mysql_fetch_array($r)) {
                if(Q_accss($a['ix'])) {
                    $i++;
                    qsearch($a);
                    if($i>=4) break;
                }
            }
        } else {
            $a = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');
            if(!$_GET['a']) {
                $n = rand(0,count($a)-1);
                $_GET['a'] = $a[$n];
            }
            echo "\n<div class='c4'>";
            for($i=0; $i<count($a); $i++) {
                if($_GET['a']==$a[$i]) echo "<span class='a1'>".strtoupper($a[$i])."</span> ";
                else echo "<a class='a2' href='".$_SERVER['PHP_SELF']."?v=".$_GET['v']."&a=".$a[$i]."'>".strtoupper($a[$i])."</a> ";
            }
            echo "\n</div>";
            $q = "SELECT DISTINCT T1.tl AS tl";
            $q.= $cs2;
            $q.= " AND T1.tl LIKE '".$_GET['a']."%'";
            if($_GET['v']=='todd')           $q.= " AND T2.ui LIKE '%1000%20English%20Vocabulary%20For%20Beginners%'";
            elseif($_GET['v']=='nation')     $q.= " AND T2.ui LIKE '%4000\%20Essential\%20English\%20Words%'";
            elseif($_GET['v']=='dictionary') $q.= " AND  T2.ui LIKE '%&e=2%'";
            $q.= " ORDER BY T1.tl";
            $r = mysql_query($q,$p_link);
            while($b=mysql_fetch_array($r)) {
                echo "\n<div class='c1'><a href='".$_SERVER['PHP_SELF']."?q=".$b['tl']."' target='_blank'>".$b['tl']."</a></div>";
            }
        }
    } elseif($_GET['i']) {
        echo "<center><table cellspacing='6' style='color:white; font-size:20px;'>\n";
        $q = $cs1;
        $q.= " AND T2.ui LIKE '%&e=%' AND T2.tn>0";
        $r = mysql_query($q." ORDER BY T1.ts LIMIT 100,1",$p_link);
        $a = mysql_fetch_array($r);
        echo "<script>var tf = ".$a['ts'].";</script>";

        if($_GET['i']=='math') $q.= " AND T2.ui LIKE '%&e=%'";
        else $q.= " AND T2.ui LIKE '%&e=3%'";
        $q.= " AND T2.tn>0";
        if($_GET['i']!='ΕͷցlιЅΞΛ') $q.= " AND T1.sy REGEXP '(^| |\n)".qesc('#'.$_GET['i'],7)."($| |\n)'";
        $q.= " ORDER BY T1.ts";
        $q.= " LIMIT 12";
        $r = mysql_query($q,$p_link);
        $n = 3;
        for($i=0; $i<$n; $i++) {
            echo "<tr>\n";
            for($j=0; $j<4; $j++) {
                $a = mysql_fetch_array($r);
                qfoto($a);
            }
            echo "</tr>\n";
        }
        echo "</table></center>\n";
    } else {
        echo "<center><table cellspacing='6' style='color:white; font-size:20px;'>\n";
        $q = "SELECT COUNT(*) AS c";
        $q.= $cs2;
        $r = mysql_query($q,$p_link);
        $a = mysql_fetch_array($r);
        echo "<tr><td colspan='4' style='color:gray;font-size:13px;'>\n";
        echo number_format($a['c'])." clips are registered.";
        echo "</td></tr>\n";
        
        $q = $cs1;
        $q.= " AND T2.ui LIKE '%&e=%' AND T2.tn>0";
        $r = mysql_query($q." ORDER BY T1.ts LIMIT 100,1",$p_link);
        $a = mysql_fetch_array($r);
        echo "<script>var tf = ".$a['ts'].";</script>";

        $q.= " AND T1.sy REGEXP '(^| |\n)".qesc('#front',7)."($| |\n)'";
        $q.= " ORDER BY T1.ts";
        $q.= " LIMIT 4";
        $r = mysql_query($q,$p_link);
        $n = 1;
        for($i=0; $i<$n; $i++) {
            echo "<tr>\n";
            for($j=0; $j<4; $j++) {
                $a = mysql_fetch_array($r);
                qfoto($a);
            }
            echo "</tr>\n";
        }
        $q = $cs1;
        $q.= " AND T2.ui LIKE '%&e=%'";
        $r = mysql_query($q." ORDER BY T1.ts LIMIT 100,1",$p_link);
        $a = mysql_fetch_array($r);
        echo "<script>var tw = ".$a['ts'].";</script>";
        // temerary start
        $q = "SELECT COUNT(*) AS c";
        $cs3 = " FROM qix AS T1";
        $cs3.= " JOIN uri AS T2";
        $cs3.= " ON T1.ui=T2.ix";
        $cs3.= " WHERE";
        $cs3.= "     T1.iy='EngliSea'";
        $cs3.= " AND T1.oc='o'";
        $cs3.= " AND T1.tp='p'";
        $cs3.= " AND T2.ui LIKE '%://qindex.info/v.php?%'";
        $cs3.= " AND (T2.ui LIKE '%&e=1%' OR T2.ui LIKE '%&e=2%') AND T1.sy=''";
        $q.= $cs3;
        $r = mysql_query($q,$p_link);
        $a = mysql_fetch_array($r);
        echo "<tr><td colspan='4' style='color:gray; font-size:13px;'>\n";
        echo number_format($a['c'])." remained.";
        echo "</td></tr>\n";
        $q = $cs1;
        $q.= " AND (T2.ui LIKE '%&e=1%' OR T2.ui LIKE '%&e=2%') AND T1.sy=''";
        $q.= " ORDER BY T1.ts";
        // temerary end
        $q.= " LIMIT 5";
        $r = mysql_query($q,$p_link);
        while($a=mysql_fetch_array($r)) qword($a);
        echo "</table></center>\n";
    } ?>
    <!-- end of pages -->
    <br>
    <div class='cd'><center><table cellspacing='0'><tr>
        <?php if($_GET['i'] OR $_GET['q']) { ?>
        -
        <a href='/EngliSEA.php'>
            <img src='/i/ptt.php?sw=0&ct=696969&t=home' class='txt'>
        </a>
        <?php } ?>
        <?php if($_GET['i']!='ΕͷցlιЅΞΛ') { ?>
        -
        <a href='/EngliSEA.php?i=ΕͷցlιЅΞΛ'>
            <img src='/i/ptt.php?sw=0&ct=696969&t=photos' class='txt'>
        </a>
        <?php } ?>
        <?php if($_GET['q']!='#bookmark') { ?>
        -
        <a href='/EngliSEA.php?q=%23bookmark'>
            <img src='/i/ptt.php?sw=0&ct=696969&t=bookmarks' class='txt'>
        </a>
        <?php } ?>
        <?php if($_GET['q']!='#TOEIC') { ?>
        -
        <a href='/EngliSEA.php?q=%23TOEIC'>
            <img src='/i/ptt.php?sw=0&ct=696969&t=TOEIC' class='txt'>
        </a>
        <?php } ?>
        <?php if($_GET['i']!='math' AND false) { ?>
        -
        <a href='/EngliSEA.php?i=math'>
            <img src='/i/ptt.php?sw=0&ct=696969&t=maths' class='txt'>
        </a>
        <?php } ?>
        -
        <a href='/EngliSEA.php?q=%23listening' target='_blank'>
            <img src='/i/ptt.php?sw=0&ct=696969&t=listening' class='txt'>
        </a>
    </tr></table></center></div>
    <div class='bl'><img class='bi' src='/g/refresh.png' onclick="location.reload();"></div>
    <?php if($_SERVER["HTTP_REFERER"]) { ?>
        <div class='br'><img class='bi' src='/g/bttn_close.png' onclick="window.close();"></div>
    <?php } ?>
    <br>
</body></html>