Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Save user submitted server info statistics

  • Loading branch information...
commit 36d7111cacce2a68fc05496c1209fb2527b762eb 1 parent a8d7d91
Harald Ponce de Leon authored
3  .htaccess
@@ -36,6 +36,9 @@ RewriteRule ^public/sites/Website/rss/news\.xml$ http://feeds.feedburner.co
36 36 RewriteCond %{HTTP_USER_AGENT} !FeedBurner
37 37 RewriteRule ^public/sites/Website/rss/addons\.xml$ http://feeds.feedburner.com/osCommerce_Contributions [R=301,L]
38 38
  39 +RewriteCond %{HTTP_HOST} ^usage\.oscommerce\.com$
  40 +RewriteRule ^submit\.php$ RPC&Website&Index&SaveUserServerInfo [L]
  41 +
39 42 Redirect 301 /newsletter/subscribe http://oscommerce.list-manage.com/subscribe?u=a5961750a3635e18fdf4bb539&id=10af90c126
40 43
41 44 RewriteCond %{REQUEST_FILENAME} !-f
1  README.md
Source Rendered
@@ -76,6 +76,7 @@ which can be copied from an existing block:
76 76 community_api_module = ""
77 77 community_api_address = ""
78 78 cron_key = ""
  79 + save_user_server_info_salt = ""
79 80
80 81 The following SQL file needs to be imported into the installation database to
81 82 create the tables for the website:
67 osCommerce/OM/Custom/Site/Website/Application/Index/RPC/SaveUserServerInfo.php
... ... @@ -0,0 +1,67 @@
  1 +<?php
  2 +/**
  3 + * osCommerce Website
  4 + *
  5 + * @copyright Copyright (c) 2012 osCommerce; http://www.oscommerce.com
  6 + * @license BSD License; http://www.oscommerce.com/bsdlicense.txt
  7 + */
  8 +
  9 + namespace osCommerce\OM\Core\Site\Website\Application\Index\RPC;
  10 +
  11 + use osCommerce\OM\Core\OSCOM;
  12 + use osCommerce\OM\Core\Registry;
  13 +
  14 + class SaveUserServerInfo {
  15 + public static function execute() {
  16 + $OSCOM_PDO = Registry::get('PDO');
  17 +
  18 + $result = '';
  19 +
  20 + if ( isset($_POST['info']) && !empty($_POST['info']) ) {
  21 + $info = unserialize(base64_decode($_POST['info']));
  22 +
  23 + if ( is_array($info) && isset($info['oscommerce']['version']) && isset($info['system']['os']) && isset($info['system']['http_server']) && isset($info['php']['version']) && isset($info['php']['extensions']) && isset($info['php']['sapi']) && isset($info['php']['memory_limit']) && isset($info['mysql']['version']) ) {
  24 + $data = array('osc_version' => $info['oscommerce']['version'],
  25 + 'system_os' => $info['system']['os'],
  26 + 'http_server' => $info['system']['http_server'],
  27 + 'php_version' => $info['php']['version'],
  28 + 'php_extensions' => implode(',', $info['php']['extensions']),
  29 + 'php_sapi' => $info['php']['sapi'],
  30 + 'php_memory' => $info['php']['memory_limit'],
  31 + 'mysql_version' => $info['mysql']['version']);
  32 +
  33 + unset($info['php']['version']);
  34 + unset($info['php']['sapi']);
  35 + unset($info['php']['memory_limit']);
  36 + unset($info['php']['extensions']);
  37 + unset($info['mysql']['version']);
  38 + unset($info['system']['os']);
  39 + unset($info['system']['host']);
  40 + unset($info['system']['http_server']);
  41 +
  42 + $data['php_other'] = static::formatArray($info['php']);
  43 + $data['mysql_other'] = static::formatArray($info['mysql']);
  44 + $data['system_other'] = static::formatArray($info['system']);
  45 +
  46 + $data['ip_address'] = sha1(OSCOM::getIPAddress() . OSCOM::getConfig('save_user_server_info_salt', 'Website'));
  47 +
  48 + if ( OSCOM::callDB('Website\SaveUserServerInfo', $data, 'Site') === 1 ) {
  49 + $result = 'OK';
  50 + }
  51 + }
  52 + }
  53 +
  54 + echo $result;
  55 + }
  56 +
  57 + public static function formatArray($array) {
  58 + $output = '';
  59 +
  60 + foreach ( $array as $key => $value ) {
  61 + $output .= $key . ' = ' . $value . "\n";
  62 + }
  63 +
  64 + return trim($output);
  65 + }
  66 + }
  67 +?>
