Файл: public_html/tmp/inc/mode.sql.php
Строк: 31
<?php
#by FeST
#ICQ : 3452223
#Действия с таблицами
$table=chek($_GET['table']);
$sql=$_REQUEST['sql'];
$order=isset($_GET['order']) ? chek($_GET['order']) : NULL;
$ord=isset($_GET['ord']) ? chek($_GET['ord']) : NULL;
    if($order!=NULL)$order_q="ORDER BY `".$order."` ".$ord;else $order_q=NULL;
        
if(isset($_POST['go'])){
    $page=($_POST['start']*10)-10;
    header("Location:index.php?table=".$table."&mode=sql&sql=".chek($sql)."&start=".$page.($order!=NULL ? "&order=".$order : "").''.($ord!=NULL ? "&ord=".$ord : ""));
    exit;
}
    
echo "Таблица "<a href='index.php?table=".$table."&mode=show'><b>".$table."</b></a>"->MySQL<br/>
<form method='post' action='index.php?mode=sql&table=".$table."&".mt_rand()."'>
MySQL : <br/>
SELECT * FROM `".$table."` WHERE<br/>
<input name='sql'  value='".chek($sql)."' /><br/>
<input name='submit' value='Запрос' type='submit' /></form>
";
    if(!empty($sql)){
$total=mysql_result(mysql_query("SELECT COUNT(*) FROM `".$table."` WHERE ".$sql),0);
    
    
    $query="SHOW FULL FIELDS FROM ".$table."";
        $arr = mysql_query($query); 
        if(!$arr) echo "Произошла ошибка: ".mysql_error(); 
            if(mysql_num_rows($arr)) 
            { 
             $for_count=mysql_num_rows($arr);
                echo "Результат:
                <table width='100%' border='1'><tr align='center'>";
                    
                    while($q=mysql_fetch_array($arr))
                    echo "<td><b><a href='index.php?table=".$table."&mode=sql&order=".$q[0]."&sql=".chek($sql)."&ord=ASC'>".$q[0]."</a>
                    ".($ord!='ASC' ? "<a href='index.php?table=".$table."&mode=sql&order=".$q[0]."&sql=".chek($sql)."&ord=ASC'><img src='i/asc.png' /></a>" : "<a href='index.php?table=".$table."&mode=sql&sql=".chek($sql)."&order=".$q[0]."&ord=DESC'><img src='i/desc.png' /></a>")."</b></td>";
                    
                    echo "</tr>";
                    
                $total=mysql_result(mysql_query("SELECT COUNT(*) FROM `".$table."` WHERE ".$sql),0);
                if($total>0){
                
                    $quert=mysql_query("SELECT * FROM `".$table."` WHERE ".$sql." ".$order_q." LIMIT ".$start.",10");    
                        
                        $get=0;
                        while($arr=mysql_fetch_array($quert)){
                        echo "<tr class='".($get%2 ? "tr1" : "tr2")."' align='center'>";
                        
                            for($i=0;$i<$for_count;$i++)
                            echo "<td>".chek(mb_substr($arr[$i],0,100,'UTF-8'))."</td>";
                        
                        echo "</tr>";
                        $get++;
                        }        
                            }
                            else
                            echo "Таблица<br/>пуста";
                            
                            
                echo "</table>";
                if ($total > 10){
                            echo str_pages('index.php?table='.$table.'&mode=browse&'.($order!=NULL ? "order=".$order."&" : "").''.($ord!=NULL ? "ord=".$ord."&" : ""), $start, $total, 10);
   echo '<form method="post" action="index.php?table='.$table.'&mode=browse'.($order!=NULL ? "&order=".$order : "").''.($ord!=NULL ? "&ord=".$ord : "").'">
    Стр. <input type="text" name="start" value="'.(($start+10)/10).'" size="2"/>
    <input type="submit" name="go" value=">>" />
    </form>';}
        
                
                
            }
    }
?>