Guest
Public paste!

Untitled

By: a guest | Mar 20th, 2010 | Syntax: PHP | Size: 6.95 KB | Hits: 63 | Expires: Never
Copy text to clipboard
  1. <?php header('Content-type: text/html; charset=utf-8'); ?>
  2. <!DOCTYPE html>
  3. <html>
  4.    <head>
  5.       <meta http-equiv="X-UA-Compatible" content="chrome=1">
  6.       <title>#rSR URL database</title>
  7.  
  8.       <meta charset="utf-8">
  9.       <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
  10.  
  11.       <link rel="alternate" type="application/rss+xml" href="rss.php" title="#rSR URL DB">
  12.  
  13.       <link rel="stylesheet" href="style.css" type="text/css">
  14.  
  15.       <!-- <script type="text/javascript">shutterOnload = function(){shutterReloaded.Init('sh');}</script>
  16.       <script src="shutter/shutter.js" type="text/javascript"></script> -->
  17.       <link type="text/css" rel="stylesheet" href="/floatbox/floatbox.css">
  18.       <script type="text/javascript" src="/floatbox/floatbox.js"></script>
  19.       <link rel="stylesheet" href="shutter/shutter.css" type="text/css" media="screen">
  20.  
  21.       <script type="text/javascript" src="mootools-yui-compressed.js"></script>
  22.       <script type="text/javascript" src="more.js"></script>
  23.       <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></script>
  24.  
  25.       <script type="text/javascript">
  26.             window.addEvent('domready', function(){
  27.            
  28.                var Tips1 = new Tips($$('.Tips1'));
  29.                CFInstall.check({
  30.                   mode: 'popout'
  31.                });
  32.  
  33.             });
  34.       </script>
  35.    </head>
  36.  
  37.    <body>
  38.    <div id="wrapper">
  39.       <div id="header">
  40.          <h1><a href="?">#rSR URL database</a><sup style="font-variant: normal !important; font-size: 0.5em">beta</sup></h1>
  41.          <div>TODO:
  42.             <ul>
  43.                <li><del>Embedded YouTube videos!</del></li>
  44.                <li><del>RSS? ^^</del></li>
  45.             </ul>
  46.          </div>
  47.       </div>
  48.       <div id="content">
  49.          
  50.       <table>
  51.          <tr>
  52.             <th>#</th>
  53.             <th>from?</th>
  54.             <th>url</th>
  55.             <th>content</th>
  56.          </tr>
  57.  
  58. <?php
  59.  
  60. require("functions.php");
  61. require ("db.php");
  62.  
  63. $_GET=mysql_real_escape_array($_GET);
  64.  
  65. $connection = mysql_connect($dbhost, $dbuser, $dbpass);
  66. if (!$connection) {
  67.        die('Could not connect: ' . mysql_error());
  68. }
  69.  
  70. $db_selected = mysql_select_db($dbname, $connection);
  71. if (!$db_selected) {
  72.     die ('Can\'t use foo : ' . mysql_error());
  73. }
  74.  
  75. if (!isset($_GET['offset'])) { $offset = 100; } else { $offset = $_GET['offset']; }
  76. if (!isset($_GET['from'])) { $from = 0; } else { $from = $_GET['from']; }
  77. if (!isset($_GET['page'])) { $page = 1; } else { $page = $_GET['page']; }
  78. if (!isset($_GET['ord'])) { $ord = "DESC"; } else { $ord = $_GET['ord']; }
  79. if (!isset($_GET['search'])) { $search= 0; } else { $from = $_GET['search']; }
  80.  
  81. $extra = array();
  82. foreach($_GET as $key => $val) {
  83.    if ($key != "page")
  84.    $extra[] = $key."=".$val;
  85. }
  86.  
  87.  
  88. $startline = $page * $offset - $offset;
  89.  
  90. if (!empty($from) && empty($search)) {
  91.    $howmanylines = mysql_result(mysql_query("SELECT COUNT(*) FROM url WHERE nick='$from' ORDER BY id $ord", $connection),0,0);
  92.    $dbquery = "SELECT * FROM url WHERE nick='$from' ORDER BY id $ord LIMIT $startline, $offset";
  93.    } else if (empty($from) && !empty($search)) {
  94.    $howmanylines = mysql_result(mysql_query("SELECT COUNT(*) FROM url WHERE url LIKE '%$search%' ORDER BY id $ord", $connection),0,0);
  95.    $dbquery = "SELECT * FROM url WHERE url LIKE '%$search%' ORDER BY id $ord LIMIT $startline, $offset";
  96.    } else {
  97.    $howmanylines = mysql_result(mysql_query("SELECT COUNT(*) FROM url ORDER BY id $ord", $connection),0,0);
  98.    $dbquery = "SELECT * FROM url ORDER BY id $ord LIMIT $startline, $offset";
  99. }
  100.  
  101.  
  102. $dbresult = mysql_query($dbquery, $connection);
  103.  
  104. while ( $row = mysql_fetch_assoc($dbresult)) {
  105.    $adresa = urlreturn($row['url']);
  106.  
  107.    echo "<tr>";
  108.    
  109.    echo "<td>".date("d-m-Y H:i:s",$row['time'])."</td>";
  110.  
  111.    echo "<td><a class='Tips1' href='?from=".$row['nick']."' title='Show results only from ".$row['nick']."'>".$row['nick']."</a></td>";
  112.  
  113.    echo "<td><div><a class='Tips1 c".$adresa['code']."' href='".htmlentities($row['url'])."' title='".$row['message']."' target='_url'>".longwrap(htmlentities($row['url']))."</a></div>";
  114.    if ($_GET['pula'] == 1) {
  115.       $devhash=sha1($adresa['url'])."/".sha1("http://scr.linge-ma.ws/?url=".base64_encode($adresa['url']))."/".sha1($row['url']);
  116.       echo "<a href='pula.php?delete=".$devhash."' target='_devdelete'>&#9658;</a><span style='font-size: 9px'>".$devhash."</span>";
  117.    }
  118.    echo "</td>";
  119.  
  120.    if (($adresa['type'] == "image/jpeg") || ( $adresa['type'] == "image/png" ) || ( $adresa['type'] == "image/gif")  || ( $adresa['type'] == "image/jpg") || ( $adresa['type'] == "image/bmp")) {
  121.       echo "<td>";
  122.       echo "<a class=\"floatbox\" rev=\"group:pics type:img\" href='imgcache.php?img=".urlencode($adresa['url'])."' title='from ".$row['nick']."'><img src='imgcache.php?t=1&amp;img=".urlencode($adresa['url'])."'></a>";
  123.       echo "</td>";
  124.    } elseif (preg_match('@youtube\.com\/@', $adresa['url'])) {
  125.       echo "<td><a class=\"floatbox\" rev=\"group:pics width:640 height:505\" href=\"".$adresa['url']."\" title='from ".$row['nick']."'><img src='imgcache.php?t=1&amp;img=".urlencode($adresa['url'])."'></a></td>";
  126.    } elseif (($adresa['type'] == "text/html") || ($adresa['type'] == "application/xhtml+xml")) {
  127.       echo "<td><a class=\"floatbox\" rev=\"group:pics type:img\" href='imgcache.php?img=".urlencode(($adresa['url']))."' title='from ".$row['nick']."'><img          src='imgcache.php?t=1&amp;img=".urlencode($adresa['url'])."'></a></td>";
  128.    } elseif ( empty($adresa['type'])) {
  129.       echo "<td><img src='error.png' alt='nope, no pr0n'></td>";
  130.    } else {
  131.       echo "<td>".$adresa['type']."</td>";
  132.    }
  133. }
  134.  
  135. ?>
  136.     </table>
  137.    <div id="pages">
  138.    <ul>
  139. <?php
  140.       $nextpage = $page + 1;
  141.       $lastpage = ceil($howmanylines/$offset);
  142.       $prevpage = $page-1;
  143.  
  144.       echo "<li><a href='?page=1&".implode("&", $extra)."'>&laquo;</a></li>";
  145.  
  146.       if ( $prevpage < 1 ) {
  147.          echo "<li>&lsaquo;</li>";
  148.       } else {
  149.          echo "<li><a href='?page=".$prevpage."&".implode("&", $extra)."'>&lsaquo;</a></li>";
  150.       }
  151.      
  152.       $firstprintpage = $page - 10;
  153.       $lastprintpage = $page + 10;
  154.  
  155.       if ( $firstprintpage < 0 ) { $firstprintpage = 1; }
  156.       if ( $lastprintpage >= $lastpage ) { $lastprintpage = $lastpage; }
  157.  
  158.       for ($printpage=$firstprintpage;$printpage <= $lastprintpage; $printpage++) {
  159.          if ($printpage == $page) { echo "<li class='huge'>".$printpage."</li>"; } else { echo "<li><a href='?page=".$printpage."&".implode("&", $extra)."'>".$printpage."</a></li>"; }
  160.       }
  161.  
  162.       echo "<li><a href='?page=".$lastpage."&".implode("&", $extra)."'>&raquo;</a></li>";
  163.  
  164.       if ( $nextpage > $lastpage ) {
  165.          echo "<li>&rsaquo;</li>";
  166.       } else {
  167.          echo "<li><a href='?page=".$nextpage."&".implode("&", $extra)."'>&rsaquo;</a></li>";
  168.       }
  169.  
  170. ?>
  171.    </ul>
  172.    </div>
  173.       </div>
  174.    </div>
  175.    </body>
  176. </html>