本文整理汇总了PHP中COM::SpecialFolders方法的典型用法代码示例。如果您正苦于以下问题:PHP COM::SpecialFolders方法的具体用法?PHP COM::SpecialFolders怎么用?PHP COM::SpecialFolders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COM
的用法示例。
在下文中一共展示了COM::SpecialFolders方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: relocateShortcut
private static function relocateShortcut()
{
$WshShell = new COM('WScript.Shell');
$desktop = $WshShell->SpecialFolders('Desktop');
$startmenu = $WshShell->SpecialFolders('Programs');
$startmenu .= DIRECTORY_SEPARATOR . 'XAMPP for Windows';
$links = array();
$links[realpath($desktop . DIRECTORY_SEPARATOR . 'XAMPP Control Panel.lnk')] = array('TargetPath' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp-control.exe', 'WorkingDirectory' => self::$xampppath, 'WindowStyle' => 1, 'IconLocation' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp-control.exe', 'Description' => 'XAMPP Control Panel');
$links[realpath($startmenu . DIRECTORY_SEPARATOR . 'XAMPP Control Panel.lnk')] = array('TargetPath' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp-control.exe', 'WorkingDirectory' => self::$xampppath, 'WindowStyle' => 1, 'IconLocation' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp-control.exe', 'Description' => 'XAMPP Control Panel');
$links[realpath($startmenu . DIRECTORY_SEPARATOR . 'XAMPP Setup.lnk')] = array('TargetPath' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp_setup.bat', 'WorkingDirectory' => self::$xampppath, 'WindowStyle' => 1, 'IconLocation' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp_cli.exe', 'Description' => 'XAMPP Setup');
$links[realpath($startmenu . DIRECTORY_SEPARATOR . 'XAMPP Shell.lnk')] = array('TargetPath' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp_shell.bat', 'WorkingDirectory' => self::$xampppath, 'WindowStyle' => 1, 'IconLocation' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp_cli.exe', 'Description' => 'XAMPP Shell');
$links[realpath($startmenu . DIRECTORY_SEPARATOR . 'XAMPP Uninstall.lnk')] = array('TargetPath' => self::$xampppath . DIRECTORY_SEPARATOR . 'uninstall_xampp.bat', 'WorkingDirectory' => self::$xampppath, 'WindowStyle' => 1, 'IconLocation' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp_cli.exe', 'Description' => 'XAMPP Uninstall');
foreach ($links as $shortcut => $value) {
if (is_int($shortcut)) {
continue;
}
$oldfileperm = fileperms($shortcut);
if (!chmod($shortcut, 0666) && !is_writable($shortcut)) {
throw new XAMPPException('File \'' . $shortcut . '\' is not writable.');
}
$ShellLink = $WshShell->CreateShortcut($shortcut);
$ShellLink->TargetPath = $value['TargetPath'];
$ShellLink->WorkingDirectory = $value['WorkingDirectory'];
$ShellLink->WindowStyle = $value['WindowStyle'];
$ShellLink->IconLocation = $value['IconLocation'];
$ShellLink->Description = $value['Description'];
$ShellLink->Save();
$ShellLink = null;
chmod($shortcut, $oldfileperm);
}
$WshShell = null;
return;
}
示例2: relocateShortcut
private static function relocateShortcut()
{
$WshShell = new COM('WScript.Shell', null, CP_UTF8);
$FSO = new COM('Scripting.FileSystemObject', null, CP_UTF8);
$desktop = $WshShell->SpecialFolders('Desktop');
$startmenu = $WshShell->SpecialFolders('Programs');
$startmenu = $FSO->BuildPath($startmenu, utf8_encode('XAMPP for Windows'));
$xampppath = utf8_encode(self::$xampppath);
$links = array();
$links[$FSO->BuildPath($desktop, utf8_encode('XAMPP Control Panel.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('xampp-control.exe')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp-control.exe')), 'Description' => utf8_encode('XAMPP Control Panel'));
$links[$FSO->BuildPath($startmenu, utf8_encode('XAMPP Control Panel.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('xampp-control.exe')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp-control.exe')), 'Description' => utf8_encode('XAMPP Control Panel'));
$links[$FSO->BuildPath($startmenu, utf8_encode('XAMPP Setup.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('xampp_setup.bat')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp_cli.exe')), 'Description' => utf8_encode('XAMPP Setup'));
$links[$FSO->BuildPath($startmenu, utf8_encode('XAMPP Shell.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('xampp_shell.bat')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp_cli.exe')), 'Description' => utf8_encode('XAMPP Shell'));
$links[$FSO->BuildPath($startmenu, utf8_encode('XAMPP Uninstall.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('uninstall_xampp.bat')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp_cli.exe')), 'Description' => utf8_encode('XAMPP Uninstall'));
foreach ($links as $shortcut => $value) {
if (!$FSO->FileExists($shortcut)) {
continue;
}
try {
$shortcut_file = $FSO->GetFile($shortcut);
$oldfileperm = $shortcut_file->attributes;
if (($oldfileperm & 1) == 1) {
$shortcut_file->attributes += -1;
}
} catch (Exception $e) {
throw new XAMPPException('File \'' . utf8_decode($shortcut) . '\' is not writable.');
}
$ShellLink = $WshShell->CreateShortcut($shortcut);
$ShellLink->TargetPath = $value['TargetPath'];
$ShellLink->WorkingDirectory = $value['WorkingDirectory'];
$ShellLink->WindowStyle = $value['WindowStyle'];
$ShellLink->IconLocation = $value['IconLocation'];
$ShellLink->Description = $value['Description'];
$ShellLink->Save();
$ShellLink = null;
$shortcut_file->attributes = $oldfileperm;
$shortcut_file = null;
}
$FSO = null;
$WshShell = null;
return;
}
示例3: sysinfO
function sysinfO()
{
global $windows, $disablefunctions, $cwd, $safemode, $Resource_Dir;
$basedir = ini_get('open_basedir') || strtoupper(ini_get('open_basedir')) == 'ON' ? 'ON' : 'OFF';
if (!empty($_SERVER['PROCESSOR_IDENTIFIER'])) {
$CPU = $_SERVER['PROCESSOR_IDENTIFIER'];
}
$osver = $tsize = $fsize = '';
$ds = implode(' ', $disablefunctions);
$Clock = $Resource_Dir . 'images/clock/';
if ($windows) {
$osver = shelL('ver');
if (!empty($osver)) {
$osver = "({$osver})";
}
$sysroot = shelL("echo %systemroot%");
if (empty($sysroot)) {
$sysroot = $_SERVER['SystemRoot'];
}
if (empty($sysroot)) {
$sysroot = getenv('windir');
}
if (empty($sysroot)) {
$sysroot = 'Not Found';
}
if (empty($CPU)) {
$CPU = shelL('echo %PROCESSOR_IDENTIFIER%');
}
for ($i = 66; $i <= 90; $i++) {
$drive = chr($i) . ':\\';
if (@disk_total_space($drive)) {
$fsize += disk_free_space($drive);
$tsize += disk_total_space($drive);
}
}
} else {
if (empty($CPU)) {
$CPU = shelL('grep "model name" /proc/cpuinfo | cut -d ":" -f2');
}
if ($CPU) {
$CPU = nl2br($CPU);
}
$fsize = disk_free_space('/');
$tsize = disk_total_space('/');
}
$diskper = floor($fsize / $tsize * 100);
$diskcolor = '; background: ';
if ($diskper < 33) {
$diskcolor .= 'green';
} elseif ($diskper < 66 && $diskper > 33) {
$diskcolor .= 'orange';
} else {
$diskcolor .= 'red';
}
$disksize = 'Used spase: ' . showsizE($tsize - $fsize) . ' Free space: ' . showsizE($fsize) . ' Total space: ' . showsizE($tsize);
$diskspace = $tsize ? '<div class="progress-container" style="width: 100px" title="' . $disksize . '"><div style="width: ' . $diskper . '%' . $diskcolor . '"></div></div>' : 'Unknown';
if (empty($CPU)) {
$CPU = 'Unknow';
}
$os = php_uname();
$osn = php_uname('s');
$UID = $GID = 'Unknown';
$cp = $clog = '';
if (!$windows) {
if (checkfunctioN('posix_getegid') && checkfunctioN('posix_geteuid')) {
$UID = posix_geteuid();
$GID = posix_getegid();
$processUser = posix_getpwuid(posix_geteuid());
$cuser = $processUser['name'];
}
$cp = '/usr/local/cpanel/version';
$cv = is_readable($cp) ? trim(file_get_contents($cp)) : '';
$clog = is_readable('/var/cpanel/accounting.log') ? 1 : '';
$ker = php_uname('r');
$o = $osn == 'Linux' ? 'Linux+Kernel' : $osn;
$os = 'http://www.exploit-db.com/search/?action=search&filter_platform=16" target="_blank">' . $osn . '</a>';
$os = 'http://www.exploit-db.com/search/?action=search&filter_description=kernel&filter_platform=16" target="_blank">' . $ker . '</a>';
$inpa = ':';
} else {
if (class_exists('COM')) {
$cplace = array();
$obj = new COM("WScript.Shell");
$cplace['All Users Desktop'] = $obj->SpecialFolders("AllUsersDesktop");
$cplace['All Users StartMenu'] = $obj->SpecialFolders("AllUsersStartMenu");
$cplace['All Users Programs'] = $obj->SpecialFolders("AllUsersPrograms");
$cplace['All Users Startup'] = $obj->SpecialFolders("AllUsersStartup");
$cplace['Desktop'] = $obj->SpecialFolders("Desktop");
$cplace['Favorites'] = $obj->SpecialFolders("Favorites");
$cplace['Fonts'] = $obj->SpecialFolders("Fonts");
$cplace['My Documents'] = $obj->SpecialFolders("MyDocuments");
$cplace['NetHood'] = $obj->SpecialFolders("NetHood");
$cplace['PrintHood'] = $obj->SpecialFolders("PrintHood");
$cplace['Recent'] = $obj->SpecialFolders("Recent");
$cplace['SendTo'] = $obj->SpecialFolders("SendTo");
$cplace['StartMenu'] = $obj->SpecialFolders("StartMenu");
$cplace['Startup'] = $obj->SpecialFolders("Startup");
$cplace['Templates'] = $obj->SpecialFolders("Templates");
}
$cuser = get_current_user();
$sam = $sysroot . "\\system32\\config\\SAM";
//.........这里部分代码省略.........
示例4: getCOMPath
/**
* Loads a windows path via COM using $objCom.
*
* @param string $strType See $objCom for allowed values.
*
* @return mixed False if no path could be obtained, string otherwise
*
* @access protected
*/
function getCOMPath($strType)
{
if (!$this->loadCOM()) {
return false;
}
$strPath = $this->objCom->SpecialFolders($strType);
if (!$strPath || $strPath == '') {
return false;
} else {
return $strPath;
}
}
示例5: locateLocalSettingsDirectory
/**
* determines where user-specific configuration files should be saved.
*
* On unix, this is ~user/ or a location in /tmp based on the current directory.
* On windows, this is your Documents and Settings folder.
* @return string
*/
static protected function locateLocalSettingsDirectory()
{
if (class_exists('COM', false)) {
$shell = new \COM('Wscript.Shell');
$value = $shell->SpecialFolders('MyDocuments');
return $value;
}
if (isset($_ENV['HOME'])) {
return $_ENV['HOME'];
} elseif ($e = getenv('HOME')) {
return $e;
}
if (isset($_ENV['PWD'])) {
$cwd = $_ENV['PWD'];
} else {
$cwd = getcwd();
}
return '/tmp/' . md5($cwd);
}