コード例 #1
0
ファイル: daemon.php プロジェクト: BGCX261/zhpanel-svn-to-git
 function user($data)
 {
     $data = unserialize($data);
     if (!is_object($data) || !isset($data->user)) {
         return false;
     }
     $cmd = "/usr/sbin/";
     $result = false;
     $USER = $data->user;
     $PASS = $data->pass;
     $CGI_SYS = ZH_DATA . "/cgi-system";
     if (!is_dir($CGI_SYS)) {
         mkdir($CGI_SYS, 0700, true);
     }
     switch ($data->action) {
         case 'add':
             log_msg("Adding user account...");
             $pass_crypted = crypt($PASS);
             $cmd0 = "/usr/sbin/useradd -m -s /bin/bash -p '{$pass_crypted}' {$USER}";
             log_msg($cmd0);
             $result = shell_exec($cmd0);
             // ADD USER
             //if(!$result) return;
             /*echo "Setting password...\n";
             		$cmd0 = "echo '$USER:$PASS' | chpasswd";
             		echo "$cmd0\n\n";
             		$result = shell_exec($cmd0);	// SET PASSWORD
             		//if(!$result) return;*/
             log_msg("Copying template files...");
             $cmd0 = "cp -r {$CGI_SYS}/TEMPLATE {$CGI_SYS}/{$USER}";
             log_msg($cmd0);
             $result = shell_exec($cmd0);
             // MAKE FASTCGI WRAPPERS
             //if(!$result) return;
             log_msg("Updating template files...");
             $cmd0 = "sed -i 's/TEMPLATE/{$USER}/g' {$CGI_SYS}/{$USER}/*";
             log_msg($cmd0);
             $result = shell_exec($cmd0);
             // DO UPDATE
             //if(!$result) return;
             log_msg("Fixing ownership...");
             $cmd0 = "chown -R {$USER}.{$USER} {$CGI_SYS}/{$USER}";
             log_msg($cmd0);
             $result = shell_exec($cmd0);
             // FIX PERMISSIONS
             //if(!$result) return;
             log_msg("Fixing permissions...");
             $cmd0 = "chmod -R 755 {$CGI_SYS}/{$USER}";
             log_msg($cmd0);
             $result = shell_exec($cmd0);
             // FIX PERMISSIONS
             //if(!$result) return;
             log_msg("Fixing ownership...");
             $cmd0 = "chmod 711 /home/{$USER}";
             log_msg($cmd0);
             $result = shell_exec($cmd0);
             // FIX PERMISSIONS
             //if(!$result) return;
             $passwd = file_get_contents('/etc/passwd');
             preg_match("#\n{$USER}:x:(\\d+):(\\d+)#", $str, $out);
             $uid = $out[1];
             $gid = $out[2];
             global $pdo;
             $pdo->update('user', array('uid' => $uid, 'gid' => $gid), "user='******'");
             syncFtpUsers(false);
             global $zhd;
             $zhd->proftpd('restart');
             break;
         case 'mod':
             $pass_crypted = getcrypted($PASS);
             $cmd .= "/usr/sbin/usermod -p '{$pass_crypted}' {$USER}";
             $result = shell_exec($cmd);
             syncFtpUsers(false);
             global $zhd;
             $zhd->proftpd('restart');
             break;
         case 'del':
             // DANGEROUS
             log_msg('Backup user\'s files...');
             $cmd0 = "mv -f /home/{$USER} /home/backup/";
             log_msg($cmd0);
             $result = shell_exec($cmd0);
             // DO A BACKUP FIRST
             log_msg("Deleting user account...");
             $cmd0 = "/usr/sbin/userdel -rf {$USER}";
             log_msg($cmd0);
             $result = shell_exec($cmd0);
             log_msg("Deleting user's fcgid wrappers...");
             $cmd0 = "rm -rf {$CGI_SYS}/{$USER}";
             log_msg($cmd0);
             $result = shell_exec($cmd0);
             break;
         case 'jail':
             $service .= $cmd;
             break;
         case 'unjail':
             $service .= $cmd;
             break;
         default:
             return false;
     }
     return $result;
 }
コード例 #2
0
ファイル: ftp.php プロジェクト: BGCX261/zhpanel-svn-to-git
                    }
                } else {
                    if ($op == 'edit') {
                        foreach ($_REQUEST as $k => $v) {
                            $_REQUEST[$k] = str_replace(':', '', $v);
                        }
                        if (ZFtp::updateFtpAccount($owner, $name, $password, $_REQUEST['docroot'], $_REQUEST['writable'])) {
                            setmsg(t('Ftp Account Modified.'), 'notice', 'ftp.php');
                        }
                    }
                }
            }
        }
        break;
    case 'sync':
        if (syncFtpUsers()) {
            setmsg(t('Ftp configuration updated!'), 'notice');
        } else {
            setmsg(t('Can not write the configuration file.'), 'error');
        }
        break;
    case 'list':
    default:
        $task = 'list';
        $owner = isadmin() ? '' : $me;
        $accounts = ZFtp::getFtpAccounts($owner);
        break;
}
if (!$norender) {
    include template('ftp');
}
コード例 #3
0
ファイル: index.php プロジェクト: BGCX261/zhpanel-svn-to-git
     $sys = ZSystem::getSettings();
     $tpl_dir = ZH . "/tpl";
     $d = dir($tpl_dir);
     $themes = array();
     while ($f = $d->read()) {
         $param_file = "{$tpl_dir}/{$f}/param.ini";
         if (!is_file($param_file)) {
             continue;
         }
         $param = parse_ini_file($param_file);
         $themes[] = (object) $param;
     }
     break;
 case 'sync':
     syncSystemUsers();
     syncFtpUsers();
     syncVhosts();
     syncCBand();
     syncCrontab();
     setmsg(t('All data updated!'), 'notice');
     break;
 case 'ctl':
     if (!isadmin()) {
         setmsg(t('Permission Denied'));
     }
     $a = strtolower($_REQUEST['a']);
     // Application
     $o = $_REQUEST['o'];
     // Operation
     if ($a == 'apache' && in_array($o, array('start', 'stop', 'restart'))) {
         $cmd = "/etc/init.d/apache2 {$o}";
コード例 #4
0
function sync()
{
    syncFtpUsers();
    syncVhosts();
    syncCBand();
    syncSystemUsers();
    syncCrontab();
    syncQuota();
}