| 1 |
<? |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
function handle_pear_error ($error_obj) { |
|---|
| 28 |
if (DEBUG) echo ($error_obj->getMessage()."\n".$error_obj->getDebugInfo() . '<br>'); |
|---|
| 29 |
} |
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
function &getSession($branch) { |
|---|
| 37 |
global $VCSConf; |
|---|
| 38 |
if (!($vcs = VCSessionRegistry::getVCSession($branch))) { |
|---|
| 39 |
if (isset($VCSConf[$branch])) { |
|---|
| 40 |
$vcs = & new VCSession(&$VCSConf[$branch]); |
|---|
| 41 |
VCSessionRegistry::addVCSession($branch,$vcs); |
|---|
| 42 |
} else { |
|---|
| 43 |
return false; |
|---|
| 44 |
} |
|---|
| 45 |
} |
|---|
| 46 |
return $vcs; |
|---|
| 47 |
} |
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
function vcInit() { |
|---|
| 53 |
$VCSession = new VCSession(); |
|---|
| 54 |
VCSessionRegistry::addDefaultVCSession($VCSession); |
|---|
| 55 |
} |
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
function batchStart($cmd) { |
|---|
| 62 |
$pipe = popen ("/usr/bin/at now &> /dev/null", "w"); |
|---|
| 63 |
fwrite($pipe, "$cmd\n"); |
|---|
| 64 |
pclose($pipe); |
|---|
| 65 |
} |
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
function &array_copy(&$a1, &$a2) { |
|---|
| 74 |
foreach($a2 as $key => $val) { |
|---|
| 75 |
$a1[$key] = $val; |
|---|
| 76 |
} |
|---|
| 77 |
return $a1; |
|---|
| 78 |
} |
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
function reallyILang($lang) { |
|---|
| 86 |
if (is_numeric($lang)) { |
|---|
| 87 |
return $lang; |
|---|
| 88 |
} else { |
|---|
| 89 |
$langobj = mgd_get_language_by_code($lang); |
|---|
| 90 |
if (!is_object($langobj)) { |
|---|
| 91 |
trigger_error("I don't know this language code", E_USER_WARNING); |
|---|
| 92 |
return 0; |
|---|
| 93 |
} else { |
|---|
| 94 |
return $langobj->id; |
|---|
| 95 |
} |
|---|
| 96 |
} |
|---|
| 97 |
} |
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
function reallySLang($lang) { |
|---|
| 105 |
if (is_string($lang)) { |
|---|
| 106 |
return $lang; |
|---|
| 107 |
} else { |
|---|
| 108 |
$langobj = mgd_get_language($lang); |
|---|
| 109 |
if (!is_object($langobj)) { |
|---|
| 110 |
trigger_error("I don't know this language id", E_USER_WARNING); |
|---|
| 111 |
return 0; |
|---|
| 112 |
} else { |
|---|
| 113 |
return $langobj->code; |
|---|
| 114 |
} |
|---|
| 115 |
} |
|---|
| 116 |
} |
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
function create_hash_dirs ($base) { |
|---|
| 123 |
for ($i = 0; $i < 16; $i++) { |
|---|
| 124 |
$top = "$base/" . strtolower(sprintf('%X', $i)); |
|---|
| 125 |
mkdir($top); |
|---|
| 126 |
for ($j = 0; $j < 16; $j++) { |
|---|
| 127 |
mkdir("$top/" . strtolower(sprintf('%X', $j))); |
|---|
| 128 |
} |
|---|
| 129 |
} |
|---|
| 130 |
} |
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
function get_hash_path($guid) { |
|---|
| 138 |
return "{$guid{0}}/{$guid{1}}/$guid"; |
|---|
| 139 |
} |
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
function get_hash_dir($guid) { |
|---|
| 147 |
return "{$guid{0}}/{$guid{1}}"; |
|---|
| 148 |
} |
|---|
| 149 |
|
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 |
function is_guid($spec) { |
|---|
| 156 |
if (strlen($spec) == 32 and strspn($spec, '0123456789abcdef') == 32) { |
|---|
| 157 |
return true; |
|---|
| 158 |
} else { |
|---|
| 159 |
return false; |
|---|
| 160 |
} |
|---|
| 161 |
} |
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 |
|
|---|
| 168 |
function &getOutgoingDirs($branchid) { |
|---|
| 169 |
$dirs = array(); |
|---|
| 170 |
foreach ($GLOBALS['VCSConf'] as $dbconf) { |
|---|
| 171 |
if (@$dbconf['branchid'] == $branchid and !isset($dbconf['vcconf'])) { |
|---|
| 172 |
$dirs[] = $dbconf['fsconf']['import']; |
|---|
| 173 |
} |
|---|
| 174 |
} |
|---|
| 175 |
return $dirs; |
|---|
| 176 |
} |
|---|
| 177 |
|
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 |
function path_minus_one($path) { |
|---|
| 182 |
$lastslash = strrpos($path, '/'); |
|---|
| 183 |
if ($lastslash == 0) { |
|---|
| 184 |
return ''; |
|---|
| 185 |
} |
|---|
| 186 |
return substr($path, 0, $lastslash); |
|---|
| 187 |
} |
|---|
| 188 |
|
|---|
| 189 |
function isRoot() { |
|---|
| 190 |
$midgard = mgd_get_midgard(); |
|---|
| 191 |
if (!$midgard->root) { |
|---|
| 192 |
return MGD_ERR_ACCESS_DENIED; |
|---|
| 193 |
} else return true; |
|---|
| 194 |
} |
|---|
| 195 |
|
|---|
| 196 |
if (!function_exists("file_get_contents")) { |
|---|
| 197 |
function file_get_contents($filename) { |
|---|
| 198 |
$fp = @fopen($filename, "r"); |
|---|
| 199 |
if (!($fp)) { |
|---|
| 200 |
return 0; |
|---|
| 201 |
} |
|---|
| 202 |
$temp = ''; |
|---|
| 203 |
while (!feof($fp)) { |
|---|
| 204 |
$temp .= fread($fp, 4096); |
|---|
| 205 |
} |
|---|
| 206 |
return $temp; |
|---|
| 207 |
} |
|---|
| 208 |
} |
|---|
| 209 |
|
|---|
| 210 |
?> |
|---|