示例#1
0
function init()
{
    global $system;
    global $params;
    global $BD;
    global $labels;
    global $dbParams;
    global $usuario;
    global $requiereLogueo;
    global $noVerificarCambioPass;
    global $nivel;
    global $urlVolver;
    // Leo las propiedades de los archivos de configuracion
    $system = obtProperties("system.properties");
    $labels = obtProperties("labels.properties");
    $dbParams = obtProperties("bd.properties");
    // Consigo la conexion con la base de datos
    $BD = new BDCon($dbParams);
    // Leo los parametros de configuracion de la base de datos
    $params = Parametro::obtTodos($BD);
    $usuario = new Usuario();
    // Cargo la sesion, si es que hay
    $usuario->cargarSesion($BD);
    if ($requiereLogueo && (!$usuario->logueado() || !$usuario->tieneAcceso($nivel))) {
        logInfo("Intento de acceso a '" . $system["URL_BASE"] . $urlVolver . "'." . "Redirrecionado a '" . $system["URL_SINACCESO"] . "'.");
        redirect($system["URL_SINACCESO"]);
        return false;
    }
    if (!$noVerificarCambioPass && $usuario->getCambiarPass() == 'S') {
        redirect($system["URL_CAMBIAR"]);
    }
    return true;
}
function logMessage($logLevel)
{
    if ($logLevel == 'info') {
        return logInfo();
    } elseif ($logLevel == 'error') {
        return logError();
    } else {
        return "[UNK], '{$logLevel}' is unknown.";
    }
}
示例#3
0
	/**
	 * logInfo
	 * to help debugging Payment notification for example
	 * Keep it for compatibilty
	 */
	protected function logInfo ($text, $type = 'message', $doLog=false) {
		if (!class_exists( 'VmConfig' )) require(JPATH_COMPONENT_ADMINISTRATOR .'/helpers/config.php');
		VmConfig::loadConfig();
		if ((isset($this->_debug) and $this->_debug) OR $doLog) {
			$oldLogFileName= 	VmConfig::$logFileName;
			VmConfig::$logFileName =$this->getLogFileName() ;
			logInfo($text, $type);
			VmConfig::$logFileName =$oldLogFileName;
		}
	}
示例#4
0
文件: index.php 项目: ksb1712/pragyan
    exit;
}
///Parse the URL and retrieve the PageID of the request page if its valid
$pageId = parseUrlReal($pageFullPath, $pageIdArray);
///Means that the requested URL is not valid.
if ($pageId === false) {
    define("TEMPLATE", getPageTemplate(0));
    $pageId = parseUrlReal("home", $pageIdArray);
    $TITLE = CMS_TITLE;
    $MENUBAR = '';
    $CONTENT = "The requested URL was not found on this server.<br />{$_SERVER['SERVER_SIGNATURE']}" . "<br /><br />Click <a href='" . $urlRequestRoot . "'>here </a> to return to the home page";
    templateReplace($TITLE, $MENUBAR, $ACTIONBARMODULE, $ACTIONBARPAGE, $BREADCRUMB, $SEARCHBAR, $PAGEKEYWORDS, $INHERITEDINFO, $CONTENT, $FOOTER, $DEBUGINFO, $ERRORSTRING, $WARNINGSTRING, $INFOSTRING, $STARTSCRIPTS, $LOGINFORM);
    exit;
}
///If it reaches here, means the page requested is valid. Log the information for future use.
logInfo(getUserEmail($userId), $userId, $pageId, $pageFullPath, getPageModule($pageId), $action, $_SERVER['REMOTE_ADDR']);
///The URL points to a file. Download permissions for the file are handled inside the download() function in download.lib.php
if (isset($_GET['fileget'])) {
    require_once $sourceFolder . "/download.lib.php";
    $action = "";
    if (isset($_GET['action'])) {
        $action = $_GET['action'];
    }
    download($pageId, $userId, $_GET['fileget'], $action);
    exit;
}
///Check whether the user has the permission to use that action on the requested page.
$permission = getPermissions($userId, $pageId, $action);
///Gets the page-specific template for that requested page
define("TEMPLATE", getPageTemplate($pageId));
///Gets the page title of the requested page
示例#5
0
<?php

function logMessage($logLevel, $message)
{
    $fileDate = date('Y-m-d');
    $filename = "log-{$fileDate}.log";
    $logDate = date('Y-m-d H:i:s');
    $string = $logDate . ' [' . $logLevel . '] ' . $message . PHP_EOL;
    if (file_exists($filename)) {
        file_put_contents($filename, $string, FILE_APPEND);
    } else {
        file_put_contents($filename, $string);
    }
}
logMessage("INFO", "This is an info message.");
logMessage("ERROR", "This is an error message.");
function logInfo($message)
{
    $logLevel = "INFO";
    logMessage($logLevel, $message);
}
logInfo("Today is Monday.");
function logError($message)
{
    $logLevel = "ERROR";
    logMessage($logLevel, $message);
}
logError("logError() && logInfo() functions are useless.");
示例#6
0
<?php

function logMessage($logLevel, $message)
{
    $date = date("Y-m-d H:i:s");
    $string_to_append = PHP_EOL . "{$date} [{$logLevel}] {$message}";
    $file = 'log-YYYY-MM-DD.log';
    $handle = fopen($file, 'a');
    fwrite($handle, $string_to_append);
    fclose($handle);
}
function logInfo($info)
{
    logMessage("INFO", "{$info}");
}
function logError($info)
{
    logMessage("ERROR", $info);
}
// logMessage("INFO", "This is an info message.");
// logMessage("ERROR", "This is an ERRORRRRRRRR message.");
logInfo("woot it worked");
logError("woot its now messed up");
 public function webhook()
 {
     header("Content-type: text/html; charset=utf-8");
     $appId = C('PAYMENT_APP_ID');
     $appSecret = C('PAYMENT_APP_SECRET');
     $jsonStr = file_get_contents("php://input");
     logInfo('ReturnJson:' . $jsonStr);
     //$jsonStr = file_get_contents(dirname(__FILE__)."/refund_json111.txt");
     $msg = json_decode($jsonStr);
     // webhook字段文档: http://beecloud.cn/doc/php.php#webhook
     // 验证签名
     $sign = md5($appId . $appSecret . $msg->timestamp);
     if ($sign != $msg->sign) {
         // 签名不正确
         logWarn('Signature incorrect.');
         exit;
     }
     // 此处需要验证购买的产品与订单金额是否匹配:
     // 验证购买的产品与订单金额是否匹配的目的在于防止黑客反编译了iOS或者Android app的代码,
     // 将本来比如100元的订单金额改成了1分钱,开发者应该识别这种情况,避免误以为用户已经足额支付。
     // Webhook传入的消息里面应该以某种形式包含此次购买的商品信息,比如title或者optional里面的某个参数说明此次购买的产品是一部iPhone手机,
     // 开发者需要在客户服务端去查询自己内部的数据库看看iPhone的金额是否与该Webhook的订单金额一致,仅有一致的情况下,才继续走正常的业务逻辑。
     // 如果发现不一致的情况,排除程序bug外,需要去查明原因,防止不法分子对你的app进行二次打包,对你的客户的利益构成潜在威胁。
     // 如果发现这样的情况,请及时与我们联系,我们会与客户一起与这些不法分子做斗争。而且即使有这样极端的情况发生,
     // 只要按照前述要求做了购买的产品与订单金额的匹配性验证,在你的后端服务器不被入侵的前提下,你就不会有任何经济损失。
     if ($msg->transactionType == "PAY") {
         //messageDetail 参考文档
         switch ($msg->channelType) {
             case "WX":
                 $this->commonPayCallbackProcess($msg);
                 break;
             case "ALI":
                 $this->commonPayCallbackProcess($msg);
                 break;
             case "UN":
                 break;
         }
     } else {
         if ($msg->transactionType == "REFUND") {
             $this->refundCallbackProcess($msg);
         }
     }
     //处理消息成功,不需要持续通知此消息返回success
     echo 'success';
 }
