<?php error_reporting(E_ALL | E_STRICT); ini_set("track_errors", "On"); $rg_cache_socket = "rg_cache_socket.sock"; $INC = dirname(__FILE__) . "/../inc"; require_once(dirname(__FILE__) . "/config.php"); require_once($INC . "/init.inc.php"); require_once($INC . "/repo.inc.php"); require_once($INC . "/sql.inc.php"); require_once($INC . "/struct.inc.php"); require_once($INC . "/fixes.inc.php"); require_once("helpers.inc.php"); rg_log_set_file(dirname(__FILE__) . "/hook_update_help.log"); rg_log("Starting"); require_once("common.php"); $rg_sql_debug = 1; $op = $_SERVER['argv'][1]; $repo_id = getenv("ROCKETGIT_REPO_ID"); if ($repo_id === FALSE) $repo_id = 5678; $repo_uid = getenv("ROCKETGIT_REPO_UID"); if ($repo_uid === FALSE) $repo_uid = 22; $uid = getenv("ROCKETGIT_LOGIN_UID"); if ($uid === FALSE) $uid = 1234; $rights = getenv("ROCKETGIT_REPO_RIGHTS"); if ($rights === FALSE) $rights = ""; rg_log("repo_id=$repo_id repo_uid=$repo_uid uid=$uid rights=$rights"); $rg_ui = array( 'uid' => $uid, 'username' => 'user-hook-update', 'email' => 'hook_update_help@embedromix.ro', 'organization' => 0, 'confirmed' => time() ); $a = array(); $a['right_id'] = 100; $a['obj_id'] = $repo_id; $a['who'] = 400; $a['uid'] = $uid; $a['rights'] = $rights; $a['prio'] = 13; $a['ip'] = ""; $a['misc'] = ""; $a['description'] = "desc <>"; rg_log("op=$op"); if (strcmp($op, "init") == 0) { rg_log("Cleaning..."); $sql = "DELETE FROM users WHERE uid = $uid"; $res = rg_sql_query($db, $sql); rg_sql_free_result($res); $sql = "DELETE FROM rights WHERE obj_id = $repo_id"; $res = rg_sql_query($db, $sql); rg_sql_free_result($res); $sql = "INSERT INTO rights (right_id, type, uid, obj_id, rights, prio, itime, who)" . " VALUES (100, 'repo_refs', $uid, $repo_id, '', 100, 1, $repo_uid)"; $res = rg_sql_query($db, $sql); if ($res === FALSE) { rg_log("Cannot add first right!"); exit(1); } rg_sql_free_result($res); rg_log("Inserting a fake user uid=$uid"); $sql = "INSERT INTO users (uid, username, realname, salt, pass, email" . ", itime, suspended, rights)" . " VALUES ($uid, 'user-$uid', 'realname-$uid', '', '', ''" . ", $uid, 0, '')"; $res = rg_sql_query($db, $sql); if ($res === FALSE) { rg_log("Cannot insert user uid $uid (" . rg_sql_error() . ")!"); exit(1); } rg_sql_free_result($res); $new = array('repo_id' => $repo_id, 'uid' => $repo_uid, 'public' => 0); rg_test_create_repo_no_dir($db, $rg_ui, $new); } else if (strcmp($op, "repo") == 0) { $v = rg_rights_set($db, "repo", $a); if ($v === FALSE) { rg_log("Cannot give rights (1)!"); exit(1); } } else if (strcmp($op, "refs") == 0) { $v = rg_rights_set($db, "repo_refs", $a); if ($v === FALSE) { rg_log("Cannot give rights (1)!"); exit(1); } } else if (strcmp($op, "path") == 0) { $v = rg_rights_set($db, "repo_path", $a); if ($v === FALSE) { rg_log("Cannot give rights (1)!"); exit(1); } } rg_sql_close($db); ?>