本文整理汇总了PHP中Tools::file_get_contents方法的典型用法代码示例。如果您正苦于以下问题:PHP Tools::file_get_contents方法的具体用法?PHP Tools::file_get_contents怎么用?PHP Tools::file_get_contents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tools
的用法示例。
在下文中一共展示了Tools::file_get_contents方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
public function postProcess()
{
if (Tools::isSubmit('submitLocalizationPack')) {
$version = str_replace('.', '', _PS_VERSION_);
$version = substr($version, 0, 2);
if (Validate::isFileName(Tools::getValue('iso_localization_pack'))) {
$pack = @Tools::file_get_contents('http://api.prestashop.com/localization/' . $version . '/' . Tools::getValue('iso_localization_pack') . '.xml');
if (!$pack && !($pack = @Tools::file_get_contents(dirname(__FILE__) . '/../../localization/' . Tools::getValue('iso_localization_pack') . '.xml'))) {
$this->errors[] = Tools::displayError('Cannot load localization pack (from prestashop.com and from your local folder "localization")');
}
if (!($selection = Tools::getValue('selection'))) {
$this->errors[] = Tools::displayError('Please select at least one item to import.');
} else {
foreach ($selection as $selected) {
if (!Validate::isLocalizationPackSelection($selected)) {
$this->errors[] = Tools::displayError('Invalid selection');
return;
}
}
$localization_pack = new LocalizationPack();
if (!$localization_pack->loadLocalisationPack($pack, $selection)) {
$this->errors = array_merge($this->errors, $localization_pack->getErrors());
} else {
Tools::redirectAdmin(self::$currentIndex . '&conf=23&token=' . $this->token);
}
}
}
}
parent::postProcess();
}
示例2: WebServiceCheck
public static function WebServiceCheck($vat_number)
{
if (empty($vat_number)) {
return array();
}
$vat_number = str_replace(' ', '', $vat_number);
$prefix = Tools::substr($vat_number, 0, 2);
if (array_search($prefix, self::getPrefixIntracomVAT()) === false) {
return array(Tools::displayError('Invalid VAT number'));
}
$vat = Tools::substr($vat_number, 2);
$url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode($prefix) . '&iso=' . urlencode($prefix) . '&vat=' . urlencode($vat);
@ini_set('default_socket_timeout', 2);
for ($i = 0; $i < 3; $i++) {
if ($page_res = Tools::file_get_contents($url)) {
if (preg_match('/invalid VAT number/i', $page_res)) {
@ini_restore('default_socket_timeout');
return array(Tools::displayError('VAT number not found'));
} else {
if (preg_match('/valid VAT number/i', $page_res)) {
@ini_restore('default_socket_timeout');
return array();
} else {
++$i;
}
}
} else {
sleep(1);
}
}
@ini_restore('default_socket_timeout');
return array(Tools::displayError('VAT number validation service unavailable'));
}
示例3: postProcess
public function postProcess()
{
if (Tools::isSubmit('submitLocalizationPack')) {
$version = str_replace('.', '', _PS_VERSION_);
$version = substr($version, 0, 2);
if (Validate::isFileName(Tools::getValue('iso_localization_pack'))) {
$pack = @Tools::file_get_contents('http://api.prestashop.com/localization/' . $version . '/' . Tools::getValue('iso_localization_pack') . '.xml');
if (!$pack && !($pack = @Tools::file_get_contents(dirname(__FILE__) . '/../../localization/' . Tools::getValue('iso_localization_pack') . '.xml'))) {
$this->errors[] = Tools::displayError('Cannot load the localization pack.');
}
if (!($selection = Tools::getValue('selection'))) {
$this->errors[] = Tools::displayError('Please select at least one item to import.');
} else {
foreach ($selection as $selected) {
if (!Validate::isLocalizationPackSelection($selected)) {
$this->errors[] = Tools::displayError('Invalid selection');
return;
}
}
$localization_pack = new LocalizationPack();
if (!$localization_pack->loadLocalisationPack($pack, $selection)) {
$this->errors = array_merge($this->errors, $localization_pack->getErrors());
} else {
Tools::redirectAdmin(self::$currentIndex . '&conf=23&token=' . $this->token);
}
}
}
}
// Remove the module list cache if the default country changed
if (Tools::isSubmit('submitOptionsconfiguration') && file_exists(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST)) {
@unlink(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST);
}
parent::postProcess();
}
示例4: install
public function install()
{
$result = true;
// We need CURL to function correctly
if (!$this->curlExists()) {
$this->context->controller->errors[] = $this->l('Riskified require CURL to be installed and enabled.');
$result = false;
}
if (!file_exists(dirname(__FILE__) . '/' . self::INSTALL_SQL_FILE)) {
return false;
} else {
if (!($sql = Tools::file_get_contents(dirname(__FILE__) . '/' . self::INSTALL_SQL_FILE))) {
return false;
}
}
$sql = str_replace(array('PREFIX_', 'ENGINE_TYPE'), array(_DB_PREFIX_, _MYSQL_ENGINE_), $sql);
$sql = preg_split("/;\\s*[\r\n]+/", trim($sql));
foreach ($sql as $query) {
if (!Db::getInstance()->execute(trim($query))) {
return false;
}
}
if (!parent::install() || !$this->registerHook('displayAdminOrder') || !$this->registerHook('displayBackOfficeHeader') || !$this->registerHook('displayBackOfficeTop') || !$this->registerHook('actionValidateOrder') || !$this->registerHook('header')) {
$result = false;
}
RiskifiedLogger::insertLog(__METHOD__ . ' : ' . __LINE__, 'Riskified::install() = ' . $result);
return $result;
}
示例5: exportCsv
public function exportCsv()
{
header("Content-Type: text/csv");
header("Content-Disposition: attachment; filename=\"export-" . date("Ymd-His") . ".csv\"");
$db = Db::getInstance();
$is_cods = is_array(Tools::getValue('packetery_order_is_cod')) ? Tools::getValue('packetery_order_is_cod') : array();
foreach ($is_cods as $id => $is_cod) {
$db->execute('update `' . _DB_PREFIX_ . 'packetery_order` set is_cod=' . (int) $is_cod . ' where id_order=' . (int) $id);
}
$ids = array_map('floor', is_array(Tools::getValue('packetery_order_id')) && count(Tools::getValue('packetery_order_id')) > 0 ? Tools::getValue('packetery_order_id') : array(0));
$data = $db->executeS('select
o.id_order, a.firstname, a.lastname, a.phone, a.phone_mobile, c.email,
o.total_paid total, po.id_branch, po.is_cod, o.id_currency, po.currency_branch,
a.company, a.address1, a.address2, a.postcode, a.city
from
`' . _DB_PREFIX_ . 'orders` o
join `' . _DB_PREFIX_ . 'packetery_order` po on(po.id_order=o.id_order)
join `' . _DB_PREFIX_ . 'customer` c on(c.id_customer=o.id_customer)
join `' . _DB_PREFIX_ . 'address` a on(a.id_address=o.id_address_delivery)
where o.id_order in (' . implode(',', $ids) . ')');
$cnb_rates = null;
foreach ($data as $order) {
$phone = "";
foreach (array('phone', 'phone_mobile') as $field) {
if (preg_match('/^(((?:\\+|00)?420)?[67][0-9]{8}|((?:\\+|00)?421|0)?9[0-9]{8})$/', preg_replace('/\\s+/', '', $order[$field]))) {
$phone = trim($order[$field]);
}
}
$currency = new Currency($order['id_currency']);
$total = $order['total'];
if ($currency->iso_code != $order['currency_branch']) {
$target_currency = Currency::getIdByIsoCode($order['currency_branch']);
if ($target_currency) {
$target_currency = new Currency($target_currency);
$total = round($total * $target_currency->conversion_rate / $currency->conversion_rate, 2);
} else {
if (!$cnb_rates) {
if ($data = @Tools::file_get_contents('http://www.cnb.cz/cs/financni_trhy/devizovy_trh/kurzy_devizoveho_trhu/denni_kurz.txt')) {
$cnb_rates = array();
foreach (array_slice(explode("\n", $data), 2) as $rate) {
$rate = explode('|', $rate);
$cnb_rates[$rate[3]] = (double) preg_replace('/[^0-9.]*/', '', str_replace(',', '.', $rate[4]));
}
$cnb_rates['CZK'] = 1;
}
}
if ($cnb_rates) {
$total = round($total * $cnb_rates[$currency->iso_code] / $cnb_rates[$order['currency_branch']], 2);
}
}
}
$cod_total = $total;
if ($order['currency_branch'] == 'CZK') {
$cod_total = round($total);
}
echo ';"' . $this->csvEscape($order['id_order']) . '";"' . $this->csvEscape($order['firstname']) . '";"' . $this->csvEscape($order['lastname']) . '";"' . $this->csvEscape($order['company']) . '";"' . $this->csvEscape($order['email']) . '";"' . $this->csvEscape($phone) . '";"' . ($order['is_cod'] == 1 ? $this->csvEscape($cod_total) : "0") . '";"' . $this->csvEscape($total) . '";"' . $this->csvEscape($order['id_branch']) . '";"' . Configuration::get('PACKETERY_ESHOP_DOMAIN') . '";"' . $this->csvEscape($order['address1'] . ($order['address2'] ? ", " . $order['address2'] : "")) . '";;"' . $this->csvEscape($order['city']) . '";"' . $this->csvEscape($order['postcode']) . '"' . "\r\n";
}
$db->execute('update `' . _DB_PREFIX_ . 'packetery_order` set exported=1 where id_order in(' . implode(',', $ids) . ')');
exit;
}
示例6: install
/**
* Operation on module installation
*
* @return boolean
*/
public function install()
{
//create log file
KwixoLogger::insertLogKwixo(__METHOD__ . " : " . __LINE__, "Création du fichier de log");
/** database tables creation * */
$sqlfile = dirname(__FILE__) . '/install.sql';
if (!file_exists($sqlfile) || !($sql = Tools::file_get_contents($sqlfile))) {
return false;
}
$sql = str_replace('PREFIX_', _DB_PREFIX_, $sql);
$sql = str_replace('KWIXO_ORDER_TABLE_NAME', self::KWIXO_ORDER_TABLE_NAME, $sql);
$queries = preg_split("/;\\s*[\r\n]+/", $sql);
foreach ($queries as $query) {
if (!Db::getInstance()->Execute(trim($query))) {
KwixoLogger::insertLogKwixo(__METHOD__ . " : " . __LINE__, "Installation échouée, création base échouée : " . Db::getInstance()->getMsgError());
return false;
}
}
//waiting payment status creation
$this->createKwixoPaymentStatus($this->kw_os_statuses, '#3333FF', '', false, false, '', false);
//validate green payment status creation
$this->createKwixoPaymentStatus($this->kw_os_payment_green_status, '#DDEEFF', 'payment', true, true, true, true);
//validate red payment status creation
$this->createKwixoPaymentStatus($this->kw_os_payment_red_status, '#DDEEFF', 'payment_error', false, true, false, true);
//hook register
return parent::install() && $this->registerHook('newOrder') && $this->registerHook('paymentConfirm') && $this->registerHook('adminOrder') && $this->registerHook('header') && $this->registerHook('leftColumn') && $this->registerHook('rightColumn') && $this->registerHook('payment') && $this->registerHook('extraRight') && $this->registerHook('paymentReturn') && $this->registerHook('top') && $this->registerHook('footer') && $this->registerHook('backOfficeHeader');
}
示例7: postProcess
public function postProcess()
{
global $currentIndex;
if (isset($_POST['submitLocalization' . $this->table])) {
if ($this->tabAccess['edit'] === '1') {
$this->_postConfig($this->_fieldsLocalization);
} else {
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
} elseif (Tools::isSubmit('submitLocalizationPack')) {
if (!($pack = @Tools::file_get_contents('http://www.prestashop.com/download/localization/' . Tools::getValue('iso_localization_pack') . '.xml')) and !($pack = @Tools::file_get_contents(dirname(__FILE__) . '/../../localization/' . Tools::getValue('iso_localization_pack') . '.xml'))) {
$this->_errors[] = Tools::displayError('Cannot load localization pack (from prestashop.com and from your local folder "localization")');
} elseif (!($selection = Tools::getValue('selection'))) {
$this->_errors[] = Tools::displayError('Please select at least one content item to import.');
} else {
foreach ($selection as $selected) {
if (!Validate::isLocalizationPackSelection($selected)) {
$this->_errors[] = Tools::displayError('Invalid selection');
return;
}
}
$localizationPack = new LocalizationPack();
if (!$localizationPack->loadLocalisationPack($pack, $selection)) {
$this->_errors = array_merge($this->_errors, $localizationPack->getErrors());
} else {
Tools::redirectAdmin($currentIndex . '&conf=23&token=' . $this->token);
}
}
}
parent::postProcess();
}
示例8: processNextStep
/**
* @see InstallAbstractModel::processNextStep()
*/
public function processNextStep()
{
if (Tools::isSubmit('shop_name')) {
// Save shop configuration
$this->session->shop_name = trim(Tools::getValue('shop_name'));
$this->session->shop_activity = Tools::getValue('shop_activity');
$this->session->install_type = Tools::getValue('db_mode');
$this->session->shop_country = Tools::getValue('shop_country');
$this->session->shop_timezone = Tools::getValue('shop_timezone');
// Save admin configuration
$this->session->admin_firstname = trim(Tools::getValue('admin_firstname'));
$this->session->admin_lastname = trim(Tools::getValue('admin_lastname'));
$this->session->admin_email = trim(Tools::getValue('admin_email'));
$this->session->send_informations = Tools::getValue('send_informations');
if ($this->session->send_informations) {
$params = http_build_query(array('email' => $this->session->admin_email, 'method' => 'addMemberToNewsletter', 'language' => $this->session->lang, 'visitorType' => 1, 'source' => 'installer'));
Tools::file_get_contents('http://www.prestashop.com/ajax/controller.php?' . $params);
}
// If password fields are empty, but are already stored in session, do not fill them again
if (!$this->session->admin_password || trim(Tools::getValue('admin_password'))) {
$this->session->admin_password = trim(Tools::getValue('admin_password'));
}
if (!$this->session->admin_password_confirm || trim(Tools::getValue('admin_password_confirm'))) {
$this->session->admin_password_confirm = trim(Tools::getValue('admin_password_confirm'));
}
}
}
示例9: send
/**
* WS call APP
* @param type $data : data array
* @return array : WS return JSON decoded
*/
public static function send($url, $data)
{
// add data for trackers if not empty
if (!empty(self::$trackers_data)) {
$data['data']['trackers_data'] = self::$trackers_data;
}
$url = 'http://' . $url . 'ws/';
$enc = self::encodeData($data);
$dat = 'k=' . $enc['key'] . '&d=' . $enc['data'];
if (function_exists('curl_init')) {
// if curl active
$c = curl_init($url);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, $dat);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($c);
curl_close($c);
} else {
// otherwise : file_get_contents
$opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $dat));
$context = stream_context_create($opts);
$res = Tools::file_get_contents($url, false, $context);
}
$ret = Tools::jsonDecode($res, true);
if ($ret != null) {
Configuration::updateValue('checkyourdata_last_errors', implode(', ', $ret['errors']));
}
if (!empty($ret['data']['demoEnd'])) {
Configuration::updateValue('checkyourdata_demo_end', $ret['data']['demoEnd']);
}
return $ret;
}
示例10: process
public function process()
{
$body = Tools::file_get_contents('php://input');
$data = trim($body);
$result = OpenPayU_Order::consumeNotification($data);
$response = $result->getResponse();
SimplePayuLogger::addLog('notification', __FUNCTION__, print_r($result, true), $response->order->orderId, 'Incoming notification: ');
if (isset($response->order->orderId)) {
$payu = new PayU();
$payu->payu_order_id = $response->order->orderId;
$order_payment = $payu->getOrderPaymentBySessionId($payu->payu_order_id);
$id_order = (int) $order_payment['id_order'];
// if order not validated yet
if ($id_order == 0 && $order_payment['status'] == PayU::PAYMENT_STATUS_NEW) {
$id_order = $this->createOrder($order_payment, $payu, $response);
}
if (!empty($id_order)) {
$payu->id_order = $id_order;
$payu->updateOrderData($response);
}
if ($this->checkIfPaymentIdIsPresent($response) && $response->order->status == PayU::ORDER_V2_COMPLETED) {
$this->addPaymentIdToOrder($response, $payu, $id_order);
}
//the response should be status 200
header("HTTP/1.1 200 OK");
exit;
}
}
示例11: sendInfo
public static function sendInfo($url, $args)
{
$data = array('data' => $args);
$postdata = http_build_query($data);
$opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata));
$context = stream_context_create($opts);
return Tools::file_get_contents($url, false, $context);
}
示例12: getContent
function getContent()
{
$ebay_country = EbayCountrySpec::getInstanceByKey($this->ebay_profile->getConfiguration('EBAY_COUNTRY_DEFAULT'));
$help_file = dirname(__FILE__) . '/../../help/help-' . Tools::strtolower($ebay_country->getDocumentationLang()) . '.html';
if (!file_exists($help_file)) {
$help_file = dirname(__FILE__) . '/../../help/help-en.html';
}
return Tools::file_get_contents($help_file);
}
示例13: __construct
/**
* Build an EMS handler
* @param array $secrets An array where each key is your merchant login and the value is the related passphrase
* @param boolean $skipAuthCheck Skip the checksum validation
*/
public function __construct(array $secrets, $skipAuthCheck = false)
{
$this->secrets = $secrets;
$this->skipAuthCheck = $skipAuthCheck;
$this->headers['content-type'] = isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : 'application/x-www-form-urlencoded';
$this->headers['x-merchant'] = isset($_SERVER['HTTP_X_MERCHANT']) ? $_SERVER['HTTP_X_MERCHANT'] : null;
$this->headers['x-checksum'] = isset($_SERVER['HTTP_X_CHECKSUM']) ? $_SERVER['HTTP_X_CHECKSUM'] : null;
$this->content = Tools::file_get_contents('php://input');
}
示例14: install
public function install()
{
if (!function_exists('curl_version') || !extension_loaded('soap')) {
$this->_errors[] = $this->l('Mondial Relay needs SOAP & cURL to be installed on your server.');
return false;
}
if (!parent::install()) {
return false;
}
if (!$this->registerHookByVersion()) {
return false;
}
if (!file_exists(MondialRelay::$modulePath . MondialRelay::INSTALL_SQL_FILE) || !($sql = Tools::file_get_contents(MondialRelay::$modulePath . MondialRelay::INSTALL_SQL_FILE))) {
return false;
}
$sql = str_replace('PREFIX_', _DB_PREFIX_, $sql);
$sql = preg_split("/;\\s*[\r\n]+/", $sql);
foreach ($sql as $query) {
if (!empty($query)) {
Db::getInstance()->execute(trim($query));
}
}
$result = Db::getInstance()->getRow('
SELECT id_tab
FROM `' . _DB_PREFIX_ . 'tab`
WHERE class_name="AdminMondialRelay"');
if (!$result) {
$tab = new Tab();
$languages = Language::getLanguages(false);
foreach ($languages as $language) {
$tab->name[$language['id_lang']] = 'Mondial Relay';
}
$tab->class_name = 'AdminMondialRelay';
$tab->module = 'mondialrelay';
$tab->id_parent = Tab::getIdFromClassName('AdminOrders');
if (!$tab->add()) {
return false;
}
if (is_dir(_PS_MODULE_DIR_ . 'mondialrelay/')) {
@copy(_PS_MODULE_DIR_ . 'mondialrelay/img/AdminMondialRelay.gif', _PS_IMG_DIR_ . '/AdminMondialRelay.gif');
}
}
/* If module isn't installed, set default value */
if (!Configuration::get('MONDIAL_RELAY')) {
Configuration::updateValue('MONDIAL_RELAY', $this->version);
Configuration::updateValue('MONDIAL_RELAY_SECURE_KEY', md5(_COOKIE_KEY_ . time()));
Configuration::updateValue('MONDIAL_RELAY_MODE', 'widget');
} else {
$query = 'UPDATE `' . _DB_PREFIX_ . 'carrier` c, `' . _DB_PREFIX_ . 'mr_method` m
SET c.`deleted` = 0
WHERE c.`id_carrier` = m.`id_carrier`
AND m.`is_deleted` = 0';
/* Reactive transport if database wasn't remove at the last uninstall */
Db::getInstance()->execute($query);
}
return true;
}
示例15: queryAll
/**
* query all pilibaba supported currency
*
* @return array
*/
public static function queryAll()
{
$result = Tools::file_get_contents(self::PILIPAY_CURRENCY_PATH);
if (empty($result)) {
return array();
}
$array = Tools::jsonDecode($result, true);
return $array;
}