<?php
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
// WebSite: http://www.rvglobalsoft.com
// Unauthorized copying is strictly forbidden and may result in severe legal action.
// Copyright (c) 2006 RV Global Soft Co.,Ltd. All rights reserved.
//
// =====YOU MUST KEEP THIS COPYRIGHTS NOTICE INTACT AND CAN NOT BE REMOVE =======
// Copyright (c) 2006 RV Global Soft Co.,Ltd. All rights reserved.
// This Agreement is a legal contract, which specifies the terms of the license
// and warranty limitation between you and RV Global Soft Co.,Ltd. and RV Site Builder.
// You should carefully read the following terms and conditions before
// installing or using this software. Unless you have a different license
// agreement obtained from RV Global Soft Co.,Ltd., installation or use of this software
// indicates your acceptance of the license and warranty limitation terms
// contained in this Agreement. If you do not agree to the terms of this
// Agreement, promptly delete and destroy all copies of the Software.
//
// ===== Grant of License =======
// The Software may only be installed and used on a single host machine.
//
// ===== Disclaimer of Warranty =======
// THIS SOFTWARE AND ACCOMPANYING DOCUMENTATION ARE PROVIDED "AS IS" AND
// WITHOUT WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY OTHER
// WARRANTIES WHETHER EXPRESSED OR IMPLIED. BECAUSE OF THE VARIOUS HARDWARE
// AND SOFTWARE ENVIRONMENTS INTO WHICH RV SITE BUILDER MAY BE USED, NO WARRANTY OF
// FITNESS FOR A PARTICULAR PURPOSE IS OFFERED. THE USER MUST ASSUME THE
// ENTIRE RISK OF USING THIS PROGRAM. ANY LIABILITY OF RV GLOBAL SOFT CO.,LTD. WILL BE
// LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT OR REFUND OF PURCHASE PRICE.
// IN NO CASE SHALL RV GLOBAL SOFT CO.,LTD. BE LIABLE FOR ANY INCIDENTAL, SPECIAL OR
// CONSEQUENTIAL DAMAGES OR LOSS, INCLUDING, WITHOUT LIMITATION, LOST PROFITS
// OR THE INABILITY TO USE EQUIPMENT OR ACCESS DATA, WHETHER SUCH DAMAGES ARE
// BASED UPON A BREACH OF EXPRESS OR IMPLIED WARRANTIES, BREACH OF CONTRACT,
// NEGLIGENCE, STRICT TORT, OR ANY OTHER LEGAL THEORY. THIS IS TRUE EVEN IF
// RV GLOBAL SOFT CO.,LTD. IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN NO CASE WILL
// RV GLOBAL SOFT CO.,LTD.'S LIABILITY EXCEED THE AMOUNT OF THE LICENSE FEE ACTUALLY PAID
// BY LICENSEE TO RV GLOBAL SOFT CO.,LTD.
// +---------------------------------------------------------------------------+
// $Id$
// +---------------------------------------------------------------------------+
/**
*
* @package sitebuilder
* @author
* @version $Revision$
* @since PHP 4.1
*/
class RVSGL_Emailer
{
/**
* RVSGL_Emailer : Constructer
*
*/
function RVSGL_Emailer()
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
}
/**
* Append Plan Text : Read data plan text
*
* @author Puttipong <puttipong@rvglobalsoft.com>
* @param String $moduleName - Module component
* @param String $template - Template Email
* @return String $strAppend - Return string plan text
*/
function appendPlanText($moduleName, $template)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$template = preg_replace("/\.php$/", ".txt", $template);
$lang = $_SESSION['aPrefs']['language'];
$strAppend = '';
$path = RVS_USER_HOME . '/.rvsitebuilder/projects/' . RVS_PROJECT_ID . '/lang/' . $moduleName . '/emailtemplate/'. $lang .'/' . $template;
if (is_file($path)) {
$handle = @fopen($path, 'r');
if ($handle) {
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
$strAppend .= $buffer;
}
}
fclose($handle);
}
return $strAppend;
}
/**
* Build Translation - Build Value 'bodyKey' and 'sujectKey' new
*
* @author Puttipong <puttipong@rvglobalsoft.com>
* @param String $moduleName - Module component
* @param String $template - Template Email
*/
function chkCreatePath($path)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
if (!is_dir($path)) {
System::mkdir(array('-p',0755,($path)));
//@mkdir($path, 0755, true);
}
}
/**
* CompileFlexy - Compile flexy
*
* @author Puttipong <puttipong@rvglobalsoft.com>
* @param String $moduleName - Module component
* @param String $template - Template Email
* @param String $option - Option get translate {bodyKey,$subjectKey}
* @param String $bodyKey - Content string bodyKey
* @param String $subjectKey - Content string subjectKey
* @param String $lang - String language project
* @param String $body - Content string body
*/
function compileFlexy($moduleName, $template, $option, $bodyKey, $subjectKey, $words, $lang, $body)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$strCompileFlexy = '';
$content = '';
if ($option == 'bodyKey') {
if (isset($words[$bodyKey])) {
$content = $words[$bodyKey];
} else {
return $body;
}
} else if ($option == 'subjectKey') {
if (isset($words[$subjectKey])) {
$content = $words[$subjectKey];
} else {
return $this->options['subject'];
}
}
$path = SGL_VAR_DIR; //RVS_USER_HOME . '/.rvsitebuilder/projects/' . RVS_PROJECT_ID . '/lang/' . $moduleName . '/emailtemplate/'. $lang;
$this->chkCreatePath($path);
$fileFlexy = $path . '/' . 'tmp_' . substr(time(),-3,2).rand(10,99) . '.html';
$handle = @fopen($fileFlexy, "w+");
fwrite($handle, $content);
fclose($handle);
if (is_file($fileFlexy) === false) {
return ;
}
include_once SGL_LIB_PEAR_DIR . '/HTML/Template/Flexy.php';
$this->flexyHandle = new HTML_Template_Flexy();
$this->flexyHandle->compile($fileFlexy);
$strCompileFlexy = $content;
$strCompileFlexy = $this->flexyHandle->bufferedOutputObject($this);
@unlink($fileFlexy);
$strCompileFlexy = $this->replaceUrlPath($strCompileFlexy);
if ($option == 'bodyKey') {
$strCompileFlexy = $this->appendHtml($strCompileFlexy, $moduleName);
}
return $strCompileFlexy;
}
/**
* Replace Url Path - Replace URL seagull
*
* @author Puttipong <puttipong@rvglobalsoft.com>
* @param String $strCompileFlexy - String compile flexy
* @return String replace url seagull complete.
*/
function replaceUrlPath($strCompileFlexy)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$strScrDoc = preg_replace('/src="\/rvsitebuilder\/www\/project(.*?)(\/documents)/', 'src="' . SGL_BASE_URL . '/documents', $strCompileFlexy);
$strScrLib = preg_replace('/src="\/rvsitebuilder\/www(\/rvs_library)/', 'src="' . SGL_BASE_URL . '/rvs_library', $strScrDoc);
$strHrefDoc = preg_replace('/href="\/rvsitebuilder\/www\/project(.*?)(\/documents)/', 'href="' . SGL_BASE_URL . '/documents', $strScrLib);
$strHrefLib = preg_replace('/href="\/rvsitebuilder\/www(\/rvs_library)/', 'href="' . SGL_BASE_URL . '/rvs_library', $strHrefDoc);
return $strHrefLib;
}
/**
* Append HTML - Append html
*
* @param String $strCompileFlexy - Content data to append html
* @param String $moduleName - Module email template
* @return String $strCompile - String append html
*/
function appendHtml($strCompileFlexy, $moduleName)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$strHtml = "<html>" . "\r\n";
$strHtml .= $this->appendCss($moduleName) . "\r\n";
$strHtml .= "<body>";
$strCompileFlexy = $strHtml . $strCompileFlexy;
$strHtml = "\r\n" . "</body>" . "\r\n";
$strHtml .= "</html>" . "\r\n";
$strCompileFlexy = $strCompileFlexy . $strHtml;
return $strCompileFlexy;
}
/**
* Append Css - Append css
*
* @param String $moduleName - Module email template
* @return String $strCss - String Css
*/
function appendCss($moduleName)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$lang = $_SESSION['aPrefs']['language'];
$strCss = "";
$strTypeCss = "";
$pathCss = RVS_USER_HOME . '/.rvsitebuilder/projects/' . RVS_PROJECT_ID . '/lang/' . $moduleName . '/emailtemplate/'. $lang .'/config.txt';
if (is_file($pathCss)) {
$handle = @fopen($pathCss, 'r');
if ($handle) {
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
$strTypeCss .= $buffer;
}
}
fclose($handle);
$strCss = "<link rel=\"stylesheet\" href=\"". SGL_BASE_URL . "/" . $strTypeCss . ".css\" type=\"text/css\" />";
}
return $strCss;
}
/**
* getTranslationFlexy - Get translate flexy
*
* @author Puttipong <puttipong@rvglobalsoft.com>
* @param String $moduleName - Module component
* @param String $template - Template Email
* @param String $option - Option get translate {bodyKey,$subjectKey}
* @return String - Content email config
*/
function getTranslationFlexy($moduleName, $template, $option)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$lang = $_SESSION['aPrefs']['language'];
$pathEmailTemplate = SGL_MOD_DIR . '/' . $moduleName . '/' . 'templates' . '/' . $template;
$pathSaveLangEmailTemplate = RVS_USER_HOME . '/.rvsitebuilder/projects/' . RVS_PROJECT_ID . '/lang/' . $moduleName . '/emailtemplate/'. $lang .'/' . $template;
$pathLangEmailDefault = SGL_MOD_DIR . '/default/lang/english-utf-8.php';
if (is_file($pathEmailTemplate)) {
SGL::logMessage(' is_file $pathEmailTemplate ' .$pathEmailTemplate, PEAR_LOG_DEBUG);
include $pathEmailTemplate;
}
if (isset($bodyKey) && isset($subjectKey)) {
if (is_file($pathSaveLangEmailTemplate) && is_file($pathEmailTemplate)) {
include $pathSaveLangEmailTemplate;
return $this->compileFlexy($moduleName, $template, $option, $bodyKey, $subjectKey, $words, $lang, $body);
} else if (is_file($pathLangEmailDefault) && is_file($pathEmailTemplate)) {
include $pathLangEmailDefault;
return $this->compileFlexy($moduleName, $template, $option, $bodyKey, $subjectKey, $defaultWords, $lang, $body);
}
}
if ($option == 'bodyKey') {
return $body;
} else if ($option == 'subjectKey') {
return $this->options['subject'];
}
}
/**
* loadBcc - load Bcc
*
* @author Puttipong <puttipong@rvglobalsoft.com>
* @param String $moduleName - Module component
* @param String $template - Template Email
* @return String $this->option['Bcc'] - If is file $pathSaveCc Return Bcc EmailConfirmation
* Else default $this->option['Bcc']
*/
function loadBcc($moduleName, $template)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$template = preg_replace("/\.php$/", "_Bcc.txt", $template);
$lang = $_SESSION['aPrefs']['language'];
$strBcc = '';
$pathSaveCc = RVS_USER_HOME . '/.rvsitebuilder/projects/' . RVS_PROJECT_ID . '/lang/' . $moduleName . '/emailtemplate/'. $lang .'/' . $template;
if (is_file($pathSaveCc)) {
$handle = @fopen($pathSaveCc, 'r');
if ($handle) {
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
$strBcc .= $buffer;
}
}
fclose($handle);
}
if ($strBcc != '') {
$this->options['Bcc'] = $strBcc;
}
}
}
?>
Copyright 2K16 - 2K18 Indonesian Hacker Rulez