当前位置: 首页>>代码示例>>PHP>>正文


PHP COM::run方法代码示例

本文整理汇总了PHP中COM::run方法的典型用法代码示例。如果您正苦于以下问题:PHP COM::run方法的具体用法?PHP COM::run怎么用?PHP COM::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在COM的用法示例。


在下文中一共展示了COM::run方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: insert

function insert()
{
    $newDomainName = isset($_GET['newdomain']) ? $_GET['newdomain'] : null;
    $domainFileToCreate = NGINX_DOMAINS_DIR . $newDomainName . '.conf';
    clearstatcache();
    /**
     * Create folder "domains" in "/bin/nginx/conf", if not existant yet.
     *
     * Note: the folder is normally created during installation.
     * This is just a fallback, in case the user might have removed it.
     */
    if (!is_dir(NGINX_DOMAINS_DIR)) {
        mkdir(NGINX_DOMAINS_DIR, 0777);
    }
    // read domain template file
    $tplContent = file_get_contents(WPNXM_DATA_DIR . '/config-templates/nginx-domain-conf.tpl');
    // replace the host name in the domain template
    $content = str_replace('%%domain%%', $newDomainName, $tplContent);
    // write new domain file using the domain template as content
    file_put_contents($domainFileToCreate, $content);
    // Add include-line for new domain file in "\bin\nginx\conf\domains.conf"
    clearstatcache();
    $domainsMainConfigFile = WPNXM_DIR . '\\bin\\nginx\\conf\\domains.conf';
    if (!is_writable($domainsMainConfigFile) && !chmod($domainsMainConfigFile, 0777)) {
        exit('The "domains.conf" file is not writeable. Please modify permissions.');
    } else {
        file_put_contents($domainsMainConfigFile, "\n # automatically added domain configuration file \n include domains/{$newDomainName}.conf;", FILE_APPEND);
    }
    // check for "COM" (php_com_dotnet.dll)
    if (!class_exists('COM') and !extension_loaded("com_dotnet")) {
        $msg = 'COM class not found. Enable the extension by adding "extension=php_com_dotnet.dll" to your php.ini.';
        throw new Exception($msg);
    }
    $WshShell = new COM("WScript.Shell");
    // reload nginx configuration
    $cmdRestartNginx = 'cmd /c "' . WPNXM_DIR . '\\bin\\nginx\\nginx.exe -p ' . WPNXM_DIR . ' -c ' . WPNXM_DIR . '\\bin\\nginx\\conf\\nginx.conf -s reload"';
    $oExec = $WshShell->run($cmdRestartNginx, 0, false);
    // add the new virtual host to the windows .hosts file using the "hosts" tool
    $cmdAddHosts = 'cmd /c "' . WPNXM_DIR . '\\bin\\tools\\hosts' . ' add ' . $_SERVER['SERVER_ADDR'] . ' ' . $newDomainName . ' # added by WPN-XM"';
    passthru($cmdAddHosts);
    // flush ipcache
    $cmdIpflush = 'ipconfig /flushdns';
    $oExec = $WshShell->run($cmdIpflush, 0, false);
    // wait a second for dns flush
    sleep(1);
    // forward to new host
    header("Location: http://{$newDomainName}/");
}
开发者ID:siltronicz,项目名称:webinterface,代码行数:48,代码来源:domains.php

示例2: compile_wb


//.........这里部分代码省略.........

\$(DLLDIR)\\php_winbinder.dll: \$(OBJS)
\t\$(rc) /r /fo \$(OUTDIR)\\php_winbinder.dll.res /i "\$(SRCDIR)\\" /d \$(FD) /d FILE_NAME="\\"php_winbinder.dll\\"" /d \$(PN) /d \$(PV) \$(RCFILE)

\t\$(link) /nologo /dll /machine:I386 -out:\$(DLLDIR)\\php_winbinder.dll \\
\t\$(OBJS) \$(LIBS) \$(OUTDIR)\\php_winbinder.dll.res