<?php

function logMessage($logLevel, $message)
{
    $today = date("Y-m-d");
    $filename = 'log-' . $today . 'log';
    $todayLog = date("Y-m-d h:i:s");
    $handle = fopen($filename, 'a');
    fwrite($handle, $todayLog . ' ' . $logLevel . ' ' . $message . PHP_EOL);
    fclose($handle);
}
function logInfo($message)
{
    logMessage("INFO", $message);
}
function logError($message)
{
    logMessage("ERROR", $message);
}
// logMessage("INFO", "This is an info message.");
logInfo("This is an info message");
// logMessage("ERROR", "This is an error message.");
logError("This is an error message");
示例#9
0
 /**
  * logInfo
  * to help debugging Payment notification for example
  * Keep it for compatibilty
  */
 protected function logInfo($text, $type = 'message', $doLog = false)
 {
     if (!class_exists('VmConfig')) {
         require JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
     }
     VmConfig::loadConfig();
     if (isset($this->_debug) and $this->_debug or $doLog) {
         $oldLogFileName = VmConfig::$logFileName;
         VmConfig::$logFileName = $this->getLogFileName();
         logInfo($text, $type);
         VmConfig::$logFileName = $oldLogFileName;
     }
 }
示例#10
0
/**
* This method creates a game object that is good for one game session. Everytime a game object is created, it is all random.
* The twitter users, their tweet, all random. 
*
* NOTE: This method logs a bunch of stuff in a new live log html file called "gameSelectionLogs.html". This is done 
*       because even though the game object is created there is a minor glitch in creation of the game object. Some 
*       Tweets do not work when doing json_decode ("enigma-bug"). Sometiumes it works sometimes it doesnt. 
*
* @return gameObject :: A json form string that could be converted into json in JS easily.
*/
function createGameObject()
{
    // Get random 10 Twitter Users
    $twitterUsers = getRandomTwitterUsers(10);
    // Get Connection Link
    $link = getConnection();
    $correct = array();
    $incorrect = array();
    $userKeys = array();
    foreach ($twitterUsers as $user) {
        // Select a random number between 1 and 200
        $rand = mt_rand(1, 200);
        logInfo("gameSelectionLogs.html", "Grabbing Tweet Number: " . $rand . " for Twitter User: "******" from the DB.");
        $query = "SELECT TwitterResp FROM Tweets WHERE Number = " . (string) $rand . " AND TwitterHandle = \"" . $user . "\";";
        $res = mysqli_query($link, $query);
        $row = $res->fetch_array();
        // Get the textual tweet response form the DB
        $twitterResp = $row[0];
        // Convert that text to associative array
        $twitterRespJson = json_decode($twitterResp, true, 200000);
        // Creating a new user variable jsut in case the last one fails
        $newUser = $user;
        // If it fails...
        while ($twitterRespJson == null) {
            logError("gameSelectionLogs.html", "Conversion of Tweet Response text from DB to JSON in PHP failed.");
            logInfo("gameSelectionLogs.html", "Finding a new random Twitter User for the game...");
            // Get new random twitter user
            $newUser = getRandomTwitterUsers(1);
            $newUser = $newUser[0];
            // Select a random number between 1 and 200
            $rand = mt_rand(1, 200);
            logInfo("gameSelectionLogs.html", "Grabbing Tweet Number: " . $rand . " for Twitter User: "******" from the DB.");
            $query = "SELECT TwitterResp FROM Tweets WHERE Number = " . (string) $rand . " AND TwitterHandle = \"" . $newUser . "\";";
            $res = mysqli_query($link, $query);
            $row = $res->fetch_array();
            // Grab the Twitter Response as text from the DB
            $twitterResp = $row[0];
            $twitterRespJson = json_decode($twitterResp, true, 20000);
        }
        logSuccess("gameSelectionLogs.html", "User: "******" with Tweet Number: " . $rand . " has been selected for the game.");
        // If Everything went OK
        if ($twitterResp != "") {
            $response = $twitterRespJson;
            $userObj = array('name' => $response['user']['name'], 'handle' => '@' . $response['user']['screen_name'], 'profilePicURL' => str_replace("_normal", "", $response['user']['profile_image_url']), 'followURL' => "https://twitter.com/intent/follow?screen_name=" . '@' . $response['user']['screen_name']);
            //var_dump($userObj);
            $tweetObj = array('tweetID' => $response['id'], 'tweetDate' => $response['created_at'], 'tweetHTML' => getTweetHTML($response), 'tweetText' => $response['text'], 'numOfRetweets' => $response['retweet_count'], 'numOfFavorites' => $response['favorite_count']);
            $unit = array('userInfo' => $userObj, 'tweetInfo' => $tweetObj);
            array_push($userKeys, $response['user']['screen_name']);
            $correct[$response['user']['screen_name']] = $unit;
        }
    }
    logInfo("gameSelectionLogs.html", "'Correct' part of the game object has been COMPLETED. Starting the construction of 'incorrect' part of the game object.");
    $incorrect = array();
    // Variable to log the final Game Layout.
    $gameObjectLog = "";
    foreach ($correct as $unit) {
        $rand = $rand = mt_rand(0, count($userKeys) - 1);
        // Swap that random number with the last user in the userKeys array
        if (count($userKeys) != 0) {
            $temp = $userKeys[count($userKeys) - 1];
            $userKeys[count($userKeys) - 1] = $userKeys[$rand];
            $userKeys[$rand] = $temp;
        }
        // get random tweet user
        $randomTwitterUser = array_pop($userKeys);
        $gameObjectLog = $gameObjectLog . '<b>' . substr($unit['userInfo']['handle'], 1) . '</b> has <b>' . $randomTwitterUser . '\'s</b> tweet infront of him/her in the game. <br>';
        // Select that random tweet from the correct part of game object and add in current incorrect unit
        $incorrect[substr($unit['userInfo']['handle'], 1)]['userInfo'] = $correct[substr($unit['userInfo']['handle'], 1)]['userInfo'];
        $incorrect[substr($unit['userInfo']['handle'], 1)]['tweetInfo'] = $correct[$randomTwitterUser]['tweetInfo'];
    }
    // Game object construction
    $gameObject = array('correct' => $correct, 'incorrect' => $incorrect);
    logSuccess("gameSelectionLogs.html", "Game Object Creation Successful. <br><u>GAME INFO:</u><br>" . $gameObjectLog);
    logInfo("gameSessionObjects.txt", json_encode($gameObject));
    return json_encode($gameObject);
}
示例#11
0
<?php