44 osCommerce/OM/Custom/Site/Website/SQL/ANSI/SaveUserServerInfo.php
... ... @@ -0,0 +1,44 @@
  1 +<?php
  2 +/**
  3 + * osCommerce Website
  4 + *
  5 + * @copyright Copyright (c) 2012 osCommerce; http://www.oscommerce.com
  6 + * @license BSD License; http://www.oscommerce.com/bsdlicense.txt
  7 + */
  8 +
  9 + namespace osCommerce\OM\Core\Site\Website\SQL\ANSI;
  10 +
  11 + use osCommerce\OM\Core\Registry;
  12 +
  13 + class SaveUserServerInfo {
  14 + public static function execute($data) {
  15 + $OSCOM_PDO = Registry::get('PDO');
  16 +
  17 + $Qcheck = $OSCOM_PDO->prepare('select id from :table_website_user_server_info where submit_ip = :submit_ip limit 1');
  18 + $Qcheck->bindValue(':submit_ip', $data['ip_address']);
  19 + $Qcheck->execute();
  20 +
  21 + if ( count($Qcheck->fetchAll()) > 0 ) {
  22 + $Qrecord = $OSCOM_PDO->prepare('update :table_website_user_server_info set osc_version = :osc_version, system_os = :system_os, http_server = :http_server, php_version = :php_version, php_extensions = :php_extensions, php_sapi = :php_sapi, php_memory = :php_memory, mysql_version = :mysql_version, php_other = :php_other, system_other = :system_other, mysql_other = :mysql_other, date_updated = now(), update_count = update_count+1 where submit_ip = :submit_ip');
  23 + } else {
  24 + $Qrecord = $OSCOM_PDO->prepare('insert into :table_website_user_server_info values (null, :submit_ip, :osc_version, :system_os, :http_server, :php_version, :php_extensions, :php_sapi, :php_memory, :mysql_version, :php_other, :system_other, :mysql_other, now(), now(), 1)');
  25 + }
  26 +
  27 + $Qrecord->bindValue(':submit_ip', $data['ip_address']);
  28 + $Qrecord->bindValue(':osc_version', $data['osc_version']);
  29 + $Qrecord->bindValue(':system_os', $data['system_os']);
  30 + $Qrecord->bindValue(':http_server', $data['http_server']);
  31 + $Qrecord->bindValue(':php_version', $data['php_version']);
  32 + $Qrecord->bindValue(':php_extensions', $data['php_extensions']);
  33 + $Qrecord->bindValue(':php_sapi', $data['php_sapi']);
  34 + $Qrecord->bindValue(':php_memory', $data['php_memory']);
  35 + $Qrecord->bindValue(':mysql_version', $data['mysql_version']);
  36 + $Qrecord->bindValue(':php_other', $data['php_other']);
  37 + $Qrecord->bindValue(':mysql_other', $data['mysql_other']);
  38 + $Qrecord->bindValue(':system_other', $data['system_other']);
  39 + $Qrecord->execute();
  40 +
  41 + return $Qrecord->rowCount();
  42 + }
  43 + }
  44 +?>
22 osCommerce/OM/Custom/Site/Website/Setup/SQL/mysql.sql
@@ -128,3 +128,25 @@ CREATE TABLE osc_website_partner_transaction (
128 128 KEY idx_ws_partner_tx_date_start (date_start),
129 129 KEY idx_ws_partner_tx_date_end (date_end)
130 130 ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci;
  131 +
  132 +DROP TABLE IF EXISTS osc_website_user_server_info;
  133 +CREATE TABLE osc_website_user_server_info (
  134 + id int unsigned NOT NULL AUTO_INCREMENT,
  135 + submit_ip varchar(255),
  136 + osc_version varchar(255),
  137 + system_os varchar(255),
  138 + http_server varchar(255),
  139 + php_version varchar(255),
  140 + php_extensions text,
  141 + php_sapi varchar(255),
  142 + php_memory varchar(255),
  143 + mysql_version varchar(255),
  144 + php_other text,
  145 + system_other text,
  146 + mysql_other text,
  147 + date_added datetime,
  148 + date_updated datetime,
  149 + update_count int DEFAULT 1,
  150 + PRIMARY KEY (id),
  151 + KEY idx_ws_user_server_info_ip (submit_ip)
  152 +) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci;

0 comments on commit 36d7111

Please sign in to comment.
Something went wrong with that request. Please try again.