Revision: 6719
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 10, 2008 21:43 by dereklio
Initial Code
<?php class Shell { private static $singleton; public static function singleton() { if (!isset(self::$singleton)) { $c = __CLASS__; self::$singleton = new $c; } return self::$singleton; } private $dir_temp; private function __construct() { $this->dir_temp = $this->touch_dir(dirname(__FILE__) . '/temp/'); } public function __clone() { trigger_error('Clone is not allowed.', E_USER_ERROR); } public function temp($file = '') { return $this->dir_temp . $file; } public function out($text = '') { if (is_string($text)) { echo iconv('utf-8', 'big5', $text) . "\n"; } else if (is_bool($text)) { echo ($text ? 'true' : 'false') . "\n"; } else { $this->dump($text); } } public function dump($obj = false) { $this->out(print_r($obj, true)); } public function nircmd($cmd) { $this->out("[nircmd] $cmd"); exec("nircmd $cmd"); } public function concmd_utf8($data, $src_encoding) { $path = $this->temp('concmd-' . rand(1000, 9999) . '.tmp'); file_put_contents($path, $data); $cmd = "concmd /i:$src_encoding /o:UTF8 /f:T \"$path\""; $this->out("[concmd] $cmd"); exec($cmd); $data = file_get_contents($path); unlink($path); return $data; } public function touch_file($path) { $path = str_replace('\\', '/', $path); touch($path); return $path; } public function touch_dir($path) { $path = str_replace('\\', '/', $path); if (!file_exists($path)) mkdir($path); return $path; } } ?>
Initial URL
Initial Description
Initial Title
A shell access wrapper for windows in PHP
Initial Tags
Initial Language
PHP