/**
 * DESCRIPCION
 * 
 * @author Agustin Arias <*****@*****.**>
 */
chdir("..");
include_once 'util/includes.php';
include_once 'util/util.php';
$usuario = new Usuario();
$username = $_POST["username"] ? $_POST["username"] : '******';
$pass = $_POST["pass"] ? $_POST["pass"] : '';
if ($usuario->login($username, $pass, $BD)) {
    logInfo("Login. Usuario: {$username}");
    $ret["e"] = "OK";
} else {
    logInfo("Fallo login. Usuario: {$username}");
    $ret["e"] = "ERROR";
    $ret["error"] = "<B>Lo sentimos.</B> La combinaci&oacute;n de usuario y contrase&ntilde;a no es correcta.";
}
echo json_encode($ret);
 protected function testLogShoppingList()
 {
     $shoppingList = session('shoppingList');
     logInfo('shoppingList  totalItemCount:' . $shoppingList['totalItemCount'] . ',totalAmount:' . $shoppingList['totalAmount']);
     $shoppingListItems = session('shoppingListItems');
     logInfo('shoppingListItems:');
     foreach ($shoppingListItems as $value) {
         logInfo('itemId:' . $value['itemId'] . ',itemSize:' . $value['itemSize'] . ',itemName:' . $value['itemName'] . ',brandName:' . $value['brandName'] . ',itemImage:' . $value['itemImage'] . ',itemColor:' . $value['itemColor'] . ',sizeDescription:' . $value['sizeDescription'] . ',price:' . $value['price'] . ',quantity:' . $value['quantity']);
     }
 }
 protected function _processCommand()
 {
     $this->repoPath = $this->reposPath . DIRECTORY_SEPARATOR . $this->repoName;
     if ($this->gitCommand == 'git-annex-shell') {
         if (!$this->config->gitAnnexEnabled()) {
             Exception::throwException(30002, [$this->gitCommand, $this->user['name']]);
         }
     } else {
         logInfo("find-shell: executing git command '{$this->gitCommand} {$this->repoPath} by " . $this->user['name'] . ".", $this->config->commonLogFile());
         $this->_runCommand($this->gitCommand, array($this->repoPath));
     }
 }
date_default_timezone_set("America/Chicago");
function logMessage($logLevel, $message)
{
    $todaysDate = date("Y-m-d");
    $todaysDateTime = date("h:i:s A");
    $filename = "log-{$todaysDate}.log";
    $handle = fopen($filename, 'a');
    $formattedMessage = $todaysDate . " " . $todaysDateTime . " " . $logLevel . " " . $message . PHP_EOL;
    fwrite($handle, $formattedMessage);
    fclose($handle);
}
function logInfo($message)
{
    logMessage("INFO", $message);
}
function logError($message)
{
    logMessage("ERROR", $message);
}
function logWarning($message)
{
    logMessage("WARNING", $message);
}
function logCritical($message)
{
    logMessage("CRITICAL", $message);
}
logInfo("This is an INFO message.");
logError("This is an ERROR message.");
logWarning("This is a WARNING message.");
logCritical("This is a CRITICAL message.");
示例#15
0
///       local DB for the Game Object.
///
/// Author: Vishrut Reddi
/// MidnightJabber (c) 2015 - 2016
// Got it from: https://github.com/themattharris/tmhOAuth
require 'tmhOAuth.php';
//Connect Connection Script
include "connection.php";
// To log data
include "logger.php";
// Use the data from http://dev.twitter.com/apps to fill out this info
// notice the slight name difference in the last two items)
// Log a new session start
logInfo('tweetylogs.txt', 'New Session Starting.');
logInfo('info.txt', 'New Session Starting.');
logInfo('tweetylogs.html', '<b>New Session Starting</b>');
insertTweetInDB();
//getTweet('@katyperry', 200);
/**
* This method retreives all the Twitter user handles from the local DB (midnight_tweety).
* All the handles exist inside the table 'TwitterUsers'.
*
* NOTE: Each handle has '@' infront of it.
*       Each handle is a string and not an object containing a string.
*
* @return JSON OBJ {"result": [ __Array_of_handles__]}
*/
function getAllTwitterUsers()
{
    $query = "SELECT TwitterHandle FROM TwitterUsers ORDER BY UserID;";
    // Execute the query
 public function sendSubscriptionMail()
 {
     $res = array("status" => "0");
     $itemId = I('itemId');
     $itemSubscription = D('ItemSubscription', 'Logic');
     $subscriptionList = $itemSubscription->queryByItemId($itemId);
     $item = D('Item', 'Logic')->findById($itemId);
     $userInfo['userName'] = '******';
     $sentSbuscriptions = array();
     foreach ($subscriptionList as $subscription) {
         if ($subscription['status'] == '1') {
             //状态为1的已经发了邮件
             continue;
         }
         $userInfo['email'] = $subscription['email'];
         if (sendMailNewVersion($item, "itemSubscription", $userInfo)) {
             array_push($sentSbuscriptions, $subscription['subscriptionId']);
         }
     }
     if (!empty($sentSbuscriptions)) {
         logInfo('fk222');
         $itemSubscription->batchUpdateStatus($sentSbuscriptions);
         $res['status'] = '1';
     }
     echo json_encode($res);
 }
示例#17
0
function sendMailNewVersion($mailContent, $type, $userInfo)
{
    $mail = new \PHPMailer();
    //$mail->SMTPDebug = 3;                               // Enable verbose debug output
    $mail->CharSet = 'UTF-8';
    // Set CharSet to UTF-8
    $mail->isSMTP();
    // Set mailer to use SMTP
    $mail->Host = 'smtp.ym.163.com';
    // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;
    // Enable SMTP authentication
    $mail->Username = '******';
    // SMTP username
    $mail->Password = '******';
    // SMTP password
    $mail->Port = 25;
    // TCP port to connect to
    $mail->setFrom(C('EMAIL_FROM'), 'StarballKids');
    $mail->addAddress($userInfo["email"], $userInfo["userName"]);
    // Add a recipient
    //$mail->addAddress('*****@*****.**');               // Name is optional
    //$mail->addReplyTo('*****@*****.**', 'Information');
    //$mail->addCC('*****@*****.**');
    //$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
    //$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
    $mail->isHTML(true);
    // Set email format to HTML
    if ($type == "payment") {
        foreach (explode(';', C('SELLER_EMAIL_ADDRESS')) as $bccEmail) {
            $mail->addBCC($bccEmail);
            //发给卖家的邮件通知
        }
        $address = D('ShippingAddress', 'Logic')->getDefaultAddress($mailContent['userId']);
        $address = parseAddressCode($address);
        $template = "";
        $template = $template . "<p>尊敬的" . $userInfo["userName"] . ":</p>";
        $template = $template . "<p>非常感谢您对StarBall.Kids的支持,您的订单下单时间为" . date('y-m-d H:i:s', time()) . ",您的订单号码为" . $mailContent["orderNumber"] . "。</p>";
        $template = $template . "<p>我们正在打包您的包裹。当您的包裹开始邮寄时,您将会收到另一封邮件,包含您的包裹追踪号码。您可以登录快递公司官方网站,输入您的包裹追踪号码进而跟踪您的商品。</p>";
        $template = $template . "<p>您的订单详情: </p>";
        $currency = C('CURRENCY');
        $tableContent = "";
        $tableContent = $tableContent . "<table width='600' cellpadding='0' cellspacing='0' style='border: 1px #F2F2F2 solid; background-color: #F8F8F8'><tbody>\n\t\t<tr><td>描述</td><td>数量</td><td>尺寸</td><td>价钱(" . $currency[$mailContent['currency']] . ")</td></tr>";
        foreach ($mailContent['orderItems'] as $orderItem) {
            $tableContent = $tableContent . "<tr><td>" . $orderItem['itemName'] . "</td><td>" . $orderItem['quantity'] . "</td><td>" . $orderItem['sizeDescription'] . "</td><td>" . $orderItem['price'] . "</td></tr>";
        }
        $tableContent = $tableContent . "<tr><td>商品总计</td><td>-</td><td>-</td><td>" . $mailContent['totalAmount'] . "</td></tr>";
        $tableContent = $tableContent . "<tr><td>运费</td><td>-</td><td>-</td><td>" . $mailContent['shippingFee'] . "</td></tr>";
        $tableContent = $tableContent . "<tr><td>礼品包装费用</td><td>-</td><td>-</td><td>" . $mailContent['giftPackageFee'] . "</td></tr>";
        $tableContent = $tableContent . "<tr><td>总金额</td><td>-</td><td>-</td><td>" . $mailContent['totalFee'] . "</td></tr>";
        $tableContent = $tableContent . "</tbody></table>";
        $template = $template . $tableContent;
        if ($mailContent['addtionalGreetings'] != '') {
            $template = $template . "<p>礼品包装祝福信息:" . $mailContent['addtionalGreetings'] . "</p>";
        }
        $template = $template . "<p>您提供的收货地址:</p>";
        $template = $template . "<p>" . $address['address'] . "<p>";
        if ($address['postCode'] != '') {
            $template = $template . " " . $address['postCode'];
        }
        if ($address['city'] != '') {
            $template = $template . " " . $address['city'];
        }
        if ($address['province'] != '') {
            $template = $template . ' ' . $address['province'];
        }
        $template = $template . ' ' . $address['country'] . '<br></p>';
        $template = $template . "收货人姓名:" . $address['contactName'] . ' 电话:' . $address['phone'];
        $template = $template . "<p><img src='http://7xr7p7.com2.z0.glb.qiniucdn.com/1660857294.jpg' width='80' height='51'></p>";
        $template = $template . "<p>StarBall.Kids是一家来自香港的婴幼儿品牌集合店,主营进口婴幼儿童服装,这里有世界各地的大牌潮牌衣服供您选择。</p>";
        $template = $template . "<p>联系我们:邮件(starballkidshk@gmail.com)</p>";
        $mail->Subject = 'StarballKids支付成功通知-订单号' . $mailContent["orderNumber"];
        $mail->Body = $template;
    } elseif ($type == "delivered") {
        $address = D('ShippingAddress', 'Logic')->getDefaultAddress($mailContent['userId']);
        $address = parseAddressCode($address);
        $mail->Subject = 'StarballKids发货通知-订单号' . $mailContent["orderNumber"];
        $template = "";
        $template = $template . "<p>尊敬的" . $userInfo["userName"] . ":</p>";
        $template = $template . "<p>很高兴的通知您,您的订单" . $mailContent["orderNumber"] . "已经发货了。</p>";
        $template = $template . "<p>您的订单详情:</p>";
        $currency = C('CURRENCY');
        $tableContent = "";
        $tableContent = $tableContent . "<table width='600' cellpadding='0' cellspacing='0' style='border: 1px #F2F2F2 solid; background-color: #F8F8F8'><tbody>\n\t\t<tr><td>描述</td><td>数量</td><td>尺寸</td><td>价钱(" . $currency[$mailContent['currency']] . ")</td></tr>";
        foreach ($mailContent['orderItems'] as $orderItem) {
            $tableContent = $tableContent . "<tr><td>" . $orderItem['itemName'] . "</td><td>" . $orderItem['quantity'] . "</td><td>" . $orderItem['sizeDescription'] . "</td><td>" . $orderItem['price'] . "</td></tr>";
        }
        $tableContent = $tableContent . "<tr><td>商品总计</td><td>-</td><td>-</td><td>" . $mailContent['totalAmount'] . "</td></tr>";
        $tableContent = $tableContent . "<tr><td>运费</td><td>-</td><td>-</td><td>" . $mailContent['shippingFee'] . "</td></tr>";
        $tableContent = $tableContent . "<tr><td>礼品包装费用</td><td>-</td><td>-</td><td>" . $mailContent['giftPackageFee'] . "</td></tr>";
        $tableContent = $tableContent . "<tr><td>总金额</td><td>-</td><td>-</td><td>" . $mailContent['totalFee'] . "</td></tr>";
        $tableContent = $tableContent . "</tbody></table>";
        $template = $template . $tableContent;
        $template = $template . "<p>您可以登录快递公司的官方网站,输入您的包裹追踪号码来跟踪您的商品。</p>";
        $template = $template . "<p>您的快递公司:" . $mailContent["expressName"] . "</p>";
        $template = $template . "<p>您的包裹追踪号码:" . $mailContent["expressNumber"] . "</p>";
        $template = $template . "<p>您提供的收货地址:</p>";
        $template = $template . "<p>" . $address['address'];
        if ($address['city'] != '') {
            $template = $template . " " . $address['city'];
        }
        if ($address['province'] != '') {
            $template = $template . ' ' . $address['province'];
        }
        $template = $template . ' ' . $address['country'] . '<br></p>';
        $template = $template . "<p>有关于商品退换货事宜,请查看官网 www.starballkids.com 主页下方的退换政策了解详情。或联系我们的客服微信 starballkidshk. 我们会在第一时间给您回复并处理相关事宜。</p>";
        $template = $template . "<p>非常感谢您选择StarBall.Kids,相信是一次愉快的购物体验。希望很快再见到您,谢谢光临。</p>";
        $template = $template . "<p><img src='http://7xr7p7.com2.z0.glb.qiniucdn.com/1660857294.jpg' width='80' height='51'></p>";
        $template = $template . "<p>StarBall.Kids是一家来自香港的婴幼儿品牌集合店,主营进口婴幼儿童服装,这里有世界各地的大牌潮牌衣服供您选择。</p>";
        $template = $template . "<p>联系我们:邮件(starballkidshk@gmail.com)</p>";
        $mail->Body = $template;
        $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
    } else {
        if ($type == 'itemSubscription') {
            $mail->Subject = 'StarballKids到货通知';
            $template = "";
            $template = $template . "<p>尊敬的顾客:</p>";
            $template = $template . "<p>很高兴的通知您,您喜爱的商品 " . $mailContent['name'] . " 现货已登陆StarBall.Kids官方网站。库存有限,立即行动吧。</p>";
            $template = $template . "<p>点击下方链接进行购买</p>";
            $template = $template . "<p>http://www.starballkids.com/Starball/Item/index/itemId/" . $mailContent['itemId'] . ".html</p>";
            $template = $template . "<p>我们的官方网站 www.starballkids.com 还有更多选择,欢迎浏览购买,相信会是一次愉快的购物体验。感谢您对StarBall.Kids的支持。</p>";
            $template = $template . "<p><img src='http://7xr7p7.com2.z0.glb.qiniucdn.com/1660857294.jpg' width='80' height='51'></p>";
            $template = $template . "<p>StarBall.Kids是一家来自香港的婴幼儿品牌集合店,主营进口婴幼儿童服装,这里有世界各地的大牌潮牌衣服供您选择。</p>";
            $mail->Body = $template;
            $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
        }
    }
    if (!$mail->send()) {
        //echo 'Message could not be sent.';
        logInfo('Mailer Error: ' . $mail->ErrorInfo);
        return false;
    }
    return true;
}
 public function cancelSingleOrderItem()
 {
     $orderItemLogic = D("OrderItem", "Logic");
     $res = array("status" => "0", "needOpenNewWindow" => 'false');
     $id = I("post.cancelId", "");
     if ($id == "") {
         echo json_encode($res);
         return;
     }
     //找到支付成功的bill记录
     $orderItem = D('OrderItem', 'Logic')->getOrderItemById($id);
     $order = D('Order', 'Logic')->findByOrderId($orderItem['orderId']);
     $orderNumber = $order['orderNumber'];
     $orderBill = D('OrderBill', 'Logic')->findOrderSuccessPayBill($orderNumber);
     //向第三方支付发起退款请求
     $data = array();
     $appSecret = C('PAYMENT_APP_SECRET');
     $data["app_id"] = C('PAYMENT_APP_ID');
     $data["timestamp"] = time() * 1000;
     $data["app_sign"] = md5($data["app_id"] . $data["timestamp"] . $appSecret);
     //bill_no为支付成功的支付单号
     $data["bill_no"] = $orderBill['billNumber'];
     //商户退款单号,格式为:退款日期(8位) + 流水号(3~24 位)。请自行确保在商户系统中唯一,且退款日期必须是发起退款的当天日期,同一退款单号不可重复提交,否则会造成退款单重复。流水号可以接受数字或英文字符,建议使用数字,但不可接受“000”
     $data["refund_no"] = date("Ymd") . $data["timestamp"];
     $data["refund_fee"] = intval($orderItem['price'] * 100);
     //选择渠道类型(WX、WX_APP、WX_NATIVE、WX_JSAPI、ALI、ALI_APP、ALI_WEB、ALI_QRCODE、UN、UN_APP、UN_WEB)
     $data["channel"] = $orderBill['channel'];
     //选填 optional
     $data["optional"] = json_decode(json_encode(array("tag" => "msgtoreturn")));
     //创建退款的数据库记录,t_orderbill
     $billData['orderNumber'] = $orderNumber;
     $billData['billNumber'] = $data["bill_no"];
     $billData['refundNumber'] = $data["refund_no"];
     //只有退单个商品时才有值
     $billData['orderItemId'] = $orderItem['id'];
     $billData['totalAmount'] = $data["refund_fee"] / 100;
     $billData['channel'] = $data["channel"];
     $billData['type'] = 'REFUND';
     $billData['status'] = 'N';
     D('OrderBill', 'Logic')->createBill($billData);
     //$this->createOrderBill($data, $orderNumber, $data["channel"], 'REFUND');
     if (C('IS_DEV') == 'false') {
         //本地测试不用向第三方发送请求
         Vendor("beecloud.autoload");
         $result = \beecloud\rest\api::refund($data);
         if ($result->result_code != 0 || $result->result_msg != "OK") {
             echo json_encode($result->err_detail);
             logInfo('errorDetail:' . $result->err_detail);
             exit;
         }
     }
     if (D('OrderItem', 'Logic')->cancelSingleOrderItem($id)) {
         $res["status"] = "1";
     }
     if ($result->url != '') {
         $res["url"] = $result->url;
         $res["needOpenNewWindow"] = 'true';
     }
     echo json_encode($res);
 }
示例#19
0
 static function renderCustomfieldsFE(&$product, &$customfields, $virtuemart_category_id)
 {
     static $calculator = false;
     if (!$calculator) {
         if (!class_exists('calculationHelper')) {
             require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php';
         }
         $calculator = calculationHelper::getInstance();
     }
     $selectList = array();
     $dynChilds = 1;
     static $currency = false;
     if (!$currency) {
         if (!class_exists('CurrencyDisplay')) {
             require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
         }
         $currency = CurrencyDisplay::getInstance();
     }
     foreach ($customfields as $k => $customfield) {
         if (!isset($customfield->display)) {
             $customfield->display = '';
         }
         $calculator->_product = $product;
         if (!class_exists('vmCustomPlugin')) {
             require VMPATH_PLUGINLIBS . DS . 'vmcustomplugin.php';
         }
         if ($customfield->field_type == "E") {
             JPluginHelper::importPlugin('vmcustom');
             $dispatcher = JDispatcher::getInstance();
             $ret = $dispatcher->trigger('plgVmOnDisplayProductFEVM3', array(&$product, &$customfields[$k]));
             continue;
         }
         $fieldname = 'field[' . $product->virtuemart_product_id . '][' . $customfield->virtuemart_customfield_id . '][customfield_value]';
         $customProductDataName = 'customProductData[' . $product->virtuemart_product_id . '][' . $customfield->virtuemart_custom_id . ']';
         //This is a kind of fallback, setting default of custom if there is no value of the productcustom
         $customfield->customfield_value = empty($customfield->customfield_value) ? $customfield->custom_value : $customfield->customfield_value;
         $type = $customfield->field_type;
         $idTag = 'customProductData_' . (int) $product->virtuemart_product_id . '_' . $customfield->virtuemart_customfield_id;
         $idTag = VmHtml::ensureUniqueId($idTag);
         $emptyOption = new stdClass();
         $emptyOption->text = tsmText::_('COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT');
         $emptyOption->value = 0;
         switch ($type) {
             case 'C':
                 $html = '';
                 $dropdowns = array();
                 if (isset($customfield->options->{$product->virtuemart_product_id})) {
                     $productSelection = $customfield->options->{$product->virtuemart_product_id};
                 } else {
                     $productSelection = false;
                 }
                 $stockhandle = tsmConfig::get('stockhandle', 'none');
                 $q = 'SELECT `virtuemart_product_id` FROM #__virtuemart_products WHERE product_parent_id = "' . $customfield->virtuemart_product_id . '" and ( published = "0" ';
                 if ($stockhandle == 'disableit_children') {
                     $q .= ' OR (`product_in_stock` - `product_ordered`) <= "0"';
                 }
                 $q .= ');';
                 $db = JFactory::getDbo();
                 $db->setQuery($q);
                 $ignore = $db->loadColumn();
                 //vmdebug('my q '.$q,$ignore);
                 foreach ($customfield->options as $product_id => $variants) {
                     if ($ignore and in_array($product_id, $ignore)) {
                         //vmdebug('$customfield->options Product to ignore, continue ',$product_id);
                         continue;
                     }
                     foreach ($variants as $k => $variant) {
                         if (!isset($dropdowns[$k]) or !is_array($dropdowns[$k])) {
                             $dropdowns[$k] = array();
                         }
                         if (!in_array($variant, $dropdowns[$k])) {
                             if ($k == 0 or !$productSelection) {
                                 $dropdowns[$k][] = $variant;
                             } else {
                                 if ($k > 0 and $productSelection[$k - 1] == $variants[$k - 1]) {
                                     $break = false;
                                     for ($h = 1; $h <= $k; $h++) {
                                         if ($productSelection[$h - 1] != $variants[$h - 1]) {
                                             //$ignore[] = $variant;
                                             $break = true;
                                         }
                                     }
                                     if (!$break) {
                                         $dropdowns[$k][] = $variant;
                                     }
                                 } else {
                                     //	break;
                                 }
                             }
                         }
                     }
                 }
                 $tags = array();
                 foreach ($customfield->selectoptions as $k => $soption) {
                     $options = array();
                     $selected = false;
                     if (isset($dropdowns[$k])) {
                         foreach ($dropdowns[$k] as $i => $elem) {
                             $elem = trim((string) $elem);
                             $text = $elem;
                             if ($soption->clabel != '' and in_array($soption->voption, VirtueMartModelCustomfields::$dimensions)) {
                                 $rd = $soption->clabel;
                                 if (is_numeric($rd) and is_numeric($elem)) {
                                     $text = number_format(round((double) $elem, (int) $rd), $rd);
                                 }
                                 //vmdebug('($dropdowns[$k] in DIMENSION value = '.$elem.' r='.$rd.' '.$text);
                             } else {
                                 if ($soption->voption === 'clabels' and $soption->clabel != '') {
                                     $text = tsmText::_($elem);
                                 }
                             }
                             if (empty($elem)) {
                                 $text = tsmText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION');
                             }
                             $options[] = array('value' => $elem, 'text' => $text);
                             if ($productSelection and $productSelection[$k] == $elem) {
                                 $selected = $elem;
                             }
                         }
                     }
                     if (empty($selected)) {
                         $product->orderable = false;
                     }
                     $idTagK = $idTag . 'cvard' . $k;
                     if ($customfield->showlabels) {
                         if (in_array($soption->voption, VirtueMartModelCustomfields::$dimensions)) {
                             $soption->slabel = tsmText::_('COM_VIRTUEMART_' . strtoupper($soption->voption));
                         } else {
                             if (!empty($soption->clabel) and !in_array($soption->voption, VirtueMartModelCustomfields::$dimensions)) {
                                 $soption->slabel = tsmText::_($soption->clabel);
                             }
                         }
                         if (isset($soption->slabel)) {
                             $html .= '<span class="vm-cmv-label" >' . $soption->slabel . '</span>';
                         }
                     }
                     $attribs = array('class' => 'vm-chzn-select cvselection no-vm-bind', 'data-dynamic-update' => '1', 'style' => 'min-width:70px;');
                     if ('productdetails' != vRequest::getCmd('view') or !tsmConfig::get('jdynupdate', TRUE)) {
                         $attribs['reload'] = '1';
                     }
                     $html .= JHtml::_('select.genericlist', $options, $fieldname, $attribs, "value", "text", $selected, $idTagK);
                     $tags[] = $idTagK;
                 }
                 $Itemid = vRequest::getInt('Itemid', '');
                 // '&Itemid=127';
                 if (!empty($Itemid)) {
                     $Itemid = '&Itemid=' . $Itemid;
                 }
                 //create array for js
                 $jsArray = array();
                 $url = '';
                 foreach ($customfield->options as $product_id => $variants) {
                     if ($ignore and in_array($product_id, $ignore)) {
                         continue;
                     }
                     $url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $virtuemart_category_id . '&virtuemart_product_id=' . $product_id . $Itemid, false);
                     $jsArray[] = '["' . $url . '","' . implode('","', $variants) . '"]';
                 }
                 vmJsApi::addJScript('cvfind', false, false);
                 $jsVariants = implode(',', $jsArray);
                 $j = "\n\t\t\t\t\t\tjQuery('#" . implode(',#', $tags) . "').off('change',Virtuemart.cvFind);\n\t\t\t\t\t\tjQuery('#" . implode(',#', $tags) . "').on('change', { variants:[" . $jsVariants . "] },Virtuemart.cvFind);\n\t\t\t\t\t";
                 $hash = md5(implode('', $tags));
                 vmJsApi::addJScript('cvselvars' . $hash, $j, false);
                 //Now we need just the JS to reload the correct product
                 $customfield->display = $html;
                 break;
             case 'A':
                 $html = '';
                 $productModel = tmsModel::getModel('product');
                 //Note by Jeremy Magne (Daycounts) 2013-08-31
                 //Previously the the product model is loaded but we need to ensure the correct product id is set because the getUncategorizedChildren does not get the product id as parameter.
                 //In case the product model was previously loaded, by a related product for example, this would generate wrong uncategorized children list
                 $productModel->setId($customfield->virtuemart_product_id);
                 $uncatChildren = $productModel->getUncategorizedChildren($customfield->withParent);
                 $options = array();
                 if (!$customfield->withParent) {
                     $options[0] = $emptyOption;
                     $options[0]->value = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $virtuemart_category_id . '&virtuemart_product_id=' . $customfield->virtuemart_product_id, FALSE);
                     //$options[0] = array('value' => JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $virtuemart_category_id . '&virtuemart_product_id=' . $customfield->virtuemart_product_id,FALSE), 'text' => vmText::_ ('COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT'));
                 }
                 $selected = vRequest::getInt('virtuemart_product_id', 0);
                 $selectedFound = false;
                 $parentStock = 0;
                 if ($uncatChildren) {
                     foreach ($uncatChildren as $k => $child) {
                         /*if(!isset($child[$customfield->customfield_value])){
                         			vmdebug('The child has no value at index '.$customfield->customfield_value,$customfield,$child);
                         		} else {*/
                         $productChild = $productModel->getProduct((int) $child, false);
                         if (!$productChild) {
                             continue;
                         }
                         if (!isset($productChild->{$customfield->customfield_value})) {
                             vmdebug('The child has no value at index ' . $customfield->customfield_value, $customfield, $child);
                             continue;
                         }
                         $available = $productChild->product_in_stock - $productChild->product_ordered;
                         if (tsmConfig::get('stockhandle', 'none') == 'disableit_children' and $available <= 0) {
                             continue;
                         }
                         $parentStock += $available;
                         $priceStr = '';
                         if ($customfield->wPrice) {
                             //$product = $productModel->getProductSingle((int)$child['virtuemart_product_id'],false);
                             $productPrices = $calculator->getProductPrices($productChild);
                             $priceStr = ' (' . $currency->priceDisplay($productPrices['salesPrice']) . ')';
                         }
                         $options[] = array('value' => JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $virtuemart_category_id . '&virtuemart_product_id=' . $productChild->virtuemart_product_id, false), 'text' => $productChild->{$customfield->customfield_value} . $priceStr);
                         if ($selected == $child) {
                             $selectedFound = true;
                             vmdebug($customfield->virtuemart_product_id . ' $selectedFound by vRequest ' . $selected);
                         }
                         //vmdebug('$child productId ',$child['virtuemart_product_id'],$customfield->customfield_value,$child);
                         //}
                     }
                 }
                 if (!$selectedFound) {
                     $pos = array_search($customfield->virtuemart_product_id, $product->allIds);
                     if (isset($product->allIds[$pos - 1])) {
                         $selected = $product->allIds[$pos - 1];
                         //vmdebug($customfield->virtuemart_product_id.' Set selected to - 1 allIds['.($pos-1).'] = '.$selected.' and count '.$dynChilds);
                         //break;
                     } elseif (isset($product->allIds[$pos])) {
                         $selected = $product->allIds[$pos];
                         //vmdebug($customfield->virtuemart_product_id.' Set selected to allIds['.$pos.'] = '.$selected.' and count '.$dynChilds);
                     } else {
                         $selected = $customfield->virtuemart_product_id;
                         //vmdebug($customfield->virtuemart_product_id.' Set selected to $customfield->virtuemart_product_id ',$selected,$product->allIds);
                     }
                 }
                 $url = 'index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $virtuemart_category_id . '&virtuemart_product_id=' . $selected;
                 $attribs['option.key.toHtml'] = false;
                 $attribs['id'] = $idTag;
                 $attribs['list.attr'] = 'onchange="window.top.location.href=this.options[this.selectedIndex].value" size="1" class="vm-chzn-select no-vm-bind" data-dynamic-update="1" ';
                 $attribs['list.translate'] = false;
                 $attribs['option.key'] = 'value';
                 $attribs['option.text'] = 'text';
                 $attribs['list.select'] = JRoute::_($url, false);
                 $html .= JHtml::_('select.genericlist', $options, $fieldname, $attribs);
                 vmJsApi::chosenDropDowns();
                 if ($customfield->parentOrderable == 0) {
                     if ($product->virtuemart_product_id == $customfield->virtuemart_product_id) {
                         $product->orderable = false;
                         $product->product_in_stock = $parentStock;
                     }
                 }
                 $dynChilds++;
                 $customfield->display = $html;
                 break;
                 /*Date variant*/
             /*Date variant*/
             case 'D':
                 if (empty($customfield->custom_value)) {
                     $customfield->custom_value = 'LC2';
                 }
                 //Customer selects date
                 if ($customfield->is_input) {
                     $customfield->display = '<span class="product_custom_date">' . vmJsApi::jDate($customfield->customfield_value, $customProductDataName) . '</span>';
                     //vmJsApi::jDate($field->custom_value, 'field['.$row.'][custom_value]','field_'.$row.'_customvalue').$priceInput;
                 } else {
                     $customfield->display = '<span class="product_custom_date">' . vmJsApi::date($customfield->customfield_value, $customfield->custom_value, TRUE) . '</span>';
                 }
                 break;
                 /* text area or editor No vmText, only displayed in BE */
             /* text area or editor No vmText, only displayed in BE */
             case 'X':
             case 'Y':
                 $customfield->display = $customfield->customfield_value;
                 break;
                 /* string or integer */
             /* string or integer */
             case 'B':
             case 'S':
             case 'M':
                 //vmdebug('Example for params ',$customfield);
                 if (isset($customfield->selectType)) {
                     if (empty($customfield->selectType)) {
                         $selectType = 'select.genericlist';
                         if (!empty($customfield->is_input)) {
                             vmJsApi::chosenDropDowns();
                             $class = 'class="vm-chzn-select"';
                         }
                     } else {
                         $selectType = 'select.radiolist';
                         $class = '';
                     }
                 } else {
                     if ($type == 'M') {
                         $selectType = 'select.radiolist';
                         $class = '';
                     } else {
                         $selectType = 'select.genericlist';
                         if (!empty($customfield->is_input)) {
                             vmJsApi::chosenDropDowns();
                             $class = 'class="vm-chzn-select"';
                         }
                     }
                 }
                 if ($customfield->is_list and $customfield->is_list != 2) {
                     if (!empty($customfield->is_input)) {
                         $options = array();
                         if ($customfield->addEmpty) {
                             $options[0] = $emptyOption;
                         }
                         $values = explode(';', $customfield->custom_value);
                         foreach ($values as $key => $val) {
                             if ($val == 0 and $customfield->addEmpty) {
                                 continue;
                             }
                             if ($type == 'M') {
                                 $tmp = array('value' => $val, 'text' => VirtueMartModelCustomfields::displayCustomMedia($val, 'product', $customfield->width, $customfield->height));
                                 $options[] = (object) $tmp;
                             } else {
                                 $options[] = array('value' => $val, 'text' => tsmText::_($val));
                             }
                         }
                         $currentValue = $customfield->customfield_value;
                         $customfield->display = JHtml::_($selectType, $options, $customProductDataName . '[' . $customfield->virtuemart_customfield_id . ']', $class, 'value', 'text', $currentValue, $idTag);
                     } else {
                         if ($type == 'M') {
                             $customfield->display = VirtueMartModelCustomfields::displayCustomMedia($customfield->customfield_value, 'product', $customfield->width, $customfield->height);
                         } else {
                             $customfield->display = tsmText::_($customfield->customfield_value);
                         }
                     }
                 } else {
                     if (!empty($customfield->is_input)) {
                         if (!isset($selectList[$customfield->virtuemart_custom_id])) {
                             $selectList[$customfield->virtuemart_custom_id] = $k;
                             if ($customfield->addEmpty) {
                                 if (empty($customfields[$selectList[$customfield->virtuemart_custom_id]]->options)) {
                                     $customfields[$selectList[$customfield->virtuemart_custom_id]]->options[0] = $emptyOption;
                                     $customfields[$selectList[$customfield->virtuemart_custom_id]]->options[0]->virtuemart_customfield_id = $emptyOption->value;
                                     //$customfields[$selectList[$customfield->virtuemart_custom_id]]->options['nix'] = array('virtuemart_customfield_id' => 'none', 'text' => vmText::_ ('COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT'));
                                 }
                             }
                             $tmpField = clone $customfield;
                             $tmpField->options = null;
                             $customfield->options[$customfield->virtuemart_customfield_id] = $tmpField;
                             $customfield->customProductDataName = $customProductDataName;
                         } else {
                             $customfields[$selectList[$customfield->virtuemart_custom_id]]->options[$customfield->virtuemart_customfield_id] = $customfield;
                             unset($customfields[$k]);
                         }
                         $default = reset($customfields[$selectList[$customfield->virtuemart_custom_id]]->options);
                         foreach ($customfields[$selectList[$customfield->virtuemart_custom_id]]->options as &$productCustom) {
                             if (!isset($productCustom->customfield_price)) {
                                 $productCustom->customfield_price = 0.0;
                             }
                             $price = VirtueMartModelCustomfields::_getCustomPrice($productCustom->customfield_price, $currency, $calculator);
                             if ($type == 'M') {
                                 if (!isset($productCustom->customfield_value)) {
                                     $productCustom->customfield_value = '';
                                 }
                                 $productCustom->text = VirtueMartModelCustomfields::displayCustomMedia($productCustom->customfield_value, 'product', $customfield->width, $customfield->height) . ' ' . $price;
                             } else {
                                 $trValue = tsmText::_($productCustom->customfield_value);
                                 if ($productCustom->customfield_value != $trValue and strpos($trValue, '%1') !== false) {
                                     $productCustom->text = tsmText::sprintf($productCustom->customfield_value, $price);
                                 } else {
                                     $productCustom->text = $trValue . ' ' . $price;
                                 }
                             }
                         }
                         $customfields[$selectList[$customfield->virtuemart_custom_id]]->display = JHtml::_($selectType, $customfields[$selectList[$customfield->virtuemart_custom_id]]->options, $customfields[$selectList[$customfield->virtuemart_custom_id]]->customProductDataName, $class, 'virtuemart_customfield_id', 'text', $default->customfield_value, $idTag);
                         //*/
                     } else {
                         if ($type == 'M') {
                             $customfield->display = VirtueMartModelCustomfields::displayCustomMedia($customfield->customfield_value, 'product', $customfield->width, $customfield->height);
                         } else {
                             $customfield->display = tsmText::_($customfield->customfield_value);
                         }
                     }
                 }
                 break;
                 // Property
             // Property
             case 'P':
                 //$customfield->display = vmText::_ ('COM_VIRTUEMART_'.strtoupper($customfield->customfield_value));
                 $attr = $customfield->customfield_value;
                 $lkey = 'COM_VIRTUEMART_' . strtoupper($customfield->customfield_value) . '_FE';
                 $trValue = tsmText::_($lkey);
                 $options[] = array('value' => 'product_length', 'text' => tsmText::_('COM_VIRTUEMART_PRODUCT_LENGTH'));
                 $options[] = array('value' => 'product_width', 'text' => tsmText::_('COM_VIRTUEMART_PRODUCT_WIDTH'));
                 $options[] = array('value' => 'product_height', 'text' => tsmText::_('COM_VIRTUEMART_PRODUCT_HEIGHT'));
                 $options[] = array('value' => 'product_weight', 'text' => tsmText::_('COM_VIRTUEMART_PRODUCT_WEIGHT'));
                 $dim = '';
                 if ($attr == 'product_length' or $attr == 'product_width' or $attr == 'product_height') {
                     $dim = $product->product_lwh_uom;
                 } else {
                     if ($attr == 'product_weight') {
                         $dim = $product->product_weight_uom;
                     }
                 }
                 if (!isset($product->{$attr})) {
                     logInfo('customfield.php: case P, property ' . $attr . ' does not exists. virtuemart_custom_id: ' . $customfield->virtuemart_custom_id);
                     break;
                 }
                 $val = $product->{$attr};
                 if ($customfield->round != '') {
                     $val = round($val, $customfield->round);
                 }
                 if ($lkey != $trValue and strpos($trValue, '%1') !== false) {
                     $customfield->display = tsmText::sprintf($customfield->customfield_value, $val, $dim);
                 } else {
                     if ($lkey != $trValue) {
                         $customfield->display = $trValue . ' ' . $val;
                     } else {
                         $customfield->display = tsmText::_('COM_VIRTUEMART_' . strtoupper($customfield->customfield_value)) . ' ' . $val . $dim;
                     }
                 }
                 break;
             case 'Z':
                 if (empty($customfield->customfield_value)) {
                     break;
                 }
                 $html = '';
                 $q = 'SELECT * FROM `#__virtuemart_categories_' . tsmConfig::$vmlang . '` as l INNER JOIN `#__virtuemart_categories` AS c using (`virtuemart_category_id`) WHERE `published`=1 AND l.`virtuemart_category_id`= "' . (int) $customfield->customfield_value . '" ';
                 $db = JFactory::getDBO();
                 $db->setQuery($q);
                 if ($category = $db->loadObject()) {
                     if (empty($category->virtuemart_category_id)) {
                         break;
                     }
                     $q = 'SELECT `virtuemart_media_id` FROM `#__virtuemart_category_medias`WHERE `virtuemart_category_id`= "' . $category->virtuemart_category_id . '" ';
                     $db->setQuery($q);
                     $thumb = '';
                     if ($media_id = $db->loadResult()) {
                         $thumb = VirtueMartModelCustomfields::displayCustomMedia($media_id, 'category', $customfield->width, $customfield->height);
                     }
                     $customfield->display = JHtml::link(JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $category->virtuemart_category_id), $thumb . ' ' . $category->category_name, array('title' => $category->category_name, 'target' => '_blank'));
                 }
                 break;
             case 'R':
                 if (empty($customfield->customfield_value)) {
                     $customfield->display = 'customfield related product has no value';
                     break;
                 }
                 $pModel = tmsModel::getModel('product');
                 $related = $pModel->getProduct((int) $customfield->customfield_value, TRUE, $customfield->wPrice, TRUE, 1);
                 if (!$related) {
                     break;
                 }
                 $thumb = '';
                 if ($customfield->wImage) {
                     if (!empty($related->virtuemart_media_id[0])) {
                         $thumb = VirtueMartModelCustomfields::displayCustomMedia($related->virtuemart_media_id[0], 'product', $customfield->width, $customfield->height) . ' ';
                     } else {
                         $thumb = VirtueMartModelCustomfields::displayCustomMedia(0, 'product', $customfield->width, $customfield->height) . ' ';
                     }
                 }
                 $customfield->display = shopFunctionsF::renderVmSubLayout('related', array('customfield' => $customfield, 'related' => $related, 'thumb' => $thumb));
                 break;
         }
         $viewData['customfields'][$k] = $customfield;
         //vmdebug('my customfields '.$type,$viewData['customfields'][$k]->display);
     }
 }
