Example #1
0
/**
 * Submits an HTTP POST to a reCAPTCHA server
 * @param string $host
 * @param string $path
 * @param array $data
 * @param int port
 * @return array response
 */
function _recaptcha_http_post($host, $path, $data, $port = 80)
{
    $req = _recaptcha_qsencode($data);
    $request = new Request($host, $path, $port, true, true, 10);
    $request->setData($data);
    $request->setUserAgent('reCAPTCHA/PHP');
    $request->skiplog(true);
    if (!($response = $request->send())) {
        trigger_error("Unable to reach reCAPCHA server.");
    }
    $response = explode("\r\n\r\n", $response, 2);
    return $response;
}
Example #2
0
 public function createRequest($method, $url, $body = NULL, array $headers = array())
 {
     $request = new Request($url);
     if ($method === 'GET') {
         $request->setType($method);
     } else {
         $request->setType('POST');
         if ($method !== 'POST') {
             $headers['X-HTTP-METHOD-OVERRIDE'] = $method;
         }
     }
     if (isset($this->authentication)) {
         list($user, $password, $type) = $this->authentication;
         $request->setAuthentication($user, $password, $type);
     }
     if ($body) {
         $request->setData($body);
     }
     foreach ($headers as $name => $value) {
         $request->setHeaderField($name, $value);
     }
     return $request;
 }
Example #3
0
 public function createConsignment(ConsignmentRequest $consignmentRequest)
 {
     $recipient = $consignmentRequest->getRecipient();
     if ($recipient == null) {
         $recipient = new Recipient();
     }
     $labelsRequest = $consignmentRequest->getLabelsRequest();
     $consignmentArray = array('transport_service_id' => $consignmentRequest->getTransportServiceId(), 'address_state' => $recipient->getCountry(), 'register_branch_id' => $consignmentRequest->getRegisterBranchId(), 'destination_branch_id' => $consignmentRequest->getDestinationBranchId(), 'order_number' => $consignmentRequest->getOrderNumber(), 'partner_consignment_id' => $consignmentRequest->getPartnerConsignmentId(), 'parcel_count' => $consignmentRequest->getParcelCount(), 'weight' => $consignmentRequest->getWeight(), 'cash_on_delivery' => $consignmentRequest->getCashOnDelivery(), 'insurance' => $consignmentRequest->getInsurance(), 'stated_price' => $consignmentRequest->getStatedPrice(), 'currency' => $consignmentRequest->getCurrency(), 'variable' => $consignmentRequest->getValiable(), 'password' => $consignmentRequest->getPassword(), 'customer_name' => $recipient->getName(), 'customer_surname' => $recipient->getSurname(), 'company_name' => $recipient->getCompany(), 'customer_phone' => $recipient->getPhone(), 'customer_email' => $recipient->getEmail(), 'address_street' => $recipient->getStreet(), 'address_town' => $recipient->getTown(), 'address_zip' => $recipient->getZip(), 'allow_card_payment' => $consignmentRequest->getAllowCardPayment() ? 1 : 0, 'require_full_age' => $consignmentRequest->getRequireFullAge() ? 1 : 0, 'note' => $consignmentRequest->getNote());
     if (isset($labelsRequest)) {
         $consignmentArray['labels'] = array('type' => $labelsRequest->getType(), 'first_position' => $labelsRequest->getFirstPosition(), 'labels_per_page' => $labelsRequest->getLabelsPerPage());
     }
     $request = new Request($this->apiUrl, $this->shopId, $this->apiKey);
     $request->setType('POST');
     $request->setResource(self::CONSIGNMENT_RESOURCE);
     $request->setData($consignmentArray);
     $response = $request->getResponse();
     if ($response->isError()) {
         $this->errors = $response->getErrors();
         return false;
     } else {
         $data = $response->getData();
         return new Consignment($data[0]);
     }
 }
