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


PHP COM类代码示例

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


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

示例1: listLastVisit

function listLastVisit()
{
    global $xml_database_comname;
    global $userfolder;
    global $lastvisit_config_file;
    $lastvisitfile = $userfolder . $lastvisit_config_file;
    $lastvisitfile = encode_utf8($lastvisitfile);
    $xml = new COM($xml_database_comname, NULL, CP_UTF8) or die("create com instance error");
    $xml->ReadDB($lastvisitfile);
    $xml->ResetPos();
    if (!$xml->FindElem("database")) {
        return false;
    }
    $xml->IntoElem();
    if (!$xml->FindElem("lastvisit")) {
        return false;
    }
    $lastvisit = array();
    while ($xml->FindElem("item")) {
        $info = array();
        $xml->ResetChildPos();
        while ($xml->FindChildElem("")) {
            $name = $xml->GetChildTagName();
            $value = $xml->GetChildData();
            $info[strtolower($name)] = $value;
        }
        $lastvisit[] = $info;
    }
    return true;
}
开发者ID:honj51,项目名称:taobaocrm,代码行数:30,代码来源:lib.lastvisit.php

示例2: _exec

function _exec($cmd)
{
    $WshShell = new COM("WScript.Shell");
    $oExec = $WshShell->Run("{$cmd}", 3, false);
    //echo $cmd;
    return $oExec == 0 ? true : false;
}
开发者ID:tofula,项目名称:m4loc,代码行数:7,代码来源:common.php

示例3: actionCheckComtool

 function actionCheckComtool()
 {
     if (class_exists('COM')) {
         try {
             $objComport = new COM("ActiveXperts.Comport");
             $objComport->Logfile = "C:\\PhpSerialLog.txt";
             $objComport->Device = "COM1";
             $objComport->Baudrate = 9600;
             $objComport->ComTimeout = 1000;
             $objComport->Open();
             print '<br>Check errros of COMport tool using (trying to connect with COM1)';
             if ($objComport->LastError != 0) {
                 if ($objComport->LastError >= 1000 && $objComport->LastError <= 1999) {
                     print '<br>LICENSING ERROR!!!';
                 } else {
                     print '<br>no licensing errors, some errors with com-port connection';
                 }
                 $ErrorNum = $objComport->LastError;
                 $ErrorDes = $objComport->GetErrorDescription($ErrorNum);
                 echo "<br><br>Error sending commands: #{$ErrorNum} ({$ErrorDes}).";
             }
         } catch (Exception $e) {
             print_r($e->getMessage());
         }
         $objComport->Close();
     } else {
         print "Class for work with COM ports is not available";
     }
 }
开发者ID:anton-itscript,项目名称:WM-Web,代码行数:29,代码来源:BugfixController.php

示例4: notify

function notify($type, $title, $message)
{
    $WshShell = new COM("WScript.Shell");
    $command = 'cmd /C %cd%/exe/notifu.exe /t ' . $type . ' /p "' . $title . '" /m "' . $message . '"';
    exec($command);
    $WshShell->Run($command, 0, false);
}
开发者ID:madnerdTRASH,项目名称:webmanage,代码行数:7,代码来源:func.php

示例5: getCpuFrequency

 /**
  * Get CPU frequency in MHz
  *
  * @return float
  * @throws phpRack_Exception If can't get cpu frequency
  * @see getBogoMips()
  * @see phpRack_Adapters_Cpu_Abstract::getCpuFrequency()
  */
 public function getCpuFrequency()
 {
     $wmi = new COM('Winmgmts://');
     $query = 'SELECT maxClockSpeed FROM CIM_Processor';
     // get CPUS-s data
     $cpus = $wmi->execquery($query);
     $maxClockSpeed = 0;
     /**
      * We must iterate through all CPU-s because $cpus is object
      * and we can't get single entry by $cpus[0]->maxClockSpeed
      */
     foreach ($cpus as $cpu) {
         $maxClockSpeed = max($maxClockSpeed, $cpu->maxClockSpeed);
     }
     /**
      * If returned $cpus set was empty(some error occured)
      *
      * We can't check it earlier with empty($cpus) or count($cpus)
      * because $cpus is object and doesn't implement countable
      * interface.
      */
     if (!$maxClockSpeed) {
         throw new phpRack_Exception("Unable to get maxClockSpeed using COM 'Winmgmts://' and '{$query}' query");
     }
     return floatval($maxClockSpeed);
 }
开发者ID:tpc2,项目名称:phprack,代码行数:34,代码来源:Windows.php

示例6: pdf2swf

function pdf2swf($input, $output)
{
    $command = "pdf2swf.exe -t \"" . $input . "\" -o \"" . $output . "\" -s flashversion=9 ";
    //		echo $command;
    $Shell = new COM("WScript.shell") or die("创建COM失败");
    $oExec = $Shell->exec($command);
}
开发者ID:dalinhuang,项目名称:back,代码行数:7,代码来源:file_upload.php

