Mercurial > public > src > phphgadmin
annotate admin/application/libraries/hgphp.php @ 19:51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
author | joshjcarrier |
---|---|
date | Sat, 15 May 2010 13:23:40 -0700 |
parents | 9aceab434288 |
children | 6f38dd98ff78 |
rev | line source |
---|---|
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
1 <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
2 |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
3 /** |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
4 * CodeIgniter Mercurial Repository Management class |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
5 * |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
6 * Scans file system and Mercurial projects directory, allowing |
11
2ec108f96fad
Cleaned up config. UI tidy up. Commenting. Still missing caching and concurrency checks.
joshjcarrier
parents:
10
diff
changeset
|
7 * web-based manipulation of the hgweb.config and hgrc configuration files. |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
8 * |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
9 * Depends on the HgConf2Ini library. |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
10 * |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
11 * @package CodeIgniter |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
12 * @subpackage Libraries |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
13 * @category Libraries |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
14 * @author Josh Carrier |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
15 * @link blog.joshjcarrier.com |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
16 * |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
17 */ |
7 | 18 class HgPHP |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
19 { |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
20 private $_ci; |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
21 |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
22 function __construct($config = array()) |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
23 { |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
24 if(!empty($config)) |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
25 { |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
26 $this->initialize($config); |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
27 } |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
28 |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
29 $this->_ci =& get_instance(); |
7 | 30 $this->_ci->lang->load('hgphp'); |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
31 $this->_ci->load->library('hgconf2ini'); |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
32 log_message('debug', 'HgPHP class Initialized'); |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
33 } |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
34 |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
35 function initialize($config = array()) |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
36 { |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
37 foreach($config as $key=>$val) |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
38 { |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
39 $this->{'_'.$key} = $val; |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
40 } |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
41 } |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
42 |
1
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
43 /** |
4 | 44 * Public accessors - hgweb.config |
45 */ | |
46 | |
47 /** | |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
48 * Returns a list of available repositories. |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
49 * Will show up if: detected in repo directory |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
50 * Will have status "enabled" if: detected in hgweb.config |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
51 * |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
52 * @param ofl_lock_hgwebconf (updated by reference) the current optimistic file lock value |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
53 * @return an array of 0 or more detected repositories |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
54 */ |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
55 function lsdir(&$ofl_lock_hgwebconf) |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
56 { |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
57 $realdir = $this->__realdirscan(); |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
58 $hgwebdir_compat = $this->_ci->hgconf2ini->getHgWebDirCollections($ofl_lock_hgwebconf); |
2
492f28533a05
Cleaned up hgweb.config loading data array a bit. Starting to implement locking system, repository editor.
joshjcarrier
parents:
1
diff
changeset
|
59 |
492f28533a05
Cleaned up hgweb.config loading data array a bit. Starting to implement locking system, repository editor.
joshjcarrier
parents:
1
diff
changeset
|
60 $allrepo = array_merge($realdir, $hgwebdir_compat); |
1
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
61 |
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
62 $hgrepos = array(); |
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
63 foreach($allrepo as $repo) |
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
64 { |
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
65 $hgrepos[$repo]['name'] = $repo; |
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
66 |
2
492f28533a05
Cleaned up hgweb.config loading data array a bit. Starting to implement locking system, repository editor.
joshjcarrier
parents:
1
diff
changeset
|
67 if(isset($realdir[$repo]) && isset($hgwebdir_compat[$repo])) |
1
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
68 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
69 $hgrepos[$repo]['status'] = HGPHP_REPO_STATUS_ENABLED; |
1
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
70 } |
2
492f28533a05
Cleaned up hgweb.config loading data array a bit. Starting to implement locking system, repository editor.
joshjcarrier
parents:
1
diff
changeset
|
71 else if(isset($realdir[$repo]) && !isset($hgwebdir_compat[$repo])) |
1
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
72 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
73 $hgrepos[$repo]['status'] = HGPHP_REPO_STATUS_DISABLED; |
1
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
74 } |
2
492f28533a05
Cleaned up hgweb.config loading data array a bit. Starting to implement locking system, repository editor.
joshjcarrier
parents:
1
diff
changeset
|
75 else if(!isset($realdir[$repo]) && isset($hgwebdir_compat[$repo])) |
1
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
76 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
77 $hgrepos[$repo]['status'] = HGPHP_REPO_STATUS_MISSING; |
1
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
78 } |
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
79 } |
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
80 |
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
81 return $hgrepos; |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
82 } |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
83 |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
84 /** |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
85 * Create a Hg repository by: |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
86 * - adding an entry in hgrc if not present |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
87 * - creating a bare repository if not present |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
88 * @param r_name name of the new repository to create, used as folder name |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
89 * @param hg_lock_hgwebconf (updated by reference) the last known optimistic file lock value of hgwebconf |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
90 * @param hg_lock_hgrc (updated by reference) value of hgrc's lock value |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
91 * @return status code |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
92 */ |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
93 function create_repository($r_name, &$ofl_lock_hgwebconf, &$hg_lock_hgrc) |
3
53341b414217
Ability to create repository entry (via uri), which updates live hgweb.config + sets up an empty directory to push to.
joshjcarrier
parents:
2
diff
changeset
|
94 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
95 if(!$this->can_create($r_name)) |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
96 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
97 return HGPHP_ERR_PERM_USR; |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
98 } |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
99 |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
100 $create_status = HGPHP_OK; |
19
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
101 $ofl_dummylock_hgwebconf = ''; |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
102 $lsdir = $this->lsdir($ofl_dummylock_hgwebconf); // don't want to update the lock yet |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
103 |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
104 // simplifies repo list into array where name is both key and value |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
105 // this is how hgweb.config wants it |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
106 $existingdir = array_keys($lsdir); |
19
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
107 $tempexistingdir = array(); |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
108 foreach($existingdir as $repo_name) |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
109 { |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
110 $tempexistingdir[$repo_name] = $repo_name; |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
111 } |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
112 $existingdir = $tempexistingdir; |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
113 |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
114 // not registered in hgweb.config |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
115 if(!isset($lsdir[$r_name])) |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
116 { |
19
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
117 // edit the directory |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
118 $existingdir[$r_name] = $r_name; |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
119 $create_status = $this->_ci->hgconf2ini->setHgWebDirCollections($existingdir, $ofl_lock_hgwebconf); |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
120 if($create_status == HGPHP_OK) |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
121 { |
19
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
122 // then create the repository |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
123 $create_status = $this->create_repository_dir($r_name, $hg_lock_hgrc); |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
124 } |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
125 } |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
126 // TODO repair missing directory? |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
127 else if($lsdir[$r_name]['status'] == HGPHP_REPO_STATUS_MISSING) |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
128 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
129 $create_status = -100; |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
130 //$this->template->inject_partial('user_msg', 'Repository "'. $r_name .'" RESTORE.'); |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
131 } |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
132 else |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
133 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
134 // repository already exists |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
135 $create_status = HGPHP_ERR_FS_PREEXISTS; |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
136 } |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
137 return $create_status; |
3
53341b414217
Ability to create repository entry (via uri), which updates live hgweb.config + sets up an empty directory to push to.
joshjcarrier
parents:
2
diff
changeset
|
138 } |
53341b414217
Ability to create repository entry (via uri), which updates live hgweb.config + sets up an empty directory to push to.
joshjcarrier
parents:
2
diff
changeset
|
139 |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
140 /** |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
141 * update_repository |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
142 * Update repository's hgrc |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
143 * @param r_name name of the repository to update hgrc for |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
144 * @param hgrc_data array representing new hgrc file |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
145 * @param ofl_lock_hgrc (updated by reference) the current optimistic file lock value |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
146 * @return status code |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
147 */ |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
148 function update_repository($r_name, $hgrc_data, &$ofl_lock_hgrc) |
10 | 149 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
150 return $this->_ci->hgconf2ini->setHGRC($r_name, $hgrc_data, $ofl_lock_hgrc); |
10 | 151 } |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
152 |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
153 /** |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
154 * delete_repository |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
155 * Deletes a repository from the file system and unregisters it from hgweb.config |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
156 * @param r_name name of the repo to delete permanently |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
157 * @param $ofl_lock_hgwebconf (updated by reference) the current optimistic file lock value |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
158 * @return status code |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
159 */ |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
160 function delete_repository($r_name, &$ofl_lock_hgwebconf) |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
161 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
162 if(!$this->can_delete($r_name)) |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
163 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
164 return HGPHP_ERR_PERM_USR; |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
165 } |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
166 |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
167 $del_status = HGPHP_OK; |
19
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
168 $ofl_dummylock_hgwebconf = ''; |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
169 $lsdir = $this->lsdir($ofl_dummylock_hgwebconf); // don't want to update lock yet |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
170 |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
171 // simplifies repo list into array where name is both key and value |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
172 // this is how hgweb.config wants it |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
173 $existingdir = array_keys($lsdir); |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
174 $tempexistingdir = array(); |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
175 foreach($existingdir as $repo_name) |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
176 { |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
177 $tempexistingdir[$repo_name] = $repo_name; |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
178 } |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
179 $existingdir = $tempexistingdir; |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
180 |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
181 if(isset($lsdir[$r_name])) |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
182 { |
19
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
183 // edit the directory |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
184 unset($existingdir[$r_name]); |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
185 // remove hgweb.config |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
186 $del_status = $this->_ci->hgconf2ini->setHgWebDirCollections($existingdir, $ofl_lock_hgwebconf); |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
187 |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
188 // remove from hgweb.config |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
189 if($del_status == HGPHP_OK) |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
190 { |
19
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
191 // existing filesystem is not missing, thus needs to be deleted |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
192 if($lsdir[$r_name]['status'] != HGPHP_REPO_STATUS_MISSING) |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
193 { |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
194 // FIXME ofl lock? |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
195 $del_status = $this->_ci->hgconf2ini->unlinkHGRC($r_name, $ofl_lock); |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
196 |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
197 if($del_status == HGPHP_OK) |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
198 { |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
199 $del_status = $this->delete_repository_dir($r_name); |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
200 } |
51f6d4415b09
completed Issue #8 security - block creation of 'admin' repository name and issue #2 concurrency - hgweb support
joshjcarrier
parents:
18
diff
changeset
|
201 } |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
202 } |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
203 } |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
204 else |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
205 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
206 $del_status = HGPHP_ERR_FS_PREEXISTS; |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
207 } |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
208 return $del_status; |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
209 } |
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
210 |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
211 /** |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
212 * stat_repository |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
213 * Returns the HGRC represented as an array for the specified repository |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
214 * @param r_name name of the project whose hgrc to retrieve |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
215 * @param ofl_lock_hgrc (updated by reference) the current optimistic file lock value will be updated |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
216 * @return array representing hgrc or status code |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
217 */ |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
218 function stat_repository($r_name, &$ofl_lock_hgrc) |
9 | 219 { |
220 // FIXME permission check | |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
221 return $this->_ci->hgconf2ini->getHGRC($r_name, $ofl_lock_hgrc); |
9 | 222 } |
4 | 223 |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
224 |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
225 /** |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
226 * can_create |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
227 * Checks if user has permissions to create this repository |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
228 * @param r_name name of repository wanting to be created |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
229 * @return true if allowed |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
230 */ |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
231 function can_create($r_name) |
4 | 232 { |
233 return $this->_hgwebconf_allow_repo_create; | |
234 } | |
7 | 235 |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
236 /** |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
237 * can_delete |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
238 * Checks if user has permissions to delete this repository |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
239 * @param r_name name of repository wanting to be deleted |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
240 * @return true if allowed |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
241 */ |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
242 function can_delete($r_name) |
7 | 243 { |
244 return $this->_hgwebconf_allow_repo_delete; | |
245 } | |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
246 |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
247 /** |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
248 * create_repository_dir |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
249 * Creates a whole repository directory, with hgrc |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
250 * @param r_name name of repository to create directory for |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
251 * @param ofl_lock_hgrc (updated by reference) the current optimistic file lock value will be updated |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
252 * @return status code |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
253 */ |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
254 function create_repository_dir($r_name, &$ofl_lock_hgrc) |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
255 { |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
256 if(!$this->can_create($r_name)) |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
257 { |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
258 return HGPHP_ERR_PERM_USR; |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
259 } |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
260 |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
261 // create repo directory structure recursively |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
262 $create_status = mkdir($this->_repositories_abs_dir . $r_name . '/.hg/store/data/', 0755, TRUE); |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
263 |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
264 if($create_status == TRUE) |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
265 { |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
266 // create hgrc |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
267 $create_status = $this->_ci->hgconf2ini->touchHGRC($r_name, $ofl_lock); |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
268 } |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
269 else |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
270 { |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
271 // system couldn't make directory |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
272 $create_status = HGPHP_ERR_PERM_SYS_REPODIR; |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
273 } |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
274 return $create_status; |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
275 } |
7 | 276 |
4 | 277 /** |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
278 * delete_repository_dir |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
279 * Deletes a whole repository directory including hgrc and data files |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
280 * @param r_name name of repository to delete directory of |
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
281 * @return status code |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
282 */ |
8
6215bb22f3d3
Refactored config handler functions to new library.
joshjcarrier
parents:
7
diff
changeset
|
283 function delete_repository_dir($repository_name) |
4 | 284 { |
7 | 285 if(!$this->can_delete($repository_name)) |
286 { | |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
287 return HGPHP_ERR_PERM_USR; |
7 | 288 } |
4 | 289 |
11
2ec108f96fad
Cleaned up config. UI tidy up. Commenting. Still missing caching and concurrency checks.
joshjcarrier
parents:
10
diff
changeset
|
290 $cd = $this->_repositories_abs_dir . $repository_name; |
7 | 291 $this->recursiveDelete($cd . '/.hg/'); |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
292 $del_status = $this->recursiveDelete($cd); |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
293 if($del_status == TRUE) |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
294 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
295 $del_status = HGPHP_OK; |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
296 } |
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
297 else |
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
298 { |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
299 $del_status = HGPHP_ERR_PERM_SYS_REPODIR; |
17
4aa2707ae587
Optimistic locking integration mostly completed (missing some temp file stuff on hgweb.config). Need return code constants + ensure all error codes can be returned. OFL not enabled until session integration
joshjcarrier
parents:
11
diff
changeset
|
300 } |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
301 return $del_status; |
4 | 302 } |
3
53341b414217
Ability to create repository entry (via uri), which updates live hgweb.config + sets up an empty directory to push to.
joshjcarrier
parents:
2
diff
changeset
|
303 |
1
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
304 /** |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
305 * Performs a real directory scan where the projects are suppose to reside. |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
306 * |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
307 * @return the array containing 0 or more valid directories |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
308 */ |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
309 function __realdirscan() |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
310 { |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
311 $this->_ci->load->helper('directory'); |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
312 |
11
2ec108f96fad
Cleaned up config. UI tidy up. Commenting. Still missing caching and concurrency checks.
joshjcarrier
parents:
10
diff
changeset
|
313 $realdir = directory_map($this->_repositories_abs_dir, TRUE); |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
314 |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
315 $verifiedrealdir = array(); |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
316 foreach($realdir as $file) |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
317 { |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
318 // checks if we detected a folder |
11
2ec108f96fad
Cleaned up config. UI tidy up. Commenting. Still missing caching and concurrency checks.
joshjcarrier
parents:
10
diff
changeset
|
319 if(is_dir($this->_repositories_abs_dir . $file)) |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
320 { |
1
2d2757428cc6
Repository directory can detect if a repo is enabled, disabled, or missing. Can also parse hgweb.config with a compatibility fix (convert / to ---- as defined in config)
joshjcarrier
parents:
0
diff
changeset
|
321 $verifiedrealdir[$file] = $file; |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
322 } |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
323 } |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
324 |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
325 return $verifiedrealdir; |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
326 } |
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
327 |
7 | 328 /** |
329 * Delete a file or recursively delete a directory | |
330 * | |
331 * @param string $str Path to file or directory | |
18
9aceab434288
Using constants instead of magic numbers. Cleaned up code and commenting.
joshjcarrier
parents:
17
diff
changeset
|
332 * @return true on successful deletion |
7 | 333 */ |
334 function recursiveDelete($str){ | |
335 if(is_file($str)){ | |
336 return @unlink($str); | |
337 } | |
338 elseif(is_dir($str)){ | |
339 $scan = glob(rtrim($str,'/').'/*'); | |
340 foreach($scan as $index=>$path){ | |
341 $this->recursiveDelete($path); | |
342 } | |
343 return @rmdir($str); | |
344 } | |
345 } | |
0
9124b60de5a6
CodeIgniter 1.7.2 base. .htaccess modification for subdirectory serve. Hg_conf library begin - can scan directories on disk.
joshjcarrier
parents:
diff
changeset
|
346 } |