# foreach ( session_get_cookie_params () as $key => $val ) # { $MSG .= "key '$key' val '$val'\n" ; } # echo $MSG ; require_once 'session.ppp' ; require_once 'local.ppp' ; require_once 'conf.ppp' ; require_once 'baselib.ppp' ; require_once 'wwwsec.ppp' ; require_once 'librepo.ppp' ; # $DEBUG = 2 ; # echo session_vars () ; get_config () ; # conf_dump () ; $conn = db_connect_or_die () ; $TIT = REPO_TIT ( 'repositories' ) ; if ( $_GET [ 'login' ] or $_POST [ 'login' ] or ( $_SESSION [ 'USER' ] ) ) { assert_login () ; } if ( $ADM = GETVAR ( 'ADM' ) ) { switch_actv ( $ADM ) ; } $USER_GROUPS = user_group_ids () ; $ACT = GETVAR ( 'ACT' ) ; $view = 'form' ; $view_err = '' ; $view_upd = '' ; $view_ack = '' ; function sort_by_name ( $a, $b ) { return strcasecmp ( $a -> repo_name (), $b -> repo_name () ) ; } function gen_repos_tab () { global $USER, $TBL ; $Repos = TBL ( 'repos' ) ; $Paths = TBL ( 'paths' ) ; $Rights = TBL ( 'rights' ) ; $Groups = TBL ( 'groups' ) ; $Mems = TBL ( 'gr_mem' ) ; if ( is_adm () ) { $qwe = '' ; } elseif ( $USER ) { $qwe = << info_row () ; # var_dump ( $repo ) ; echo " here1 \n" ; } return BQ ( TAB ( $res ) ) ; } if ( $_POST [ 'CANCEL' ] ) { $view = 'home' ; } elseif ( ! $USER or ! $ACT ) { if ( $RID = GETVAR ( 'RID', '/^[0-9]*$/' ) ) { $repo = try_repo ( $RID ) ; if ( ! $repo ) { html_exit ( "can't find repository $RID" ) ; } } else { $view = 'home' ; } } elseif ( $ACT == 'NEW_REPO_FORM' ) { if ( ! may_create_repo () ) { html_exit ( "you can't create repositories ($USER)" ) ; } $repo = new Repo ; $repo -> set_defaults () ; $view = 'new_repo' ; } elseif ( $ACT == 'UPD_REPO_FORM' ) { $RID = GETVAR ( 'RID' ) ; if ( ! $RID ) { $view_err .= UL ( LI ( "no RID" ) ) ; $view = 'home' ; } else { $repo = get_repo ( $RID ) ; $repo -> assert_has_manager () ; } } elseif ( $ACT == 'GET_FORM_REPO' ) { if ( $id = GETVAR ( 'ID' ) ) { $repo = get_repo ( $id ) ; } else { $repo = new Repo ; $repo -> set_defaults () ; } if ( $id ) { $repo -> root () -> assert_is_manager () ; } if ( $err = $repo -> get_form_repo () ) { $view_err .= $err ; } elseif ( $repo -> id ) { $view_upd .= $repo -> update () ; $repo = $repo -> reget () ; # in update : make_svnaccess_file () ; } else { $view_upd .= $repo -> insert () ; $repo = $repo -> reget () ; make_svnaccess_file () ; } } elseif ( $ACT == 'GET_FORM_SUB' ) { $ID = GETVAR ( 'ID' ) ; if ( ! $ID ) { $view_err .= UL ( LI ( "GET_FORM_SUB : no ID" ) ) ; } else { $repo = get_repo ( $ID ) ; $PATH = GETVAR ( 'PATH' ) ; $sub = $repo -> find_sub ( $PATH ) ; $sub -> assert_is_manager () ; $err = $sub -> get_form_sub () ; if ( $err ) { $view_err .= $err ; } elseif ( $err = $repo -> check_managers () ) { $view_err .= $err ; $repo = $repo -> reget () ; } else { $view_upd .= $sub -> update () ; $repo = $sub -> reget () ; make_svnaccess_file () ; } } } elseif ( $ACT == 'DEL' ) { $RID = GETVAR ( 'RID' ) ; if ( ! $RID ) { $view_upd .= UL ( LI ( "no RID" ) ) ; $view = 'home' ; } elseif ( $repo = try_repo ( $RID ) ) { $repo -> root () -> assert_is_manager () ; $view_ack .= $repo -> gen_form_del_ack ( 'DEL_ACK' ) ; $view = 'del_ack' ; } else { $view_err .= UL ( LI ( "can't find repository $RID" ) ) ; $view = 'home' ; } } elseif ( $ACT == 'DEL_ACK' ) { $RID = GETVAR ( 'XID' ) ; if ( ! $RID ) { $view_err .= UL ( LI ( "no RID" ) ) ; $view = 'home' ; } elseif ( $repo = try_repo ( $RID ) ) { $repo -> root () -> assert_is_manager () ; if ( $_POST [ 'YES' ] ) { $view_upd .= $repo -> delete () ; $view = 'home' ; } else { $view_upd .= UL ( LI ( "canceled delete" ) ) ; } } else { $view_upd .= UL ( LI ( "can't find repository $RID" ) ) ; $view = 'home' ; } } elseif ( $ACT == 'DEL_PATH' ) { $RID = GETVAR ( 'RID' ) ; if ( ! $RID ) { $view_upd .= UL ( LI ( "no RID" ) ) ; } elseif ( $repo = try_repo ( $RID ) ) { $repo -> root () -> assert_is_manager () ; $PID = GETVAR ( 'PID' ) ; if ( $Path = $repo -> pids [ $PID ] ) { $sub = $repo -> make_sub ( $Path -> path ) ; $view_ack .= $sub -> gen_form_del_ack ( 'DEL_PATH_ACK' ) ; $view = 'del_ack' ; } else { $view_err .= UL ( LI ( "can't find path '$PID'" ) ) ; } } else { $view_err .= UL ( LI ( "can't find repository $RID" ) ) ; } } elseif ( $ACT == 'DEL_PATH_ACK' ) { $PID = GETVAR ( 'XID' ) ; if ( ! $PID ) { $view_err .= UL ( LI ( "no PID" ) ) ; $view = 'home' ; } elseif ( $Path = get_path ( $PID ) ) { $repo = get_repo ( $Path -> rid ) ; $repo -> root () -> assert_is_manager () ; if ( $_POST [ 'YES' ] ) { $view_upd .= $Path -> delete () ; $repo = $repo -> reget () ; make_svnaccess_file () ; } else { $view_upd .= UL ( LI ( "canceled path delete" ) ) ; } } else { $view_upd .= UL ( LI ( "can't find Path $PID" ) ) ; } } elseif ( $ACT ) { $view_err .= BLD ( "unknown ACT ($ACT)" ) ; $view = 'home' ; } else { $view = 'home' ; } html_start ( $TIT ) ; if ( $view_err ) { echo H2 ( RED ( 'error' ) ) , BQ ( RED ( "Nothing changed because :\n" . $view_err ) ) ; } if ( $view_upd ) { echo H3 ( 'updates' ) ; echo RED ( $view_upd ) ; } if ( $view == 'home' ) { $class = Conf ( 'clases' ) ; $dscr = $class [ $CLAS ] -> dscr ; $msg = "$dscr can't create repositories" ; echo ULc ( $USER, LI2 ( may_create_repo (), new_repo_url (), $msg ) ) ; echo gen_repos_tab () ; } elseif ( $view == 'new_repo' ) { if ( ! $USER ) { html_exit ( "go away" ) ; } if ( $repo -> id ) { html_exit ( "view $view : repo has id??" ) ; } echo H2 ( 'create a new repository' ) ; echo BQ ( $repo -> gen_form_top ( 'GET_FORM_REPO' ) ) ; } elseif ( $view == 'form' ) { if ( ! $USER and ! $repo -> has_public () ) { html_exit ( "repo isn't public" ) ; } elseif ( $USER and ! $repo -> has_reader () and ! $repo -> has_manager () ) { html_exit ( "not your repo" ) ; } $id = $repo -> id ; $rev = $repo -> revision () ; $stts = $repo -> cnt_stats () ; $name = $id ? $repo -> repo_name () : 'undefined' ; if ( $stts > 1 ) { echo BQ ( $repo -> plot_url ( '' ) ) ; } echo H2 ( "repo $name" ) ; if ( $repo -> is_root_manager () ) { echo ULcc ( LIc ( $id, $repo -> del_url () ) ) ; echo BQ ( $repo -> gen_form_top ( 'GET_FORM_REPO' ) ) ; } else { echo BQ ( $repo -> show_top () ) ; } if ( $repo -> id ) { $rman = $repo -> is_root_manager () ; foreach ( $repo -> subs as $sub ) { $tag = ITA ( $sub -> tag () ) ; $path = $sub -> path ; if ( $sub -> is_manager () ) { echo H3 ( "edit rights on $tag" ) ; if ( $path and $rman ) { echo UL ( LI ( $sub -> del_url () ) ) ; } echo BQ ( $sub -> gen_form_sub ( 'GET_FORM_SUB' ) ) ; } elseif ( $sub -> is_reader () ) { echo H3 ( "path $tag" ) ; echo BQ ( $sub -> show_sub () ) ; } } } else { html_exit ( "view $view : repo has no id??" ) ; } if ( $id and $repo -> is_root_manager () ) { if ( $rev == 0 ) { echo H3 ( 'svn load' ) ; echo BQ ( $repo -> load_form () ) ; } echo H3 ( 'svn access rights' ) ; echo "" ; echo gen_conf_repo ( $repo, NULL ) ; echo "\n" ; } } elseif ( $view == 'del_ack' ) { echo H4 ( 'confirm' ) ; echo $view_ack ; } else { html_exit ( "unknown view ($view)" ) ; } html_end () ; # phpinfo() ; ?>
" ; echo gen_conf_repo ( $repo, NULL ) ; echo "