示例7: filesize64

 public static function filesize64($file)
 {
     static $iswin;
     if (!isset($iswin)) {
         $iswin = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN';
     }
     static $exec_works;
     if (!isset($exec_works)) {
         $exec_works = function_exists('exec') && !ini_get('safe_mode') && @exec('echo EXEC') == 'EXEC';
     }
     // try a shell command
     if ($exec_works) {
         $cmd = $iswin ? "for %F in (\"{$file}\") do @echo %~zF" : "stat -c%s \"{$file}\"";
         @exec($cmd, $output);
         if (is_array($output) && ctype_digit($size = trim(implode("\n", $output)))) {
             return intval($size);
         }
     }
     // try the Windows COM interface
     if ($iswin && class_exists("COM")) {
         try {
             $fsobj = new COM('Scripting.FileSystemObject');
             $f = $fsobj->GetFile(realpath($file));
             $size = $f->Size;
         } catch (Exception $e) {
             $size = null;
         }
         if (ctype_digit($size)) {
             return intval($size);
         }
     }
     // if all else fails
     return filesize($file);
 }
开发者ID:joshhodgson,项目名称:Website,代码行数:34,代码来源:FileHelpers.php

示例8: syncOrg

 public function syncOrg()
 {
     $obj = $this->getObj(false);
     $config = $this->getConfig();
     $rtxParam = new COM("rtxserver.collection");
     $obj->Name = "USERSYNC";
     $obj->ServerIP = $config["server"];
     $obj->ServerPort = $config["sdkport"];
     $xmlDoc = new DOMDocument("1.0", "GB2312");
     $xml = $this->makeOrgstructXml();
     if ($xml) {
         $xmlDoc->load("userdata.xml");
         $rtxParam->Add("DATA", $xmlDoc->saveXML());
         $rs = $obj->Call2(1, $rtxParam);
         $newObj = $this->getObj();
         try {
             $u = $newObj->UserManager();
             foreach ($this->users as $user) {
                 $u->SetUserPwd(ConvertUtil::iIconv($user, CHARSET, "gbk"), $this->pwd);
             }
             return true;
         } catch (Exception $exc) {
             $this->setError("同步过程中出现未知错误", self::ERROR_SYNC);
             return false;
         }
     } else {
         $this->setError("无法生成组织架构XML文件", self::ERROR_SYNC);
         return false;
     }
 }
开发者ID:AxelPanda,项目名称:ibos,代码行数:30,代码来源:ICIMRtx.php