Example #4
0
 /**
  * Create sitemap
  *
  * @return bool
  */
 public function sitemap()
 {
     // Generate a Sitemap Protocol v0.9 compliant sitemap (http://sitemaps.org)
     $this->_sitemap_xml = new XML();
     $this->_sitemap_xml->startElement('urlset', array('xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9'));
     // Generate Standard records
     $store_url = CC_SSL ? $GLOBALS['config']->get('config', 'ssl_url') : $GLOBALS['config']->get('config', 'standard_url');
     $this->_sitemap_link(array('url' => $store_url . '/index.php'));
     # Sale Items
     if ($GLOBALS['config']->get('config', 'catalogue_sale_mode') !== '0') {
         $this->_sitemap_link(array('url' => $store_url . '/index.php?_a=saleitems'));
     }
     # Gift Certificates
     if ($GLOBALS['config']->get('gift_certs', 'status') == '1') {
         $this->_sitemap_link(array('url' => $store_url . '/index.php?_a=certificates'));
     }
     $queryArray = array('category' => $GLOBALS['db']->select('CubeCart_category', array('cat_id'), array('status' => '1')), 'product' => $GLOBALS['db']->select('CubeCart_inventory', array('product_id', 'updated'), array('status' => '1')), 'document' => $GLOBALS['db']->select('CubeCart_documents', array('doc_id'), array('doc_parent_id' => '0', 'doc_status' => 1)));
     foreach ($queryArray as $type => $results) {
         if ($results) {
             foreach ($results as $record) {
                 switch ($type) {
                     case 'category':
                         $id = $record['cat_id'];
                         $key = 'cat_id';
                         break;
                     case 'product':
                         $id = $record['product_id'];
                         $key = 'product_id';
                         break;
                     case 'document':
                         $id = $record['doc_id'];
                         $key = 'doc_id';
                         break;
                 }
                 $this->_sitemap_link(array('key' => $key, 'id' => $id), !isset($record['updated']) ? (int) $record['updated'] : time(), $type);
             }
         }
     }
     $sitemap = $this->_sitemap_xml->getDocument(true);
     if (function_exists('gzencode')) {
         // Compress the file if GZip is enabled
         $filename = CC_ROOT_DIR . '/sitemap.xml.gz';
         $mapdata = gzencode($sitemap, 9, FORCE_GZIP);
     } else {
         $filename = CC_ROOT_DIR . '/sitemap.xml';
         $mapdata = $sitemap;
     }
     if ($GLOBALS['config']->get('config', 'offline') == '0') {
         if (file_put_contents($filename, $mapdata)) {
             // Ping Google
             $request = new Request('www.google.com', '/webmasters/sitemaps/ping');
             $request->setMethod('get');
             $request->setData(array('sitemap' => $store_url . '/' . basename($filename)));
             $request->send();
             return true;
         }
     }
     return false;
 }