#clean temporary files:
\tdel /q \$(OUTDIR)\\ *.pch \$(DLLDIR)\\php_winbinder.exp \$(DLLDIR)\\php_winbinder.lib
MCOMP;
    if (!is_dir($obj_tmp_dir)) {
        if (!mkdir($obj_tmp_dir)) {
            // Stefano: now returns message to enable warning handling, instead of calling echo
            return 'Warning: could not create ' . $obj_tmp_dir;
        }
    } else {
        delete_files($obj_tmp_dir . '\\');
    }
    $libs = array("user32.lib", "gdi32.lib", "comdlg32.lib", "comctl32.lib", "shell32.lib", "ole32.lib ", "oleaut32.lib", "winmm.lib", "advapi32.lib", $phplib);
    $c_files = array();
    $h_files = array();
    $rc_files = array();
    $sub_dirs = array('.');
    while (($s_dir = array_shift($sub_dirs)) != null) {
        $content = get_all_files($source_dir, $s_dir);
        $sub_dirs = array_merge($sub_dirs, $content['dir']);
        $c_files = array_merge($c_files, $content['c']);
        $h_files = array_merge($h_files, $content['h']);
        $rc_files = array_merge($rc_files, $content['rc']);
    }
    // while
    if (count($c_files) == 0) {
        // Stefano: now returns message to enable error handling, instead of calling die
        return 'Fatal error: source to compile not found';
    }
    // assemble SOURCES OBJS
    $sources_str = "SOURCES = ";
    $objs_str = "OBJS = ";
    foreach ($c_files as $c_f) {
        $sources_str .= "\t\\\n\t" . $source_dir . $c_f;
        $objs_str .= "\t\\\n\t" . $obj_tmp_dir . "\\" . str_replace('.c', '.obj', basename($c_f));
    }
    // assemble LIBS
    $libs_str = "LIBS = ";
    foreach ($libs as $l) {
        $libs_str .= "\t\\\n\t" . $l;
    }
    // get rc file
    if (count($rc_files) == 1) {
        $rc_file = $source_dir . $rc_files[0];
        // should only one!
    } else {
        $rc_file = "";
    }
    // def
    $def_str = "OUTDIR = {$obj_tmp_dir} \n";
    $def_str .= "LIBDIR = {$lib_dir} \n";
    $def_str .= "DLLDIR = {$dll_dir} \n";
    $def_str .= "SRCDIR = {$source_dir} \n";
    $def_str .= "INCDIR = {$inc_dir} \n";
    $def_str .= "MSLIB = {$ms_lib} \n";
    $def_str .= "RCFILE = {$rc_file} \n";
    $def_str .= "cc = {$cl} \n";
    $def_str .= "rc = {$rc} \n";
    $def_str .= "link = {$link} \n";
    $sources_str .= "\n\n";
    $objs_str .= "\n\n";
    $def_str .= "\n\n";
    // stitch together makefile
    $make_str = $def_str . $sources_str . $objs_str . $libs_str . $m_comp;
    $res = file_put_contents("makefile", $make_str);
    // nmake run
    $cmd = PATH_BIN . 'nmake';
    $par = ' -f makefile FD="FILE_DESCRIPTION=\\"\\\\\\"Windows Binding for PHP ' . $vers_plus . '\\\\\\"\\"" PN="PRODUCT_NAME=\\"\\\\\\"PHP ' . $vers_plus . ' php_winbinder.dll\\\\\\"\\"" PV="P_VERSION=\\"\\\\\\"' . $vers_plus . '\\\\\\"\\""';
    $par = ' -f ' . PATH_BASE . 'makefile FD="FILE_DESCRIPTION=\\"\\\\\\"Windows Binding for PHP ' . $vers_plus . '\\\\\\"\\"" PN="PRODUCT_NAME=\\"\\\\\\"PHP ' . $vers_plus . ' php_winbinder.dll\\\\\\"\\"" PV="P_VERSION=\\"\\\\\\"' . $vers_plus . '\\\\\\"\\""';
    // needed for PHPedit + debugger and php-4.3.10
    if (!empty($_ENV['HTTP_COOKIE']) and strstr($_ENV['HTTP_COOKIE'], 'DBGSESSID') != false or PHP_VERSION == '4.3.10') {
        $dspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
        $pro = proc_open($cmd . $par, $dspec, $pipes);
        if (is_resource($pro)) {
            $result = "";
            while (!feof($pipes[1])) {
                $result .= fgets($pipes[1], 1024);
            }
            while (!feof($pipes[2])) {
                $result .= fread($pipes[2], 8024);
            }
            fclose($pipes[0]);
            fclose($pipes[1]);
            fclose($pipes[2]);
        }
        proc_close($pro);
    } else {
        $WshShell = new COM('WScript.Shell');
        $WshShell->run('cmd /K ' . $cmd . ' ' . $par . ' > ' . PATH_BASE . 'log.txt & exit', 0, true);
        $result = file_get_contents(PATH_BASE . 'log.txt');
        unlink('log.txt');
    }
    return $result;
}
开发者ID:BackupTheBerlios,项目名称:winbinder-svn,代码行数:101,代码来源:compile_wb.php

示例3: executeScript

 public static function executeScript($scriptAndArgs, $bPassKeys = false, $scriptDir = __DIR__)
 {
     $scriptDir = utils::normalize($scriptDir);
     $bWindows = substr(php_uname(), 0, 7) == 'Windows';
     $cmd = $bWindows ? '"C:/Program Files/PHP.5.6.16/php.exe" ' : '/usr/bin/php -q ';
     $cmd .= "{$scriptDir}{$scriptAndArgs}";
     if ($bPassKeys === true) {
         $config = lmv::config();
         $cmd .= " --keys CONSUMERKEY={$config['credentials']['client_id']}" . " --keys CONSUMERSECRET={$config['credentials']['client_secret']}" . " -k MAILJET1={$config['MAILJET1']}" . " -k MAILJET2={$config['MAILJET2']}";
     } else {
         if (is_string($bPassKeys)) {
             $cmd .= $bPassKeys;
         }
     }
     utils::log("Launching command: {$cmd}");
     $result = null;
     if ($bWindows) {
         //$result =pclose (popen ("start /B \"\" $cmd", 'w')) ;
         //$result =exec ("start /B \"\" $cmd") ;
         //$result =shell_exec ("start /B \"\" $cmd") ;
         $com = new \COM('WScript.shell');
         //$cmd .=" > C:/temp/aaa.txt 2>&1" ;
         $com->run($cmd, 0, false);
         // 0 for prod, 1 for debug
     } else {
         //$result =exec ("$cmd > /dev/null 2>&1 &") ;
         //$result =shell_exec ("$cmd > /dev/null 2>&1 &") ;
         putenv('SHELL=/bin/bash');
         print `echo {$cmd} | at now 2>&1`;
     }
     return true;
 }
开发者ID:cyrillef,项目名称:extract-php-view.and.data.api,代码行数:32,代码来源:utils.php


注:本文中的COM::run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。