Recent Posts
None | 25 sec ago
Prolog | 56 sec ago
PHP | 1 min ago
None | 1 min ago
None | 1 min ago
None | 1 min ago
None | 1 min ago
Python | 1 min ago
None | 1 min ago
None | 2 min ago
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Anonymous on the 9th of Feb 2010 08:06:42 PM Download | Raw | Embed | Report
  1. <?php
  2. /**
  3.  * QuDB by agrafix.net
  4.  *
  5.  */
  6. class QuDB {
  7.         private $fp = null;
  8.        
  9.         private $data = array();
  10.        
  11.         public function __construct($filename = '_qudb.php') {
  12.                 if (!file_exists($filename)) {
  13.                         $f = fopen($filename, "w");
  14.                         fclose($f);
  15.                 }
  16.                
  17.                 $get = file($filename);
  18.                
  19.                 foreach ($get As $line) {
  20.                         if (trim($line) != "<?php" && trim($line) != "?>") {
  21.                                 $p = explode("=", $line);
  22.                                 $this->data[trim($p[0])] = trim($p[1]);
  23.                         }
  24.                 }
  25.                
  26.                 $this->fp = fopen($filename, "w");
  27.         }
  28.        
  29.         public function get($var) {
  30.                 return (isset($this->data[$var]) ? $this->data[$var] : 0);
  31.         }
  32.        
  33.         public function set($var, $value) {
  34.                 $this->data[$var] = $value;
  35.         }
  36.        
  37.         public function __destruct() {
  38.                 fwrite($this->fp, "<?php\n");
  39.                 foreach ($this->data As $k => $v) {
  40.                         fwrite($this->fp, $k.'='.$v."\n");
  41.                 }
  42.                 fwrite($this->fp, "?>\n");
  43.                 fclose($this->fp);
  44.         }
  45. }
  46. ?>
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: