function __construct($params)
 {
     if (isset($params['mailname'])) {
         $this->mailname = $params['mailname'];
     } else {
         if (function_exists('posix_uname')) {
             $uname = posix_uname();
             $this->mailname = $uname['nodename'];
         }
     }
     if (isset($params['port'])) {
         $this->_port = $params['port'];
     } else {
         $this->_port = getservbyname('smtp', 'tcp');
     }
     if (isset($params['timeout'])) {
         $this->timeout = $params['timeout'];
     }
     if (isset($params['verp'])) {
         $this->verp = $params['verp'];
     }
     if (isset($params['test'])) {
         $this->test = $params['test'];
     }
     if (isset($params['peardebug'])) {
         $this->test = $params['peardebug'];
     }
     if (isset($params['netdns'])) {
         $this->withNetDns = $params['netdns'];
     }
 }
Example #2
0
 private static function getIdc()
 {
     $uname = posix_uname();
     $hostname = $uname["nodename"];
     $words = explode(".", $hostname);
     $cluster = $words[count($words) - 3];
     return $cluster;
 }
Example #3
0
 public static function report($topic, $msg, $email = '')
 {
     /*{{{*/
     $sysinfo = posix_uname();
     $nodename = $sysinfo['nodename'];
     if (empty($email)) {
         $email = ALARM_EMAIL;
     }
     return mail($email, 'phpcron-' . $nodename . '-' . $topic, $msg);
 }
Example #4
0
 /**
  * Constroi o objeto de conexão HTTP.
  *
  * @param string $client
  */
 public function __construct($client = 'SDK PHP')
 {
     if (self::$userAgent == null) {
         $locale = setlocale(LC_ALL, null);
         if (function_exists('posix_uname')) {
             $uname = posix_uname();
             self::$userAgent = sprintf('Mozilla/4.0 (compatible; %s; PHP/%s %s; %s; %s; %s)', $client, PHP_SAPI, PHP_VERSION, $uname['sysname'], $uname['machine'], $locale);
         } else {
             self::$userAgent = sprintf('Mozilla/4.0 (compatible; %s; PHP/%s %s; %s; %s)', $client, PHP_SAPI, PHP_VERSION, PHP_OS, $locale);
         }
     }
 }
/**
* get 1 minute load average
*/
function get_loadavg()
{
    $uname = posix_uname();
    switch ($uname['sysname']) {
        case 'Linux':
            return linux_loadavg();
            break;
        case 'FreeBSD':
            return freebsd_loadavg();
            break;
        default:
            return -1;
    }
}
Example #6
0
 /**
  * @brief	Constroi o objeto de conexão HTTP.
  */
 public function __construct()
 {
     if (self::$userAgent == null) {
         $locale = setlocale(LC_ALL, null);
         if (function_exists('posix_uname')) {
             $uname = posix_uname();
             self::$userAgent = sprintf('Mozilla/4.0 (compatible; %s; PHP/%s; %s %s; %s)', PHP_SAPI, PHP_VERSION, $uname['sysname'], $uname['machine'], $locale);
         } else {
             self::$userAgent = sprintf('Mozilla/4.0 (compatible; %s; PHP/%s; %s; %s)', PHP_SAPI, PHP_VERSION, PHP_OS, $locale);
         }
     }
     $this->requestHeader = array();
     $this->requestParameter = array();
 }
Example #7
0
 /**
  * Creates a new Request_Session with all the default values.
  * A Session is created at construction.
  *
  * @param float $timeout         How long should we wait for a response?(seconds with a millisecond precision, default: 30, example: 0.01).
  * @param float $connect_timeout How long should we wait while trying to connect? (seconds with a millisecond precision, default: 10, example: 0.01)
  */
 public function createNewSession($timeout = 30.0, $connect_timeout = 30.0)
 {
     if (function_exists('posix_uname')) {
         $uname = posix_uname();
         $user_agent = sprintf('Mozilla/4.0 (compatible; %s; PHP/%s %s; %s; %s)', self::CLIENT, PHP_SAPI, PHP_VERSION, $uname['sysname'], $uname['machine']);
     } else {
         $user_agent = sprintf('Mozilla/4.0 (compatible; %s; PHP/%s %s; %s)', self::CLIENT, PHP_SAPI, PHP_VERSION, PHP_OS);
     }
     $sess = new Requests_Session($this->endpoint);
     $sess->options['auth'] = $this->moipAuthentication;
     $sess->options['timeout'] = $timeout;
     $sess->options['connect_timeout'] = $connect_timeout;
     $sess->options['useragent'] = $user_agent;
     $this->session = $sess;
 }
Example #8
0
 /**
  * Retrieve system property. Note: Results of this method are
  * cached!
  *
  * Known property names:
  * <pre>
  * php.version       PHP version
  * php.api           PHP api
  * os.name           Operating system name
  * os.tempdir        System-wide temporary directory
  * host.name         Host name
  * host.arch         Host architecture
  * user.home         Current user's home directory
  * user.name         Current user's name
  * file.separator    File separator ("/" on UNIX)
  * path.separator    Path separator (":" on UNIX)
  * </pre>
  *
  * @param   string name
  * @return  var
  */
 public static function getProperty($name)
 {
     static $prop = [];
     if (!isset($prop[$name])) {
         switch ($name) {
             case 'php.version':
                 $prop[$name] = PHP_VERSION;
                 break;
             case 'php.api':
                 $prop[$name] = PHP_SAPI;
                 break;
             case 'os.name':
                 $prop[$name] = PHP_OS;
                 break;
             case 'os.tempdir':
                 $prop[$name] = self::tempDir();
                 break;
             case 'host.name':
                 $prop[$name] = gethostname();
                 break;
             case 'host.arch':
                 if (extension_loaded('posix')) {
                     $uname = posix_uname();
                     $prop[$name] = $uname['machine'];
                     break;
                 }
                 $prop[$name] = self::_env('HOSTTYPE', 'PROCESSOR_ARCHITECTURE');
                 break;
             case 'user.home':
                 if (extension_loaded('posix')) {
                     $pwuid = posix_getpwuid(posix_getuid());
                     $prop[$name] = $pwuid['dir'];
                     break;
                 }
                 $prop[$name] = str_replace('\\', DIRECTORY_SEPARATOR, self::_env('HOME', 'HOMEPATH'));
                 break;
             case 'user.name':
                 $prop[$name] = get_current_user();
                 break;
             case 'file.separator':
                 return DIRECTORY_SEPARATOR;
             case 'path.separator':
                 return PATH_SEPARATOR;
         }
     }
     return $prop[$name];
 }
Example #9
0
function u_syslog($str)
{
    global $_SYSLOG_FD, $_SYSLOG_MODE;
    if (!$_SYSLOG_MODE) {
        u_openlog('unknown');
    }
    if ($_SYSLOG_MODE == 'syslog') {
        syslog(LOG_DEBUG, $s);
        return TRUE;
    } elseif ($_SYSLOG_MODE == 'file') {
        $uname = posix_uname();
        if (fputs($_SYSLOG_FD, date("M d H:i:s") . " " . $uname['nodename'] . " " . $str . "\n")) {
            return TRUE;
        }
    }
    return FALSE;
}
Example #10
0
 /**
  * @private
  */
 private function __construct()
 {
     $system = posix_uname();
     $backtrace = debug_backtrace();
     $starter = array_pop($backtrace);
     unset($backtrace);
     $startFile = isset($starter['file']) ? $starter['file'] : 'Daemon';
     $startFile = $startFile == '-' ? 'Daemon' : $startFile;
     unset($starter);
     $this->fqdn = $system['nodename'];
     $this->hostname = preg_replace('/\\..*/', '', $this->fqdn);
     $this->processName = str_replace(array('.phpt', '.php'), '', $startFile);
     $this->userId = posix_getuid();
     $this->groupId = posix_getgid();
     $this->pid = posix_getpid();
     $this->parentPid = posix_getppid();
     $this->pidPath = sprintf('/var/run/%s', $this->processName);
 }
Example #11
0
 /**
  * Returns the distribution
  *
  * @return string string
  */
 public function getRelease()
 {
     switch (strtolower($this->getPlatform())) {
         case "freebsd":
             /**
              * Unfortunately, there's no text file on FreeBSD which tells us the release
              * number. Thus, we hope that "release" within posix_uname() is defined.
              */
             if (function_exists("posix_uname")) {
                 $data = posix_uname();
                 if (array_key_exists("release", $data)) {
                     return $data["release"];
                 }
             }
             break;
         case "darwin":
             /**
              * Mac stores its version number in a public readable plist file, which
              * is in XML format.
              */
             $document = new \DomDocument();
             $document->load("/System/Library/CoreServices/SystemVersion.plist");
             $xpath = new \DOMXPath($document);
             $entries = $xpath->query("/plist/dict/*");
             $previous = "";
             foreach ($entries as $entry) {
                 if (strpos($previous, "ProductVersion") !== false) {
                     return $entry->textContent;
                 }
                 $previous = $entry->textContent;
             }
             break;
         case "linux":
             return $this->getLinuxDistribution();
             break;
         default:
             break;
     }
     return "unknown";
 }
Example #12
0
 /**
  * wkhtmltopdf command should be available in the vendor/bin/ folder
  * if composer is used to get the sources from message/wkhtmltopdf in the project vendor/ folder
  * @see \t41\View\Adapter\WebAdapter::display()
  */
 public function display($content = null, $error = false)
 {
     error_reporting(0);
     $html = parent::display($content, $error);
     $unames = posix_uname();
     $ext = $unames['machine'] == 'x86_64' ? 'amd64' : 'i386';
     $bin = Core::$basePath . 'vendor/bin/wkhtmltopdf-' . $ext;
     if (!is_executable($bin)) {
         throw new Exception("Missing or not executable {$bin}");
     }
     if ($this->getParameter('orientation') == PdfAdapter::ORIENTATION_LANDSCAPE) {
         $bin .= ' --orientation Landscape';
     }
     if ($this->getParameter('copies') > 1) {
         $bin .= ' --copies ' . $this->getParameter('copies');
     }
     $dir = '/dev/shm/';
     $key = hash('md5', $html);
     file_put_contents($dir . $key . '.html', $html);
     exec(sprintf("%s %s%s.html %s%s.pdf", $bin, $dir, $key, $dir, $key));
     $doc = $this->getParameter('title') ? str_replace('/', '-', $this->getParameter('title')) . '.pdf' : 'Export.pdf';
     if ($this->getParameter('destination') == 'D') {
         header('Content-Type: application/pdf');
         header('Cache-Control: private, must-revalidate, post-check=0, pre-check=0, max-age=1');
         header('Pragma: public');
         header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
         // Date in the past
         header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
         header('Content-Disposition: inline; filename="' . $doc . '";');
         header('Content-Length: ' . filesize($dir . $key . '.pdf'));
         echo file_get_contents($dir . $key . '.pdf');
         unlink($dir . $key . '.html');
         unlink($dir . $key . '.pdf');
     } else {
         $pdf = file_get_contents($dir . $key . '.pdf');
         unlink($dir . $key . '.html');
         unlink($dir . $key . '.pdf');
         return $pdf;
     }
 }
Example #13
0
 public function __construct($path = null, array $options = [])
 {
     if (!$path) {
         if (!($path = static::$path)) {
             # Check which version we should use based on the current machine architecture
             $bin = "wkhtmltopdf-";
             if (posix_uname()["machine"][0] == "i") {
                 $bin .= "i386";
             } else {
                 $bin .= "amd64";
             }
             # Start in the directory that we are in
             $path = __DIR__;
             # Move up to the composer vendor directory
             $path .= "/../../..";
             # Add the wkhtmltopdf binary path
             $path .= "/h4cc/" . $bin . "/bin/" . $bin;
             static::$path = $path;
         }
     }
     parent::__construct($path, $options);
 }
Example #14
0
function get_hostname()
{
    static $host = false;
    if ($host === false) {
        if (function_exists("posix_uname")) {
            $uname = posix_uname();
            $host = $uname["nodename"];
        } else {
            if (file_exists("/etc/farmconfig")) {
                $lines = file("/etc/farmconfig");
                foreach ($lines as $line) {
                    $tmp = explode("=", $line);
                    if ($tmp[0] == "HOST") {
                        $host = trim($tmp[1]);
                        break;
                    }
                }
                if ($host === false) {
                    $host = "localhost";
                }
            } else {
                if (file_exists("/etc/hostname")) {
                    $host = file_get_contents("/etc/hostname");
                    $host = trim($host);
                } else {
                    if (file_exists("/etc/HOSTNAME")) {
                        $host = file_get_contents("/etc/HOSTNAME");
                        $host = trim($host);
                    } else {
                        $host = "localhost";
                    }
                }
            }
        }
    }
    return $host;
}
Example #15
0
VERIFY(posix_getpgrp());
VERIFY(posix_getpid());
VERIFY(posix_getppid());
$ret = posix_getpwnam("root");
VERIFY($ret != false);
VERIFY(count((array) $ret) != 0);
VS(posix_getpwnam(""), false);
VS(posix_getpwnam(-1), false);
$ret = posix_getpwuid(0);
VERIFY($ret != false);
VERIFY(count((array) $ret) != 0);
VS(posix_getpwuid(-1), false);
$ret = posix_getrlimit();
VERIFY($ret != false);
VERIFY(count((array) $ret) != 0);
VERIFY(posix_getsid(posix_getpid()));
$tmpfifo = tempnam('/tmp', 'vmmkfifotest');
unlink($tmpfifo);
VERIFY(posix_mkfifo($tmpfifo, 0));
$tmpnod = tempnam('/tmp', 'vmmknodtest');
unlink($tmpnod);
VERIFY(posix_mknod($tmpnod, 0));
VERIFY(posix_setpgid(0, 0));
VERIFY(posix_setsid());
VERIFY(strlen(posix_strerror(1)));
$ret = posix_times();
VERIFY($ret != false);
VERIFY(count((array) $ret) != 0);
$ret = posix_uname();
VERIFY($ret != false);
VERIFY(count((array) $ret) != 0);
Example #16
0
 /**
  * @param array $params  Additional options:
  *   - debug: (boolean) Activate SMTP debug mode?
  *            DEFAULT: false
  *   - mailname: (string) The name of the local mail system (a valid
  *               hostname which matches the reverse lookup)
  *               DEFAULT: Auto-determined
  *   - netdns: (boolean) Use PEAR:Net_DNS2 (true) or the PHP builtin
  *             getmxrr().
  *             DEFAULT: true
  *   - port: (integer) Port.
  *           DEFAULT: Auto-determined
  *   - test: (boolean) Activate test mode?
  *           DEFAULT: false
  *   - timeout: (integer) The SMTP connection timeout (in seconds).
  *              DEFAULT: 10
  *   - verp: (boolean) Whether to use VERP.
  *           If not a boolean, the string value will be used as the VERP
  *           separators.
  *           DEFAULT: false
  *   - vrfy: (boolean) Whether to use VRFY.
  *           DEFAULT: false
  */
 public function __construct(array $params = array())
 {
     /* Try to find a valid mailname. */
     if (!isset($params['mailname']) && function_exists('posix_uname')) {
         $uname = posix_uname();
         $params['mailname'] = $uname['nodename'];
     }
     if (!isset($params['port'])) {
         $params['port'] = getservbyname('smtp', 'tcp');
     }
     $this->_params = array_merge(array('debug' => false, 'mailname' => 'localhost', 'netdns' => true, 'port' => 25, 'test' => false, 'timeout' => 10, 'verp' => false, 'vrfy' => false), $params);
     /* SMTP requires CRLF line endings. */
     $this->sep = "\r\n";
 }
Example #17
0
/**
 * Fetch server name for use in error reporting etc.
 * Use real server name if available, so we know which machine
 * in a server farm generated the current page.
 *
 * @return string
 */
function wfHostname()
{
    static $host;
    if (is_null($host)) {
        # Hostname overriding
        global $wgOverrideHostname;
        if ($wgOverrideHostname !== false) {
            # Set static and skip any detection
            $host = $wgOverrideHostname;
            return $host;
        }
        if (function_exists('posix_uname')) {
            // This function not present on Windows
            $uname = posix_uname();
        } else {
            $uname = false;
        }
        if (is_array($uname) && isset($uname['nodename'])) {
            $host = $uname['nodename'];
        } elseif (getenv('COMPUTERNAME')) {
            # Windows computer name
            $host = getenv('COMPUTERNAME');
        } else {
            # This may be a virtual server.
            $host = $_SERVER['SERVER_NAME'];
        }
    }
    return $host;
}
Example #18
0
 /**
  * Parses and verifies the digest challenge*
  *
  * @param  string $challenge The digest challenge
  * @return array             The parsed challenge as an assoc
  *                           array in the form "directive => value".
  * @access private
  */
 function _parseChallenge($challenge)
 {
     $tokens = array();
     while (preg_match('/^([a-z-]+)=("[^"]+(?<!\\\\)"|[^,]+)/i', $challenge, $matches)) {
         // Ignore these as per rfc2831
         if ($matches[1] == 'opaque' or $matches[1] == 'domain') {
             $challenge = substr($challenge, strlen($matches[0]) + 1);
             continue;
         }
         // Allowed multiple "realm" and "auth-param"
         if (!empty($tokens[$matches[1]]) and ($matches[1] == 'realm' or $matches[1] == 'auth-param')) {
             if (is_array($tokens[$matches[1]])) {
                 $tokens[$matches[1]][] = preg_replace('/^"(.*)"$/', '\\1', $matches[2]);
             } else {
                 $tokens[$matches[1]] = array($tokens[$matches[1]], preg_replace('/^"(.*)"$/', '\\1', $matches[2]));
             }
             // Any other multiple instance = failure
         } elseif (!empty($tokens[$matches[1]])) {
             $tokens = array();
             break;
         } else {
             $tokens[$matches[1]] = preg_replace('/^"(.*)"$/', '\\1', $matches[2]);
         }
         // Remove the just parsed directive from the challenge
         $challenge = substr($challenge, strlen($matches[0]) + 1);
     }
     /**
      * Defaults and required directives
      */
     // Realm
     if (empty($tokens['realm'])) {
         $uname = posix_uname();
         $tokens['realm'] = $uname['nodename'];
     }
     // Maxbuf
     if (empty($tokens['maxbuf'])) {
         $tokens['maxbuf'] = 65536;
     }
     // Required: nonce, algorithm
     if (empty($tokens['nonce']) or empty($tokens['algorithm'])) {
         return array();
     }
     return $tokens;
 }
Example #19
0
/**
 * function for sending email to users, gets addresses-array and data-array
 */
function phorum_email_user($addresses, $data)
{
    $PHORUM = $GLOBALS['PHORUM'];
    require_once './include/api/mail.php';
    // If we have no from_address in the message data, then generate
    // from_address ourselves, based on the system_email_* settings.
    if (!isset($data['from_address']) || trim($data['from_address']) == '') {
        $from_name = trim($PHORUM['system_email_from_name']);
        if ($from_name != '') {
            // Handle (Quoted-Printable) encoding of the from name.
            // Mail headers cannot contain 8-bit data as per RFC821.
            $from_name = phorum_api_mail_encode_header($from_name);
            $prefix = $from_name . ' <';
            $postfix = '>';
        } else {
            $prefix = $postfix = '';
        }
        $data['from_address'] = $prefix . $PHORUM['system_email_from_address'] . $postfix;
    }
    /*
     * [hook]
     *     email_user_start
     *
     * [description]
     *     This hook is put at the very beginning of 
     *     <literal>phorum_email_user()</literal> and is therefore called for
     *     <emphasis>every</emphasis> email that is sent from Phorum. It is put
     *     before every replacement done in that function so that all data which
     *     is sent to that function can be replaced/changed at will.
     *
     * [category]
     *     Moderation
     *
     * [when]
     *     In the file <filename>email_functions.php</filename> at the start of
     *     <literal>phorum_email_user()</literal>, before any modification of
     *     data.
     *
     * [input]
     *     An array containing:
     *     <ul>
     *     <li>An array of addresses.</li>
     *     <li>An array containing the message data.</li>
     *     </ul>
     *
     * [output]
     *     Same as input.
     *
     * [example]
     *     <hookcode>
     *     function phorum_mod_foo_email_user_start (list($addresses, $data)) 
     *     {
     *         global $PHORUM;
     *
     *         // Add our disclaimer to the end of every email message.
     *         $data["mailmessage"] = $PHORUM["mod_foo"]["email_disclaimer"];
     *
     *         return array($addresses, $data);
     *     }
     *     </hookcode>
     */
    if (isset($PHORUM["hooks"]["email_user_start"])) {
        list($addresses, $data) = phorum_hook("email_user_start", array($addresses, $data));
    }
    // Clear some variables that are meant for use by the email_user_start hook.
    unset($data['mailmessagetpl']);
    unset($data['mailsubjecttpl']);
    unset($data['language']);
    // Extract message body and subject.
    $mailmessage = $data['mailmessage'];
    unset($data['mailmessage']);
    $mailsubject = $data['mailsubject'];
    unset($data['mailsubject']);
    // Replace template variables.
    if (is_array($data) && count($data)) {
        foreach (array_keys($data) as $key) {
            if ($data[$key] === NULL || is_array($data[$key])) {
                continue;
            }
            $mailmessage = str_replace("%{$key}%", $data[$key], $mailmessage);
            $mailsubject = str_replace("%{$key}%", $data[$key], $mailsubject);
        }
    }
    $num_addresses = count($addresses);
    $from_address = $data['from_address'];
    # Try to find a useful hostname to use in the Message-ID.
    $host = "";
    if (isset($_SERVER["HTTP_HOST"])) {
        $host = $_SERVER["HTTP_HOST"];
    } else {
        if (function_exists("posix_uname")) {
            $sysinfo = @posix_uname();
            if (!empty($sysinfo["nodename"])) {
                $host .= $sysinfo["nodename"];
            }
            if (!empty($sysinfo["domainname"])) {
                $host .= $sysinfo["domainname"];
            }
        } else {
            if (function_exists("php_uname")) {
                $host = @php_uname("n");
            } else {
                if (($envhost = getenv("HOSTNAME")) !== false) {
                    $host = $envhost;
                }
            }
        }
    }
    if (empty($host)) {
        $host = "webserver";
    }
    // Compose an RFC compatible Message-ID header.
    if (isset($data["msgid"])) {
        $messageid = "<{$data['msgid']}@{$host}>";
    } else {
        $l = localtime(time());
        $l[4]++;
        $l[5] += 1900;
        $stamp = sprintf("%d%02d%02d%02d%02d", $l[5], $l[4], $l[3], $l[2], $l[1]);
        $rand = substr(md5(microtime()), 0, 14);
        $messageid = "<{$stamp}.{$rand}@{$host}>";
    }
    $messageid_header = "\nMessage-ID: {$messageid}";
    // Handle (Quoted-Printable) encoding of the Subject: header.
    // Mail headers can not contain 8-bit data as per RFC821.
    $mailsubject = phorum_api_mail_encode_header($mailsubject);
    /*
     * [hook]
     *     send_mail
     *
     * [description]
     *     This hook can be used for implementing an alternative mail sending
     *     system. The hook should return true if Phorum should still send the
     *     mails. If you do not want to have Phorum send the mails also, return
     *     false.<sbr/>
     *     <sbr/>
     *     The SMTP module is a good example of using this hook to replace
     *     Phorum's default mail sending system.
     *
     * [category]
     *     Moderation
     *
     * [when]
     *     In the file <filename>email_functions.php</filename> in
     *     <literal>phorum_email_user()</literal>, right before email is sent
     *     using <phpfunc>mail</phpfunc>.
     *
     * [input]
     *     Array with mail data (read-only) containing:
     *     <ul>
     *     <li><literal>addresses</literal>, an array of e-mail addresses</li>
     *     <li><literal>from</literal>, the sender address</li>
     *     <li><literal>subject</literal>, the mail subject</li>
     *     <li><literal>body</literal>, the mail body</li>
     *     <li><literal>bcc</literal>, whether to use Bcc for mailing multiple
     *     recipients</li>
     *     </ul>
     *
     * [output]
     *     true or false - see description.
     *
     */
    $send_messages = 1;
    if (isset($PHORUM["hooks"]["send_mail"])) {
        $hook_data = array('addresses' => $addresses, 'from' => $from_address, 'subject' => $mailsubject, 'body' => $mailmessage, 'bcc' => $PHORUM['use_bcc'], 'messageid' => $messageid);
        $send_messages = phorum_hook("send_mail", $hook_data);
    }
    if ($send_messages != 0 && $num_addresses > 0) {
        $phorum_major_version = substr(PHORUM, 0, strpos(PHORUM, '.'));
        $mailer = "Phorum" . $phorum_major_version;
        $mailheader = "Content-Type: text/plain; charset={$PHORUM["DATA"]["CHARSET"]}\nContent-Transfer-Encoding: {$PHORUM["DATA"]["MAILENCODING"]}\nX-Mailer: {$mailer}{$messageid_header}\n";
        // adding custom headers if defined
        if (!empty($data['custom_headers'])) {
            $mailheader .= $data['custom_headers'] . "\n";
        }
        if (isset($PHORUM['use_bcc']) && $PHORUM['use_bcc'] && $num_addresses > 3) {
            mail(" ", $mailsubject, $mailmessage, $mailheader . "From: {$from_address}\nBCC: " . implode(",", $addresses));
        } else {
            foreach ($addresses as $address) {
                mail($address, $mailsubject, $mailmessage, $mailheader . "From: {$from_address}");
            }
        }
    }
    return $num_addresses;
}
 function backup($pWrite = true)
 {
     $timeout = 20 * 60 * 60;
     //20minutes
     @set_time_limit($timeout);
     @ini_set('max_execution_time', $timeout);
     MainWP_Helper::endSession();
     //Cleanup pid files!
     $dirs = MainWP_Helper::getMainWPDir('backup');
     $backupdir = trailingslashit($dirs[0]);
     /** @var $wp_filesystem WP_Filesystem_Base */
     global $wp_filesystem;
     MainWP_Helper::getWPFilesystem();
     $files = glob($backupdir . '*');
     //Find old files (changes > 3 hr)
     foreach ($files as $file) {
         if (MainWP_Helper::endsWith($file, '/index.php') | MainWP_Helper::endsWith($file, '/.htaccess')) {
             continue;
         }
         if (time() - filemtime($file) > 60 * 60 * 3) {
             @unlink($file);
         }
     }
     $fileName = isset($_POST['fileUID']) ? $_POST['fileUID'] : '';
     if ('full' === $_POST['type']) {
         $excludes = isset($_POST['exclude']) ? explode(',', $_POST['exclude']) : array();
         $excludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/uploads/mainwp';
         $uploadDir = MainWP_Helper::getMainWPDir();
         $uploadDir = $uploadDir[0];
         $excludes[] = str_replace(ABSPATH, '', $uploadDir);
         $excludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/object-cache.php';
         if (function_exists('posix_uname')) {
             $uname = @posix_uname();
             if (is_array($uname) && isset($uname['nodename'])) {
                 if (stristr($uname['nodename'], 'hostgator')) {
                     if (!isset($_POST['file_descriptors']) || '0' == $_POST['file_descriptors'] || $_POST['file_descriptors'] > 1000) {
                         $_POST['file_descriptors'] = 1000;
                     }
                     $_POST['file_descriptors_auto'] = 0;
                     $_POST['loadFilesBeforeZip'] = false;
                 }
             }
         }
         $file_descriptors = isset($_POST['file_descriptors']) ? $_POST['file_descriptors'] : 0;
         $file_descriptors_auto = isset($_POST['file_descriptors_auto']) ? $_POST['file_descriptors_auto'] : 0;
         if (1 === (int) $file_descriptors_auto) {
             if (function_exists('posix_getrlimit')) {
                 $result = @posix_getrlimit();
                 if (isset($result['soft openfiles'])) {
                     $file_descriptors = $result['soft openfiles'];
                 }
             }
         }
         $loadFilesBeforeZip = isset($_POST['loadFilesBeforeZip']) ? $_POST['loadFilesBeforeZip'] : true;
         $newExcludes = array();
         foreach ($excludes as $exclude) {
             $newExcludes[] = rtrim($exclude, '/');
         }
         $excludebackup = isset($_POST['excludebackup']) && '1' == $_POST['excludebackup'];
         $excludecache = isset($_POST['excludecache']) && '1' == $_POST['excludecache'];
         $excludezip = isset($_POST['excludezip']) && '1' == $_POST['excludezip'];
         $excludenonwp = isset($_POST['excludenonwp']) && '1' == $_POST['excludenonwp'];
         if ($excludebackup) {
             //Backup buddy
             $newExcludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/uploads/backupbuddy_backups';
             $newExcludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/uploads/backupbuddy_temp';
             $newExcludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/uploads/pb_backupbuddy';
             //ManageWP
             $newExcludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/managewp';
             //InfiniteWP
             $newExcludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/infinitewp';
             //WordPress Backup to Dropbox
             $newExcludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/backups';
             //BackUpWordpress
             $newExcludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/backups';
             //BackWPUp
             $newExcludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/uploads/backwpup*';
             //WP Complete Backup
             $newExcludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/plugins/wp-complete-backup/storage';
             //WordPress EZ Backup
             //This one may be hard to do since they add random text at the end for example, feel free to skip if you need to
             ///backup_randomkyfkj where kyfkj is random
             //Online Backup for WordPress
             $newExcludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/backups';
             //XCloner
             $newExcludes[] = '/administrator/backups';
         }
         if ($excludecache) {
             //W3 Total Cache
             $newExcludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/w3tc-cache';
             $newExcludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/w3tc';
             $newExcludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/cache/config';
             $newExcludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/cache/minify';
             $newExcludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/cache/page_enhanced';
             $newExcludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/cache/tmp';
             //WP Super Cache
             $newExcludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/cache/supercache';
             //Quick Cache
             $newExcludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/cache/quick-cache';
             //Hyper Cache
             $newExcludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/hyper-cache/cache';
             //WP Fastest Cache
             $newExcludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/cache/all';
             //WP-Rocket
             $newExcludes[] = str_replace(ABSPATH, '', WP_CONTENT_DIR) . '/cache/wp-rocket';
         }
         $file = false;
         if (isset($_POST['f'])) {
             $file = $_POST['f'];
         } else {
             if (isset($_POST['file'])) {
                 $file = $_POST['file'];
             }
         }
         $ext = 'zip';
         if (isset($_POST['ext'])) {
             $ext = $_POST['ext'];
         }
         $pid = false;
         if (isset($_POST['pid'])) {
             $pid = $_POST['pid'];
         }
         $append = isset($_POST['append']) && '1' == $_POST['append'];
         $res = MainWP_Backup::get()->createFullBackup($newExcludes, $fileName, true, true, $file_descriptors, $file, $excludezip, $excludenonwp, $loadFilesBeforeZip, $ext, $pid, $append);
         if (!$res) {
             $information['full'] = false;
         } else {
             $information['full'] = $res['file'];
             $information['size'] = $res['filesize'];
         }
         $information['db'] = false;
     } else {
         if ('db' == $_POST['type']) {
             $ext = 'zip';
             if (isset($_POST['ext'])) {
                 $ext = $_POST['ext'];
             }
             $res = $this->backupDB($fileName, $ext);
             if (!$res) {
                 $information['db'] = false;
             } else {
                 $information['db'] = $res['file'];
                 $information['size'] = $res['filesize'];
             }
             $information['full'] = false;
         } else {
             $information['full'] = false;
             $information['db'] = false;
         }
     }
     if ($pWrite) {
         MainWP_Helper::write($information);
     }
     return $information;
 }
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
	POSSIBILITY OF SUCH DAMAGE.
*/
$pf_version = substr(trim(file_get_contents("/etc/version")), 0, 3);
if ($pf_version == "2.1" || $pf_version == "2.2") {
    define('SARG_DIR', '/usr/pbi/sarg-' . php_uname("m"));
} else {
    define('SARG_DIR', '/usr/local');
}
$uname = posix_uname();
if ($uname['machine'] == 'amd64') {
    ini_set('memory_limit', '250M');
}
function get_cmd()
{
    global $config, $g;
    // print $_REQUEST['type'];
    if ($_REQUEST['cmd'] == 'sarg') {
        $update_config = 0;
        // Check report xml info
        if (!is_array($config['installedpackages']['sargrealtime'])) {
            $config['installedpackages']['sargrealtime']['config'][0]['realtime_types'] = "";
            $config['installedpackages']['sargrealtime']['config'][0]['realtime_users'] = "";
        }
        // Check report http actions to show
Example #22
0
 $awaitingtickets_text = '';
 if ($opentickets > 0) {
     $awaitingtickets_text = strtr($lng['ticket']['awaitingticketreply'], array('%s' => '<a href="admin_tickets.php?page=tickets&amp;s=' . $s . '">' . $opentickets['count'] . '</a>'));
 }
 if (function_exists('sys_getloadavg')) {
     $loadArray = sys_getloadavg();
     $load = number_format($loadArray[0], 2, '.', '') . " / " . number_format($loadArray[1], 2, '.', '') . " / " . number_format($loadArray[2], 2, '.', '');
 } else {
     $load = @file_get_contents('/proc/loadavg');
     if (!$load) {
         $load = $lng['admin']['noloadavailable'];
     }
 }
 if (function_exists('posix_uname')) {
     $showkernel = 1;
     $kernel_nfo = posix_uname();
     $kernel = $kernel_nfo['release'] . ' (' . $kernel_nfo['machine'] . ')';
 } else {
     $showkernel = 0;
     $kernel = '';
 }
 // Try to get the uptime
 // First: With exec (let's hope it's enabled for the Froxlor - vHost)
 $uptime_array = explode(" ", @file_get_contents("/proc/uptime"));
 if (is_array($uptime_array) && isset($uptime_array[0]) && is_numeric($uptime_array[0])) {
     // Some calculatioon to get a nicly formatted display
     $seconds = round($uptime_array[0], 0);
     $minutes = $seconds / 60;
     $hours = $minutes / 60;
     $days = floor($hours / 24);
     $hours = floor($hours - $days * 24);
function uname($part = 'a')
{
    $result = '';
    if (!function_is_disabled('php_uname')) {
        $result = @php_uname($part);
    } elseif (function_exists('posix_uname') && !function_is_disabled('posix_uname')) {
        $posix_equivs = array('m' => 'machine', 'n' => 'nodename', 'r' => 'release', 's' => 'sysname');
        $puname = @posix_uname();
        if ($part == 'a' || !array_key_exists($part, $posix_equivs)) {
            $result = join(' ', $puname);
        } else {
            $result = $puname[$posix_equivs[$part]];
        }
    } else {
        if (!function_is_disabled('phpinfo')) {
            ob_start();
            phpinfo(INFO_GENERAL);
            $pinfo = ob_get_contents();
            ob_end_clean();
            if (preg_match('~System.*?(</B></td><TD ALIGN="left">| => |v">)([^<]*)~i', $pinfo, $match)) {
                $uname = $match[2];
                if ($part == 'r') {
                    if (!empty($uname) && preg_match('/\\S+\\s+\\S+\\s+([0-9.]+)/', $uname, $matchver)) {
                        $result = $matchver[1];
                    } else {
                        $result = '';
                    }
                } else {
                    $result = $uname;
                }
            }
        } else {
            $result = '';
        }
    }
    return $result;
}
Example #24
0
function build($nopid = false)
{
    if (isset($GLOBALS["BUILD_EXECUTED"])) {
        progress_logs(20, "{continue}", "Already executed");
        return;
    }
    $GLOBALS["BUILD_EXECUTED"] = true;
    $unix = new unix();
    $sock = new sockets();
    $function = __FUNCTION__;
    $EnableKerbAuth = $sock->GET_INFO("EnableKerbAuth");
    if (!is_numeric($EnableKerbAuth)) {
        $EnableKerbAuth = 0;
    }
    if ($EnableKerbAuth == 0) {
        progress_logs(110, "{authentication_via_activedirectory_is_disabled}", "{authentication_via_activedirectory_is_disabled}");
        if (is_file("/etc/monit/conf.d/winbindd.monitrc")) {
            @unlink("/etc/monit/conf.d/winbindd.monitrc");
        }
        return;
    }
    if (!$nopid) {
        $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
        $pid = $unix->get_pid_from_file($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            $timeExec = intval($unix->PROCCESS_TIME_MIN($pid));
            if ($GLOBALS["OUTPUT"]) {
                progress_logs(20, "{join_activedirectory_domain}", "Process {$pid} already exists since {$timeExec}Mn");
            }
            writelogs("Process {$pid} already exists since {$timeExec}Mn", __FUNCTION__, __FILE__, __LINE__);
            if ($timeExec > 5) {
                $kill = $unix->find_program("kill");
                progress_logs(20, "{join_activedirectory_domain}", "killing old pid {$pid} (already exists since {$timeExec}Mn)");
                unix_system_kill_force($pid);
            } else {
                return;
            }
        }
        $time = $unix->file_time_min($timefile);
        if ($time < 2) {
            if ($GLOBALS["OUTPUT"]) {
                progress_logs(20, "{join_activedirectory_domain}", "2mn minimal to run this script currently ({$time}Mn)");
            }
            writelogs("2mn minimal to run this script currently ({$time}Mn)", __FUNCTION__, __FILE__, __LINE__);
            return;
        }
    }
    pinglic(true);
    $mypid = getmypid();
    @file_put_contents($pidfile, $mypid);
    progress_logs(20, "{join_activedirectory_domain} Running PID {$mypid}", "Running PID {$mypid}", __LINE__);
    writelogs("Running PID {$mypid}", __FUNCTION__, __FILE__, __LINE__);
    $wbinfo = $unix->find_program("wbinfo");
    $nohup = $unix->find_program("nohup");
    $tar = $unix->find_program("tar");
    $ntpdate = $unix->find_program("ntpdate");
    $php5 = $unix->LOCATE_PHP5_BIN();
    if (!is_file($wbinfo)) {
        shell_exec("{$php5} /usr/share/artica-postfix exec.apt-get.php --sources-list");
        shell_exec("{$nohup} /usr/share/artica-postfix/bin/setup-ubuntu --check-samba >/dev/null 2>&1 &");
        $wbinfo = $unix->find_program("wbinfo");
    }
    if (!is_file($wbinfo)) {
        progress_logs(20, "{join_activedirectory_domain}", "Auth Winbindd, samba is not installed");
        progress_logs(100, "{finish}", "Auth Winbindd, samba is not installed");
        return;
    }
    if (!checkParams()) {
        progress_logs(20, "{join_activedirectory_domain} {failed}", "Auth Winbindd, misconfiguration failed");
        progress_logs(100, "{finish}", "Auth Winbindd, misconfiguration failed");
        return;
    }
    $unix = new unix();
    $chmod = $unix->find_program("chmod");
    $msktutil = check_msktutil();
    $kdb5_util = $unix->find_program("kdb5_util");
    $kadmin_bin = $unix->find_program("kadmin");
    $netbin = $unix->LOCATE_NET_BIN_PATH();
    if (!is_file($msktutil)) {
        return;
    }
    @mkdir("/var/log/samba", 0755, true);
    @mkdir("/var/run/samba", 0755, true);
    $uname = posix_uname();
    $mydomain = $uname["domainname"];
    $myFullHostname = $unix->hostname_g();
    $myNetBiosName = $unix->hostname_simple();
    $enctype = null;
    $sock = new sockets();
    $array = unserialize(base64_decode($sock->GET_INFO("KerbAuthInfos")));
    $hostname = strtolower(trim($array["WINDOWS_SERVER_NETBIOSNAME"])) . "." . strtolower(trim($array["WINDOWS_DNS_SUFFIX"]));
    $domainUp = strtoupper($array["WINDOWS_DNS_SUFFIX"]);
    $domaindow = strtolower($array["WINDOWS_DNS_SUFFIX"]);
    $kinitpassword = $array["WINDOWS_SERVER_PASS"];
    $kinitpassword = $unix->shellEscapeChars($kinitpassword);
    $ipaddr = trim($array["ADNETIPADDR"]);
    $UseADAsNameServer = $sock->GET_INFO("UseADAsNameServer");
    if (!is_numeric($UseADAsNameServer)) {
        $UseADAsNameServer = 0;
    }
    if ($UseADAsNameServer == 1) {
        if (preg_match("#[0-9\\.]+#", $ipaddr)) {
            progress_logs(8, "{apply_settings}", "Patching Resolv.conf");
            PatchResolvConf($ipaddr);
        }
    }
    if ($ipaddr != null) {
        $ipaddrZ = explode(".", $ipaddr);
        while (list($num, $a) = each($ipaddrZ)) {
            $ipaddrZ[$num] = intval($a);
        }
        $ipaddr = @implode(".", $ipaddrZ);
    }
    progress_logs(9, "{apply_settings} Synchronize time", "Synchronize time" . " in line " . __LINE__);
    sync_time();
    progress_logs(10, "{apply_settings} Check kerb5", "Check kerb5..in line " . __LINE__);
    if (!krb5conf(12)) {
        progress_logs(110, "{apply_settings} Check kerb5 {failed}", "Check kerb5..in line " . __LINE__);
        return;
    }
    progress_logs(15, "{apply_settings} Check mskt", "Check msktutils in line " . __LINE__);
    if (!run_msktutils()) {
        progress_logs(110, "{apply_settings} Check mskt {failed}", "Check mskt..in line " . __LINE__);
        return;
    }
    progress_logs(15, "{apply_settings} netbin", "netbin -> {$netbin} in line " . __LINE__);
    if (is_file($netbin)) {
        try {
            progress_logs(15, "{apply_settings} netbin", "netbin -> SAMBA_PROXY()  in line " . __LINE__);
            SAMBA_PROXY();
        } catch (Exception $e) {
            progress_logs(15, "{failed}", "Exception Error: Message: " . $e->getMessage());
        }
    }
    progress_logs(19, "{apply_settings} [kadmin_bin]", $kadmin_bin);
    progress_logs(19, "{apply_settings} [netbin]", $netbin);
    if (is_file("{$netbin}")) {
        progress_logs(20, "{join_activedirectory_domain}", "netbin -> JOIN_ACTIVEDIRECTORY() ");
        JOIN_ACTIVEDIRECTORY();
        // 29%
    }
    progress_logs(51, "{restarting_winbind} 1", "winbind_priv();");
    winbind_priv(false, 52);
    progress_logs(60, "{restarting_winbind} 2", "winbind_priv();");
    winbindd_monit();
    progress_logs(65, "{restarting_winbind} 3", "winbind_priv();");
    $php5 = $unix->LOCATE_PHP5_BIN();
    if (!is_file("/etc/init.d/winbind")) {
        shell_exec("{$php5} /usr/share/artica-postfix/exec.initslapd.php --winbind");
    }
    progress_logs(65, "{restarting_winbind}", "winbind_priv();");
    system("/etc/init.d/winbind restart --force");
    return true;
}
Example #25
0
<?php

require_once 'butts.php';
include_once 'config.php';
if (posix_uname()['sysname'] === 'Darwin') {
    define('DEV_MODE', true);
}
function get_connections()
{
    if (is_dir('/sys')) {
        // if this is linux (ie. not dev)
        $conns = file_get_contents('/proc/sys/net/netfilter/nf_conntrack_count');
        $conns = intval($conns);
    } else {
        // dev
        $conns = rand(1, 100);
    }
    debug(sprintf("%7d connections", $conns), 3);
    return $conns;
}
function sample($count = 60, $interval = 1)
{
    $avg = 0;
    $total = 0;
    // fripping microseconds
    $interval = $interval * 1000000;
    $samples = array();
    for ($i = 0; $i < $count; $i++) {
        $total += get_connections();
        usleep($interval);
    }
/**
 * Fetch server name for use in error reporting etc.
 * Use real server name if available, so we know which machine
 * in a server farm generated the current page.
 *
 * @return string
 */
function wfHostname()
{
    static $host;
    if (is_null($host)) {
        if (function_exists('posix_uname')) {
            // This function not present on Windows
            $uname = posix_uname();
        } else {
            $uname = false;
        }
        if (is_array($uname) && isset($uname['nodename'])) {
            $host = $uname['nodename'];
        } elseif (getenv('COMPUTERNAME')) {
            # Windows computer name
            $host = getenv('COMPUTERNAME');
        } else {
            # This may be a virtual server.
            $host = $_SERVER['SERVER_NAME'];
        }
    }
    return $host;
}
Example #27
0
 public static function dns_start()
 {
     if (config::byKey('ngrok::addr') == '') {
         return;
     }
     network::dns_stop();
     $config_file = '/tmp/ngrok_jeedom';
     $logfile = log::getPathToLog('ngrok');
     $uname = posix_uname();
     if (strrpos($uname['machine'], 'arm') !== false) {
         $cmd = dirname(__FILE__) . '/../../script/ngrok/ngrok-arm';
     } else {
         if ($uname['machine'] == 'x86_64') {
             $cmd = dirname(__FILE__) . '/../../script/ngrok/ngrok-x64';
         } else {
             $cmd = dirname(__FILE__) . '/../../script/ngrok/ngrok-x86';
         }
     }
     exec('chmod +x ' . $cmd);
     $cmd .= ' -config=' . $config_file . ' start jeedom';
     if (!self::dns_run()) {
         $replace = array('#server_addr#' => 'dns.jeedom.com:4443', '#name#' => 'jeedom', '#proto#' => 'https', '#port#' => 80, '#remote_port#' => '', '#token#' => config::byKey('ngrok::token'), '#auth#' => '', '#subdomain#' => 'subdomain : ' . config::byKey('ngrok::addr'));
         $config = template_replace($replace, file_get_contents(dirname(__FILE__) . '/../../script/ngrok/config'));
         if (file_exists($config_file)) {
             unlink($config_file);
         }
         file_put_contents($config_file, $config);
         log::remove('ngrok');
         log::add('ngork', 'debug', 'Lancement de ngork : ' . $cmd);
         exec($cmd . ' >> /dev/null 2>&1 &');
     }
     return true;
 }
Example #28
0
 /**
  * Set System constants which can be retrieved by calling Phing::getProperty($propName).
  * @return void
  */
 private static function setSystemConstants()
 {
     /*
      * PHP_OS returns on
      *   WindowsNT4.0sp6  => WINNT
      *   Windows2000      => WINNT
      *   Windows ME       => WIN32
      *   Windows 98SE     => WIN32
      *   FreeBSD 4.5p7    => FreeBSD
      *   Redhat Linux     => Linux
      *   Mac OS X         => Darwin
      */
     self::setProperty('host.os', PHP_OS);
     // this is used by some tasks too
     self::setProperty('os.name', PHP_OS);
     // it's still possible this won't be defined,
     // e.g. if Phing is being included in another app w/o
     // using the phing.php script.
     if (!defined('PHP_CLASSPATH')) {
         define('PHP_CLASSPATH', get_include_path());
     }
     self::setProperty('php.classpath', PHP_CLASSPATH);
     // try to determine the host filesystem and set system property
     // used by Fileself::getFileSystem to instantiate the correct
     // abstraction layer
     switch (strtoupper(PHP_OS)) {
         case 'WINNT':
             self::setProperty('host.fstype', 'WINNT');
             self::setProperty('php.interpreter', getenv('PHP_COMMAND'));
             break;
         case 'WIN32':
             self::setProperty('host.fstype', 'WIN32');
             break;
         default:
             self::setProperty('host.fstype', 'UNIX');
             break;
     }
     self::setProperty('line.separator', PHP_EOL);
     self::setProperty('php.version', PHP_VERSION);
     self::setProperty('user.home', getenv('HOME'));
     self::setProperty('application.startdir', getcwd());
     self::setProperty('phing.startTime', gmdate('D, d M Y H:i:s', time()) . ' GMT');
     // try to detect machine dependent information
     $sysInfo = array();
     if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' && function_exists("posix_uname")) {
         $sysInfo = posix_uname();
     } else {
         $sysInfo['nodename'] = php_uname('n');
         $sysInfo['machine'] = php_uname('m');
         //this is a not so ideal substition, but maybe better than nothing
         $sysInfo['domain'] = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : "unknown";
         $sysInfo['release'] = php_uname('r');
         $sysInfo['version'] = php_uname('v');
     }
     self::setProperty("host.name", isset($sysInfo['nodename']) ? $sysInfo['nodename'] : "unknown");
     self::setProperty("host.arch", isset($sysInfo['machine']) ? $sysInfo['machine'] : "unknown");
     self::setProperty("host.domain", isset($sysInfo['domain']) ? $sysInfo['domain'] : "unknown");
     self::setProperty("host.os.release", isset($sysInfo['release']) ? $sysInfo['release'] : "unknown");
     self::setProperty("host.os.version", isset($sysInfo['version']) ? $sysInfo['version'] : "unknown");
     unset($sysInfo);
 }
Example #29
0
<?php

/**
 * @package WordPress
 * @subpackage Toolbox
 */
$info = posix_uname();
//$times = posix_times();
//$rebooted = time()-$times["ticks"]/100;
$uptime = exec('cat /proc/uptime');
$uptime = explode(' ', $uptime);
$rebooted = time() - intval($uptime);
?>

	</div><!-- #main -->

	<footer id="colophon" role="contentinfo">
			<div id="site-generator">
				<?php 
_e('Kernel:', 'bulmapress');
?>
 <?php 
echo $info['sysname'] . ' - ' . $info['machine'] . ' - ' . $info['release'];
?>
 |
				<?php 
_e('Last boot:', 'bulmapress');
?>
 <?php 
echo date('d/m/Y H:i', $rebooted);
?>
Example #30
0
wfProfileIn($fname . '-includes');
require_once "{$IP}/includes/GlobalFunctions.php";
require_once "{$IP}/includes/Hooks.php";
require_once "{$IP}/includes/Namespace.php";
require_once "{$IP}/includes/ProxyTools.php";
require_once "{$IP}/includes/ObjectCache.php";
require_once "{$IP}/includes/ImageFunctions.php";
require_once "{$IP}/includes/StubObject.php";
wfProfileOut($fname . '-includes');
wfProfileIn($fname . '-misc1');
$wgIP = false;
# Load on demand
# Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
$wgRequest = new WebRequest();
if (function_exists('posix_uname')) {
    $wguname = posix_uname();
    $wgNodeName = $wguname['nodename'];
} else {
    $wgNodeName = '';
}
# Useful debug output
if ($wgCommandLineMode) {
    wfDebug("\n\nStart command line script {$self}\n");
} elseif (function_exists('getallheaders')) {
    wfDebug("\n\nStart request\n");
    wfDebug($_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . "\n");
    $headers = getallheaders();
    foreach ($headers as $name => $value) {
        wfDebug("{$name}: {$value}\n");
    }
    wfDebug("\n");