Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Wed, Jul 23, 12:22 PM

in-portal

Index: tags/RC_mar08_2/admin/orderids_import.php
===================================================================
--- tags/RC_mar08_2/admin/orderids_import.php (nonexistent)
+++ tags/RC_mar08_2/admin/orderids_import.php (revision 9311)
@@ -0,0 +1,117 @@
+<?php
+
+$start = getmicrotime();
+
+define('ADMIN', 1);
+define('FULL_PATH', realpath(dirname(__FILE__).'/..') );
+if (!file_exists(FULL_PATH.'/core/kernel/application.php')) {
+ die('Please re-checkout _inportal_kernel4 cvs module into the root directory ('.FULL_PATH.') and remove kernel/kernel4 folder. Make sure to checkout correct branch (RC or HEAD).');
+}
+include_once(FULL_PATH.'/core/kernel/startup.php');
+
+/*
+ kApplication $application
+*/
+$application =& kApplication::Instance();
+$application->Init();
+
+if ($_SERVER['REMOTE_ADDR'] != '213.180.111.232')
+{
+ exit;
+}
+
+
+$sql = 'UPDATE '.TABLE_PREFIX.'Orders SET OrderId = -ABS(OrderId)';
+$application->Conn->Query($sql);
+
+$sql = 'UPDATE '.TABLE_PREFIX.'OrderItems SET OrderId = -ABS(OrderId)';
+$application->Conn->Query($sql);
+
+
+$sql = 'SELECT co.orderid, date, o.OrderId AS wrong_id
+ FROM cybercomm_orders co
+ LEFT JOIN '.TABLE_PREFIX.'Orders o
+ ON co.date = o.OrderDate
+ ';
+
+$a_orderids = $application->Conn->Query($sql, 'date');
+
+foreach ($a_orderids AS $date => $a_ids)
+{
+ if ($a_ids['wrong_id'] == 0)
+ {
+ continue;
+ }
+
+ $sql = 'UPDATE '.TABLE_PREFIX.'Orders
+ SET OrderId = '.$a_ids['orderid'].'
+ WHERE OrderId = '.$a_ids['wrong_id'];
+ $application->Conn->Query($sql);
+
+ $sql = 'UPDATE '.TABLE_PREFIX.'OrderItems
+ SET OrderId = '.$a_ids['orderid'].'
+ WHERE OrderId = '.$a_ids['wrong_id'];
+ $application->Conn->Query($sql);
+
+ echo 'ID changed from '.$a_ids['wrong_id'].' TO '.$a_ids['orderid'].'<br>';
+}
+
+// new orders
+
+$sql = 'SELECT OrderId
+ FROM '.TABLE_PREFIX.'Orders
+ WHERE OrderId < 0
+ ';
+$a_neworders = $application->Conn->GetCol($sql);
+
+// Max ID
+
+$sql = 'SELECT MAX(OrderId) FROM '.TABLE_PREFIX.'Orders';
+$max_id = $application->Conn->GetOne($sql);
+
+
+foreach ($a_neworders AS $order_id)
+{
+ $max_id++;
+
+ $sql = 'UPDATE '.TABLE_PREFIX.'Orders
+ SET OrderId = '.$max_id.'
+ WHERE OrderId = '.$order_id;
+ $application->Conn->Query($sql);
+
+ $sql = 'UPDATE '.TABLE_PREFIX.'OrderItems
+ SET OrderId = '.$max_id.'
+ WHERE OrderId = '.$order_id;
+ $application->Conn->Query($sql);
+
+ echo 'New order ID changed from '.$order_id.' TO '.$max_id.'<br>';
+
+}
+
+
+//$application->Run();
+$application->Done();
+
+$end = getmicrotime();
+
+function getmicrotime()
+{
+ list($usec, $sec) = explode(" ", microtime());
+ return ((float)$usec + (float)$sec);
+}
+
+//update_memory_check_script();
+
+function update_memory_check_script() {
+ $files = get_included_files();
+ $script = '$files = Array('."\n";
+ foreach ($files as $file_name) {
+ $script .= "\t\t'".str_replace(FULL_PATH, '', $file_name)."',\n";
+ }
+ $script .= ");\n";
+ echo "<pre>";
+ echo $script;
+ echo "</pre>";
+}
+
+?>
\ No newline at end of file
Property changes on: tags/RC_mar08_2/admin/orderids_import.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.1.2.1
\ No newline at end of property

Event Timeline