All pastes #594069 Raw Edit

Someone

public text v1 · immutable
#594069 ·published 2007-06-28 18:48 UTC
rendered paste body
<?PHP

  // id, title, content
  
  function content() {
  
    if ($_GET["page"]) {
    
      switch($_GET["page"]) {
      
        case "articles":
          list_articles();
          break;
        
        case "article":
          article($_GET["id"]);
          break;
          
        default:
          print "wtf, lol!";
          
      }
        
    } else {
    
      include ROOT . "resources/frontpage.php";
    
      global $title;
      $title = "Hello.";
      
    }
    
  }
  
  function list_articles() {
  
    $q = mysql_query("SELECT * FROM articles ORDER BY id DESC");
    
    print "          <ul>";
    
    while($data = mysql_fetch_array($q)) {
    
      print "            <li><a href=\"/articles/" . $data["id"] . "\">" . $data["title"] . "</a></li>";
      
    }
    
    print "          </ul>";
    
    global $title;
    $title = "Listing Articles.";
    
  }
  
  function article($id) {
  
    $q = mysql_query("SELECT * FROM articles WHERE id = '" . $id . "' LIMIT 1");
    $q = mysql_fetch_array($q);
    
    print "          <div id=\"article-header\">\n            <h2>" . $data["title"] . " <small>" . $data["id"] . "</small></h2>\n          </div>";
    print "          <div id=\"article-content\">";
    
    $content = explode("\n", $data["content"]);  
    foreach ($content as $line) { print "            <p>" . htmlentities($line) . "</p>"; }
    
    print "          </div>";
    
    global $title;
    $title = $data["title"];
    
  }
  
  function title() {
    
    global $title;
    print $title;
    
  }
  
?>