Advertisement
Guest User

Untitled

a guest
Mar 13th, 2012
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 34.44 KB | None | 0 0
  1. <?php
  2. // -------------------------------------------------------------------------//
  3. // Nuked-KlaN - PHP Portal                                                  //
  4. // http://www.nuked-klan.org                                                //
  5. // -------------------------------------------------------------------------//
  6. // This program is free software. you can redistribute it and/or modify     //
  7. // it under the terms of the GNU General Public License as published by     //
  8. // the Free Software Foundation; either version 2 of the License.           //
  9. // -------------------------------------------------------------------------//
  10. if (!defined("INDEX_CHECK"))
  11. {
  12.     die ("<div style=\"text-align: center;\">You cannot open this page directly</div>");
  13. }
  14.  
  15. global $nuked, $language, $user;
  16. translate("modules/Divers_Gallery/lang/" . $language . ".lang.php");
  17. include("modules/Divers_Gallery/config.php");
  18.  
  19. if (!$user)
  20. {
  21.     $visiteur = 0;
  22. }
  23. else
  24. {
  25.     $visiteur = $user[1];
  26. }
  27. $ModName = basename(dirname(__FILE__));
  28. $level_access = nivo_mod($ModName);
  29. if ($visiteur >= $level_access && $level_access > -1)
  30. {
  31.     compteur("Divers_Gallery");
  32.  
  33.     function view_screen($sid)
  34.     {
  35.         global $nuked;
  36.  
  37.         $sql = mysql_query("SELECT titre, url FROM " . DIVERS_GALLERY_TABLE . " WHERE sid = '" . $sid . "'");
  38.         list($titre, $url) = mysql_fetch_array($sql);
  39.         $titre = stripslashes($titre);
  40.         $titre = htmlentities($titre);
  41.  
  42.         $name = strrchr($url, '/');
  43.         $name = substr($name, 1);
  44.         $name_enc = rawurlencode($name);
  45.         $url = str_replace($name, $name_enc, $url);
  46.  
  47.     echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
  48.     . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"fr\">\n"
  49.     . "<head><title>" . $titre . "</title>\n"
  50.     . "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n"
  51.     . "<meta http-equiv=\"content-style-type\" content=\"text/css\" />\n"
  52.     . "<link title=\"style\" type=\"text/css\" rel=\"stylesheet\" href=\"themes/" . $theme . "/style.css\" /></head>\n"
  53.     . "<body style=\"background: " . $bgcolor2 . ";margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;\">\n"
  54.     . "<div style=\"text-align: center;\"><a href=\"javascript: self.close()\"><img style=\"border: 0;\" src=\"" . $url . "\" alt=\"\" title=\"" . _CLICTOCLOSE . "\" /></a></div></body></html>";
  55.  
  56.     }
  57.  
  58.     function cat($cat)
  59.     {
  60.         global $nuked, $bgcolor1, $bgcolor2, $bgcolor3, $img_cat, $img_none, $image_resize, $image_gd;
  61.  
  62.         $counter = 0;
  63.  
  64.         $sql = mysql_query("SELECT cid, titre, description FROM " . DIVERS_GALLERY_CAT_TABLE . " WHERE parentid = '" . $cat . "'");
  65.     $nb_subcat = mysql_num_rows($sql);
  66.  
  67.         if ($nb_subcat > 0)
  68.         {
  69.             echo "<table width=\"100%\" cellspacing=\"5\" cellpadding=\"0\" border=\"0\">\n";
  70.  
  71.             $sql = mysql_query("SELECT cid, titre, description FROM " . Divers_Gallery_CAT_TABLE . " WHERE parentid = '" . $cat . "' ORDER BY position, titre");
  72.             while (list($catid, $parentcat, $parentdesc) = mysql_fetch_array($sql))
  73.             {
  74.                 $parentcat = stripslashes($parentcat);
  75.                 $parentdesc = stripslashes($parentdesc);
  76.  
  77.                 $parentcat = htmlentities($parentcat);
  78.                 $parentdesc = htmlentities($parentdesc);
  79.  
  80.                 $parentdesc = BBcode($parentdesc);
  81.                 $parentdesc = icon($parentdesc);
  82.  
  83.                 $sql_img = mysql_query("SELECT sid, url, url2, date FROM " . DIVERS_GALLERY_TABLE . " WHERE cat = '" . $catid . "' ORDER BY sid DESC");
  84.                 $nb_imgcat = mysql_num_rows($sql_img);
  85.                 list($sid, $url, $url2, $date) = mysql_fetch_array($sql_img);
  86.  
  87.                 if ($url2 != "" && $url2 != "http://")
  88.                 {
  89.                     $image = $url2;
  90.                 }
  91.                 else if ($url2 == "" && $image_gd == "on" && @extension_loaded('gd') && !eregi("http://", $url) && is_file($url))
  92.                 {          
  93.                     $org = $rep_img;
  94.                     $dest = $rep_img_gd;
  95.                     $name = str_replace ($org,'',$url);
  96.                    
  97.                     // instanciation de l'objet
  98.                     $thb = new thb;
  99.                     // appel du constructeur
  100.                     // nim de la source: image.jpeg
  101.                     // chemin source: ./ (dossier courant)
  102.                     // destianation: ./ (dossier courant)
  103.                     $thb->doImg($name, $org, $dest);
  104.                     // Config des parametres
  105.                     // prefix
  106.                     // taille du + grd coté
  107.                     // qualité
  108.                     $thb->SetParam('_tmb', $img_screen1, 90);
  109.                     // pour connaitre le nom et chemin de l'image réduite
  110.                     // résultat: ./image_thb.jpeg
  111.                     $thumb = $thb->GetThbName();
  112.                     // pour connaitre le nom et chemin de l'image d'origine
  113.                     // résultat: ./image.jpeg
  114.                     $source = $thb->GetOrigine();
  115.                     // Lance le redimensionenemt
  116.                     $thb->doThb();
  117.                     if ($thumb) $sql_insert = mysql_query ("UPDATE " . $nuked['prefix'] . "_divers_gallery SET url2 = '" . $thumb . "' WHERE sid = '" . $sid . "'");
  118.                     $image = $thumb;           
  119.                 }
  120.                 if (!$image) $image = $url;
  121.  
  122.                 $name = strrchr($image, '/');
  123.                 $name = substr($name, 1);
  124.                 $name_enc = rawurlencode($name);
  125.                 $image = str_replace($name, $name_enc, $image);
  126.  
  127.                 if ($date)
  128.                 {
  129.                     $date = strftime("%x", $date);
  130.                     $last_date = _LASTADD . "&nbsp;" . $date;
  131.                 }
  132.                 else
  133.         {
  134.                     $last_date = "";
  135.         }
  136.  
  137.                 if ($catid != $last_catid)
  138.                 {
  139.                     $counter++;
  140.  
  141.                     if ($counter == 1)
  142.                     {
  143.                         echo "<tr>";
  144.                     }
  145.  
  146.                     echo "<td style=\"width: 50%;\" valign=\"top\">\n"
  147.                     . "<table style=\"background: " . $bgcolor1 . ";border: 1px solid " . $bgcolor3 . ";\" width=\"100%\" cellspacing=\"1\" cellpadding=\"5\" border=\"0\">\n"
  148.                     . "<tr><td colspan=\"2\"><a href=\"index.php?file=Divers_Gallery&amp;op=categorie&amp;cat=" . $catid . "\"><b>" . $parentcat . "</b></a></td></tr>\n"
  149.                     . "<tr><td style=\"width: 50px;background: " . $bgcolor2 . ";\" align=\"center\" valign=\"middle\">";
  150.  
  151.                     if ($image != "")
  152.                     {
  153.                         echo "<a href=\"index.php?file=Divers_Gallery&amp;op=categorie&amp;cat=" . $catid . "\">" . img_size($image, $img_cat, $parentcat, $image_resize) . "</a>";
  154.                     }
  155.                     else
  156.                     {
  157.                         echo "<a href=\"index.php?file=Divers_Gallery&amp;op=categorie&amp;cat=" . $catid . "\">" . img_size($img_none, $img_cat, $parentcat, $image_resize) . "</a>";
  158.                     }
  159.  
  160.                     echo "</td><td style=\"height: 100%;background: " . $bgcolor2 . ";\">\n"
  161.                     . "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";
  162.  
  163.                     if ($parentdesc != "") echo "<tr><td>" . $parentdesc . "</td></tr>\n";
  164.  
  165.                     echo "<tr><td>" . $nb_imgcat . "&nbsp;" . _SCREENINDB;
  166.  
  167.                     if ($last_date != "") echo "<br />" . $last_date;
  168.  
  169.                     echo "</td></tr></table></td></tr></table></td>\n";
  170.  
  171.                     if ($counter == 2)
  172.                     {
  173.                         $counter = 0;
  174.                         echo "</tr>";
  175.                     }
  176.  
  177.                     $last_catid = $catid;
  178.                 }
  179.             }
  180.  
  181.             if ($counter == 1) echo "<td style=\"width: 50%;border: 1px solid " . $bgcolor3 . ";\">&nbsp;</td></tr>\n";
  182.  
  183.             echo "</table>\n";
  184.         }
  185.     }
  186.  
  187.  
  188.     function categorie($cat)
  189.     {
  190.         global $nuked;
  191.  
  192.         opentable();
  193.  
  194.         if ($nuked['divers_gallery_title'] != "")
  195.         {
  196.             $title = $nuked['divers_gallery_title'];
  197.         }
  198.         else
  199.         {
  200.             $title = _divers_gallery;
  201.         }
  202.  
  203.         $sql = mysql_query("SELECT titre, description, parentid FROM " . DIVERS_GALLERY_CAT_TABLE . " WHERE cid = '" . $cat . "'");
  204.         list($cat_titre, $cat_desc, $parentid) = mysql_fetch_array($sql);
  205.         $cat_titre = stripslashes($cat_titre);
  206.         $cat_desc = stripslashes($cat_desc);
  207.  
  208.         $cat_titre = htmlentities($cat_titre);
  209.         $cat_desc = htmlentities($cat_desc);
  210.  
  211.         $cat_desc = BBcode($cat_desc);
  212.         $cat_desc = icon($cat_desc);
  213.  
  214.         if ($parentid > 0)
  215.         {
  216.             $sql_parent = mysql_query("SELECT titre FROM " . DIVERS_GALLERY_CAT_TABLE . " WHERE cid = '" . $parentid . "'");
  217.             list($parent_titre) = mysql_fetch_array($sql_parent);
  218.             $parent_titre = stripslashes($parent_titre);
  219.             $parent_titre = htmlentities($parent_titre);
  220.  
  221.             echo "<br /><div style=\"text-align: center;\"><a href=\"index.php?file=Divers_Gallery\" style=\"text-decoration:none\"><big><b>" . $title . "</b></big></a> &gt; <a href=\"index.php?file=Divers_Gallery&amp;op=categorie&amp;cat=" . $parentid . "\" style=\"text-decoration:none\"><big><b>" . $parent_titre . "</b></big></a> &gt; <big><b>" . $cat_titre . "</b></big></div><br />\n";
  222.         }
  223.         else
  224.         {
  225.             echo "<br /><div style=\"text-align: center;\"><a href=\"index.php?file=Divers_Gallery\" style=\"text-decoration:none\"><big><b>" . $title . "</b></big></a> &gt; <big><b>" . $cat_titre . "</b></big></div><br />\n";
  226.         }
  227.  
  228.         if ($cat_desc != "")
  229.         {
  230.             echo "<div style=\"text-align: center;\">" . $cat_desc . "</div><br />\n";
  231.         }
  232.        
  233.         cat($cat);
  234.         classe($cat);
  235.        
  236.         closetable();
  237.     }
  238.  
  239.     function description($sid)
  240.     {
  241.         global $nuked, $user, $visiteur, $orderby, $bgcolor1, $bgcolor2, $bgcolor3, $img_width, $image_resize;
  242.  
  243.         if ($nuked['divers_gallery_title'] != "")
  244.         {
  245.             $title = $nuked['divers_gallery_title'];
  246.         }
  247.         else
  248.         {
  249.             $title = _divers_gallery;
  250.         }
  251.  
  252.         opentable();
  253.  
  254.         $upd = mysql_query("UPDATE " . DIVERS_GALLERY_TABLE . " SET count = count + 1 WHERE sid = '" . $sid . "'");
  255.  
  256.         $sql = mysql_query("SELECT cat, titre, description, autor, url, url_file, date, count FROM " . DIVERS_GALLERY_TABLE . " WHERE sid = '" . $sid . "'");
  257.         list($cat, $titre, $description, $autor, $url, $url_file, $date, $count) = mysql_fetch_array($sql);
  258.         $titre = stripslashes($titre);
  259.         $description = stripslashes($description);
  260.         $autor = stripslashes($autor);
  261.  
  262.         $titre = htmlentities($titre);
  263.         $description = htmlentities($description);
  264.         $autor = htmlentities($autor);
  265.  
  266.         $name = strrchr($url, '/');
  267.         $name = substr($name, 1);
  268.         $name_enc = rawurlencode($name);
  269.         $url = str_replace($name, $name_enc, $url);
  270.  
  271.         if (!$name) $name = "N/A";
  272.  
  273.         if ($date) $date = strftime("%x %H:%M", $date);
  274.         else $date = "N/A";
  275.  
  276.         if ($url_file != "")
  277.         {
  278.             $button = "<br /><div style=\"text-align: center;\"><input type=\"button\" value=\"" . _DOWNFILE . "\" onclick=\"window.open('" . $url_file . "')\" /><div><br />\n";
  279.         }
  280.         else
  281.         {
  282.             $button = "<br />\n";
  283.         }
  284.  
  285.         $sql2 = mysql_query("SELECT titre, parentid FROM " . DIVERS_GALLERY_CAT_TABLE . " WHERE cid = '" . $cat . "'");
  286.         list($cat_name, $parentid) = mysql_fetch_array($sql2);
  287.         $cat_name = stripslashes($cat_name);
  288.         $cat_name = htmlentities($cat_name);
  289.  
  290.         if ($cat == 0)
  291.         {
  292.             $category = _NONE;
  293.         }
  294.         else if ($parentid > 0)
  295.         {
  296.             $sql3 = mysql_query("SELECT titre FROM " . DIVERS_GALLERY_CAT_TABLE . " WHERE cid = '" . $parentid . "'");
  297.             list($parent_name) = mysql_fetch_array($sql3);
  298.             $parent_name = stripslashes($parent_name);
  299.             $parent_name = htmlentities($parent_name);
  300.  
  301.             $category = "<a href=\"index.php?file=Divers_Gallery&amp;op=categorie&amp;cat=" . $parentid . "\">" . $parent_name . "</a> -&gt; <a href=\"index.php?file=Divers_Gallery&amp;op=categorie&amp;cat=" . $cat . "\">" . $cat_name . "</a>";
  302.         }
  303.         else
  304.         {
  305.             $category = "<a href=\"index.php?file=Divers_Gallery&amp;op=categorie&amp;cat=" . $cat . "\">" . $cat_name . "</a>";
  306.         }
  307.  
  308.        
  309.         if ($orderby == "name")
  310.         {
  311.             $sql_next = mysql_query("SELECT sid FROM " . DIVERS_GALLERY_TABLE . " WHERE cat = '" . $cat . "' AND titre > '" . $titre . "' ORDER BY titre LIMIT 0, 1");
  312.             list($nextid) = mysql_fetch_array($sql_next);
  313.  
  314.             $sql_last = mysql_query("SELECT sid FROM " . DIVERS_GALLERY_TABLE . " WHERE cat = '" . $cat . "' AND titre < '" . $titre . "' ORDER BY titre DESC LIMIT 0, 1");
  315.             list($lastid) = mysql_fetch_array($sql_last);
  316.         }
  317.         else if ($orderby == "count")
  318.         {
  319.             $sql_next = mysql_query("SELECT sid FROM " . DIVERS_GALLERY_TABLE . " WHERE cat = '" . $cat . "' AND count < '" . $count . "' ORDER BY count DESC LIMIT 0, 1");
  320.             list($nextid) = mysql_fetch_array($sql_next);
  321.  
  322.             $sql_last = mysql_query("SELECT sid FROM " . DIVERS_GALLERY_TABLE . " WHERE cat = '" . $cat . "' AND count > '" . $count . "' ORDER BY count LIMIT 0, 1");
  323.             list($lastid) = mysql_fetch_array($sql_last);
  324.         }
  325.         else if ($orderby == "note")
  326.         {
  327.             $sql_note = mysql_query("SELECT AVG(vote) FROM " . VOTE_TABLE . " WHERE vid = '" . $sid . "' AND module = 'Divers_Gallery'");
  328.             list($note) = mysql_fetch_array($sql_note);
  329.  
  330.             $sql_next = mysql_query("SELECT L.sid, AVG(V.vote) AS note FROM " . DIVERS_GALLERY_TABLE . " AS L LEFT JOIN " . VOTE_TABLE . " AS V ON L.sid = V.vid AND V.module = 'Divers_Gallery' WHERE L.cat = '" . $cat . "' GROUP BY L.sid HAVING note < '" . $note . "' ORDER BY note DESC LIMIT 0, 1");
  331.             list($nextid) = mysql_fetch_array($sql_next);
  332.  
  333.             $sql_last = mysql_query("SELECT L.sid, AVG(V.vote) AS note FROM " . DIVERS_GALLERY_TABLE . " AS L LEFT JOIN " . VOTE_TABLE . " AS V ON L.sid = V.vid AND V.module = 'Divers_Gallery' WHERE L.cat = '" . $cat . "' GROUP BY L.sid HAVING note > '" . $note . "' ORDER BY note LIMIT 0, 1");
  334.             list($lastid) = mysql_fetch_array($sql_last);
  335.         }
  336.         else
  337.         {
  338.             $orderby = "news";
  339.  
  340.             $sql_next = mysql_query("SELECT sid FROM " . DIVERS_GALLERY_TABLE . " WHERE cat = '" . $cat . "' AND sid < '" . $sid . "' ORDER BY sid DESC LIMIT 0, 1");
  341.             list($nextid) = mysql_fetch_array($sql_next);
  342.  
  343.             $sql_last = mysql_query("SELECT sid FROM " . DIVERS_GALLERY_TABLE . " WHERE cat = '" . $cat . "' AND sid > '" . $sid . "' ORDER BY sid LIMIT 0, 1");
  344.             list($lastid) = mysql_fetch_array($sql_last);
  345.         }
  346.  
  347.  
  348.         if ($nextid != "")
  349.         {
  350.             $next = "<small><a href=\"index.php?file=Divers_Gallery&amp;op=description&amp;sid=" . $nextid . "&amp;orderby=" . $orderby . "\">" . _NEXTIMG . "</a> &gt;</small>";
  351.         }
  352.  
  353.  
  354.         if ($lastid != "")
  355.         {
  356.             $prev = "<small>&lt; <a href=\"index.php?file=Divers_Gallery&amp;op=description&amp;sid=" . $lastid . "&amp;orderby=" . $orderby . "\">" . _LASTIMG . "</a> &nbsp;</small>";
  357.         }
  358.  
  359.         echo "<br />\n";
  360.  
  361.         if ($visiteur >= admin_mod("Divers_Gallery"))
  362.         {
  363.             echo"<script type=\"text/javascript\">\n"
  364.             ."<!--\n"
  365.             ."\n"
  366.             . "function delimg(titre, id)\n"
  367.             . "{\n"
  368.             . "if (confirm('" . _SCREENDELETE  . " '+titre+' ! " . _CONFIRM . "'))\n"
  369.             . "{document.location.href = 'index.php?file=Divers_Gallery&page=admin&op=del_screen&sid='+id;}\n"
  370.             . "}\n"
  371.             . "\n"
  372.             . "// -->\n"
  373.             . "</script>\n";
  374.  
  375.             echo "<div style=\"text-align: right;\"><a href=\"index.php?file=Divers_Gallery&amp;page=admin&amp;op=edit_screen&amp;sid=" . $sid . "\"><img style=\"border: 0;\" src=\"images/edition.gif\" alt=\"\" title=\"" . _EDIT . "\" /></a>"
  376.             . "&nbsp;<a href=\"javascript:delimg('" . addslashes($titre) . "', '" . $sid . "');\"><img style=\"border: 0;\" src=\"images/delete.gif\" alt=\"\" title=\"" . _DEL . "\" /></a></div>\n";
  377.         }
  378.  
  379.         echo "<br /><div style=\"text-align: center;\"><a href=\"index.php?file=Divers_Gallery\" style=\"text-decoration:none\"><big><b>" . $title . "</b></big></a></div><br />\n"
  380.     . "<table style=\"margin-left: auto;margin-right: auto;text-align: left;\" cellpadding=\"20\" cellspacing=\"0\" border=\"0\">\n"
  381.     . "<tr style=\"background: " . $bgcolor1 . ";\"><td style=\"border: 1px dashed " . $bgcolor3 . ";\">"
  382.     .  "<a href=\"" . $url . "\" class=\"thickbox\" title=\"" . $titre . "\">"
  383.     . img_size($url, $img_width, _CLICTOSCREEN, $image_resize) . "</a></td></tr></table><br />\n"
  384.     . "<table style=\"margin-left: auto;margin-right: auto;text-align: left;\" width=\"90%\" cellpadding=\"3\" cellspacing=\"0\">\n"
  385.     . "<tr><td align=\"left\">" . $prev . "</td><td align=\"right\">" . $next . "</td></tr></table>\n"
  386.     . "<table style=\"margin-left: auto;margin-right: auto;text-align: left;background: " . $bgcolor2 . ";\" width=\"90%\" cellpadding=\"3\" cellspacing=\"3\" border=\"0\">\n"
  387.     . "<tr style=\"background: " . $bgcolor2 . ";\"><td style=\"border: 1px solid " . $bgcolor3 . ";\" align=\"center\"><big><b>" . $titre . "</b></big></td></tr>\n";
  388.  
  389.         if ($description != "")
  390.         {
  391.             $description = BBcode($description);
  392.             $description = icon($description);
  393.  
  394.             echo "<tr style=\"background: " . $bgcolor1 . ";\"><td style=\"border: 1px dashed " . $bgcolor3 . ";\">" . $description . "</td></tr>\n"
  395.             . "<tr style=\"background: " . $bgcolor2 . ";\"><td>&nbsp;</td></tr>";
  396.         }
  397.  
  398.         echo "<tr style=\"background: " . $bgcolor1 . ";\"><td style=\"border: 1px dashed " . $bgcolor3 . ";\"><b>" . _CAT . " :</b> " . $category . "</td></tr>\n";
  399.  
  400.         if ($autor != "")
  401.         {
  402.             echo "<tr style=\"background: " . $bgcolor1 . ";\"><td style=\"border: 1px dashed " . $bgcolor3 . ";\"><b>" . _AUTHOR . " :</b>  " . $autor . "</td></tr>\n";
  403.     }
  404.  
  405.         echo "<tr style=\"background: " . $bgcolor1 . ";\"><td style=\"border: 1px dashed " . $bgcolor3 . ";\"><b>" . _ADDTHE . " :</b>  " . $date . "</td></tr>\n"
  406.     . "<tr style=\"background: " . $bgcolor1 . ";\"><td style=\"border: 1px dashed " . $bgcolor3 . ";\"><b>" . _FILENAME . " :</b> " . $name . "</td></tr>\n"
  407.     . "<tr style=\"background: " . $bgcolor1 . ";\"><td style=\"border: 1px dashed " . $bgcolor3 . ";\"><b>" . _SEEN . " :</b> " . $count . "&nbsp;" . _TIMES . "</td></tr>\n"
  408.     . "<tr style=\"background: " . $bgcolor1 . ";\"><td style=\"border: 1px dashed " . $bgcolor3 . ";\">";
  409.  
  410.         include ("modules/Comment/index.php");
  411.         com_index("Divers_Gallery", $sid);
  412.  
  413.         echo "</td></tr><tr style=\"background: " . $bgcolor1 . ";\"><td style=\"border: 1px dashed " . $bgcolor3 . ";\">";
  414.  
  415.         include ("modules/Vote/index.php");
  416.         vote_index("Divers_Gallery", $sid);
  417.  
  418.         echo "</td></tr></table>" . $button;
  419.  
  420.         closetable();
  421.     }
  422.  
  423.     function index()
  424.     {
  425.         global $nuked, $bgcolor1, $bgcolor2, $bgcolor3, $nb_subcat, $orderby, $p;
  426.  
  427.         if ($nuked['divers_gallery_title'] != "")
  428.         {
  429.             $title = $nuked['divers_gallery_title'];
  430.         }
  431.         else
  432.         {
  433.             $title = _divers_gallery;
  434.         }
  435.  
  436.         opentable();
  437.  
  438.         echo "<br /><div style=\"text-align: center;\"><big><b>" . $title . "</b></big></div>\n"
  439.         . "<div style=\"text-align: center;\"><br />\n"
  440.         . "[  " . _INDEX_DIVERS_GALLERY . " | "
  441.     . "<a href=\"index.php?file=Divers_Gallery&amp;op=classe&amp;orderby=news\" style=\"text-decoration: underline\">" . _NEWSIMG . "</a> | "
  442.     . "<a href=\"index.php?file=Divers_Gallery&amp;op=classe&amp;orderby=count\" style=\"text-decoration: underline\">" . _TOPIMG . "</a> | "
  443.     . "<a href=\"index.php?file=Suggest&amp;module=Divers_Gallery\" style=\"text-decoration: underline\">" . _SUGGESTIMG . "</a> ]</div><br />\n";
  444.  
  445.         $sql_nbimages = mysql_query("SELECT sid FROM " . DIVERS_GALLERY_TABLE . "");
  446.         $nb_images = mysql_num_rows($sql_nbimages);
  447.  
  448.         $sql_nbcat = mysql_query("SELECT cid FROM " . DIVERS_GALLERY_CAT_TABLE . "");
  449.         $nb_cat = mysql_num_rows($sql_nbcat);
  450.  
  451.         if ($nb_cat > 0)
  452.         {
  453.             echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr><td>";
  454.  
  455.             $sql_cat = mysql_query("SELECT cid, titre, description FROM " . DIVERS_GALLERY_CAT_TABLE . " WHERE parentid = '0' ORDER BY position, titre");
  456.             while (list($cid, $titre, $description) = mysql_fetch_array($sql_cat))
  457.             {
  458.                 $titre = stripslashes($titre);
  459.                 $description = stripslashes($description);
  460.  
  461.                 $titre = htmlentities($titre);
  462.                 $description = htmlentities($description);
  463.  
  464.                 $description = BBcode($description);
  465.                 $description = icon($description);
  466.  
  467.                 $sql_img = mysql_query("SELECT sid, date FROM " . DIVERS_GALLERY_TABLE . " WHERE cat = '" . $cid . "' ORDER BY sid DESC LIMIT 0, 1");
  468.                 $nb_imgcat = mysql_num_rows($sql_img);
  469.                 list($sid, $date) = mysql_fetch_row($sql_img);
  470.  
  471.                 $sql_img_tt = mysql_query("SELECT sid FROM " . DIVERS_GALLERY_TABLE . ", " . DIVERS_GALLERY_CAT_TABLE . " WHERE cat = cid AND (parentid = '" . $cid . "' OR cid = '" . $cid . "')");
  472.                 $nb_imgcat_tt = mysql_num_rows($sql_img_tt);
  473.  
  474.                 $sql_nbcat = mysql_query("SELECT cid FROM " . DIVERS_GALLERY_CAT_TABLE . " WHERE parentid = '" . $cid . "'");
  475.                 $nb_nbcat = mysql_num_rows($sql_nbcat);
  476.  
  477.                 if ($date != "")
  478.                 {
  479.                     $date = strftime("%x", $date);
  480.                     $last_date = "" . _LASTADD . " $date";
  481.                 }
  482.                 else
  483.                 {
  484.                     $last_date = "";
  485.                 }
  486.  
  487.                 echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"border: 1px solid " . $bgcolor3 . ";\"><tr><td>\n"
  488.                 . "<table style=\"background: " . $bgcolor2 . ";\" width=\"100%\" cellspacing=\"1\" cellpadding=\"5\" border=\"0\">\n"
  489.                 . "<tr><td style=\"width: 80%;background: " . $bgcolor1 . ";\"><a href=\"index.php?file=Divers_Gallery&amp;op=categorie&amp;cat=" . $cid . "\"><big><b>" . $titre . "</b></big></a></td>\n"
  490.                 . "<td style=\"width: 10%;background: " . $bgcolor1 . ";\">" . $nb_imgcat_tt . "&nbsp;" . _SCREENINDB . "</td>\n";
  491.  
  492.                 if ($nb_nbcat)
  493.                 {
  494.                     echo "<td style=\"width: 10%;background: " . $bgcolor1 . ";\">" . $nb_nbcat . "&nbsp;" . _NBCAT . "</td>";
  495.                 }
  496.  
  497.                 echo "</tr></table></td></tr><tr><td>";
  498.  
  499.                 if ($nb_nbcat == 0)
  500.                 {
  501.                     echo "<table width=\"100%\"><tr><td>&nbsp;</td></tr><tr><td align=\"center\">" . $description . "</td></tr><tr><td>&nbsp;</td></tr></table>\n";
  502.                 }
  503.                 else
  504.                 {
  505.                     cat($cid);
  506.                 }
  507.  
  508.                 echo "</td></tr></table><br />\n";
  509.             }
  510.  
  511.             echo "</td></tr></table>\n";
  512.         }
  513.         else
  514.     {
  515.             echo "<br />";
  516.     }
  517.  
  518.         classe("0");
  519.          
  520.         if ($nb_cat > 0 || $nb_images > 0) echo "<br /><div style=\"text-align: center;\"><small>( <i>" . _THEREIS . "&nbsp;" . $nb_images . "&nbsp;" . _SCREENINDB . " &amp; " . $nb_cat . "&nbsp;" . _NBCAT . "&nbsp;" . _INDATABASE . "</i> )</small></div><br /><br />\n";
  521.         else echo "<div style=\"text-align: center;\">" . _NOSCREENINDB . "</div><br /><br />\n";
  522.  
  523.         closetable();
  524.     }
  525.    
  526.     function classe($cat)
  527.     {
  528.     global $nuked, $p, $bgcolor1, $bgcolor2, $bgcolor3, $op, $orderby, $img_screen1, $img_screen2, $img_screen3, $image_resize;
  529.    
  530.     $nb_img_guest = $nuked['max_img'];
  531.     $nb_img_line = $nuked['max_img_line'];
  532.    
  533.     if ($cat > 0)
  534.     {
  535.             $sql = mysql_query("SELECT cid FROM " . DIVERS_GALLERY_CAT_TABLE . " WHERE parentid = '" . $cat . "'");
  536.             $nb_subcat = mysql_num_rows($sql);
  537.     }
  538.     else
  539.     {
  540.             $nb_subcat = 0;
  541.     }
  542.        
  543.         if ($op == "classe")
  544.         {
  545.    
  546.             if ($nuked['divers_gallery_title'] != "")
  547.             {
  548.                 $title = $nuked['divers_gallery_title'];
  549.             }
  550.             else
  551.             {
  552.                 $title = _divers_gallery;
  553.             }
  554.  
  555.             echo "<br /><div style=\"text-align: center;\"><big><b>" . $title . "</b></big></div>\n"
  556.             . "<div style=\"text-align: center;\"><br />\n"
  557.             . "[ <a href=\"index.php?file=Divers_Gallery\" style=\"text-decoration: underline\">" . _INDEX_Divers_Gallery . "</a> | ";
  558.  
  559.             if ($orderby == "news")
  560.             {
  561.                 echo _NEWSIMG . " | ";
  562.             }
  563.             else
  564.             {
  565.                 echo "<a href=\"index.php?file=Divers_Gallery&amp;op=classe&amp;orderby=news\" style=\"text-decoration: underline\">" . _NEWSIMG . "</a> | ";
  566.             }
  567.  
  568.             if ($orderby == "count")
  569.             {
  570.                 echo _TOPIMG . " | ";
  571.             }
  572.             else
  573.             {
  574.                 echo "<a href=\"index.php?file=Divers_Gallery&amp;op=classe&amp;orderby=count\" style=\"text-decoration: underline\">" . _TOPIMG . "</a> | ";
  575.             }
  576.  
  577.             echo "<a href=\"index.php?file=Suggest&amp;module=Divers_Gallery\" style=\"text-decoration: underline\">" . _SUGGESTIMG . "</a> ]</div><br />\n";
  578.         }
  579.        
  580.         if ($cat != "") $where = "WHERE L.cat = '" . $cat . "'";
  581.     else $where = "";
  582.  
  583.  
  584.         if ($orderby == "name")
  585.         {
  586.             $order = "ORDER BY L.titre";
  587.         }
  588.  
  589.         else if ($orderby == "count")
  590.         {
  591.             $order = "ORDER BY L.count DESC";
  592.         }
  593.  
  594.         else if ($orderby == "note")
  595.         {
  596.             $order = "ORDER BY note DESC";
  597.         }
  598.  
  599.         else
  600.         {
  601.             $orderby = "news";
  602.             $order = "ORDER BY L.sid DESC";
  603.         }
  604.  
  605.         $sql = mysql_query("SELECT L.sid, L.titre, L.url, L.url2, L.date, AVG(V.vote) AS note  FROM " . DIVERS_GALLERY_TABLE . " AS L LEFT JOIN " . VOTE_TABLE . " AS V ON L.sid = V.vid AND V.module = 'Divers_Gallery' " . $where . " GROUP BY L.sid " . $order);
  606.         $count = mysql_num_rows($sql);
  607.  
  608.         if ($count > 1 && $cat != "")
  609.         {
  610.             echo "<table style=\"margin-left: auto;margin-right: auto;text-align: left;\" width=\"90%\">\n"
  611.             . "<tr><td align=\"right\"><small>" . _ORDERBY . " : ";
  612.  
  613.             if ($orderby == "news")
  614.             {
  615.                 echo "<b>" . _DATE . "</b> | ";
  616.             }
  617.             else
  618.             {
  619.                 echo "<a href=\"index.php?file=Divers_Gallery&amp;op=" . $op . "&amp;orderby=news&amp;cat=" . $cat . "\">" . _DATE . "</a> | ";
  620.             }
  621.  
  622.             if ($orderby == "name")
  623.             {
  624.                 echo "<b>" . _NAME . "</b> | ";
  625.             }
  626.  
  627.             else
  628.             {
  629.                 echo "<a href=\"index.php?file=Divers_Gallery&amp;op=" . $op . "&amp;orderby=name&amp;cat=" . $cat . "\">" . _NAME . "</a> | ";
  630.             }
  631.  
  632.             if ($orderby == "count")
  633.             {
  634.                 echo "<b>" . _TOPFILE . "</b> | ";
  635.             }
  636.             else
  637.             {
  638.                 echo "<a href=\"index.php?file=Divers_Gallery&amp;op=" . $op . "&amp;orderby=count&amp;cat=" . $cat . "\">" . _TOPFILE . "</a> | ";
  639.             }
  640.  
  641.             if ($orderby == "note")
  642.             {
  643.                 echo "<b>" . _NOTE . "</b>&nbsp;";
  644.             }
  645.             else
  646.             {
  647.                 echo "<a href=\"index.php?file=Divers_Gallery&amp;op=" . $op . "&amp;orderby=note&amp;cat=" . $cat . "\">" . _NOTE . "</a>&nbsp;";
  648.             }
  649.  
  650.             echo "</small></td></tr></table>\n";
  651.         }
  652.  
  653.  
  654.         if ($count > 0)
  655.         {
  656.             if (!$p) $p = 1;
  657.             $start = $p * $nb_img_guest - $nb_img_guest;
  658.  
  659.             echo "<table style=\"margin-left: auto;margin-right: auto;text-align: left;\" width=\"90%\" cellspacing=\"5\" cellpadding=\"10\" border=\"0\">\n"
  660.             . "<tr><td  style=\"background: " . $bgcolor1 . ";border: 1px solid " . $bgcolor3 . ";\" colspan=\"" . $nb_img_line . "\">";
  661.  
  662.             if ($count > $nb_img_guest)
  663.             {
  664.                 $url_page = "index.php?file=Divers_Gallery&amp;op=" . $op . "&amp;cat=" . $cat . "&amp;orderby=" . $orderby;
  665.                 number($count, $nb_img_guest, $url_page);
  666.             }
  667.             else
  668.             {
  669.                 echo "&nbsp;";
  670.             }
  671.  
  672.             echo "</td></tr>\n";
  673.  
  674.             $l = 0;
  675.             $pourcent = 100 / $nb_img_line;
  676.             $seek = mysql_data_seek($sql, $start);
  677.             for($i = 0;$i < $nb_img_guest;$i++)
  678.             {
  679.                 if (list($sid, $titre, $url, $url2, $date) = mysql_fetch_row($sql))
  680.                 {
  681.  
  682.                     if ($url2 != "" && $url2 != "http://")
  683.                     {
  684.                         $img = $url2;
  685.                     }
  686.                     else
  687.                     {
  688.                         $img = $url;
  689.                     }
  690.  
  691.                     if ($nb_img_line > 4)
  692.                     {
  693.                         $img_w = $img_screen3;
  694.                     }
  695.                     else if ($nb_img_line > 3)
  696.                     {
  697.                         $img_w = $img_screen2;
  698.                     }
  699.                     else
  700.                     {
  701.                         $img_w = $img_screen1;
  702.                     }
  703.  
  704.                     $name = strrchr($img, '/');
  705.                     $name = substr($name, 1);
  706.                     $name_enc = rawurlencode($name);
  707.                     $img = str_replace($name, $name_enc, $img);
  708.  
  709.                     $titre = stripslashes($titre);
  710.                     $titre = htmlentities($titre);
  711.  
  712.                     if ($date != "") $alt = _ADDTHE . "&nbsp;" . strftime("%x %H:%M", $date);
  713.                     else $alt = $titre;
  714.  
  715.                     if ($sid != $last_sid)
  716.                     {
  717.                         $l++;
  718.                         if ($l == 1)
  719.                         {
  720.                             echo "<tr>";
  721.                         }
  722.  
  723.                         echo "<td style=\"width: " . $pourcent . "%;background: " . $bgcolor1 . ";border: 1px solid $bgcolor3;\" align=\"center\">"              
  724.                         . "<a href=\"index.php?file=Divers_Gallery&amp;op=description&amp;sid=" . $sid . "&amp;orderby=" . $orderby . "\">" . img_size($img, $img_w, $alt, $image_resize) . "</a><br />\n"
  725.                         . "<a href=\"index.php?file=Divers_Gallery&amp;op=description&amp;sid=" . $sid . "&amp;orderby=" . $orderby . "\"><b>" . $titre . "</b></a></td>\n";
  726.  
  727.                         if ($l == $nb_img_line)
  728.                         {
  729.                             $l = 0;
  730.                             echo "</tr>";
  731.                         }
  732.  
  733.                         $last_sid = $sid;
  734.                     }
  735.                 }
  736.             }
  737.  
  738.             if ($l > 0)
  739.             {
  740.                 for ($j = $l;$j < $nb_img_line;$j++)
  741.                 {
  742.                     echo "<td style=\"width: " . $pourcent . "%;background: " . $bgcolor1 . ";border: 1px solid $bgcolor3;\">&nbsp;</td>\n";
  743.                 }
  744.  
  745.                 echo "</tr>\n";
  746.             }
  747.  
  748.             if ($nb_subcat == 0 && $count == 0) echo "<tr><td align=\"center\" colspan=\"$nb_img_line\">" . _NOSCREEN . "</td></tr>\n";
  749.  
  750.             echo "<tr><td style=\"background: " . $bgcolor1 . ";border: 1px solid $bgcolor3;\" colspan=\"$nb_img_line\">";
  751.  
  752.             if ($count > $nb_img_guest)
  753.             {
  754.                 $url_page = "index.php?file=Divers_Gallery&amp;op=" . $op . "&amp;cat=" . $cat . "&amp;orderby=" . $orderby;
  755.                 number($count, $nb_img_guest, $url_page);
  756.             }
  757.             else
  758.             {        
  759.                 echo "&nbsp;";
  760.             }
  761.  
  762.             echo "</td></tr></table><br />\n";
  763.  
  764.         }
  765.         else
  766.         {
  767.              if ($nb_subcat == 0 && $cat > 0) echo "<div style=\"text-align: center;\"><br />" . _NOSCREEN . "</div><br /><br />\n";
  768.              if ($op == "classe") echo "<div style=\"text-align: center;\"><br />" . _NOSCREENINDB . "</div><br /><br />\n";
  769.         }
  770.    
  771.     }
  772.  
  773.     function img_size($image, $largeur, $title, $image_resize)
  774.     {
  775.         if ($image_resize == "off") $test = 0;
  776.         else if (eregi("http://", $image) && $image_resize == "local") $test = 0;
  777.         else  $test = 1;
  778.  
  779.         if ($test == 1) $style = "style=\"border: 1px solid #000000; overflow: auto; max-width: " . $largeur . "px;  width: expression(this.scrollWidth >= " . $largeur . "? '" . $largeur . "px' : 'auto');\"";
  780.         else $style = "style=\"border: 1px solid #000000;\"";
  781.        
  782.         $image_resize = "<img " . $style . " src=\"" . checkimg($image) . "\" alt=\"\" title=\"" . $title . "\" />";
  783.         return($image_resize);
  784.     }
  785.  
  786.     switch ($op)
  787.     {
  788.         case "view_screen":
  789.             view_screen($sid);
  790.             break;
  791.  
  792.         case "description":
  793.             description($sid);
  794.             break;
  795.  
  796.         case "categorie":
  797.             categorie($cat);
  798.             break;
  799.            
  800.         case "classe":
  801.             opentable();
  802.             classe($cat);
  803.             closetable();
  804.             break;
  805.  
  806.         default:
  807.             index();
  808.             break;
  809.     }
  810.  
  811. }
  812. else if ($level_access == -1)
  813. {
  814.     opentable();
  815.     echo "<br /><br /><div style=\"text-align: center;\">" . _MODULEOFF . "<br /><br /><a href=\"javascript:history.back()\"><b>" . _BACK . "</b></a><br /><br /></div>";
  816.     closetable();
  817. }
  818. else if ($level_access == 1 && $visiteur == 0)
  819. {
  820.     opentable();
  821.     echo "<br /><br /><div style=\"text-align: center;\">" . _USERENTRANCE . "<br /><br /><b><a href=\"index.php?file=User&amp;op=login_screen\">" . _LOGINUSER . "</a> | <a href=\"index.php?file=User&amp;op=reg_screen\">" . _REGISTERUSER . "</a></b><br /><br /></div>";
  822.     closetable();
  823. }
  824. else
  825. {
  826.     opentable();
  827.     echo "<br /><br /><div style=\"text-align: center;\">" . _NOENTRANCE . "<br /><br /><a href=\"javascript:history.back()\"><b>" . _BACK . "</b></a><br /><br /></div>";
  828.     closetable();
  829. }
  830.  
  831. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement