ThaiSEOBoard.com

พัฒนาเว็บไซต์ => Programming => ข้อความที่เริ่มโดย: krite2010 ที่ 10 กุมภาพันธ์ 2011, 19:31:37



หัวข้อ: ถาม php แปลงเป็น phtml อย่างไรคับ ขอบคุณ
เริ่มหัวข้อโดย: krite2010 ที่ 10 กุมภาพันธ์ 2011, 19:31:37
คือ

โค๊ด:
<?php
/**
*
* AWS_Cart 0.0.1 - November 2008
* Copyright (C) awsfm.com
* AWS_Cart is licensed under a Creative Commons License
*
*/

include('config.php');

function 
priceCheck($id,$sku,$price,$type){
$request "http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=".KEYID."&AssociateTag=".AssocTag."&Version=2006-09-11&Operation=ItemLookup&ItemId=$sku&ResponseGroup=Medium,Offers";
$session curl_init($request);
curl_setopt($sessionCURLOPT_HEADERfalse);
curl_setopt($sessionCURLOPT_RETURNTRANSFERtrue);
$response curl_exec($session);
$response file_get_contents($request);
$parsed_xml simplexml_load_string($response);
$awsListPrice=$parsed_xml->Items->Item->ItemAttributes->ListPrice->FormattedPrice;
        
$awsListPriceDB=substr_replace($parsed_xml->Items->Item->ItemAttributes->ListPrice->Amount'.', -20);        
        
$awsOfferListPrice=$parsed_xml->Items->Item->Offers->Offer->OfferListing->Price->FormattedPrice;
        
$awsOfferListPriceDB=substr_replace($parsed_xml->Items->Item->Offers->Offer->OfferListing->Price->Amount'.', -20);
if($type=='regular'){
if($awsListPrice!=$price){
                  
$con mysql_connect(dbhost,dbuser,dbpass);
                  
mysql_select_db(dbname,$con);
                  
mysql_query("UPDATE catalog_product_entity_decimal SET value=$awsListPriceDB WHERE entity_id=$id AND attribute_id='59'");
                  
mysql_close($con);
          print $awsListPrice;
}else{
                  print 
$price;
}
}
if($type=='final'){
if($awsOfferListPrice!=$price){
                  
$con mysql_connect(dbhost,dbuser,dbpass);
                  
mysql_select_db(dbname,$con);
                  
mysql_query("UPDATE catalog_product_entity_decimal SET value=$awsOfferListPriceDB WHERE entity_id=$id AND attribute_id='60'");
                  
mysql_close($con);
  print $awsOfferListPrice;
}else{
                  print 
$price;
}
}
}

function 
priceCheckCheckout($id,$sku,$price){
$request "http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=".KEYID."&AssociateTag=".AssocTag."&Version=2006-09-11&Operation=ItemLookup&ItemId=$sku&ResponseGroup=Medium,Offers";
$session curl_init($request);
curl_setopt($sessionCURLOPT_HEADERfalse);
curl_setopt($sessionCURLOPT_RETURNTRANSFERtrue);
$response curl_exec($session);
$response file_get_contents($request);
$parsed_xml simplexml_load_string($response);
$awsListPrice=$parsed_xml->Items->Item->ItemAttributes->ListPrice->FormattedPrice;
        
$awsListPriceDB=substr_replace($parsed_xml->Items->Item->ItemAttributes->ListPrice->Amount'.', -20);        
        
$awsOfferListPrice=$parsed_xml->Items->Item->Offers->Offer->OfferListing->Price->FormattedPrice;
        
$awsOfferListPriceDB=substr_replace($parsed_xml->Items->Item->Offers->Offer->OfferListing->Price->Amount'.', -20);
if($awsOfferListPrice!=$price){
                  
$con mysql_connect(dbhost,dbuser,dbpass);
                  
mysql_select_db(dbname,$con);
                  
mysql_query("UPDATE catalog_product_entity_decimal SET value=$awsOfferListPriceDB WHERE entity_id=$id AND attribute_id='60'");
                  
mysql_close($con);
        }
}

function 
itemLookup($sku$qty){
     
$request "http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=".KEYID."&AssociateTag=".AssocTag."&Version=2006-09-11&Operation=ItemLookup&ItemId=$sku&ResponseGroup=Medium,Offers";
     
$session curl_init($request);
     
curl_setopt($sessionCURLOPT_HEADERfalse);
     
curl_setopt($sessionCURLOPT_RETURNTRANSFERtrue);
     
$response curl_exec($session);
     
$response file_get_contents($request);
     
$parsed_xml simplexml_load_string($response);
     
$offerListingId urlencode($parsed_xml->Items->Item->Offers->Offer->OfferListing->OfferListingId);
     
cartCreate($offerListingId$qty);
}

function 
cartCreate($offerListingId$qty){
     
$request "http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=".KEYID."&AssociateTag=".AssocTag."&Version=2006-09-11&Operation=CartCreate&Item.1.OfferListingId=$offerListingId&Item.1.Quantity=$qty";
     
$session curl_init($request);
     
curl_setopt($sessionCURLOPT_HEADERfalse);
     
curl_setopt($sessionCURLOPT_RETURNTRANSFERtrue);
     
$response curl_exec($session);
     
$response file_get_contents($request);
     
$parsed_xml simplexml_load_string($response);
     
showCartContents($parsed_xml);
}

function 
itemLookupAdd($sku$qty$cart$hmac){
     
$request "http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=".KEYID."&AssociateTag=".AssocTag."&Version=2006-09-11&Operation=ItemLookup&ItemId=$sku&ResponseGroup=Medium,Offers";
     
$session curl_init($request);
     
curl_setopt($sessionCURLOPT_HEADERfalse);
     
curl_setopt($sessionCURLOPT_RETURNTRANSFERtrue);
     
$response curl_exec($session);
     
$response file_get_contents($request);
     
$parsed_xml simplexml_load_string($response);
     
$offerListingId urlencode($parsed_xml->Items->Item->Offers->Offer->OfferListing->OfferListingId);
     
cartAdd($offerListingId$qty$cart$hmac);
}

function 
cartAdd($offerListingId$qty$cart$hmac){
     
$request="http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=".KEYID."&AssociateTag=".AssocTag."&Version=2006-09-11&Operation=CartAdd&CartId=$cart&HMAC=$hmac&Item.1.OfferListingId=$offerListingId&Item.1.Quantity=$qty";
     
$session curl_init($request);
     
curl_setopt($sessionCURLOPT_HEADERfalse);
     
curl_setopt($sessionCURLOPT_RETURNTRANSFERtrue);
     
$response curl_exec($session);
     
$response file_get_contents($request);
     
$parsed_xml simplexml_load_string($response);
     
showCartContents($parsed_xml);
}

function 
showCartContents($parsed_xml){
     global 
$checkout;
     global 
$CartId;
     global 
$HMAC;
     
$checkout $parsed_xml->Cart->PurchaseURL;
     
$CartId $parsed_xml->Cart->CartId;
     
$HMAC $parsed_xml->Cart->URLEncodedHMAC;
}
?>


ถ้าต้องการแปลงเป็น phtml ทำอย่างไรคับ ขอบคุณ


หัวข้อ: Re: ถาม php แปลงเป็น phtml อย่างไรคับ ขอบคุณ
เริ่มหัวข้อโดย: ohmohm ที่ 18 กุมภาพันธ์ 2011, 15:33:43
มันคือการเข้ารหัส ไม่ให้เห็น source code หรือเปล่า