/** * 发送通知 * * @param unknown_type $uid 接收者用户ID或用户名,多个ID用","连接,如:"501,yuanwei" * @param unknown_type $msg 消息文本 * @param unknown_type $url 连接地址 * @param unknown_type $notifyType 通知类型 'rtx' | 'mail' * @param unknown_type $title 标题,可以为空 */ public static function notify($uids, $msg, $url, $notifyType, $title = '') { // 得到 userid 得到 username $usernames = $spr = ''; $uidArr = explode(',', $uids); foreach ($uidArr as $uid) { $idtype = is_numeric($uid) ? 0 : 1; $uinfo = self::getInfo($uid, '', $idtype); $value = $notifyType == 'rtx' ? $uinfo['username'] : $uinfo['email']; if ($value) { $usernames .= $spr . $value; $spr = ','; } } // 找不到接收者则退出 if ($usernames == '') { return; } // 发送对应的通知 if ($title == '') { $title = 'QuickBug Notify'; } else { $title = 'QuickBug-' . $title; } if ($notifyType == 'rtx') { Rtx::send($usernames, $msg, $url, $title); } else { $usernames = str_replace(',', ';', $usernames); $mailObj = new Qmail(); $view = new QP_View(); $contents = $view->render('/Common/Mail-tpl.html'); $body = str_replace(array('{title}', '{msg}', '{url}'), array($title, $msg, $url), $contents); $mailObj->send($usernames, $title, $body); } }
foreach (new DirectoryIterator($path) as $qdir) { $qdir = $qdir->__toString(); if ($qdir[0] != '.') { foreach (new DirectoryIterator($path . DIRECTORY_SEPARATOR . $qdir) as $file) { $fname = $file->__toString(); if ($fname[0] != '.') { $total++; } } } } return $total; } public function countRemote() { $path = $this->queue_path . DIRECTORY_SEPARATOR . 'remote'; $remote = $this->countQueue($path); return $remote; } public function countLocal() { $path = $this->queue_path . DIRECTORY_SEPARATOR . 'local'; $local = $this->countQueue($path); return $local; } } $q = new Qmail(); $r = $q->countRemote(); $l = $q->countLocal(); exec("/usr/bin/gmetric --name qmail_remote_queue --value {$r} --type int16 --units Messages"); exec("/usr/bin/gmetric --name qmail_local_queue --value {$l} --type int16 --units Messages");