function table_all_videos_search()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $users = new usersMenus();
    $TB_HEIGHT = 500;
    $TB_WIDTH = 910;
    $uid = $_GET["uid"];
    $t = time();
    $new_entry = $tpl->javascript_parse_text("{new_backup_rule}");
    $imapserv = $tpl->_ENGINE_parse_body("{imap_server}");
    $account = $tpl->_ENGINE_parse_body("{account}");
    //	$title=$tpl->_ENGINE_parse_body("$attachments_storage {items}: «$size»");
    $filessize = $tpl->_ENGINE_parse_body("{filesize}");
    $action_delete_rule = $tpl->javascript_parse_text("{action_delete_rule}");
    $enable = $tpl->_ENGINE_parse_body("{enable}");
    $compile_rules = $tpl->_ENGINE_parse_body("{compile_rules}");
    $online_help = $tpl->_ENGINE_parse_body("{online_help}");
    $enabled = $tpl->_ENGINE_parse_body("{enabled}");
    $items = $tpl->_ENGINE_parse_body("{items}");
    $error_want_operation = $tpl->javascript_parse_text("{error_want_operation}");
    $events = $tpl->javascript_parse_text("{events}");
    $category = $tpl->javascript_parse_text("{category}");
    $title = $tpl->javascript_parse_text("{video_title}");
    $created = $tpl->javascript_parse_text("{created}");
    $duration = $tpl->javascript_parse_text("{duration}");
    $hits = $tpl->javascript_parse_text("{hits}");
    $categories = $tpl->javascript_parse_text("{categories}");
    if (!isset($_SESSION["QUERY_YOUTUBE_LIMIT"])) {
        $_SESSION["QUERY_YOUTUBE_LIMIT"] = 250;
    }
    $q = new mysql_squid_builder();
    $search = string_to_flexquery("videos-search");
    $filters = array();
    $filters[] = SearchToSql("category", $_SESSION["QUERY_YOUTUBE_CATE"]);
    $sql = "SELECT *  FROM youtube_objects WHERE 1 {$search} " . @implode($filters, " ") . " ORDER BY uploaded DESC LIMIT 0,{$_SESSION["QUERY_YOUTUBE_LIMIT"]}";
    $results = $q->QUERY_SQL($sql);
    $boot = new boostrap_form();
    if (!$q->ok) {
        die("<p class=text-error>{$q->mysql_error}</p>");
    }
    $seconds = $tpl->_ENGINE_parse_body("{seconds}");
    $minutes = $tpl->_ENGINE_parse_body("{minutes}");
    $hours = $tpl->_ENGINE_parse_body("{hours}");
    while ($ligne = mysql_fetch_assoc($results)) {
        $youtubeid = $ligne["youtubeid"];
        $color = "black";
        $unit = $seconds;
        $ligne["duration"] = format_time($ligne["duration"]);
        $urljsSIT = "Loadjs('miniadm.webstats.youtubeid.php?youtubeid={$youtubeid}')";
        $link = $boot->trswitch($urljsSIT);
        $jsvideo = $boot->trswitch("Loadjs('miniadm.webstats.youtubeid.php?youtubeid={$youtubeid}');");
        $tr[] = "\n\t\t<tr id='{$id}'>\n\t\t<td {$jsvideo}><img  src='{$page}?thumbnail={$youtubeid}' class=img-polaroid></td>\n\t\t<td {$link} nowrap><i class='icon-time'></i>&nbsp;{$ligne["uploaded"]}</td>\n\t\t<td {$link}><i class='icon-info-sign'></i>&nbsp;{$ligne["title"]}</td>\n\t\t<td {$link} nowrap><i class='icon-info-sign'></i>&nbsp;{$ligne["category"]}</td>\n\t\t<td {$link} nowrap><i class='icon-info-sign'></i>&nbsp;{$ligne["duration"]}</td>\n\t\t<td {$link} nowrap><i class='icon-info-sign'></i>&nbsp;{$ligne["hits"]}</td>\n\t\t</tr>";
    }
    echo $tpl->_ENGINE_parse_body("\n\t<table class='table table-bordered table-hover'>\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>{$created}</th>\n\t\t\t\t\t<th>{$title}</th>\n\t\t\t\t\t<th>{$category} {$_SESSION["QUERY_YOUTUBE_CATE"]}</th>\n\t\t\t\t\t<th>{$duration}</th>\n\t\t\t\t\t<th>{$hits}</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t <tbody>\n\t\t\t") . @implode("", $tr) . "</tbody></table>";
}
function search_database()
{
    $page = 1;
    $MyPage = CurrentPageName();
    $users = new usersMenus();
    $tpl = new templates();
    $sock = new sockets();
    $q = new mysql_storelogs();
    if (!$q->BD_CONNECT()) {
        senderror($q->mysql_error);
    }
    if ($q->start_error != null) {
        senderror($q->start_error);
    }
    $table = "files_info";
    $tableOrg = $table;
    $database = $q->database;
    $t = time();
    $delete_alert = $tpl->javascript_parse_text("{delete_this_item}");
    $MySQLType = $tpl->_ENGINE_parse_body($q->MYSQLTypeText);
    //if(!$q->TABLE_EXISTS($table,$database)==0){senderror("{table_does_not_exists}: <strong>$database/$table</strong> $MySQLType: `$q->SocketName`!");}
    if ($q->COUNT_ROWS($table, $database) == 0) {
        senderror("{$table}/{$database} is empty");
    }
    $searchstring = string_to_flexquery("search-database");
    $limit = "LIMIT 0,250";
    if (is_numeric($_GET["xtime"])) {
        $WHERE1 = " (DATE_FORMAT(filetime,'%Y-%m-%d')='" . date("Y-m-d") . "') AND";
        unset($_SESSION["QUERY_SYSLOG_DATE"]);
    }
    if ($_SESSION["QUERY_SYSLOG_LIMIT"] > 0) {
        $limit = "LIMIT 0,{$_SESSION["QUERY_SYSLOG_LIMIT"]}";
    }
    $filters = array();
    $filters[] = SearchToSql("DATE_FORMAT(filetime,'%Y-%m-%d')", $_SESSION["QUERY_SYSLOG_DATE"]);
    $filters[] = SearchToSql("filename", $_SESSION["QUERY_SYSLOG_FILE"]);
    $filters[] = SearchToSql("hostname", $_SESSION["QUERY_SYSLOG_HOST"]);
    $table = "(SELECT `filename`,`taskid`,`storeid`,`filesize`,`filetime`,`hostname` FROM {$table}\n\t\t\tWHERE {$WHERE1} (`filename` LIKE 'auth.log%') OR (filename LIKE 'squid-access%')) as t";
    $sql = "SELECT *  FROM {$table} WHERE 1 {$searchstring} " . @implode(" ", $filters) . " ORDER BY `filetime` DESC LIMIT 0,250";
    writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
    $results = $q->QUERY_SQL($sql, $database);
    if (!$q->ok) {
        senderror("{$q->mysql_error}");
    }
    if (mysql_num_rows($results) == 0) {
        senderror("Query return empty array");
    }
    $boot = new boostrap_form();
    while ($ligne = mysql_fetch_assoc($results)) {
        $md5S = md5(serialize($ligne));
        $filename = $ligne["filename"];
        $hostname = $ligne["hostname"];
        $storeid = $ligne["storeid"];
        $taskid = $ligne["taskid"];
        $filesize = FormatBytes($ligne["filesize"] / 1024);
        $filetime = $ligne["filetime"];
        $delete = imgsimple("delete-32.png", null, "Delete{$t}('{$storeid}','{$md5S}')");
        $action = "&nbsp;";
        if (preg_match("#auth\\.log-.*?#", $ligne["filename"])) {
            $action = imgsimple("32-import.png", null, "Loadjs('squid.restoreSource.php?filename={$ligne["filename"]}&storeid={$storeid}')");
        }
        if (preg_match("#squid-access-(.*?)\\.log\\.#", $ligne["filename"])) {
            $action = imgsimple("32-import.png", null, "Loadjs('squid.restoreSource.php?filename={$ligne["filename"]}&storeid={$storeid}')");
        }
        $download = "<a href=\"{$MyPage}?download={$storeid}&filename={$ligne["filename"]}&storeid={$storeid}\"><img src='img/arrow-down-32.png'></a>";
        $js = "Loadjs('logrotate.php?log-js=yes&filename={$filename}&storeid={$storeid}&t=1368560783');";
        $trlink = $boot->trswitch($js);
        $tr[] = "\n\t\t<tr id='{$md5S}'>\n\t\t<td nowrap {$trlink}>{$filetime}</td>\n\t\t<td nowrap {$trlink}>{$filename}</td>\n\t\t<td nowrap {$trlink}>{$hostname}</td>\n\t\t<td nowrap {$trlink}>{$filesize}</td>\n\t\t<td width=1% align=center>{$download}</td>\n\t\t<td width=1% align=center>{$action}</td>\n\t\t<td width=1% align=center>{$delete}</td>\n\t\t</tr>\n\t\t";
    }
    echo $tpl->_ENGINE_parse_body("\n\n\t\t\t<table class='table table-bordered table-hover'>\n\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>{date}</th>\n\t\t\t\t\t<th>{filename}</th>\n\t\t\t\t\t<th>{hostname}</th>\n\t\t\t\t\t<th>{size}</th>\n\t\t\t\t\t<th>&nbsp;</th>\n\t\t\t\t\t<th>&nbsp;</th>\n\t\t\t\t\t<th>&nbsp;</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t <tbody>\n\t\t\t") . @implode("", $tr) . "</tbody></table>\n\t\t\t<script>\n\t\t\tvar memedb{$t}='';\n\t\t\tvar xDelete{$t}= function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>2){alert(results);return;}\n\t\t\t\$('#'+memedb{$t}).remove();\n}\n\n\t\t\tfunction Delete{$t}(ID,md){\n\t\t\tmemedb{$t}=md;\n\t\t\tif(confirm('{$delete_alert} '+ID+' ?')){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('syslog-delete',ID);\n\t\t\tXHR.sendAndLoad('{$MyPage}', 'POST', xDelete{$t});\n}\n}\n\t\t\t</script>";
}