function output_pages_from_cache($http, $otp) { $npg = $_SESSION['prmb'][6]; $page = $_SESSION['page']; $min = ($page - 1) * $npg; $max = $page * $npg; if (is_array($otp)) { foreach ($otp as $id => $nb) { if (is_numeric($id)) { $i++; if ($i >= $min && $i < $max) { $mg = $http . '/imgc/' . first_img($nb[3]); if (is_link($mg)) { $ret .= btn('imgl', image($mg, '', 50)); } $ret .= bal('h2', lka($http . '/' . $id, $nb[2])); $ret .= btn('txtx', $nb[1]) . ' '; if (rstr(27)) { $ret .= btn('txtsmall', mkday($nb[0], 1)) . ' ' . pub_link($nb[9]) . ' '; } if (rstr(25)) { $ret .= btn('txtsmall', art_length($nb[8])); } $ret .= br() . br(); } } } } $n_pages = nb_page($i, $npg, $page); return $n_pages . $ret . $n_pages; }
function by_pages($r, $p) { $n = count($r); $page = $p ? $p : 1; $npg = 10; $ret = nb_page($n, $npg, $page); $min = ($page - 1) * $npg; $max = $page * $npg; for ($i = 0; $i < $n; $i++) { if ($i >= $min && $i < $max) { $ret .= $r[$i]; } } return $ret; }
function output_pages($otp, $md, $tp) { $rch = get('search'); if (rstr(39) or $md == 'flow') { $fw = 1; $_POST['flow'] = 1; } $npg = $_SESSION['prmb'][6]; $page = $_SESSION['page']; $min = ($page - 1) * $npg; $max = $page * $npg; $md = slct_media($md); if (is_array($otp)) { foreach ($otp as $id => $nb) { if ($id > 0) { $i++; if ($md == 'prw') { $media = $nb; } elseif ($rch) { $media = 'rch'; } else { $media = $md; } if ($i >= $min && $i < $max) { $ret .= art_read_b($id, $nb, $media, $tp); } elseif ($fw) { $ret .= div(atd($id) . atc($media), ''); } } } } if (!$fw) { $nbpg = nb_page($i, $npg, $page); } return $nbpg . $ret . $nbpg; }
function play_arts($frm, $prw, $tp) { $prw = slct_media($prw); $page = $_SESSION['page']; $npg = $_SESSION['prmb'][6]; $min = ($page - 1) * $npg; $r = load_arts($frm, $prw); //pr($r); $nbarts = count($r); if (!$r) { return; } //$rb=req_load($r); foreach ($r as $k => $v) { $i++; if ($prw == 'auto') { $prw = $rb[$k]['re'] >= 2 ? 2 : 1; } if ($i >= $min && $i < $npg * $page && $v) { $ret .= batch_load($v, $prw, $tp); } elseif (rstr(39)) { $ret .= div(atd($k) . atc($prw), ''); } } if (!rstr(39)) { $nbpg = nb_page($nbarts, $npg, $page); } return $nbpg . $ret . $nbpg; }
} } //view of all group's machin if (isset($systemid)) { if ($_POST['tri2'] == "") { $_POST['tri2'] = 1; } if (!isset($_POST["pcparpage"]) and isset($_GET['res_pag'])) { $_POST["pcparpage"] = $_GET['res_pag']; } if (!isset($_POST["page"]) and isset($_GET['page'])) { $_POST["page"] = $_GET['page']; } $form_name = 'nb_4_pag'; echo open_form($form_name); $limit = nb_page($form_name); $sql = "select download_servers.HARDWARE_ID ID,\n\t\t\t hardware.NAME,\n\t\t\t hardware.IPADDR,\n\t\t\t hardware.DESCRIPTION,\n\t\t\t download_servers.URL,\n\t\t\t download_servers.ADD_REP\n\t\tfrom hardware right join download_servers on hardware.id=download_servers.hardware_id\n\t\twhere download_servers.GROUP_ID=" . $systemid . " order by " . $_POST['tri2'] . " " . $_POST['sens']; $reqCount = "select count(*) nb from (" . $sql . ") toto"; $resCount = mysqli_query($_SESSION['OCS']["readServer"], $reqCount); $valCount = mysqli_fetch_array($resCount); $sql .= " limit " . $limit["BEGIN"] . "," . $limit["END"]; $result = mysqli_query($_SESSION['OCS']["readServer"], $sql); $i = 0; if ($_POST['sens'] == "ASC") { $sens = "DESC"; } else { $sens = "ASC"; } while ($colname = mysqli_fetch_field($result)) { $col = $colname->name; $deb = "<a OnClick='tri(\"" . $col . "\",\"tri2\",\"" . $sens . "\",\"sens\",\"" . $form_name . "\")' >";
function make_table_bypage($r, $csa, $csb) { if ($r["_menus_"]) { foreach ($r["_menus_"] as $k => $v) { $td .= balc("td", $csa, $v); } $tr = balc("tr", '', $td); unset($r["_menus_"]); } $n = count($r) + 1; $page = $_SESSION['page']; $npg = 1000; req('spe'); $ret = nb_page($n, $npg, $page, ''); $min = ($page - 1) * $npg; $max = $page * $npg; if (is_array($r)) { foreach ($r as $k => $v) { $td = ""; $i++; if ($i >= $min && $i < $max && is_array($v)) { foreach ($v as $ka => $va) { $td .= balc("td", $csb, $va); } } if ($td) { $tr .= balc("tr", "", $td); } } } return $ret . balc("table", '', $tr) . $ret; }
function make_tables_pages($otp, $qrt) { list($p, $page) = explode('/', $_GET['set']); $rtt = make_table_titles($qrt); $npg = 41; $page = $page ? $page : 1; $min = ($page - 1) * $npg; $max = $page * $npg; if (is_array($otp)) { foreach ($otp as $id => $va) { $i++; if ($i >= $min && $i < $max) { $rtr[] = $va; } } } $n_pages = nb_page($i, $npg, $page); $ret = make_tables($rtt, $rtr, 'txtblc', ""); return $n_pages . $ret . $n_pages; }
function tab_req($table_name, $list_fields, $default_fields, $list_col_cant_del, $queryDetails, $form_name, $width = '100', $tab_options = '') { global $protectedPost, $l, $pages_refs; if (!$tab_options['AS']) { $tab_options['AS'] = array(); } if ($_SESSION['OCS']["tabcache"] == 0) { $tab_options['CACHE'] = 'RESET'; } echo "<script language='javascript'>\n\t\tfunction checkall()\n\t\t {\n\t\t\tfor(i=0; i<document." . $form_name . ".elements.length; i++)\n\t\t\t{\n\t\t\t\tif(document." . $form_name . ".elements[i].name.substring(0,5) == 'check'){\n\t\t\t if (document." . $form_name . ".elements[i].checked)\n\t\t\t\t\t\tdocument." . $form_name . ".elements[i].checked = false;\n\t\t\t\t\telse\n\t\t\t\t\t\tdocument." . $form_name . ".elements[i].checked = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t</script>"; $link = $_SESSION['OCS']["readServer"]; //show select nb page $limit = nb_page($form_name, 100, "", "", $table_name); //you want to filter your result if (isset($tab_options['FILTRE'])) { $Details = filtre($tab_options['FILTRE'], $form_name, $queryDetails, $tab_options['ARG_SQL'], $tab_options['ARG_SQL_COUNT']); $queryDetails = $Details['SQL']; if (is_array($Details['ARG'])) { $tab_options['ARG_SQL'] = $Details['ARG']; } if (is_array($Details['ARG_COUNT'])) { $tab_options['ARG_SQL_COUNT'] = $Details['ARG_COUNT']; } } //by default, sort by column 1 if ($protectedPost['tri_' . $table_name] == "" or !in_array($protectedPost['tri_' . $table_name], $list_fields) and !in_array($protectedPost['tri_' . $table_name], $tab_options['AS'])) { $protectedPost['tri_' . $table_name] = 1; } //by default, sort ASC if ($protectedPost['sens_' . $table_name] == "") { $protectedPost['sens_' . $table_name] = 'ASC'; } //if data is signed and data = ip $tab_iplike = array('H.IPADDR', 'IPADDRESS', 'IP', 'IPADDR'); if (in_array(mb_strtoupper($protectedPost['tri_' . $table_name]), $tab_iplike)) { $queryDetails .= " order by INET_ATON(" . $protectedPost['tri_' . $table_name] . ") " . $protectedPost['sens_' . $table_name]; } elseif ($tab_options['TRI']['SIGNED'][$protectedPost['tri_' . $table_name]]) { $queryDetails .= " order by cast(" . $protectedPost['tri_' . $table_name] . " as signed) " . $protectedPost['sens_' . $table_name]; } elseif ($tab_options['TRI']['DATE'][$protectedPost['tri_' . $table_name]]) { if (isset($tab_options['ARG_SQL'])) { $queryDetails .= " order by STR_TO_DATE(%s,'%s') %s"; $tab_options['ARG_SQL'][] = $protectedPost['tri_' . $table_name]; $tab_options['ARG_SQL'][] = $tab_options['TRI']['DATE'][$protectedPost['tri_' . $table_name]]; $tab_options['ARG_SQL'][] = $protectedPost['sens_' . $table_name]; } else { $queryDetails .= " order by STR_TO_DATE(" . $protectedPost['tri_' . $table_name] . ",'" . $tab_options['TRI']['DATE'][$protectedPost['tri_' . $table_name]] . "') " . $protectedPost['sens_' . $table_name]; } } else { $queryDetails .= " order by " . $protectedPost['tri_' . $table_name] . " " . $protectedPost['sens_' . $table_name]; } if (isset($protectedPost["pcparpage"]) and $protectedPost["pcparpage"] <= 200) { $limit_result_cache = 200; $force_no_cache = false; } elseif (isset($protectedPost["pcparpage"])) { $limit_result_cache = $protectedPost["pcparpage"]; $force_no_cache = true; } //$tab_options['CACHE']='RESET'; //suppression de la limite de cache //si on est sur la m�me page mais pas sur le m�me onglet if ($_SESSION['OCS']['csv']['SQL'][$table_name] != $queryDetails or isset($tab_options['ARG_SQL']) and $tab_options['ARG_SQL'] != $_SESSION['OCS']['csv']['ARG'][$table_name]) { unset($protectedPost['page']); $tab_options['CACHE'] = 'RESET'; } //Delete cache if ($tab_options['CACHE'] == 'RESET' or isset($protectedPost['SUP_PROF']) and $protectedPost['SUP_PROF'] != '' or isset($protectedPost['RESET']) and $protectedPost['RESET'] != '') { if ($_SESSION['OCS']['DEBUG'] == 'ON') { msg_info($l->g(5003)); } unset($_SESSION['OCS']['DATA_CACHE'][$table_name]); unset($_SESSION['OCS']['NUM_ROW'][$table_name]); } if (isset($_SESSION['OCS']['NUM_ROW'][$table_name]) and $_SESSION['OCS']['NUM_ROW'][$table_name] > $limit["BEGIN"] and $_SESSION['OCS']['NUM_ROW'][$table_name] <= $limit["END"] and !isset($_SESSION['OCS']['DATA_CACHE'][$table_name][$limit["END"]])) { if ($_SESSION['OCS']['DEBUG'] == 'ON') { msg_info($l->g(5004) . " " . $limit["END"] . " => " . ($_SESSION['OCS']['NUM_ROW'][$table_name] - 1)); } $limit["END"] = $_SESSION['OCS']['NUM_ROW'][$table_name] - 1; } if (isset($_SESSION['OCS']['DATA_CACHE'][$table_name][$limit["END"]]) and isset($_SESSION['OCS']['NUM_ROW'][$table_name])) { if ($_SESSION['OCS']['DEBUG'] == 'ON') { msg_info($l->g(5005)); } $var_limit = $limit["BEGIN"]; while ($var_limit <= $limit["END"]) { $sql_data[$var_limit] = $_SESSION['OCS']['DATA_CACHE'][$table_name][$var_limit]; $var_limit++; } $num_rows_result = $_SESSION['OCS']['NUM_ROW'][$table_name]; if (isset($_SESSION['OCS']['REPLACE_VALUE_ALL_TIME'])) { $tab_options['REPLACE_VALUE_ALL_TIME'] = $_SESSION['OCS']['REPLACE_VALUE_ALL_TIME']; } $result_data = gestion_donnees($sql_data, $list_fields, $tab_options, $form_name, $default_fields, $list_col_cant_del, $queryDetails, $table_name); $data = $result_data['DATA']; $entete = $result_data['ENTETE']; $correct_list_col_cant_del = $result_data['correct_list_col_cant_del']; $correct_list_fields = $result_data['correct_list_fields']; $i = 1; } else { //search static values if (isset($_SESSION['OCS']['SQL_DATA_FIXE'][$table_name])) { foreach ($_SESSION['OCS']['SQL_DATA_FIXE'][$table_name] as $key => $sql) { if (!isset($_SESSION['OCS']['ARG_DATA_FIXE'][$table_name][$key])) { $arg = array(); } else { $arg = $_SESSION['OCS']['ARG_DATA_FIXE'][$table_name][$key]; } if ($table_name == "TAB_MULTICRITERE") { $sql .= " and hardware_id in (" . implode(',', $_SESSION['OCS']['ID_REQ']) . ") group by hardware_id "; //ajout du group by pour r�gler le probl�me des r�sultats multiples sur une requete //on affiche juste le premier crit�re qui match $result = mysql_query($sql, $_SESSION['OCS']["readServer"]); } else { //add sort on column if need it if ($protectedPost['tri_fixe'] != '' and strstr($sql, $protectedPost['tri_fixe'])) { $sql .= " order by '%s' %s"; array_push($protectedPost['tri_fixe'], $arg); array_push($protectedPost['sens_' . $table_name], $arg); } $result = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg); } while ($item = mysql_fetch_object($result)) { if ($item->HARDWARE_ID != "") { $champs_index = $item->HARDWARE_ID; } elseif ($item->FILEID != "") { $champs_index = $item->FILEID; } //echo $champs_index."<br>"; if (isset($tablename_fixe_value)) { if (strstr($sql, $tablename_fixe_value[0])) { $list_id_tri_fixe[] = $champs_index; } } foreach ($item as $field => $value) { if ($field != "HARDWARE_ID" and $field != "FILEID" and $field != "ID") { // echo "<br>champs => ".$field." valeur => ".$value; $tab_options['REPLACE_VALUE_ALL_TIME'][$field][$champs_index] = $value; } } } } if (isset($tab_options['REPLACE_VALUE_ALL_TIME'])) { $_SESSION['OCS']['REPLACE_VALUE_ALL_TIME'] = $tab_options['REPLACE_VALUE_ALL_TIME']; } } // print_r($tab_options['VALUE']); // print_r($list_id_tri_fixe); //on vide les valeurs pr�c�dentes //pour optimiser la place sur le serveur if (!isset($tab_options['SAVE_CACHE'])) { unset($_SESSION['OCS']['csv'], $_SESSION['OCS']['list_fields']); } $_SESSION['OCS']['csv']['SQL'][$table_name] = $queryDetails; if (isset($tab_options['ARG_SQL'])) { $_SESSION['OCS']['csv']['ARG'][$table_name] = $tab_options['ARG_SQL']; } //requete de count unset($_SESSION['OCS']['NUM_ROW']); if (!isset($_SESSION['OCS']['NUM_ROW'][$table_name])) { unset($_SESSION['OCS']['NUM_ROW']); if (!isset($tab_options['SQL_COUNT'])) { $querycount_begin = "select count(*) count_nb_ligne "; if (stristr($queryDetails, "group by") and substr_count($queryDetails, "group by") == 1) { $querycount_end = "," . substr($queryDetails, 6); } else { $querycount_end = stristr($queryDetails, 'from '); } $querycount = $querycount_begin . $querycount_end; } else { $querycount = $tab_options['SQL_COUNT']; } if (isset($tab_options['ARG_SQL_COUNT'])) { $resultcount = mysql2_query_secure($querycount, $link, $tab_options['ARG_SQL_COUNT']); } elseif (isset($tab_options['ARG_SQL'])) { $resultcount = mysql2_query_secure($querycount, $link, $tab_options['ARG_SQL']); } else { $resultcount = mysql2_query_secure($querycount, $link); } //if this query is only for show data (like : //select '%s' as NOM,'%s' as LIBELLE) if (!stristr($queryDetails, "from")) { unset($resultcount); } //En dernier recourt, si le count n'est pas bon, //on joue la requete initiale if (!$resultcount) { if (isset($tab_options['ARG_SQL'])) { $resultcount = mysql2_query_secure($queryDetails, $link, $tab_options['ARG_SQL']); } else { $resultcount = mysql2_query_secure($queryDetails, $link); } } if ($resultcount) { $num_rows_result = mysql_num_rows($resultcount); } //echo "<b>".$num_rows_result."</b>"; if ($num_rows_result == 1) { $count = mysql_fetch_object($resultcount); // echo $queryDetails; if ($count->count_nb_ligne > 0) { $num_rows_result = $count->count_nb_ligne; } } $_SESSION['OCS']['NUM_ROW'][$table_name] = $num_rows_result; } else { $num_rows_result = $_SESSION['OCS']['NUM_ROW'][$table_name]; if ($_SESSION['OCS']['DEBUG'] == 'ON') { msg_info($l->g(5007)); } } //echo $querycount; //FIN REQUETE COUNT if (isset($limit)) { if ($limit["END"] < $limit_result_cache) { $queryDetails .= " limit " . $limit_result_cache; } else { $queryDetails .= " limit " . floor($limit["END"] / $limit_result_cache) * $limit_result_cache . "," . $limit_result_cache; } } if (isset($tab_options['ARG_SQL'])) { $resultDetails = mysql2_query_secure($queryDetails, $link, $tab_options['ARG_SQL']); } else { $resultDetails = mysql2_query_secure($queryDetails, $link); } flush(); $i = floor($limit["END"] / $limit_result_cache) * $limit_result_cache; $index = $limit["BEGIN"]; $value_data_begin = $limit["BEGIN"]; $value_data_end = $limit["END"] + 1; //echo $num_rows_result; if ($index > $num_rows_result) { $value_data_end = $num_rows_result - 1; } //echo $queryDetails; while ($item = mysql_fetch_object($resultDetails)) { if ($i >= $index) { unset($champs_index); if ($item->ID != "") { $champs_index = $item->ID; } elseif ($item->FILEID != "") { $champs_index = $item->FILEID; } if (isset($list_id_tri_fixe)) { $index = $champs_index; } if ($index > $num_rows_result) { break; } //on arr�te le traitement si on est au dessus du nombre de ligne foreach ($item as $key => $value) { $sql_data_cache[$index][$key] = $value; if ($index < $value_data_end and $index >= $value_data_begin) { flush(); $sql_data[$index][$key] = $value; foreach ($list_fields as $key => $value) { if ($tab_options['VALUE'][$key]) { if ($tab_options['VALUE'][$key][$champs_index] == "" and isset($tab_options['VALUE_DEFAULT'][$key])) { $sql_data[$index][$value] = $tab_options['VALUE_DEFAULT'][$key]; } else { $sql_data[$index][$value] = $tab_options['VALUE'][$key][$champs_index]; } } } } //ajout des valeurs statiques foreach ($list_fields as $key => $value) { if ($tab_options['VALUE'][$key]) { if ($tab_options['VALUE'][$key][$champs_index] == "" and isset($tab_options['VALUE_DEFAULT'][$key])) { $sql_data_cache[$index][$value] = $tab_options['VALUE_DEFAULT'][$key]; } else { $sql_data_cache[$index][$value] = $tab_options['VALUE'][$key][$champs_index]; } } } } $index++; } $i++; } // if ($i == 1){ // $num_rows_result=1; // $_SESSION['OCS']['NUM_ROW'][$table_name]=1; // } flush(); //traitement du tri des r�sultats sur une valeur fixe if (isset($list_id_tri_fixe)) { $i = 0; //parcourt des id tri�s while ($list_id_tri_fixe[$i]) { if ($limit["BEGIN"] <= $i and $i < $limit["BEGIN"] + $limit_result_cache) { $sql_data_tri_fixe[$i] = $sql_data[$list_id_tri_fixe[$i]]; } $i++; } unset($sql_data); $sql_data = $sql_data_tri_fixe; } // print_r($sql_data_cache); //on vide le cache des autres tableaux //pour optimiser la place dispo sur le serveur unset($_SESSION['OCS']['DATA_CACHE']); if (!$force_no_cache) { $_SESSION['OCS']['DATA_CACHE'][$table_name] = $sql_data_cache; } $result_data = gestion_donnees($sql_data, $list_fields, $tab_options, $form_name, $default_fields, $list_col_cant_del, $queryDetails, $table_name); $data = $result_data['DATA']; $entete = $result_data['ENTETE']; $correct_list_col_cant_del = $result_data['correct_list_col_cant_del']; $correct_list_fields = $result_data['correct_list_fields']; } if ($num_rows_result > 0) { if (count($data) == 1 and (!isset($protectedPost['page']) or $protectedPost['page'] == 0)) { $num_rows_result = 1; } $title = $num_rows_result . " " . $l->g(90); if (isset($tab_options['LOGS'])) { addLog($tab_options['LOGS'], $num_rows_result . " " . $l->g(90)); } if (!isset($tab_options['no_download_result'])) { $title .= "<a href='index.php?" . PAG_INDEX . "=" . $pages_refs['ms_csv'] . "&no_header=1&tablename=" . $table_name . "&base=" . $tab_options['BASE'] . "'><small> (" . $l->g(183) . ")</small></a>"; } $result_with_col = gestion_col($entete, $data, $correct_list_col_cant_del, $form_name, $table_name, $list_fields, $correct_list_fields, $form_name); $no_result = tab_entete_fixe($result_with_col['entete'], $result_with_col['data'], $title, $width, "", array(), $tab_options); if ($no_result) { show_page($num_rows_result, $form_name); echo "<input type='hidden' id='tri_" . $table_name . "' name='tri_" . $table_name . "' value='" . $protectedPost['tri_' . $table_name] . "'>"; echo "<input type='hidden' id='tri_fixe' name='tri_fixe' value='" . $protectedPost['tri_fixe'] . "'>"; echo "<input type='hidden' id='sens_" . $table_name . "' name='sens_" . $table_name . "' value='" . $protectedPost['sens_' . $table_name] . "'>"; echo "<input type='hidden' id='SUP_PROF' name='SUP_PROF' value=''>"; echo "<input type='hidden' id='MODIF' name='MODIF' value=''>"; echo "<input type='hidden' id='SELECT' name='SELECT' value=''>"; echo "<input type='hidden' id='OTHER' name='OTHER' value=''>"; echo "<input type='hidden' id='ACTIVE' name='ACTIVE' value=''>"; echo "<input type='hidden' id='CONFIRM_CHECK' name='CONFIRM_CHECK' value=''>"; echo "<input type='hidden' id='OTHER_BIS' name='OTHER_BIS' value=''>"; echo "<input type='hidden' id='OTHER_TER' name='OTHER_TER' value=''>"; return TRUE; } else { return FALSE; } } else { echo "</td></tr></table>"; msg_warning($l->g(766)); return FALSE; } }
function output_pages_spe($otp, $media, $spe) { $npg = $_SESSION['prmb'][6]; $page = $_SESSION['page']; $min = ($page - 1) * $npg; $max = $page * $npg; if (is_array($otp)) { foreach ($otp as $id => $nb) { if (is_numeric($id)) { $i++; if ($i >= $min && $i < $max) { if ($spe == 'track') { $ret .= art_read_b($id, $nb, 1, '') . output_trk(read_idy($id, "ASC")); } else { $ret .= art_read_b($id, $nb, $media, ''); } } } } } $n_pages = nb_page($i, $npg, $page); return $n_pages . $ret . $n_pages; }