Exemple #1
0
function get_reverse_id($file_id)
{
    if (file_exists(FILE_REVERSE_DB_PATH)) {
        if (!($id = dba_open(FILE_REVERSE_DB_PATH, "wd", FILEDB_HANDLER))) {
            return ERROR;
        }
    } else {
        if (!($id = dba_open(FILE_REVERSE_DB_PATH, "c", FILEDB_HANDLER))) {
            return ERROR;
        }
    }
    do {
        $key = genUniqueId();
    } while (dba_exists($key, $id));
    dba_replace($key, $file_id, $id);
    dba_close($id);
    return $key;
}
Exemple #2
0
 public function array_commit()
 {
     foreach ($this->set_array_items as $item) {
         $file_db_list_key = $this->file_id . "-" . $item;
         $item_list_str = get_string($file_db_list_key);
         if ($item_list_str == ERROR) {
             $item_list_str = "";
         }
         for ($cnt = 0; $cnt < count($this->set_array_confs[$item]); $cnt++) {
             $confs = $this->set_array_confs[$item][$cnt];
             do {
                 $array_conf_id = genUniqueId();
                 $b_exists = is_exists_key($array_conf_id);
                 if ($b_exists == ERROR) {
                     break;
                 }
             } while ($b_exists);
             if ($b_exists == ERROR) {
                 return ERROR;
             }
             $line = "";
             foreach ($confs as $key => $value) {
                 if ($line != "") {
                     $line .= ",";
                 }
                 $line .= $key . "=" . $value;
             }
             replace_string($array_conf_id, $line);
             if ($item_list_str != "") {
                 $item_list_str .= ",";
             }
             $item_list_str .= $array_conf_id;
         }
         replace_string($file_db_list_key, $item_list_str);
     }
     $set_array_items = array();
     $set_array_confs = array();
     return NOERR;
 }