Login   Register  
PHP Classes
elePHPant
Icontem

File: index.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Jaswinder  >  PHP My SVN Admin  >  index.php  >  Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Sample output
Class: PHP My SVN Admin
Manage SubVersion repositories
Author: By
Last change: Add Branch addition in when adding repo permission so that we can assign different branches to users and not just root
Date: 1 year ago
Size: 3,714 bytes
 

Contents

Class file image Download
<?php
/**
 * This file is controller for SVN requests like creating new repos, new users, new groups, remove users etc
 * User input validation is done here although validation is not that exntensive as it assumes that this application will be restricted
 *
 * @package PHPMySVNAdmin
 * @author Jaswinder Rattanpal (www.rattanpal.com)
 * @version 1.0
 */

//Include config file to grab all configuration options
require_once('config.php');

$func filter_input(INPUT_GET,'func',FILTER_SANITIZE_STRING);
$action filter_input(INPUT_GET,'action',FILTER_SANITIZE_STRING);

$title 'SVN Manager';
$content '';

$data['config'] = $config;
$data['svn'] = $svn;

switch(
$func){
    
//All groups related functions
    
case 'groups':
        
$title='Groups';
        
$group filter_input(INPUT_GET,'group',FILTER_SANITIZE_STRING);
        
$username filter_input(INPUT_GET,'username',FILTER_SANITIZE_STRING);
        switch(
$action){
            
//Remove a user from group
            
case 'removeuser':
                if(
strlen(trim($group)) && strlen(trim($username))){
                    
$svn->svnGroupRemoveUser($group,$username);
                }
                exit;
                break;
            
//Add a user from group
            
case 'adduser':
                if(
strlen(trim($group)) && strlen(trim($username))){
                    
$svn->svnGroupAddUser($group,$username);
                }
                exit;
                break;
            
//Create a new group
            
case 'create':
                if(
strlen(trim($group))){
                    
$svn->svnGroupCreate($group);
                }
                exit;
                break;
        }
        
        
$content obRequireOnce('templates/groups.php',$data);
        break;
    
//All users related functions
    
case 'users':
        
$title 'Users';
        
$username filter_input(INPUT_GET,'username',FILTER_SANITIZE_STRING);
        
$password filter_input(INPUT_GET,'password',FILTER_SANITIZE_STRING);
        switch(
$action){
            
//Create new user
            
case 'create':
                if(
strlen(trim($username)) && strlen(trim($password))){
                    
$svn->svnUserCreate($username,$password);
                }
                exit;
                break;
            
//Update user password information
            
case 'update':
                if(
strlen(trim($username)) && strlen(trim($password))){
                    
$svn->svnUserUpdate($username,$password);
                }
                exit;
                break;
            
//Remove a user
            
case 'remove':
                if(
strlen(trim($username))){
                    
$svn->svnUserRemove($username);
                }
                exit;
                break;
        }
        
$content obRequireOnce('templates/users.php',$data);
        break;
    
//Repo related functions
    
case 'repos':
        
$title 'Repos';
        switch(
$action){
            
//Remove a user from repo
            
case 'remove':
                
$repo filter_input(INPUT_GET,'repo',FILTER_SANITIZE_STRING);
                
$userGroup filter_input(INPUT_GET,'ug',FILTER_SANITIZE_STRING);
                
$svn->repoRemoveUserGroup($repo,$userGroup);
                exit;
                break;
            
//Add a user to repo
            
case 'add':
                
$branch filter_input(INPUT_GET,'b',FILTER_SANITIZE_STRING);
                
$branch = (strlen($branch))?$branch:'/';
                
$repo filter_input(INPUT_GET,'repo',FILTER_SANITIZE_STRING);
                
$userGroup filter_input(INPUT_GET,'ug',FILTER_SANITIZE_STRING);
                
$permission filter_input(INPUT_GET,'perm',FILTER_SANITIZE_STRING);
                
$svn->repoAddUserGroup($repo,$userGroup,$permission,$branch);
                exit;
                break;
            
//Create a new repo
            
case 'create':
                
$client filter_input(INPUT_GET,'client',FILTER_SANITIZE_STRING);
                
$project filter_input(INPUT_GET,'project',FILTER_SANITIZE_STRING);
                if(
strlen(trim($client)) && strlen(trim($project))){
                    
$repo $client.'__'.$project;
                    
$svn->repoCreate($repo);
                }
                exit;
                break;
        }
        
$content obRequireOnce('templates/repos.php',$data);
        break;
    default:
        
$content obRequireOnce('templates/index.php');
        break;
}

//Output all HTML data
require_once('templates/template.php');