Exemplo n.º 1
0
<?php

//加载配置文件
include "config.mvc.php";
$command = isset($argv[1]) ? $argv[1] : '';
$daemonize = isset($argv[2]) ? false : true;
switch ($command) {
    case 'start':
        __start($daemonize);
        break;
    case 'stop':
        __stop();
        break;
    case 'status':
        __status();
        break;
    case 'reload':
        __reload();
        break;
    default:
        echo "usage: php -q server.php [start|stop|reload|status]\n";
        exit(1);
}
exit(0);
function __start($daemonize = true)
{
    if ($pid = __getpid()) {
        echo sprintf("other swoole httpserver run at pid %d\n", $pid);
        exit(1);
    }
    echo "swoole httpserver start\n";
Exemplo n.º 2
0
    $targetFile = rtrim($targetFolder, '/') . "/" . $targetFileName;
    // you may want to do some additional checks on the uploaded files
    // here.
    if (file_exists($targetFile)) {
        __status("{$targetFileName}: already exists, skipping!");
        continue;
    }
    // We do not allow to upload files matching the
    // global $no_access pattern. See _config/conf.php for details.
    if (matches_noaccess_pattern($targetFile)) {
        __status("{$targetFileName}: matches \$no_access pattern");
        continue;
    }
    _debug("moving {$tempFile} to {$targetFile}");
    move_uploaded_file($tempFile, $targetFile);
    __status("{$targetFileName}: Successfully uploaded");
}
/**
TODO:
    - currently, the implementation only works if the user has configured the same home
      directory like given in the global configuration as "home_dir", since we have
      no access to the session for authenticating the user.

Notes:
    -  We don't want to pass the absolute directory to the home directory
       by a post variable. This enables everybody to move a file
       from a random location on the server to any other
       location.
    - The session seams not to be valid within this script.
        -> We cannot determine the home directory of the user
           correctly