Skip to content

Instantly share code, notes, and snippets.

@ProLoser
Created September 10, 2013 06:25

Revisions

  1. ProLoser created this gist Sep 10, 2013.
    29 changes: 29 additions & 0 deletions bash.org.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    <?php
    $con = mysqli_connect("localhost","root","","password");
    if(isset($_GET['scan'])) {
    for($i=$_GET['scan'];$i<$_GET['scan']+10;$i++){
    $string = file_get_contents('http://bash.org/?browse&p='.$i);
    preg_match_all('/<p class="quote"><a href="\?(\d+)".*?>\((-?\d+)\)<.*?<p class="qt">(.*?)<\/p>/si',$string,$matches);

    echo '<br>Page '.$i.':';

    for($j=0;$j<count($matches[0]);$j++){
    echo ' '.$j;
    //echo "INSERT INTO bash (id, rank, contents) VALUES (".$matches[1][$j].",".$matches[2][$j].",'".ereg_replace('<br />','',$matches[3][$j])."')";
    mysqli_query($con,"INSERT INTO bash (id, created, rank, contents) VALUES (".$matches[1][$j].",NOW(),".$matches[2][$j].",'".ereg_replace('<br />','',$matches[3][$j])."')");
    }
    }
    }else{

    if(isset($_GET['d']))
    mysqli_query($con,"DELETE FROM `bash` WHERE `bash`.`id` =".$_GET['d']);

    if (!isset($_GET['i'])) $_GET['i'] = 200;
    $result = mysqli_query($con, "SELECT id, rank, contents FROM bash ORDER BY rank ASC LIMIT ".$_GET['i']);
    $i=0;
    while ($row = mysqli_fetch_assoc($result)) {
    $i++;
    echo '<p><a style="color:red" href="?d='.$row['id'].'">[X]</a> #'.$i.' ID ['.$row['id'].'] RANK ['.$row['rank'].']<br>'.preg_replace('/\n/','<br>',$row['contents']).'</p>';
    }
    }
    ?>