示例9: filter

 public function filter($value)
 {
     //source: http://www.php-security.org/2010/05/09/mops-submission-04-generating-unpredictable-session-ids-and-hashes/
     $entropy = '';
     // try ssl first
     if (function_exists('openssl_random_pseudo_bytes')) {
         $entropy = openssl_random_pseudo_bytes(64, $strong);
         // skip ssl since it wasn't using the strong algo
         if ($strong !== true) {
             $entropy = '';
         }
     }
     // add some basic mt_rand/uniqid combo
     $entropy .= uniqid(mt_rand(), true);
     // try to read from the windows RNG
     if (class_exists('COM')) {
         try {
             $com = new COM('CAPICOM.Utilities.1');
             $entropy .= base64_decode($com->GetRandom(64, 0));
         } catch (Exception $ex) {
         }
     }
     // try to read from the unix RNG
     if (is_readable('/dev/urandom')) {
         $h = fopen('/dev/urandom', 'rb');
         $entropy .= fread($h, 64);
         fclose($h);
     }
     $hash = hash('whirlpool', $entropy);
     return substr($hash, 0, $this->_length);
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:31,代码来源:StrongRandom.php

示例10: RemoveDir

function RemoveDir($dir, $verbose)
{
    if (!($dh = @opendir($dir))) {
        if ($verbose) {
            echo "can't open {$dir}                                                                                                    \r";
        }
        return;
    } else {
        while (false !== ($obj = readdir($dh))) {
            if ($obj == '.' || $obj == '..') {
                continue;
            }
            $newDir = $dir . '\\' . $obj;
            if (@unlink($newDir)) {
                if ($verbose) {
                    echo "file deleted {$newDir}...                                                                                           \r";
                }
                //$file_deleted++;
            } else {
                RemoveDir($newDir, $verbose);
            }
        }
    }
    $cmdline = "cmd /c rmdir {$dir}";
    $WshShell = new COM("WScript.Shell");
    // Make the command window but dont show it.
    $oExec = $WshShell->Run($cmdline, 0, false);
}
开发者ID:kotow,项目名称:work,代码行数:28,代码来源:deleteall.php

示例11: generateUniqueId

function generateUniqueId($maxLength = null)
{
    $entropy = '';
    // On test ssl d'abord.
    if (function_exists('openssl_random_pseudo_bytes')) {
        $entropy = openssl_random_pseudo_bytes(64, $strong);
        // skip ssl since it wasn't using the strong algo
        if ($strong !== true) {
            $entropy = '';
        }
    }
    // On ajoute les basics mt_rand/uniqid combo
    $entropy .= uniqid(mt_rand(), true);
    // On test la lecture de la fenêtre RNG
    if (class_exists('COM')) {
        try {
            $com = new COM('CAPICOM.Utilities.1');
            $entropy .= base64_decode($com->GetRandom(64, 0));
        } catch (Exception $ex) {
        }
    }
    // on test la lecture de unix RNG
    if (is_readable('/dev/urandom')) {
        $h = fopen('/dev/urandom', 'rb');
        $entropy .= fread($h, 64);
        fclose($h);
    }
    $hash = hash('whirlpool', $entropy);
    if ($maxLength) {
        return substr($hash, 0, $maxLength);
    }
    return $hash;
}
开发者ID:project-paon,项目名称:paon,代码行数:33,代码来源:connection.php

示例12: getSize

function getSize($file)
{
    $size = filesize($file);
    if ($size < 0) {
        if (!(strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')) {
            $size = trim(`stat -c%s {$file}`);
        } else {
            $fsobj = new COM("Scripting.FileSystemObject");
            $f = $fsobj->GetFile($file);
            $size = $file->Size;
        }
    }
    if ($size > 1000000000) {
        $size = number_format($size / 1000000000, 2, '.', '');
        $size = $size . " GB";
    } else {
        if ($size > 1000000) {
            $size = number_format($size / 1000000, 2, '.', '');
            $size = $size . " MB";
        } else {
            if ($size > 4000) {
                $size = number_format($size / 1000, 2, '.', '');
                $size = $size . " kb";
            } else {
                $size = $size . " bytes";
            }
        }
    }
    return $size;
}
开发者ID:joeyfromspace,项目名称:hdtracks-metadata,代码行数:30,代码来源:metadata_util.php

示例13: getListVersion

 static function getListVersion($syncserver, $list)
 {
     $list[]['componentname'] = 'mysql';
     $list[]['componentname'] = 'perl';
     $list[]['componentname'] = 'php';
     $list[]['componentname'] = 'IIS';
     $list[]['componentname'] = 'Photoshop';
     $list[]['componentname'] = 'InternetExplorer';
     try {
         $obj = new COM("Winmgmts://./root/cimv2");
     } catch (exception $e) {
         throw new lxException("com_failed", 'disk');
     }
     $nlist = $obj->execQuery("select * from Win32_Product");
     foreach ($nlist as $k => $l) {
         $name = $l->Name;
         $sing['nname'] = $name . "___" . $syncserver;
         $sing['componentname'] = $name;
         $sing['status'] = "off";
         $sing['version'] = "Not Installed";
         $sing['version'] = $l->Version;
         $sing['status'] = "on";
         /*
         	if (isOn($sing['status'])) {
         		$sing['full_version'] = `rpm -qi $name`; 
         	} else {
         		$sing['full_version'] = $sing['version'];
         	}
         */
         $ret[] = $sing;
     }
     return $ret;
 }
开发者ID:lonelywoolf,项目名称:hypervm,代码行数:33,代码来源:component__windowslib.php

示例14: execBg2

 function execBg2()
 {
     $tmpBat = $this->tempBat();
     $WshShell = new COM("WScript.Shell");
     $oExec = $WshShell->Run($tmpBat, 0, false);
     return $oExec == 0 ? true : false;
 }
开发者ID:bruno-melo,项目名称:components,代码行数:7,代码来源:ExecBatch.php

示例15: readProcessList

 static function readProcessList()
 {
     try {
         $obj = new COM("Winmgmts:{impersonationLevel=impersonate}!//./root/cimv2");
     } catch (exception $e) {
         throw new lxException("com_failed", 'disk');
     }
     try {
         $list = $obj->execQuery("select * from Win32_Process");
     } catch (exception $e) {
     }
     $i = 0;
     $v = new Variant(42);
     foreach ($list as $l) {
         try {
             $result[$i]['nname'] = $l->ProcessId;
             $result[$i]['command'] = $l->Caption;
             $ret = $l->getOwner($v);
             if ($ret) {
             } else {
                 $result[$i]['username'] = "{$v}";
             }
             $result[$i]['state'] = "ZZ";
             $i++;
         } catch (exception $e) {
             $result[$i]['state'] = "ZZ";
             $result[$i]['nname'] = "Error";
             $result[$i]['command'] = $e->getMessage();
             $result[$i]['username'] = $e->getCode();
         }
     }
     return $result;
 }
开发者ID:lonelywoolf,项目名称:hypervm,代码行数:33,代码来源:process__windowslib.php


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