Esempio n. 1
0
$ATERR = true;
require './framework.php';
global $html;
if ($html) {
    preMain();
}
// Debug:
// stop('E1', "Nope");
if (isset($_POST['errid']) && isset($_POST['status'])) {
    // Get error data
    $errid = $_POST['errid'];
    $status = $_POST['status'];
    // Use colours when HTML
    if ($html) {
        if (str_starts_with($status, 'OK~ ')) {
            OK();
        } else {
            if (str_starts_with($status, 'D~ ')) {
                D();
            } else {
                if (str_starts_with($status, 'W~ ')) {
                    W();
                } else {
                    if (str_starts_with($status, 'E~ ')) {
                        E();
                    }
                }
            }
        }
        $status = explode('~', $status, 2)[1];
    }
}
$phpgw->vfs->add_lock_override(array('string' => $testfile));
$result = $phpgw->vfs->write(array('string' => $testfile, 'content' => 'delete me'));
if (!$result) {
    fail(__LINE__ . "I cant write a locked file after overriding the lock!");
} else {
    ok("lock: after lock override write succeeds");
}
###
# unlock test
$phpgw->vfs->cd();
$result = $phpgw->vfs->unlock(array('string' => $testfile), $token);
if (!$result) {
    fail(__LINE__ . "failed unlocking file!");
} else {
    OK("unlock");
}
#server side copy
$phpgw->vfs->cd();
$result = $phpgw->vfs->cp(array('from' => $testfile, 'to' => $testfile . '2', 'relatives' => array(RELATIVE_ALL, RELATIVE_ALL)));
if (!$result) {
    fail(__LINE__ . " failed copying! returned: {$result}");
} else {
    ok("server-side copy");
}
$result = $phpgw->vfs->file_exists(array('string' => $testfile . '2'));
if (!$result) {
    fail(__LINE__ . " after copy, target doesnt exist!");
} else {
    ok("server-side copy : test for target");
}
Esempio n. 3
0
 /**
  * take care of creating or updating the table structure (depending on the table previously existing or not)
  */
 function process_table($table_info)
 {
     print_r($table_info);
     echo "<hr />";
     if ($this->table_exists($table_info['name'])) {
         $query = "ALTER TABLE {$this->name}.`{$table_info['name']}`";
     } else {
         $query = "CREATE TABLE {$this->name}.`{$table_info['name']}` (";
         $create = true;
     }
     $columns = array();
     $keys = array();
     foreach ($table_info['fields'] as $name => $field) {
         $column = "\n\t";
         if (!$create) {
             $column .= "ADD COLUMN ";
         }
         $column .= "`{$name}` {$field['type']}";
         if (!$field['null']) {
             $column .= " NOT NULL";
         }
         if (!is_null($field['extra'])) {
             $column .= " {$field['extra']}";
         }
         if (!is_null($field['default'])) {
             $column .= " default '{$field['default']}'";
         } else {
             $column .= " default NULL";
         }
         $columns[] = $column;
         if (isset($field['key'])) {
             $keys[$field['key']][] = $name;
         }
     }
     $query .= implode(",", $columns);
     $constraints = array();
     foreach ($keys as $key => $keyfields) {
         for ($i = 0; $i < count($keyfields); $i++) {
             $keyfields[$i] = "`" . $keyfields[$i] . "`";
         }
         $keytext = implode(",", $keyfields);
         if ($key == "PRI") {
             $constraints[$key] = "PRIMARY KEY({$keytext})";
         } else {
             if ($key == "UNI") {
                 $constraints[$key] = "UNIQUE({$keytext})";
             }
         }
         if (!$create) {
             $constraints[$key] = "ADD " . $constraints[$key];
         }
     }
     if (count($constraints) > 0) {
         $query .= ",\n" . implode(",\n", $constraints);
     }
     if ($create) {
         $query .= "\n)";
     }
     echo "<pre>{$query}</pre>";
     $res = mysql_query($query, $this->dbh);
     if ($res == false) {
         ER(mysql_error());
     } else {
         OK("processed");
     }
     return $res;
 }