当前位置: 首页>>代码示例>>PHP>>正文


PHP Http::getError方法代码示例

本文整理汇总了PHP中Tygh\Http::getError方法的典型用法代码示例。如果您正苦于以下问题:PHP Http::getError方法的具体用法?PHP Http::getError怎么用?PHP Http::getError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tygh\Http的用法示例。


在下文中一共展示了Http::getError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fn_paypal_request

function fn_paypal_request($request, $post_url, $cert_file)
{
    $extra = array('headers' => array('Connection: close'), 'ssl_cert' => $cert_file);
    $response = Http::post($post_url, $request, $extra);
    if (!empty($response)) {
        parse_str($response, $result);
    } else {
        $result['ERROR'] = Http::getError();
    }
    return $result;
}
开发者ID:askzap,项目名称:ultimate,代码行数:11,代码来源:paypal_express.functions.php

示例2: prepareRestore

 /**
  * Prepares restore.php file.
  *
  * @return bool if all necessary information was added to restore.php
  */
 protected function prepareRestore($package_id, $content_schema, $information_schema, $backup_filename)
 {
     $logger = Log::instance($package_id);
     $logger->add('Preparing restore script');
     $upgrades_dir = $this->config['dir']['root'] . '/upgrades';
     $source_restore_file_path = $upgrades_dir . '/source_restore.php';
     $target_restore_dir_name = "{$package_id}_{$information_schema['from_version']}-{$information_schema['to_version']}";
     $target_restore_file_name = 'restore_' . date('Y-m-d_H-i-s', TIME) . '.php';
     $target_restore_dir_path = $upgrades_dir . "/{$target_restore_dir_name}/";
     $target_restore_file_path = $target_restore_dir_path . $target_restore_file_name;
     $target_restore_http_path = Registry::get('config.http_location') . "/upgrades/{$target_restore_dir_name}/{$target_restore_file_name}";
     $target_restore_dir_perms = 0755;
     $target_restore_file_perms = 0644;
     if (is_dir($upgrades_dir)) {
         $logger->add(sprintf('Upgrades directory permissions: %s', fn_get_file_perms_info($upgrades_dir)));
     } else {
         $logger->add(sprintf('Upgrades directory not found at "%s"', $upgrades_dir));
         return false;
     }
     if (file_exists($source_restore_file_path)) {
         $logger->add(sprintf('Source restore script permissions: %s', fn_get_file_perms_info($source_restore_file_path)));
         if (!is_readable($source_restore_file_path)) {
             $logger->add('Source restore script is not readable');
             return false;
         }
     } else {
         $logger->add(sprintf('Source restore script not found at "%s"', $source_restore_file_path));
         return false;
     }
     if (fn_mkdir($target_restore_dir_path, $target_restore_dir_perms)) {
         $logger->add(array(sprintf('Created directory for restore script at "%s"', $target_restore_dir_path), sprintf('Directory permissions: %s', fn_get_file_perms_info($target_restore_dir_path))));
     } else {
         $logger->add(sprintf('Unable to create directory for restore script at "%s"', $target_restore_dir_path));
         return false;
     }
     $content = fn_get_contents($source_restore_file_path);
     $restore_key = md5(uniqid()) . md5(uniqid('', true));
     $stats_data = $this->getStatsData($package_id);
     $restore_data = array('backup' => array('filename' => $backup_filename, 'created_at' => date('Y-m-d H:i:s', TIME), 'created_on_version' => PRODUCT_VERSION));
     $content = str_replace(array("'%UC_SETTINGS%'", "'%CONFIG%'", "'%BACKUP_FILENAME%'", "'%RESTORE_KEY%'", "'%STATS_DATA%'", "'%RESTORE_DATA%'"), array(var_export($this->settings, true), var_export(Registry::get('config'), true), var_export($backup_filename, true), var_export($restore_key, true), var_export($stats_data, true), var_export($restore_data, true)), $content);
     if (fn_put_contents($target_restore_file_path, $content, '', $target_restore_file_perms)) {
         $logger->add(array(sprintf('Created restore script at "%s"', $target_restore_file_path), sprintf('Restore script permissions: %s', fn_get_file_perms_info($target_restore_file_path))));
     } else {
         $logger->add(sprintf('Unable to create restore script at "%s"', $target_restore_file_path));
         return false;
     }
     // Ensure that target restore script directory has correct permissions (0755)
     $logger->add('Correcting target restore script directory permissions...');
     $this->chmod($target_restore_dir_path, $target_restore_dir_perms, $logger);
     $logger->add(sprintf('Target restore script directory permissions: %s', fn_get_file_perms_info($target_restore_dir_path)));
     // Restore validator could change permissions for upgrades directory to "0777" if it wasn't writable.
     // "0777" are not acceptable permissions for that directory because some servers restrict execution of
     // PHP scripts located at directory with "0777" permissions.
     $logger->add('Correcting upgrades directory permissions...');
     $this->chmod($upgrades_dir, $target_restore_dir_perms, $logger);
     $logger->add(sprintf('Upgrades directory permissions: %s', fn_get_file_perms_info($upgrades_dir)));
     // Check if restore is available through the HTTP
     $logger->add('Checking restore script availability via HTTP');
     $result = Http::get($target_restore_http_path);
     $http_error = Http::getError();
     if (!empty($http_error)) {
         $logger->add(sprintf('HTTP error: %s', $http_error));
     }
     if ($result != 'Access denied') {
         $logger->add(sprintf('Restore script is NOT available via HTTP at "%s".', $target_restore_http_path));
         return false;
     }
     return array($restore_key, $target_restore_file_path, $target_restore_http_path);
 }
开发者ID:ambient-lounge,项目名称:site,代码行数:74,代码来源:App.php


注:本文中的Tygh\Http::getError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。