Example #1
0
 function dba_open($path, $mode, $handler, $a1 = 0)
 {
     if ($handler == "dbm") {
         return dbmopen($path, $mode);
     } else {
         return false;
     }
 }
 function mtrc_bool_store($what, $where, $type = NULL, $params)
 {
     $result = false;
     switch ($type) {
         case 'cookie':
             $result = setcookie($where, $what, $expire);
             break;
         case 'session':
             $_SESSION[$where] = $what;
             if ($_SESSION[$where] == $what) {
                 $result = true;
             } else {
                 $result = false;
             }
             break;
         case 'dbm':
             // don't know what to do with these yet...
             if (!($dbm = dbmopen($this->defaultDBMname, "c"))) {
                 $result = false;
             }
             $result = dbminsert($dbm, $where, $what);
             return true;
             break;
         case 'global':
             $GLOBALS[$where] = $what;
             if ($GLOBALS[$where] == $what) {
                 return true;
             } else {
                 return false;
             }
             break;
         case 'mysql':
             /*
              *  INSERT INTO table_name (column1, column2, column3,...)
              *  VALUES (value1, value2, value3,...)
              *
              * $where needs to be 'table_name (column1, column2, column3,...)'
              * $what needs to be 'value1, value2, value3,...'...
              *
              */
             // make sql
             $sql = 'INSERT INTO ' . $where . 'VALUES (' . $what . ')';
             // execute it..
             $res = mysql_query($sql, GetMyConnection(isset($params['dbacct']) ? NULL : $params['dbacct']));
             break;
         default:
             if ($this->cookiesOK && !headers_sent) {
                 $reult = setcookie($where, $what);
             } else {
                 $_SESSION[$where] = $what;
                 //$reult = 'default to _SESSION[ ' . $where . ' ].';
                 $result = true;
             }
     }
     return $result;
 }
Example #3
0
function OpenDataBase($dbname)
{
    global $WikiDB;
    // hash of all the DBM file names
    reset($WikiDB);
    while (list($key, $file) = each($WikiDB)) {
        while (($dbi[$key] = @dbmopen($file, "c")) < 1) {
            $numattempts++;
            if ($numattempts > MAX_DBM_ATTEMPTS) {
                ExitWiki("Cannot open database '{$key}' : '{$file}', giving up.");
            }
            sleep(1);
        }
    }
    return $dbi;
}
Example #4
0
    for ($i = 1; $i <= 4; $i++) {
        if (isset($pagehash['r$i'])) {
            $newhash['refs'][$i] = $pagehash['r$i'];
        }
    }
    $content = implode("\n", $pagehash['text']);
    $content = str_replace("[", "[[", $content);
    $newhash['content'] = explode("\n", $content);
    InsertPage($dbi, $pagename, $newhash);
}
echo "opening dbm file: {$portdbmfile} ... \n";
if (!file_exists($portdbmfile)) {
    echo "File '{$portdbmfile}' does not exist.<br>\n";
    exit;
}
if (!($dbmh = dbmopen($portdbmfile, "r"))) {
    echo "Cannot open '{$portdbmfile}'<br>\n";
    exit;
}
echo " ok ({$dbmh})<p>\n";
$namelist = array();
$ctr = 0;
$namelist[$ctr] = $key = dbmfirstkey($dbmh);
port1_0renderhash($dbi, $dbmh, $key);
while ($key = dbmnextkey($dbmh, $key)) {
    $ctr++;
    $namelist[$ctr] = $key;
    port1_0renderhash($dbi, $dbmh, $key);
}
dbmclose($dbmh);
?>
 function store($what, $where, $type = NULL)
 {
     $result = false;
     switch ($type) {
         case 'cookie':
             $result = setcookie($where, $what);
             break;
         case 'session':
             if (isset($_SESSION[$where])) {
                 $result = 'overwrite';
             } else {
                 $result = true;
             }
             $_SESSION[$where] = $what;
             break;
         case 'dbm':
             // don't know what to do with these yet...
             if (!($dbm = dbmopen($this->defaultDBMname, "c"))) {
                 $result = false;
             }
             $result = dbminsert($dbm, $where, $what);
             break;
         case 'global':
             $GLOBALS[$where] = $what;
             if ($GLOBALS[$where] == $what) {
                 return true;
             } else {
                 return false;
             }
             break;
         default:
             if ($this->cookiesOK && !headers_sent) {
                 $reult = setcookie($where, $what);
             } else {
                 $_SESSION[$where] = $what;
                 $reult = 'default to _SESSION[ ' . $where . ' ].';
             }
     }
     return $reult;
 }