Mercurial > public > src > phphgadmin
changeset 47:325d484d38cc
- most of 1.0 functionality restored (need to verify)
- TODO code commenting, remaining minor config integration, begin new features
author | joshjcarrier |
---|---|
date | Thu, 10 Jun 2010 23:06:54 -0700 |
parents | 5e978803799f |
children | f6070bf8c280 |
files | README.txt admin/application/config/phphgadmin.php admin/application/controllers/hgdir.php admin/application/libraries/hg_filesystem.php admin/application/libraries/hg_ini.php admin/application/libraries/iniparser.php admin/application/libraries/phphgadmin.php admin/application/views/repo_directory.php |
diffstat | 8 files changed, 79 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/README.txt Thu Jun 10 17:50:53 2010 -0700 +++ b/README.txt Thu Jun 10 23:06:54 2010 -0700 @@ -14,14 +14,13 @@ Pre-requisites: * server supports Mercurial (visit web site for more information) * server supports PHP -* all files and folders are writable by the server in: - * cgi-bin, where Mercurial holds it's configuration and repositories - * /admin/lock, where this application exercises optimistic locking and has a small amount of scratch space +* all files and folders are writable by the server where: + * folders where Mercurial holds it's configuration and repositories + * ./lock directory, where this application exercises optimistic locking and has a small amount of scratch space Configuration files: Must revise and edit these configuration files before installation is complete. In /admin/application/config/: - * config.php - standard CodeIgniter setup - * hgphp.php - Mercurial-related defaults + * phphgadmin.php - Mercurial-related defaults This system was designed for use with the quick Hg installation guide available at: http://redirect.joshjcarrier.com/?r=hgwebinstall @@ -32,16 +31,15 @@ Web: http://redirect.joshjcarrier.com/?r=hgphp Changelog: -1.0.2010xxxx -- hgweb.config and the repositories can now exist in separate directories -- error suppression when invalid absolute paths set -- auto-insertion bug which re-added all folders in the repo directory on create/delete, even if not formally registered +1.1.xxx (unstable) +- rebranded to phpHgAdmin +- framework revised +- support for multiple hgweb.config +- much more customizable and flexible installation - blacklists creation of a repo derived from config 'base_url' instead of value "admin" where $config['base_url'] = http://www.contoso.com/hgadmin will blacklist "hgadmin" -- missed translation items in hgdir controller -- installation portability -- rebranded to phpHgAdmin -Upgrade warning: there are new items in hgphp.php configuration file, and some revised existing parameters. +- multiple bug fixes +Upgrade warning: fresh install recommended due to significant changes. 1.0.20100519 - initial release
--- a/admin/application/config/phphgadmin.php Thu Jun 10 17:50:53 2010 -0700 +++ b/admin/application/config/phphgadmin.php Thu Jun 10 23:06:54 2010 -0700 @@ -1,5 +1,8 @@ <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); + +$config['base_url'] = "http://localhost:8080/admin/"; + /* * Global permission levels, which override the authenticated user's permissions. * For when you want to completely lock down access.
--- a/admin/application/controllers/hgdir.php Thu Jun 10 17:50:53 2010 -0700 +++ b/admin/application/controllers/hgdir.php Thu Jun 10 23:06:54 2010 -0700 @@ -76,11 +76,6 @@ { $this->phphgadmin->start_tx($this->ofl_lock_hgwebconf, $dummy=''); $action_status = $this->phphgadmin->create_repository($r_name); - - if($action_status == HGPHP_OK) - { - $action_status = $this->hg_ini->touchHgRC($r_name); - } $this->phphgadmin->end_tx(); switch($action_status){ @@ -111,7 +106,7 @@ function delete() { - $r_key = $this->input->post('form_delete_name'); + $r_name = $this->input->post('form_delete_name'); $this->form_validation->set_rules('form_delete_name', 'form_delete_name', 'required'); if ($this->form_validation->run() == FALSE) @@ -120,9 +115,9 @@ } else { - $r_name = base64_decode($r_key); +// $r_name = base64_decode($r_key); $this->phphgadmin->start_tx($this->ofl_lock_hgwebconf, $dummy=''); - $action_status = $this->phphgadmin->delete_repository($r_key); + $action_status = $this->phphgadmin->delete_repository($r_name); $this->phphgadmin->end_tx(); switch($action_status){
--- a/admin/application/libraries/hg_filesystem.php Thu Jun 10 17:50:53 2010 -0700 +++ b/admin/application/libraries/hg_filesystem.php Thu Jun 10 23:06:54 2010 -0700 @@ -15,9 +15,9 @@ * @param r_name name of repository to create directory for * @return status code */ - function create_repository_dir($r_name, $webdir = null) + function create_repository_dir($r_name, $hgweb = null) { - $install_config = $this->_ci->hg_ini->getInstallConfig($webdir); + $install_config = $this->_ci->hg_ini->getInstallConfig($hgweb); $repo_dir = $install_config['default_repo_dir']; // create repo directory structure recursively $create_status = @mkdir($repo_dir . $r_name . '/.hg/store/data/', 0755, TRUE); @@ -25,9 +25,6 @@ if($create_status == TRUE) { // create hgrc - -// $this->_ci->hgconf2ini->register_OFL($this->_ofl_lock_hgrc); -// $create_status = $this->_ci->hgconf2ini->touchHgRC($r_name); $create_status = HGPHP_OK; } else @@ -44,10 +41,10 @@ * @param r_name name of repository to delete directory of * @return status code */ - function delete_repository_dir($repository_name, $webdir = null) + function delete_repository_dir($r_name, $hgweb = null) { - // FIXME read from hgweb - $cd = 'C:\Users\joshjcarrier\workspace\hg-php.joshjcarrier.com\admin\lock\cgi-bin/' . $repository_name; + $cd = $this->_ci->hg_ini->getHgRCPath($r_name, $hgweb); + $this->recursiveDelete($cd . '/.hg/'); $del_status = $this->recursiveDelete($cd); if($del_status == TRUE) @@ -66,11 +63,14 @@ * * @return the array containing 0 or more valid directories */ - function real_dirscan() + function real_dirscan($hgweb = null) { $this->_ci->load->helper('directory'); - $realdir = directory_map('C:\Users\joshjcarrier\workspace\hg-php.joshjcarrier.com\admin\lock\cgi-bin/', TRUE); + $install_config = $this->_ci->hg_ini->getInstallConfig($hgweb); + $repo_dir = $install_config['default_repo_dir']; + + $realdir = directory_map($repo_dir, TRUE); $verifiedrealdir = array(); if(is_array($realdir)) @@ -78,7 +78,7 @@ foreach($realdir as $file) { // checks if we detected a folder - if(is_dir('C:\Users\joshjcarrier\workspace\hg-php.joshjcarrier.com\admin\lock\cgi-bin/' . $file)) + if(is_dir($repo_dir . $file)) { $verifiedrealdir[$file] = $file; }
--- a/admin/application/libraries/hg_ini.php Thu Jun 10 17:50:53 2010 -0700 +++ b/admin/application/libraries/hg_ini.php Thu Jun 10 23:06:54 2010 -0700 @@ -17,6 +17,7 @@ { private $_ci; + private $_ofl_lock; private $_default_webdir; private $_webdir_arr; @@ -79,12 +80,12 @@ $hgwebconf_all = $this->_ci->optimisticflock->ofl_parse_ini_file($ini_path, true, $this->_ofl_lock, $hgwebconf_err_code); if($hgwebconf_err_code == HGPHP_OK) { - return $hgwebconf_all; + return $hgwebconf_all; } return $hgwebconf_err_code; } - function saveHgWeb($r_name, $hgrc_data, $hgweb = null) + function saveHgWeb($hgrc_data, $hgweb = null) { // load the PHP to file $install_config = $this->getInstallConfig($hgweb); @@ -106,7 +107,7 @@ } } - function getHgRCPath($r_name, $hgweb) + function getHgRCPath($r_name, $hgweb = null) { $hgweb_ini = $this->loadHgWeb($r_name, $hgweb); $repo_dir = $hgweb_ini->get($r_name, 'paths'); @@ -140,16 +141,16 @@ * @param r_name name of the repo folder which will have an HGRC file added to * @return status code */ - function touchHgRC($r_name) + function touchHgRC($r_name, $hgweb = null) { $hgrc_path = $this->getHgRCPath($r_name, $hgweb) . '/.hg/hgrc'; // create file + $touch_status = $this->_ci->optimisticflock->ofl_touch($hgrc_path, $this->_ofl_lock); if($touch_status == HGPHP_OK) { $blank_hgrc = $this->__blank_hgrc($r_name); - // update touch status for setHGRC return code $touch_status = $this->saveHgRC($r_name, $blank_hgrc); } @@ -177,9 +178,13 @@ * @param hgrc_data multi-array representation of the new HGRC file * @return status code */ - function saveHgRC($r_name, $hgrc_data) + function saveHgRC($r_name, $hgrc_data, $hgweb = null) { + $dummy = ''; + $ofl_lock = $this->_ofl_lock; + $this->_ofl_lock = &$dummy; $hgrc_path = $this->getHgRCPath($r_name, $hgweb) . '/.hg/hgrc'; + $this->_ofl_lock = &$ofl_lock; $hgrc_new_ini = ';Generated by Hg-PHP Mercurial Repository Manager v'.HGPHP_VERSION;
--- a/admin/application/libraries/iniparser.php Thu Jun 10 17:50:53 2010 -0700 +++ b/admin/application/libraries/iniparser.php Thu Jun 10 23:06:54 2010 -0700 @@ -180,8 +180,13 @@ } } - function unsetKey($hashkey, $collection=null) + function unsetKey($hashkey, $collection=null, $pre_hashed = FALSE) { + if(!$pre_hashed) + { + $hashkey = base64_encode($hashkey); + } + if($collection != null) { $hashcollection = base64_encode($collection);
--- a/admin/application/libraries/phphgadmin.php Thu Jun 10 17:50:53 2010 -0700 +++ b/admin/application/libraries/phphgadmin.php Thu Jun 10 23:06:54 2010 -0700 @@ -73,10 +73,10 @@ } } - foreach($hgwebrepos as $id => $repo) - { - $hgrepos[$repo]['id'] = $id; - } +// foreach($hgwebrepos as $id => $repo) +// { +// $hgrepos[$repo]['id'] = $id; +// } return $hgrepos; } @@ -131,8 +131,13 @@ // $existingdir = $tempexistingdir; // not registered in hgweb.config - if(!in_array($r_name, array_values($lsdir))) + + $hashr_name = base64_encode($r_name); +// print_r($lsdir); +// echo $hashr_name; + if(!isset($lsdir[$hashr_name])) { + // edit the directory // $existingdir[$r_name] = $r_name; $this->_ci->hg_ini->register_OFL($this->_ofl_lock_hgweb); @@ -142,7 +147,14 @@ { // then create the repository // $this->_ci->hg_ini->register_OFL($this->_ofl_lock_hgrc); + $this->_ci->hg_ini->register_OFL($this->_ofl_lock_hgrc); $create_status = $this->_ci->hg_filesystem->create_repository_dir($r_name); + + if($create_status == HGPHP_OK) + { + + $create_status = $this->_ci->hg_ini->touchHgRC($r_name); + } } } else @@ -176,8 +188,9 @@ * @param r_key id of the repo to delete permanently * @return status code */ - function delete_repository($r_key) + function delete_repository($r_key, $hgweb = null) { + $hashr_key = base64_encode($r_key); if(!$this->can_delete($r_key)) { return HGPHP_ERR_PERM_USR; @@ -188,23 +201,22 @@ // simplifies repo list into array where name is both key and value // this is how hgweb.config wants it - $existingdir = array_values($lsdir); - $tempexistingdir = array(); - foreach($existingdir as $repo_name) - { - $tempexistingdir[$repo_name] = $repo_name; - } - $existingdir = $tempexistingdir; - - if(isset($lsdir[$r_key])) +// $existingdir = array_values($lsdir); +// $tempexistingdir = array(); +// foreach($existingdir as $repo_name) +// { +// $tempexistingdir[$repo_name] = $repo_name; +// } +// $existingdir = $tempexistingdir; + if(isset($lsdir[$hashr_key])) { // edit the directory - // remove hgweb.config $this->_ci->hg_ini->register_OFL($this->_ofl_lock_hgweb); // $del_status = $this->_ci->hgconf2ini->setHgWebDirCollections($existingdir); - $del_status = $this->_ci->hg_ini->unregisterRepo($r_key); + $del_status = $this->_ci->hg_filesystem->delete_repository_dir($r_key); + // remove from hgweb.config if($del_status == HGPHP_OK) @@ -218,11 +230,11 @@ // // if($del_status == HGPHP_OK) // { - $del_status = $this->_ci->hg_filesystem->delete_repository_dir($lsdir[$r_key]); + $del_status = $this->_ci->hg_ini->unregisterRepo($r_key); // } // } } - unset($existingdir[$r_key]); +// unset($existingdir[$r_key]); } else {
--- a/admin/application/views/repo_directory.php Thu Jun 10 17:50:53 2010 -0700 +++ b/admin/application/views/repo_directory.php Thu Jun 10 23:06:54 2010 -0700 @@ -120,9 +120,9 @@ <br /> <select style="width:100%" name="form_delete_name" id="form_delete_name"> <option selected="selected" value=""></option> - <?php if(isset($lsdir)): foreach($lsdir as $repo): if(isset($repo['id'])): ?> - <option value="<?php echo $repo['id']; ?>"><?php echo $repo['name']; ?></option> - <?php endif; endforeach; endif; ?> + <?php if(isset($lsdir)): foreach($lsdir as $r_id => $repo): ?> + <option value="<?php echo $r_id; ?>"><?php echo $repo['name']; ?></option> + <?php endforeach; endif; ?> </select> <br /> </td>