Example #5
0
        $filename = basename($file);
        $type = preg_match('/^database/', $filename) ? 'database' : 'files';
        $restore = preg_match('/^database_full|files/', $filename) ? '?_g=maintenance&node=index&restore=' . $filename . '#backup' : false;
        $existing_backups[] = array('filename' => $filename, 'delete_link' => '?_g=maintenance&node=index&delete=' . $filename . '#backup', 'download_link' => '?_g=maintenance&node=index&download=' . $filename . '#backup', 'restore_link' => $restore, 'type' => $type, 'warning' => $type == 'database' ? $lang['maintain']['restore_db_confirm'] : $lang['maintain']['restore_files_confirm'], 'size' => formatBytes(filesize($file), true));
    }
}
$GLOBALS['smarty']->assign('EXISTING_BACKUPS', $existing_backups);
## Upgrade
## Check current version
if ($request = new Request('www.cubecart.com', '/version-check/' . '2.3.22')) {
    $request->skiplog(true);
    $request->setMethod('get');
    $request->cache(true);
    $request->setSSL(true);
    $request->setUserAgent('CubeCart');
    $request->setData(array('version' => CC_VERSION));
    if (($response = $request->send()) !== false) {
        if (version_compare(trim($response), CC_VERSION, '>')) {
            $GLOBALS['smarty']->assign('OUT_OF_DATE', sprintf($lang['dashboard']['error_version_update'], $response, CC_VERSION));
            $GLOBALS['smarty']->assign('LATEST_VERSION', $response);
            $GLOBALS['smarty']->assign('UPGRADE_NOW', $lang['maintain']['upgrade_now']);
            $GLOBALS['smarty']->assign('FORCE', '0');
        } else {
            $GLOBALS['smarty']->assign('LATEST_VERSION', CC_VERSION);
            $GLOBALS['smarty']->assign('UPGRADE_NOW', $lang['maintain']['force_upgrade']);
            $GLOBALS['smarty']->assign('FORCE', '1');
        }
    }
}
if (file_exists(CC_ROOT_DIR . '/backup/restore_error_log')) {
    $contents = file_get_contents(CC_ROOT_DIR . '/backup/restore_error_log');
Example #6
0
                         $GLOBALS['main']->setACPNotify($lang['module']['backup_created']);
                     }
                 }
                 if ($extract) {
                     if ($source->extract(PCLZIP_OPT_PATH, $destination, PCLZIP_OPT_REPLACE_NEWER) == 0) {
                         $GLOBALS['main']->setACPWarning($lang['module']['failed_install']);
                     } else {
                         // Attempt email template install
                         if ($import_language) {
                             $GLOBALS['language']->importEmail($import_language);
                         }
                         $GLOBALS['main']->setACPNotify($lang['module']['success_install']);
                         $request = new Request($cc_domain, $cc_conf_path, 80, false, true, 10);
                         $request->setMethod('get');
                         $request->setSSL();
                         $request->setData(array('null' => 0));
                         $request->setUserAgent('CubeCart');
                         $request->skiplog(true);
                     }
                 }
             } else {
                 $GLOBALS['main']->setACPWarning(sprintf($lang['module']['read_fail'], $data['file_name']));
             }
         } else {
             $GLOBALS['main']->setACPWarning(sprintf($lang['module']['not_writable'], $destination));
         }
     } else {
         $GLOBALS['main']->setACPWarning(sprintf($lang['module']['not_exist'], $destination));
     }
 } else {
     $GLOBALS['main']->setACPWarning($lang['module']['token_unknown']);
Example #7
0
 /**
  * Set user data by key
  *
  * @param string|array $key
  * @param        $value
  * @return $this
  */
 public function setData($key, $value = null)
 {
     $this->request->setData($key, $value);
     return $this;
 }
Example #8
0
     $GLOBALS['smarty']->assign('DISPLAY_TRANSLATE_FORM', true);
 } else {
     // Add content tabs
     $GLOBALS['main']->addTabControl($lang['catalogue']['title_pricing'], 'pricing');
     $GLOBALS['main']->addTabControl($lang['settings']['title_category'], 'category');
     $GLOBALS['main']->addTabControl($lang['catalogue']['title_options'], 'Options');
     $GLOBALS['main']->addTabControl($lang['settings']['title_images'], 'image');
     $GLOBALS['main']->addTabControl($lang['catalogue']['title_digital'], 'digital');
     $google_cats = false;
     $store_country = $GLOBALS['config']->get('config', 'store_country');
     $taxonomy_lang = $store_country == 826 ? 'en-GB' : 'en-US';
     $request = new Request('www.google.com', '/basepages/producttype/taxonomy.' . $taxonomy_lang . '.txt');
     $request->setMethod('get');
     $request->skiplog(true);
     $request->cache(true);
     $request->setData(array('null' => true));
     if ($response = $request->send()) {
         $google_cats = explode("\n", $response);
     }
     if (strstr($google_cats[0], 'Google_Product_Taxonomy_Version')) {
         unset($google_cats[0]);
     }
     $GLOBALS['smarty']->assign("GOOGLE_CATS", $google_cats);
     $GLOBALS['main']->addTabControl($lang['settings']['tab_seo'], 'seo');
     // Generate list of groups and values
     if (($groups = $GLOBALS['db']->select('CubeCart_option_group', false, false, array('priority' => 'ASC'))) !== false) {
         foreach ($groups as $group) {
             $group_list[$group['option_id']] = $group;
         }
         if (($values = $GLOBALS['db']->select('CubeCart_option_value', false, false, array('priority' => 'ASC'))) !== false) {
             foreach ($values as $value) {
Example #9
0
    $GLOBALS['smarty']->assign('STOCK_PAGINATION', $GLOBALS['db']->pagination($stock_count, $result_limit, $page, $show = 5, 'stock', 'stock_warnings', $glue = ' ', $view_all = true));
    foreach ($GLOBALS['hooks']->load('admin.dashboard.stock.post') as $hook) {
        include $hook;
    }
}
## Latest News (from RSS)
if ($GLOBALS['config']->has('config', 'default_rss_feed') && !$GLOBALS['config']->isEmpty('config', 'default_rss_feed') && filter_var($GLOBALS['config']->get('config', 'default_rss_feed'), FILTER_VALIDATE_URL)) {
    $default_rss_feed = $GLOBALS['config']->get('config', 'default_rss_feed');
    $url = preg_match('/(act=rssout&id=1|1-cubecart-news-announcements)/', $default_rss_feed) ? 'https://forums.cubecart.com/forum/1-news-announcements.xml' : $default_rss_feed;
    $url = parse_url($url);
    $path = isset($url['query']) ? $url['path'] . '?' . $url['query'] : $url['path'];
    $request = new Request($url['host'], $path);
    $request->cache(true);
    $request->skiplog(true);
    $request->setMethod('post');
    $request->setData('Null');
    if (($response = $request->send()) !== false) {
        try {
            if (($data = new SimpleXMLElement($response)) !== false) {
                foreach ($data->channel->children() as $key => $value) {
                    if ($key == 'item') {
                        continue;
                    }
                    $news[$key] = (string) $value;
                }
                if ($data['version'] >= 2) {
                    $i = 1;
                    foreach ($data->channel->item as $item) {
                        $news['items'][] = array('title' => (string) $item->title, 'link' => (string) $item->link);
                        if ($i == 5) {
                            break;