Newer
Older
$app->log('Removed client directory: '.$client_dir, LOGLEVEL_DEBUG);
if($app->system->is_group('client'.$client_id)){
$this->_exec('groupdel client'.$client_id);
$app->log('Removed group client'.$client_id, LOGLEVEL_DEBUG);
//* Wrapper for exec function for easier debugging
private function _exec($command) {
global $app;
$app->log('exec: '.$command, LOGLEVEL_DEBUG);
exec($command);
}
private function _checkTcp ($host, $port) {
$fp = @fsockopen($host, $port, $errno, $errstr, 2);
if ($fp) {
fclose($fp);
return true;
} else {
return false;
}
}
public function create_relative_link($f, $t) {
// $from already exists
$from = realpath($f);
// realpath requires the traced file to exist - so, lets touch it first, then remove
@$app->system->unlink($t); touch($t);
@$app->system->unlink($t);
// Remove from the left side matching path elements from $from and $to
// and get path elements counts
$a1 = explode('/', $from); $a2 = explode('/', $to);
for ($c = 0; $a1[$c] == $a2[$c]; $c++) {
unset($a1[$c]); unset($a2[$c]);
}
$cfrom = implode('/', $a1);
// Check if a path is fully a subpath of another - no way to create symlink in the case
if (count($a1) == 0 || count($a2) == 0) return false;
// Add ($cnt_to-1) number of "../" elements to left side of $cfrom
for ($c = 0; $c < (count($a2)-1); $c++) { $cfrom = '../'.$cfrom; }
return symlink($cfrom, $to);
}
private function _rewrite_quote($string) {
return str_replace(array('.', '*', '?', '+'), array('\\.', '\\*', '\\?', '\\+'), $string);
}
private function _is_url($string) {
return preg_match('/^(f|ht)tp(s)?:\/\//i', $string);
}
private function get_seo_redirects($web, $prefix = ''){
$seo_redirects = array();
if(substr($web['domain'], 0, 2) === '*.') $web['subdomain'] = '*';
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
if($web['subdomain'] == 'www' || $web['subdomain'] == '*'){
if($web['seo_redirect'] == 'non_www_to_www'){
$seo_redirects[$prefix.'seo_redirect_origin_domain'] = str_replace('.', '\.', $web['domain']);
$seo_redirects[$prefix.'seo_redirect_target_domain'] = 'www.'.$web['domain'];
$seo_redirects[$prefix.'seo_redirect_operator'] = '';
}
if($web['seo_redirect'] == '*_domain_tld_to_www_domain_tld'){
// ^(example\.com|(?!\bwww\b)\.example\.com)$
// ^(example\.com|((?:\w+(?:-\w+)*\.)*)((?!www\.)\w+(?:-\w+)*)(\.example\.com))$
$seo_redirects[$prefix.'seo_redirect_origin_domain'] = '('.str_replace('.', '\.', $web['domain']).'|((?:\w+(?:-\w+)*\.)*)((?!www\.)\w+(?:-\w+)*)(\.'.str_replace('.', '\.', $web['domain']).'))';
$seo_redirects[$prefix.'seo_redirect_target_domain'] = 'www.'.$web['domain'];
$seo_redirects[$prefix.'seo_redirect_operator'] = '';
}
if($web['seo_redirect'] == '*_to_www_domain_tld'){
$seo_redirects[$prefix.'seo_redirect_origin_domain'] = 'www\.'.str_replace('.', '\.', $web['domain']);
$seo_redirects[$prefix.'seo_redirect_target_domain'] = 'www.'.$web['domain'];
$seo_redirects[$prefix.'seo_redirect_operator'] = '!';
}
}
if($web['seo_redirect'] == 'www_to_non_www'){
$seo_redirects[$prefix.'seo_redirect_origin_domain'] = 'www\.'.str_replace('.', '\.', $web['domain']);
$seo_redirects[$prefix.'seo_redirect_target_domain'] = $web['domain'];
$seo_redirects[$prefix.'seo_redirect_operator'] = '';
}
if($web['seo_redirect'] == '*_domain_tld_to_domain_tld'){
// ^(.+)\.example\.com$
$seo_redirects[$prefix.'seo_redirect_origin_domain'] = '(.+)\.'.str_replace('.', '\.', $web['domain']);
$seo_redirects[$prefix.'seo_redirect_target_domain'] = $web['domain'];
$seo_redirects[$prefix.'seo_redirect_operator'] = '';
}
if($web['seo_redirect'] == '*_to_domain_tld'){
$seo_redirects[$prefix.'seo_redirect_origin_domain'] = str_replace('.', '\.', $web['domain']);
$seo_redirects[$prefix.'seo_redirect_target_domain'] = $web['domain'];
$seo_redirects[$prefix.'seo_redirect_operator'] = '!';
}
return $seo_redirects;
}
} // end class