Skip to content
Browse files

Save user submitted server info statistics

  • Loading branch information...
1 parent a8d7d91 commit 36d7111cacce2a68fc05496c1209fb2527b762eb @haraldpdl committed Nov 16, 2012
View
3 .htaccess
@@ -36,6 +36,9 @@ RewriteRule ^public/sites/Website/rss/news\.xml$ http://feeds.feedburner.co
RewriteCond %{HTTP_USER_AGENT} !FeedBurner
RewriteRule ^public/sites/Website/rss/addons\.xml$ http://feeds.feedburner.com/osCommerce_Contributions [R=301,L]
+RewriteCond %{HTTP_HOST} ^usage\.oscommerce\.com$
+RewriteRule ^submit\.php$ RPC&Website&Index&SaveUserServerInfo [L]
+
Redirect 301 /newsletter/subscribe http://oscommerce.list-manage.com/subscribe?u=a5961750a3635e18fdf4bb539&id=10af90c126
RewriteCond %{REQUEST_FILENAME} !-f
View
1 README.md
@@ -76,6 +76,7 @@ which can be copied from an existing block:
community_api_module = ""
community_api_address = ""
cron_key = ""
+ save_user_server_info_salt = ""
The following SQL file needs to be imported into the installation database to
create the tables for the website:
View
67 osCommerce/OM/Custom/Site/Website/Application/Index/RPC/SaveUserServerInfo.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * osCommerce Website
+ *
+ * @copyright Copyright (c) 2012 osCommerce; http://www.oscommerce.com
+ * @license BSD License; http://www.oscommerce.com/bsdlicense.txt
+ */
+
+ namespace osCommerce\OM\Core\Site\Website\Application\Index\RPC;
+
+ use osCommerce\OM\Core\OSCOM;
+ use osCommerce\OM\Core\Registry;
+
+ class SaveUserServerInfo {
+ public static function execute() {
+ $OSCOM_PDO = Registry::get('PDO');
+
+ $result = '';
+
+ if ( isset($_POST['info']) && !empty($_POST['info']) ) {
+ $info = unserialize(base64_decode($_POST['info']));
+
+ 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']) ) {
+ $data = array('osc_version' => $info['oscommerce']['version'],
+ 'system_os' => $info['system']['os'],
+ 'http_server' => $info['system']['http_server'],
+ 'php_version' => $info['php']['version'],
+ 'php_extensions' => implode(',', $info['php']['extensions']),
+ 'php_sapi' => $info['php']['sapi'],
+ 'php_memory' => $info['php']['memory_limit'],
+ 'mysql_version' => $info['mysql']['version']);
+
+ unset($info['php']['version']);
+ unset($info['php']['sapi']);
+ unset($info['php']['memory_limit']);
+ unset($info['php']['extensions']);
+ unset($info['mysql']['version']);
+ unset($info['system']['os']);
+ unset($info['system']['host']);
+ unset($info['system']['http_server']);
+
+ $data['php_other'] = static::formatArray($info['php']);
+ $data['mysql_other'] = static::formatArray($info['mysql']);
+ $data['system_other'] = static::formatArray($info['system']);
+
+ $data['ip_address'] = sha1(OSCOM::getIPAddress() . OSCOM::getConfig('save_user_server_info_salt', 'Website'));
+
+ if ( OSCOM::callDB('Website\SaveUserServerInfo', $data, 'Site') === 1 ) {
+ $result = 'OK';
+ }
+ }
+ }
+
+ echo $result;
+ }
+
+ public static function formatArray($array) {
+ $output = '';
+
+ foreach ( $array as $key => $value ) {
+ $output .= $key . ' = ' . $value . "\n";
+ }
+
+ return trim($output);
+ }
+ }
+?>
View
44 osCommerce/OM/Custom/Site/Website/SQL/ANSI/SaveUserServerInfo.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * osCommerce Website
+ *
+ * @copyright Copyright (c) 2012 osCommerce; http://www.oscommerce.com
+ * @license BSD License; http://www.oscommerce.com/bsdlicense.txt
+ */
+
+ namespace osCommerce\OM\Core\Site\Website\SQL\ANSI;
+
+ use osCommerce\OM\Core\Registry;
+
+ class SaveUserServerInfo {
+ public static function execute($data) {
+ $OSCOM_PDO = Registry::get('PDO');
+
+ $Qcheck = $OSCOM_PDO->prepare('select id from :table_website_user_server_info where submit_ip = :submit_ip limit 1');
+ $Qcheck->bindValue(':submit_ip', $data['ip_address']);
+ $Qcheck->execute();
+
+ if ( count($Qcheck->fetchAll()) > 0 ) {
+ $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');
+ } else {
+ $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)');
+ }
+
+ $Qrecord->bindValue(':submit_ip', $data['ip_address']);
+ $Qrecord->bindValue(':osc_version', $data['osc_version']);
+ $Qrecord->bindValue(':system_os', $data['system_os']);
+ $Qrecord->bindValue(':http_server', $data['http_server']);
+ $Qrecord->bindValue(':php_version', $data['php_version']);
+ $Qrecord->bindValue(':php_extensions', $data['php_extensions']);
+ $Qrecord->bindValue(':php_sapi', $data['php_sapi']);
+ $Qrecord->bindValue(':php_memory', $data['php_memory']);
+ $Qrecord->bindValue(':mysql_version', $data['mysql_version']);
+ $Qrecord->bindValue(':php_other', $data['php_other']);
+ $Qrecord->bindValue(':mysql_other', $data['mysql_other']);
+ $Qrecord->bindValue(':system_other', $data['system_other']);
+ $Qrecord->execute();
+
+ return $Qrecord->rowCount();
+ }
+ }
+?>
View
22 osCommerce/OM/Custom/Site/Website/Setup/SQL/mysql.sql
@@ -128,3 +128,25 @@ CREATE TABLE osc_website_partner_transaction (
KEY idx_ws_partner_tx_date_start (date_start),
KEY idx_ws_partner_tx_date_end (date_end)
) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci;
+
+DROP TABLE IF EXISTS osc_website_user_server_info;
+CREATE TABLE osc_website_user_server_info (
+ id int unsigned NOT NULL AUTO_INCREMENT,
+ submit_ip varchar(255),
+ osc_version varchar(255),
+ system_os varchar(255),
+ http_server varchar(255),
+ php_version varchar(255),
+ php_extensions text,
+ php_sapi varchar(255),
+ php_memory varchar(255),
+ mysql_version varchar(255),
+ php_other text,
+ system_other text,
+ mysql_other text,
+ date_added datetime,
+ date_updated datetime,
+ update_count int DEFAULT 1,
+ PRIMARY KEY (id),
+ KEY idx_ws_user_server_info_ip (submit_ip)
+) 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.