public static function getList() { $serverKey = MagentoDebugger::getKeyFromString($_SERVER['SERVER_NAME']); $profilerDir = MagentoDebugger::getDebuggerVarDir() . '/profiler'; $dir = opendir($profilerDir); $files = array(); while ($item = readdir($dir)) { $pathinfo = pathinfo($item); if (!isset($pathinfo['extension']) || $pathinfo['extension'] != 'jshe') { continue; } if (substr($item, 0, strlen($serverKey) + 1) != $serverKey . '.') { continue; } $headerJson = file_get_contents($profilerDir . '/' . $item); if (!$headerJson) { continue; } $header = json_decode(trim($headerJson)); $time = $header->time; $header->time = @date('Y.m.d H:i:s', $time); $files[$time] = $header; } sort($files); echo json_encode($files); }
public static function enableProfiler($status = true) { self::$_profilerEnabled = $status; if (!$status) { return; } require_once MagentoDebugger::getProjectDir() . '/lib/Varien/Profiler.php'; //require_once(self::getDebuggerDir() . '/libs/Varien/Profiler.php'); Varien_Profiler::enable(); $serverKey = MagentoDebugger::getKeyFromString(isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'console'); $time = time(); self::$_uniqId = $time . '_' . uniqid(); self::$_jsonLog = MagentoDebugger::getDebuggerVarDir() . '/profiler/' . $serverKey . '.' . self::$_uniqId; $url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : 'Not specified'; $profilerHeader = array('time' => $time, 'url' => $url, 'key' => self::$_uniqId); file_put_contents(self::$_jsonLog . '.jshe', json_encode($profilerHeader)); }
public static function getList() { $serverKey = MagentoDebugger::getKeyFromString($_SERVER['SERVER_NAME']); $mailDir = MagentoDebugger::getDebuggerVarDir() . '/mails'; $dir = opendir($mailDir); $files = array(); while ($item = readdir($dir)) { $pathinfo = pathinfo($item); if (!isset($pathinfo['extension']) || $pathinfo['extension'] != 'json') { continue; } $itemConfigurationString = file_get_contents($mailDir . '/' . $item); $itemConfiguration = (array) json_decode($itemConfigurationString); $itemConfiguration['identifier'] = $pathinfo['filename']; $itemConfiguration['time'] = filemtime($mailDir . '/' . $item); $itemConfiguration['datetime'] = @date('Y-m-d H:i:s', $itemConfiguration['time']); $files[$itemConfiguration['time'] . '_' . uniqid()] = $itemConfiguration; } sort($files); echo json_encode($files); }
/** * Send mail to recipient * * @param array|string $email E-mail(s) * @param array|string|null $name receiver name(s) * @param array $variables template variables * @return boolean **/ public function send($email, $name = null, array $variables = array()) { if (!$this->isValidForSend()) { Mage::logException(new Exception('This letter cannot be sent.')); // translation is intentionally omitted return false; } $emails = array_values((array) $email); $names = is_array($name) ? $name : (array) $name; $names = array_values($names); foreach ($emails as $key => $email) { if (!isset($names[$key])) { $names[$key] = substr($email, 0, strpos($email, '@')); } } $variables['email'] = reset($emails); $variables['name'] = reset($names); ini_set('SMTP', Mage::getStoreConfig('system/smtp/host')); ini_set('smtp_port', Mage::getStoreConfig('system/smtp/port')); $mail = $this->getMail(); $setReturnPath = Mage::getStoreConfig(self::XML_PATH_SENDING_SET_RETURN_PATH); switch ($setReturnPath) { case 1: $returnPathEmail = $this->getSenderEmail(); break; case 2: $returnPathEmail = Mage::getStoreConfig(self::XML_PATH_SENDING_RETURN_PATH_EMAIL); break; default: $returnPathEmail = null; break; } if ($returnPathEmail !== null) { $mailTransport = new Zend_Mail_Transport_Sendmail("-f" . $returnPathEmail); Zend_Mail::setDefaultTransport($mailTransport); } $debugToArray = array(); foreach ($emails as $key => $email) { array_push($debugToArray, $email); $mail->addTo($email, '=?utf-8?B?' . base64_encode($names[$key]) . '?='); } $this->setUseAbsoluteLinks(true); $text = $this->getProcessedTemplate($variables, true); $this->_mailDebuggerInfo->setEmailSubject($this->getProcessedTemplateSubject($variables)); $this->_mailDebuggerInfo->setEmailBody($text); $this->_mailDebuggerInfo->setEmailIsPlan($this->isPlain()); $this->_mailDebuggerInfo->setBacktrace(Varien_Debug::backtrace(true)); if ($this->isPlain()) { $mail->setBodyText($text); } else { $mail->setBodyHTML($text); } $mail->setSubject('=?utf-8?B?' . base64_encode($this->getProcessedTemplateSubject($variables)) . '?='); $mail->setFrom($this->getSenderEmail(), $this->getSenderName()); $this->_mailDebuggerInfo->setEmailTo(implode("; ", $debugToArray)); $this->_mailDebuggerInfo->setEmailFrom($mail->getFrom()); $jsonDebugData = Mage::helper('core')->jsonEncode($this->_mailDebuggerInfo->getData()); $serverKey = MagentoDebugger::getKeyFromString(isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'console'); $jsonDebugFile = MagentoDebugger::getDebuggerVarDir() . '/mails/' . $serverKey . '.' . time() . '_' . uniqid() . '.json'; if (!is_dir(MagentoDebugger::getDebuggerVarDir() . '/mails/')) { mkdir(MagentoDebugger::getDebuggerVarDir() . '/mails/'); } //file_put_contents($jsonDebugFile . '.html', $text); file_put_contents($jsonDebugFile, $jsonDebugData); try { $mail->send(); $this->_mail = null; } catch (Exception $e) { $this->_mail = null; Mage::logException($e); return false; } return true; }