示例#20
0
function vmTrace($notice, $force = FALSE)
{
    if ($force || VMConfig::showDebug()) {
        ob_start();
        echo '<pre>';
        debug_print_backtrace();
        echo '</pre>';
        $body = ob_get_contents();
        ob_end_clean();
        if (VmConfig::$echoDebug) {
            echo $notice . ' <pre>' . $body . '</pre>';
        } else {
            if (VmConfig::$logDebug) {
                logInfo($body, $notice);
            } else {
                $app = JFactory::getApplication();
                $app->enqueueMessage($notice . ' ' . $body . ' ');
            }
        }
    }
}
示例#21
0
<?php

date_default_timezone_set('America/Chicago');
function logMessage($logLevel, $message)
{
    $date = date("Y-m-d");
    $dateAndTime = date("Y-m-d H:i:s:A");
    $filename = "log-{$date}.log";
    $handle = fopen($this->{$filename}, 'a');
    fwrite($handle, "{$dateAndTime} [{$logLevel}] {$message}" . PHP_EOL);
    fclose($handle);
}
function logInfo($message)
{
    logMessage("INFO", $message);
}
function logError($message)
{
    logMessage("ERROR", $message);
}
function logButts($message)
{
    logMessage("FART", $message);
}
logError('Oh no!');
logError("I can't pass an arbitrary message to logError()!");
logError("That makes the function somewhat limited, don't you think?");
logInfo('This is how I should be using these functions.');
logButts("Signed: Ben.");
logbutts("( ' | ' )");