\r
\r
global $db_url, $db_type;\r
-error_log("in include for database, $db_type, $db_name");
+//error_log("in include for database, $db_type, $db_name");
function gwvpmini_DBExists()
global $WEB_ROOT_FS, $BASE_URL, $data_directory, $db_type, $db_name;
// oh this isnt working. poo.
- error_log("checking for $db_name, $db_type");
+ //error_log("checking for $db_name, $db_type");
if($db_type == "sqlite") {
if(file_exists($db_name)) {
- error_log("Exists");
+ //error_log("Exists");
return true;
}
else {
- error_log("no exists");
+ //error_log("no exists");
return false;
}
}
if($cperms_t === false) return false;
$permsarray = array();
- if($cperms_t == "") {
- $permsarray[$uid] = $acc;
+ if($uid != "b") {
+ if($cperms_t == "") {
+ $permsarray[$uid] = $acc;
+ } else {
+ $permsarray = unserialize(base64_decode($cperms_t));
+ $permsarray[$uid] = $acc;
+ if($acc == 0) {
+ error_log("PERMSUPDATE: REMOVE $uid");
+ unset($permsarray[$uid]);
+ }
+ }
} else {
- $permsarray = unserialize(base64_decode($cperms_t));
- $permsarray[$uid] = $acc;
+ error_log("CHANGEREPOPERMS for b of $acc");
+ $permsarray["b"] = $acc;
}
// check if base is now r or a, we can drop any 1's
if($permsarray["b"] == "a" || $permsarray["b"] == "r") {
foreach($permsarray as $key => $val) {
if($val == 1) {
+ error_log("CHANGEREPOPERMS removed $key $val for base perm change");
unset($permsarray[$key]);
}
}
}
+ if(is_array($permsarray)) {
+ if(!isset($permsarray["b"])) {
+ // something went wrong, repalce b bit
+ $permsarray["b"] = "a";
+ }
+ } else {
+ // something went even wronger
+ $permsarray["b"] = "a";
+ }
+
+
$encperms = base64_encode(serialize($permsarray));
$sql = "update repos set repos_perms='$encperms' where repos_id='$rid'";\r
+
+ error_log("PERMSARRAYNOW $sql ".print_r($permsarray,true));\r
$conn->query($sql);
}
+function gwvpmini_GetRepoPerms($rid)
+{
+ $conn = gwvpmini_ConnectDB();\r
+ \r
+ $sql = "select repos_perms from repos where repos_id='$rid'";\r
+ \r
+ $res = $conn->query($sql);\r
+ \r
+ $cperms_t = false;\r
+ if($res !== false) foreach($res as $row) {\r
+ $cperms_t = $row[0];\r
+ }\r
+ \r
+ if($cperms_t === false) return false;\r
+ \r
+ $permsarray = unserialize(base64_decode($cperms_t));
+
+ return $permsarray;
+}
+
//returns 0 for none, 1 for read, 2 for writes
function gwvpmini_GetRepoPerm($rid, $uid)
{
\r
$res = $conn->query($sql);
- error_log("PERMCHECK: FUCK U! $sql");\r
- \r
$cperms_t = false;\r
if($res !== false) foreach($res as $row) {\r
$cperms_t = $row[0];\r
global $WEB_ROOT_FS, $BASE_URL, $data_directory, $db_type, $db_name, $DB_CONNECTION;\r
\r
// first check if $DB_CONNECTION IS live\r
- error_log("in connection $db_type, $db_name");\r
+ //error_log("in connection $db_type, $db_name");\r
\r
if($DB_CONNECTION != false) return $DB_CONNECTION;\r
\r
if($db_type == "sqlite") {\r
$db_url = $db_name;\r
if(!file_exists($db_name)) {\r
- error_log("$db_name does not exist - problem");
+ //error_log("$db_name does not exist - problem");
// TODO: NEED A SETUP AGENT!
gwvpmini_dbCreateSQLiteStructure($db_name);
gwvpmini_setConfigVal("repodir", "$data_directory/repos");\r
}\r
\r
// and here we go with pdo.\r
- error_log("attmpting to open db, $db_type:$db_url");\r
+ //error_log("attmpting to open db, $db_type:$db_url");\r
try {\r
$DB_CONNECTION = new PDO("$db_type:$db_url");\r
} catch(PDOException $exep) {\r