GIF89a=( õ' 7IAXKgNgYvYx\%wh…hŽth%ˆs%—x¨}9®Œ©€&©‰%¶†(¹–.¹5·œD¹&Çš)ÇŸ5ǘ;Í£*È¡&Õ²)ׯ7×µ<Ñ»4ï°3ø‘HÖ§KͯT÷¨Yÿšqÿ»qÿÔFØ !ù ' !ÿ NETSCAPE2.0 , =( þÀ“pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§gª«ªE¯°¨¬ª±²Œ¹º¹E¾­”´ÂB¶¯ §Åȸ»ÑD¾¿Á•ÄÅ®° ÝH¾ÒLÀÆDÙ«D¶BÝïðÀ¾DÑÑÔTÌÍíH òGö¨A RÎڐ |¥ ٭&ºìE8œ¹kGÔAÞpx­a¶­ã R2XB®åE8I€Õ6Xî:vT)äžþÀq¦è³¥ì仕F~%xñ  4#ZÔ‰O|-4Bs‘X:= QÉ œš lºÒyXJŠGȦ|s hÏíK–3l7·B|¥$'7Jީܪ‰‡àá”Dæn=Pƒ ¤Òëí‰`䌨ljóá¯Éüv>á–Á¼5 ½.69ûϸd«­ºÀûnlv©‹ªîf{¬ÜãPbŸ  l5‘ޝpß ´ ˜3aÅùäI«O’ý·‘áÞ‡˜¾Æ‚ÙÏiÇÿ‹Àƒ #öó)pâš Þ½ ‘Ý{ó)vmÞü%D~ 6f s}ŃƒDØW Eþ`‡þ À…L8xá†ç˜{)x`X/> Ì}mø‚–RØ‘*|`D=‚Ø_ ^ð5 !_…'aä“OÚ—7âcð`D”Cx`ÝÂ¥ä‹éY¹—F¼¤¥Š?¡Õ™ n@`} lď’ÄÉ@4>ñd œ à‘vÒxNÃ×™@žd=ˆgsžG±æ ´²æud &p8Qñ)ˆ«lXD©øÜéAžHìySun jª×k*D¤LH] †¦§C™Jä–´Xb~ʪwStŽ6K,°£qÁœ:9ت:¨þªl¨@¡`‚ûÚ ».Û¬¯t‹ÆSÉ[:°=Š‹„‘Nåû”Ìî{¿ÂA ‡Rà›ÀÙ6úë°Ÿð0Ä_ ½;ÃϱîÉì^ÇÛÇ#Ëë¼ôº!±Ä˜íUîÅÇ;0L1óÁµö«p% AÀºU̬ݵ¼á%霼€‡¯Á~`ÏG¯»À× ­²± =4ªnpð3¾¤³¯­ü¾¦îuÙuµÙ®|%2ÊIÿür¦#0·ÔJ``8È@S@5ê¢ ö×Þ^`8EÜ]ý.뜃Âç 7 ú ȉÞj œ½Dç zý¸iþœÑÙûÄë!ˆÞÀl§Ïw‹*DçI€nEX¯¬¼ &A¬Go¼QföõFç°¯;é¦÷îŽêJ°îúôF5¡ÌQ|îúöXªæ»TÁÏyñêï]ê² o óÎC=öõ›ÒÓPB@ D×½œä(>èCÂxŽ`±«Ÿ–JЀ»Û á¤±p+eE0`ëŽ`A Ú/NE€Ø†À9‚@¤à H½7”à‡%B‰`Àl*ƒó‘–‡8 2ñ%¸ —€:Ù1Á‰E¸àux%nP1ð!‘ðC)¾P81lÑɸF#ˆ€{´âé°ÈB„0>±û °b¡Š´±O‚3È–Ù()yRpbµ¨E.Z‘D8ÊH@% òŒx+%Ù˜Æcü »¸˜fõ¬b·d`Fê™8èXH"ÉÈ-±|1Ô6iI, 2““¬$+](A*jÐ QTÂo‰.ÛU슬Œã„Ž`¯SN¡–¶Äåyše¯ª’­¬‚´b¦Éož œ)åyâ@Ì®3 ÎtT̉°&Ø+žLÀf"Ø-|žçÔ>‡Ðv¦Ðžì\‚ Q1)Ž@Žh#aP72”ˆ™¨$‚ !ù " , =( …7IAXG]KgNgYvYxR"k\%w]'}hŽth%ˆg+ˆs%—r.—m3šx3˜x¨}9®€&©€+¨‡7§‰%¶†(¹–.¹œD¹&ǘ;Í•&ײ)×»4ïÌ6ò§KÍ þ@‘pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g «¬ E ±± ¨­¶°ººE Á´”·®C¬²§Ç¶Œ»ÓDÃÕƷ¯Ê±H½ºM×ÁGÚ¬D¶BËÁ½î½DÓôTÏÛßîG»ôõC×CÌ l&âž:'òtU³6ɹ#·Ø)€'Ü.6±&ëÍÈ» K(8p0N?!æ2"ÛˆNIJX>R¼ÐO‚M '¡¨2¸*Ÿþ>#n↠å@‚<[:¡Iïf’ ¤TÚ˘CdbÜÙ“[«ŽEú5MBo¤×@€`@„€Êt W-3 ¶Ÿ¡BíêäjIÝ…Eò9[T…$íêﯧ„…•s»Óȳ¹€ÅÚdc®UUρ#±Ùïldj?´í¼²`\ŽÁðÞu|3'ÖŒ]ë6 ¶S#²‡˜FKLÈ *N E´‘áäŠ$˜›eÄYD„ºq«.è촁ƒs \-ÔjA 9²õ÷å- üúM[Âx(ís÷ì®x€|í¡Ù’p¦‚ ŽkÛTÇDpE@WÜ ²Ç]kŠ1¨ þ€·Yb ÓÁ‰l°*n0 ç™—žzBdОu¾7ĉBl€â‰-ºx~|UåU‰  h*Hœ|e"#"?vpÄiŠe6^ˆ„+qâŠm8 #VÇá ‘å–ÄV„œ|Аè•m"сœn|@›U¶ÆÎž—Špb¥G¨ED”€±Úê2FÌIç? >Éxå Œ± ¡¤„%‘žjŸ‘ꄯ<Ìaà9ijÐ2˜D¦È&›†Z`‚å]wþ¼Â:ç6àB¤7eFJ|õÒ§Õ,¨äàFÇ®cS·Ê¶+B°,‘Þ˜ºNûãØ>PADÌHD¹æž«ÄÀnÌ¥}­#Ë’ë QÀÉSÌÂÇ2ÌXÀ{æk²lQÁ2«ÊðÀ¯w|2Í h‹ÄÂG€,m¾¶ë3ÐÙ6-´ÅE¬L°ÆIij*K½ÀÇqï`DwVÍQXœÚÔpeœ±¬Ñ q˜§Tœ½µƒ°Œìu Â<¶aØ*At¯lmEØ ü ôÛN[P1ÔÛ¦­±$ÜÆ@`ùåDpy¶yXvCAyåB`ŽD¶ 0QwG#¯ æš[^Äþ $ÀÓÝǦ{„L™[±úKÄgÌ;ï£S~¹ìGX.ôgoT.»åˆ°ùŸûù¡?1zö¦Ÿž:ÅgÁ|ìL¹ „®£œŠ‚à0œ]PÁ^p F<"•ç?!,ñ‡N4—…PÄ Á„ö¨Û:Tè@hÀ‹%táÿ:ø-žI<`þ‹p I….)^ 40D#p@ƒj4–؀:²‰1Øâr˜¼F2oW¼#Z†;$Q q” ‘ ÂK¦ñNl#29 !’F@¥Bh·ᏀL!—XFóLH‘Kh¤.«hE&JòG¨¥<™WN!€ÑÙÚˆY„@†>Œž19J" 2,/ &.GXB%ÌRÈ9B6¹W]’î×ÔW¥’IÎ$ ñ‹ÓŒE8YÆ ¼³™ñA5“à®Q.aŸB€&Ø©³ JÁ—! ¦t)K%tœ-¦JF bòNMxLôþ)ÐR¸Ð™‘ èÝ6‘O!THÌ„HÛ ‰ !ù ) , =( …AXKgNgYvYxR"k\%wh…hŽh%ˆg+ˆs%—r.—x3˜x¨}9®€&©€+¨Œ,©‡7§‰%¶†(¹–.¹5·&Çš)ǘ;Í•&×£*Ȳ)ׯ7×»4ï°3øÌ6ò‘HÖ§KÍ»Hó¯T÷¨Yÿ»qÿÇhÿ þÀ”pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g ª« E$±²¨ª­ · °²½$E$ÂÕ««D· Í ¿¦Ç¶¸ÌŒ¾³CÃÅÆ E ééH½MÛÂGâªD­ çBêêϾD²ÒaÀà€Š1r­ðÓ¤ ÔožzU!L˜C'¾yW½UGtäÇïÙllê0×àÂuGþ)AÀs[þ·xì ÁxO%ƒûX2ó—  P£n›R/¡ÑšHše+êDm?# —‘Ç£6¡8íJ¡ŸâDiäªM¥Ö„ôj“¬¹£5oQ7°- <‡ *´lãÓŒ2r/a!l)dÈ A™ÈE¢ôÔ͆…ð ;Ö˜c ¡%ß‚’Ùˆâ¸b½—pe~C"BíëÚHïeF2§æŠ8qb t_`urŠeü wÅu3êæPv§h•"ß`íÍxçLĹÜÖ3á  ~Öº“®›¸ÏMDfJÙ °„ÛµáWõ%§œ‚à©–‚X ÓØ)@®Ñ›Eþ´wëuÅSxb8y\mÖzœ¥§ZbºE—ÂLªÌw!y(>¡™wú=Ç|ÅÝs¢d €CÁW)HÜcC$€L Ä7„r.á\{)@ð` @ äXÈ$PD” `šaG:§æˆOˆ72EÐamn]ù"ŒcÊxÑŒ° &dR8`g«iÙŸLR!¦P …d’ä¡“¦ðÎTƒ¦ià|À _ ¥ Qi#¦Šg›Æ ›noMµ ›V ã£)p ç£ÎW…š=Âeªk§†j„ ´®1ß²sÉxéW«jšl|0¯B0Û, \jÛ´›6±¬¶C ÛíWþï|ëÙ‹¸ñzĸV {ì;Ýñn¼òVˆm³I¼³.Ðã¤PN¥ ²µ¼„µCã+¹ÍByî£Ñ¾HŸ›ëê 7ìYÆFTk¨SaoaY$Dµœìï¿Ã29RÈkt Çïfñ ÇÒ:ÀÐSp¹3ÇI¨â¥DZÄ ü9Ïýögñ½­uÔ*3)O‘˜Ö[_hv ,àî×Et Ÿé¶BH€ Õ[ü±64M@ÔSÌM7dÐl5-ÄÙU܍´©zߌ3Ô€3ž„ „ ¶ÛPô½5×g› êÚ˜kN„Ý…0Îj4€Ìë°“#{þÕ3S2çKÜ'ợlø¼Ú2K{° {Û¶?žm𸧠ËI¼nEò='êüóºè^üæÃ_Û=°óž‚ì#Oý¿Í'¡½áo..ÏYìnüñCœO±Áa¿¢Kô½o,üÄËbö²çºíï{ËC Ú— "”Ï{ËK ÍÒw„õ±Oz dÕ¨à:$ ƒô—«v»] A#ð «€¿šéz)Rx׿ˆ¥‚d``èw-îyÏf×K!ð€þ­Ð|ìPľ„=Ì`ý(f” 'Pa ¥ÐBJa%Ðâf§„%Š¡}FàáÝ×6>ÉäŠG"éŽè=ø!oа^FP¼Ø©Q„ÀCÙÁ`(Ž\ÄÝ® ©Â$<n@dÄ E#ììUÒI! ‚#lù‹`k¦ÐÇ'Rró’ZýNBÈMF Í[¤+‹ðɈ-áwj¨¥þ8¾rá ,VÂh„"|½œ=×G_¦Ñ™EØ 0i*%̲˜Æda0mV‚k¾)›;„&6 p>ÓjK “¦Ç# âDÂ:ûc?:R Ó¬fÞéI-Ì“•Ã<ä=™Ï7˜3œ¨˜c2ŒW ,ˆ”8(T™P‰F¡Jhç"‚ ; 403WebShell
403Webshell
Server IP : 104.21.83.152  /  Your IP : 216.73.216.66
Web Server : LiteSpeed
System : Linux premium229.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
User : akhalid ( 749)
PHP Version : 8.3.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/akhalid/omerys/public_html/admin/model/extension/openbay/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/akhalid/omerys/public_html/admin/model/extension/openbay/ebay.php
<?php
class ModelExtensionOpenBayEbay extends Model{
	public function install() {
		$this->load->model('setting/event');

		$this->model_setting_event->addEvent('openbay_ebay_add_order', 'catalog/model/checkout/order/addOrderHistory/after', 'extension/openbay/ebay/eventAddOrderHistory');

		$settings = array();
		$settings["ebay_token"] = '';
		$settings["ebay_secret"] = '';
		$settings["ebay_encryption_key"] = '';
		$settings["ebay_encryption_iv"] = '';
		$settings["ebay_enditems"] = '0';
		$settings["ebay_logging"] = '1';
		$settings["ebay_payment_instruction"] = '';
		$settings["ebay_payment_paypal_address"] = '';
		$settings["ebay_tax"] = '0';
		$settings["ebay_status_import_id"] = '1';
		$settings["ebay_status_shipped_id"] = '3';
		$settings["ebay_status_paid_id"] = '2';
		$settings["ebay_status_cancelled_id"] = '7';
		$settings["ebay_status_refunded_id"] = '11';
		$settings["ebay_def_currency"] = 'GBP';
		$settings["ebay_stock_allocate"] = '0';
		$settings["ebay_update_notify"] = '1';
		$settings["ebay_confirm_notify"] = '1';
		$settings["ebay_confirmadmin_notify"] = '1';
		$settings["ebay_created_hours"] = '48';
		$settings["ebay_create_date"] = '0';
		$settings["ebay_itm_link"] = 'http://www.ebay.com/itm/';
		$settings["ebay_relistitems"] = 0;
		$settings["ebay_time_offset"] = 0;
		$settings["ebay_default_addressformat"] = '{firstname} {lastname}
{company}
{address_1}
{address_2}
{city}
{zone}
{postcode}
{country}';

		$this->model_setting_setting->editSetting('ebay', $settings);

		$this->db->query("
            CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "ebay_category` (
            `ebay_category_id` int(11) NOT NULL AUTO_INCREMENT,
            `CategoryID` int(11) NOT NULL,
            `CategoryParentID` int(11) NOT NULL,
            `CategoryLevel` smallint(6) NOT NULL,
            `CategoryName` char(100) NOT NULL,
            `BestOfferEnabled` tinyint(1) NOT NULL,
            `AutoPayEnabled` tinyint(1) NOT NULL,
            PRIMARY KEY (`ebay_category_id`)
            ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");

		$this->db->query("
            CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "ebay_category_history` (
            `ebay_category_history_id` int(11) NOT NULL AUTO_INCREMENT,
            `CategoryID` int(11) NOT NULL,
            `breadcrumb` varchar(255) NOT NULL,
            `used` int(6) NOT NULL,
            PRIMARY KEY (`ebay_category_history_id`)
            ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");

		$this->db->query("
            CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "ebay_listing` (
            `ebay_listing_id` int(11) NOT NULL AUTO_INCREMENT,
            `ebay_item_id` char(100) NOT NULL,
            `product_id` int(11) NOT NULL,
            `variant` int(11) NOT NULL,
            `status` SMALLINT(3) NOT NULL DEFAULT '1',
            PRIMARY KEY (`ebay_listing_id`),
            KEY `product_id` (`product_id`)
            ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");
		;
		$this->db->query("
            CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "ebay_listing_pending` (
            `ebay_listing_pending_id` int(11) NOT NULL AUTO_INCREMENT,
            `ebay_item_id` char(25) NOT NULL,
            `product_id` int(11) NOT NULL,
            `key` char(50) NOT NULL,
            `variant` int(11) NOT NULL,
            PRIMARY KEY (`ebay_listing_pending_id`),
            KEY `product_id` (`product_id`)
            ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");

		$this->db->query("
            CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "ebay_shipping` (
            `ebay_shipping_id` int(11) NOT NULL AUTO_INCREMENT,
            `description` varchar(100) NOT NULL,
            `InternationalService` tinyint(4) NOT NULL,
            `ShippingService` varchar(100) NOT NULL,
            `ShippingServiceID` int(11) NOT NULL,
            `ServiceType` varchar(100) NOT NULL,
            `ValidForSellingFlow` tinyint(4) NOT NULL,
            `ShippingCategory` varchar(100) NOT NULL,
            `ShippingTimeMin` int(11) NOT NULL,
            `ShippingTimeMax` int(11) NOT NULL,
            PRIMARY KEY (`ebay_shipping_id`)
            ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");

		$this->db->query("
            CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "ebay_shipping_location` (
            `ebay_shipping_id` int(11) NOT NULL AUTO_INCREMENT,
            `description` varchar(100) NOT NULL,
            `detail_version` varchar(100) NOT NULL,
            `shipping_location` varchar(100) NOT NULL,
            `update_time` varchar(100) NOT NULL,
            PRIMARY KEY (`ebay_shipping_id`)
            ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");

		$this->db->query("
            CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "ebay_payment_method` (
            `ebay_payment_method_id` int(11) NOT NULL AUTO_INCREMENT,
            `ebay_name` char(50) NOT NULL,
            `local_name` char(50) NOT NULL,
            PRIMARY KEY (`ebay_payment_method_id`)
            ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci AUTO_INCREMENT=5;");

		$this->db->query("
            CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "ebay_transaction` (
            `ebay_transaction_id` int(11) NOT NULL AUTO_INCREMENT,
            `order_id` int(11) NOT NULL,
            `product_id` int(11) NOT NULL,
            `sku` varchar(100) NOT NULL,
            `txn_id` varchar(100) NOT NULL,
            `item_id` varchar(100) NOT NULL,
            `containing_order_id` varchar(100) NOT NULL,
            `order_line_id` varchar(100) NOT NULL,
            `qty` int(11) NOT NULL,
            `smp_id` int(11) NOT NULL,
            `created` DATETIME NOT NULL,
            `modified` DATETIME NOT NULL,
            PRIMARY KEY (`ebay_transaction_id`),
            KEY `product_id` (`product_id`),
            KEY `order_id` (`order_id`),
            KEY `smp_id` (`smp_id`)
            ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");

		$this->db->query("
            CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "ebay_order` (
            `ebay_order_id` int(11) NOT NULL AUTO_INCREMENT,
            `parent_ebay_order_id` int(11) NOT NULL,
            `order_id` int(11) NOT NULL,
            `smp_id` int(11) NOT NULL,
            `tracking_no` varchar(100) NOT NULL,
            `carrier_id` varchar(100) NOT NULL,
            PRIMARY KEY (`ebay_order_id`),
            KEY `order_id` (`order_id`),
            KEY `smp_id` (`smp_id`),
            KEY `parent_ebay_order_id` (`parent_ebay_order_id`)
            ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");

		$this->db->query("
            CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "ebay_profile` (
            `ebay_profile_id` int(11) NOT NULL AUTO_INCREMENT,
            `name` varchar(100) NOT NULL,
            `description` text NOT NULL,
            `type` int(11) NOT NULL,
            `default` TINYINT(1) NOT NULL,
            `data` text NOT NULL,
            PRIMARY KEY (`ebay_profile_id`)
            ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");

		$this->db->query("
            CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "ebay_setting_option` (
            `ebay_setting_option_id` INT(11) NOT NULL AUTO_INCREMENT,
            `key` VARCHAR(100) NOT NULL,
            `last_updated` DATETIME NOT NULL,
            `data` TEXT NOT NULL,
            PRIMARY KEY (`ebay_setting_option_id`)
            ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");

		$this->db->query("
            CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "ebay_image_import` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `image_original` text NOT NULL,
            `image_new` text NOT NULL,
            `name` text NOT NULL,
            `product_id` int(11) NOT NULL,
            `imgcount` int(11) NOT NULL,
            PRIMARY KEY (`id`)
            ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");

		$this->db->query("
            CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "ebay_shipping_location_exclude` (
            `ebay_shipping_exclude_id` int(11) NOT NULL AUTO_INCREMENT,
            `description` varchar(100) NOT NULL,
            `location` varchar(100) NOT NULL,
            `region` varchar(100) NOT NULL,
            PRIMARY KEY (`ebay_shipping_exclude_id`)
            ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");

		$this->db->query("
            CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "ebay_stock_reserve` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `product_id` int(11) NOT NULL,
            `variant_id` varchar(100) NOT NULL,
            `item_id` varchar(100) NOT NULL,
            `reserve` int(11) NOT NULL,
            PRIMARY KEY (`id`),
            KEY `product_id` (`product_id`)
            ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");

		$this->db->query("
            CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "ebay_order_lock` (
            `smp_id` int(11) NOT NULL,
            PRIMARY KEY (`smp_id`)
            ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");

		$this->db->query("
            CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "ebay_template` (
            `template_id` INT(11) NOT NULL AUTO_INCREMENT,
            `name` VARCHAR(100) NOT NULL,
            `html` MEDIUMTEXT NOT NULL,
            PRIMARY KEY (`template_id`)
            ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");
	}

	public function uninstall() {
		$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "ebay_category`;");
		$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "ebay_category_history`;");
		$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "ebay_listing`;");
		$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "ebay_listing_pending`;");
		$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "ebay_shipping`;");
		$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "ebay_shipping_location`;");
		$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "ebay_payment_method`;");
		$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "ebay_transaction`;");
		$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "ebay_order`;");
		$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "ebay_profile`;");

		$this->load->model('setting/event');
		$this->model_setting_event->deleteEventByCode('openbay_ebay_add_order');
	}

	public function patch() {
		if ($this->config->get('ebay_status') == 1) {

		}
	}

	public function totalLinked() {
		$sql = "SELECT COUNT(DISTINCT p.product_id) AS total
				FROM `" . DB_PREFIX . "ebay_listing` `el`
				LEFT JOIN `" . DB_PREFIX . "product` `p` ON (`el`.`product_id` = `p`.`product_id`)
				LEFT JOIN `" . DB_PREFIX . "product_description` `pd` ON (`p`.`product_id` = `pd`.`product_id`)
				WHERE `el`.`status` = '1'
				AND `pd`.`language_id` = '" . (int)$this->config->get('config_language_id') . "'";

		$query = $this->db->query($sql);

		return $query->row['total'];
	}

	public function loadLinked($limit = 100, $page = 1) {
		$this->load->model('tool/image');

		$start = $limit * ($page - 1);

		$has_option = '';
		if ($this->openbay->addonLoad('openstock') ) {
			$this->load->model('extension/module/openstock');
			$has_option = '`p`.`has_option`, ';
		}

		$sql = "
		SELECT
			" . $has_option . "
			`el`.`ebay_item_id`,
			`p`.`product_id`,
			`p`.`sku`,
			`p`.`model`,
			`p`.`quantity`,
			`pd`.`name`,
			`esr`.`reserve`
		FROM `" . DB_PREFIX . "ebay_listing` `el`
		LEFT JOIN `" . DB_PREFIX . "product` `p` ON (`el`.`product_id` = `p`.`product_id`)
		LEFT JOIN `" . DB_PREFIX . "product_description` `pd` ON (`p`.`product_id` = `pd`.`product_id`)
		LEFT JOIN `" . DB_PREFIX . "ebay_stock_reserve` `esr` ON (`esr`.`product_id` = `p`.`product_id`)
		WHERE `el`.`status` = '1'
		AND `pd`.`language_id` = '" . (int)$this->config->get('config_language_id') . "'";

		$sql .= " LIMIT " . (int)$start . "," . (int)$limit;

		$qry = $this->db->query($sql);

		$data = array();
		if ($qry->num_rows) {
			foreach ($qry->rows as $row) {
				$data[$row['ebay_item_id']] = array(
					'product_id'    => $row['product_id'],
					'sku'           => $row['sku'],
					'model'         => $row['model'],
					'qty'           => $row['quantity'],
					'name'          => $row['name'],
					'link_edit'     => $this->url->link('catalog/product/edit', 'user_token=' . $this->session->data['user_token'] . '&product_id=' . $row['product_id'], true),
					'link_ebay'     => $this->config->get('ebay_itm_link') . $row['ebay_item_id'],
					'reserve'       => (int)$row['reserve'],
				);

				$data[$row['ebay_item_id']]['options'] = 0;

				if ((isset($row['has_option']) && $row['has_option'] == 1) && $this->openbay->addonLoad('openstock')) {
					$data[$row['ebay_item_id']]['options'] = $this->model_setting_module_openstock->getVariants((int)$row['product_id']);
				}

				//get the allocated stock - items that have been bought but not assigned to an order
				if ($this->config->get('ebay_stock_allocate') == 0) {
					$data[$row['ebay_item_id']]['allocated'] = $this->openbay->ebay->getAllocatedStock($row['product_id']);
				} else {
					$data[$row['ebay_item_id']]['allocated'] = 0;
				}
			}
		}

		return $data;
	}

	public function loadLinkedStatus($item_ids) {
		$this->openbay->ebay->log('loadLinkedStatus() - Get item status from ebay for multiple IDs');
		return $this->openbay->ebay->call('item/getItemsById/', array('item_ids' => $item_ids));
	}

	public function loadUnlinked($limit = 200, $page = 1, $filter = array()) {
		$unlinked = array();
		$current = 1;
		$stop_flag = 0;

		while(count($unlinked) < 5) {
			if ($current > 5) {
				$stop_flag = 1;
				break;
			} else {
				$current++;
			}

			$this->openbay->ebay->log('Checking unlinked page: ' . $page);

			$response = $this->openbay->ebay->getEbayItemList($limit, $page, $filter);

			if ($this->openbay->ebay->lasterror == true) {
				break;
			}

			foreach ($response['items'] as $item_id => $item) {
				if ($this->openbay->ebay->getProductId($item_id, 1) == false) {
					$unlinked[$item_id] = $item;
				}
			}

			$this->openbay->ebay->log('Unlinked count: ' . count($unlinked));

			if ($response['max_page'] == $page || count($unlinked) >= 5) {
				break;
			} else {
				$page++;
			}
		}

		return array(
			'items' => $unlinked,
			'break' => $stop_flag,
			'next_page' => $response['page']+1,
			'max_page' => $response['max_page']
		);
	}

	public function loadItemLinks() {
		$local      = $this->openbay->ebay->getLiveListingArray();
		$response   = $this->openbay->ebay->getEbayActiveListings();

		$data = array(
			'unlinked'  => array(),
			'linked'    => array()
		);

		if (!empty($response)) {
			foreach ($response as $key => $value) {
				if (!in_array($key, $local)) {
					$data['unlinked'][$key] = $value;
				} else {
					$data['linked'][$key] = $value;
				}
			}
		}

		return $data;
	}

	public function saveItemLink($data) {
		$this->openbay->ebay->log('Creating item link.');
		$this->openbay->ebay->createLink($data['pid'], $data['itemId'], $data['variants']);

		if (($data['qty'] != $data['ebayqty']) || $data['variants'] == 1) {
			$this->load->model('catalog/product');
			$this->openbay->ebay->log('Updating eBay with new qty');
			$this->openbay->ebay->productUpdateListen($data['pid'], $this->model_catalog_product->getProduct($data['pid']));
		} else {
			$this->openbay->ebay->log('Qty on eBay is the same as our stock, no update needed');
			return array('msg' => 'ok', 'error' => false);
		}
	}

	public function getSellerStoreCategories() {
		$qry = $this->db->query("SHOW TABLES LIKE '" . DB_PREFIX . "ebay_store_category'");

		if ($qry->num_rows) {
			$qry = $this->db->query("SELECT * FROM `" . DB_PREFIX . "ebay_store_category` WHERE `parent_id` = '0' ORDER BY `CategoryName` ASC");

			if ($qry->num_rows) {
				$cats = array();

				foreach ($qry->rows as $row) {
					$lev1 = $row['CategoryName'];
					$qry2 = $this->db->query("SELECT * FROM `" . DB_PREFIX . "ebay_store_category` WHERE `parent_id` = '" . $row['ebay_store_category_id'] . "' ORDER BY `CategoryName` ASC");

					if ($qry2->num_rows) {
						foreach ($qry2->rows as $row2) {
							$qry3 = $this->db->query("SELECT * FROM `" . DB_PREFIX . "ebay_store_category` WHERE `parent_id` = '" . $row2['ebay_store_category_id'] . "' ORDER BY `CategoryName` ASC");

							if ($qry3->num_rows) {
								foreach ($qry3->rows as $row3) {
									$cats[$row3['CategoryID']] = $lev1  . ' > ' . $row2['CategoryName']  . ' > ' . $row3['CategoryName'];
								}
							} else {
								$cats[$row2['CategoryID']] = $lev1  . ' > ' . $row2['CategoryName'];
							}
						}
					} else {
						$cats[$row['CategoryID']] = $lev1;
					}
				}

				return $cats;
			} else {
				return false;
			}
		} else {
			return false;
		}
	}

	public function getCategory($parent) {
		$this->load->language('extension/openbay/ebay_new');

		$json = array();

		if (empty($parent)) {
			$cat_qry = $this->db->query("SELECT * FROM `" . DB_PREFIX . "ebay_category` WHERE `CategoryID` = `CategoryParentID`");
		} else {
			$cat_qry = $this->db->query("SELECT * FROM `" . DB_PREFIX . "ebay_category` WHERE `CategoryParentID` = '" . $parent . "'");
		}

		if ($cat_qry->num_rows) {
			$json['cats'] = array();
			foreach ($cat_qry->rows as $row) {
				$json['cats'][] = $row;
			}
			$json['items'] = $cat_qry->num_rows;

		} else {
			if (empty($parent)) {
				$json['error'] = $this->language->get('error_category_sync');
			}

			$json['items'] = null;
		}

		return $json;
	}

	public function getSuggestedCategories($qry) {
		$response = array(
			'data' => $this->openbay->ebay->call('listing/getSuggestedCategories/', array('qry' => $qry)),
			'error' => $this->openbay->ebay->lasterror,
			'msg' => $this->openbay->ebay->lastmsg
		);

		return $response;
	}

	public function getShippingService($international, $type) {
		$json = array();
		$result = $this->db->query("SELECT * FROM `" . DB_PREFIX . "ebay_shipping` WHERE `InternationalService` = '" . (int)$international . "' AND `ValidForSellingFlow` = '1' AND `ServiceType` LIKE '%" . $this->db->escape($type) . "%'");

		if ($result->num_rows) {
			$json['service'] = array();
			foreach ($result->rows as $row) {
				$json['service'][$row['ShippingService']] = $row;
			}
		}

		return $json;
	}

	public function getShippingLocations() {
		$qry = $this->db->query("SELECT * FROM `" . DB_PREFIX . "ebay_shipping_location` WHERE `shipping_location` != 'None' AND `shipping_location` != 'Worldwide'");

		if ($qry->num_rows) {
			$json = array();
			foreach ($qry->rows as $row) {
				$json[] = $row;
			}
			return $json;
		} else {
			return false;
		}
	}

	public function getEbayCategorySpecifics($category_id) {
		$response['data']   = $this->openbay->ebay->call('listing/getEbayCategorySpecifics/', array('id' => $category_id));
		$response['error']  = $this->openbay->ebay->lasterror;
		$response['msg']    = $this->openbay->ebay->lastmsg;
		return $response;
	}

	public function getCategoryFeatures($category_id) {
		$response['data']   = $this->openbay->ebay->call('listing/getCategoryFeatures/', array('id' => $category_id));
		$response['error']  = $this->openbay->ebay->lasterror;
		$response['msg']    = $this->openbay->ebay->lastmsg;
		return $response;
	}

	public function getSellerSummary() {
		$response['data']   = $this->openbay->ebay->call('account/getSellerSummary/');
		$response['error']  = $this->openbay->ebay->lasterror;
		$response['msg']    = $this->openbay->ebay->lastmsg;

		return $response;
	}

	public function getPaymentTypes() {
		$cat_payment    = $this->db->query("SELECT * FROM `" . DB_PREFIX . "ebay_payment_method`");
		$payments       = array();

		foreach ($cat_payment->rows as $row) {
			$payments[] = $row;
		}

		return $payments;
	}

	public function getPopularCategories() {
		$res    = $this->db->query("SELECT * FROM `" . DB_PREFIX . "ebay_category_history` ORDER BY `used` DESC LIMIT 5");
		$cats   = array();

		foreach ($res->rows as $row) {
			$cats[] = $row;
		}

		return $cats;
	}

	private function getCategoryStructure($id) {
		$res = $this->db->query("SELECT * FROM `" . DB_PREFIX . "ebay_category` WHERE `CategoryID` = '" . $this->db->escape($id) . "' LIMIT 1");
		return $res->row;
	}

	public function ebayVerifyAddItem($data, $options) {
		if ($options == 'yes') {
			$response['data'] = $this->openbay->ebay->call('listing/verifyFixedPrice/', $data);
		} else {
			$response['data'] = $this->openbay->ebay->call('listing/ebayVerifyAddItem/', $data);
		}

		$response['error']  = $this->openbay->ebay->lasterror;
		$response['msg']    = $this->openbay->ebay->lastmsg;

		return $response;
	}

	public function ebayAddItem($data, $options) {
		if ($options == 'yes') {
			$response = $this->openbay->ebay->call('listing/addFixedPrice/', $data);
			$variant = 1;
		} else {
			$response = $this->openbay->ebay->call('listing/ebayAddItem/', $data);
			$variant = 0;
		}

		$data2           = array();
		$data2['data']   = $response;
		$data2['error']  = $this->openbay->ebay->lasterror;
		$data2['msg']    = $this->openbay->ebay->lastmsg;

		if (!empty($response['ItemID'])) {
			$this->openbay->ebay->createLink($data['product_id'], $response['ItemID'], $variant);
			$this->openbay->ebay->addReserve($data, $response['ItemID'], $variant);

			$item_link = $this->config->get('ebay_itm_link');

			if (!empty($item_link)) {
				$data2['data']['view_link']  = html_entity_decode($this->config->get('ebay_itm_link') . $response['ItemID']);
			} else {
				$data2['data']['view_link']  = '';
			}
		} else {
			$data2['error']             = false;
			$data2['msg']               = 'ok';
			$data2['data']['Failed']    = true;
		}

		return $data2;
	}

	public function logCategoryUsed($category_id) {
		$breadcrumb = array();
		$original_id = $category_id;
		$stop       = false;
		$i          = 0; //fallback to stop infinate loop
		$err 		= false;

		while($stop == false && $i < 10) {
			$cat = $this->getCategoryStructure($category_id);

			if (!empty($cat)) {
				$breadcrumb[] = $cat['CategoryName'];

				if ($cat['CategoryParentID'] == $category_id) {
					$stop = true;
				} else {
					$category_id = $cat['CategoryParentID'];
				}

				$i++;
			} else {
				$stop = true;
				$err = true;
			}
		}

		if ($err == false) {
			$res = $this->db->query("SELECT `used` FROM `" . DB_PREFIX . "ebay_category_history` WHERE `CategoryID` = '" . $original_id . "' LIMIT 1");

			if ($res->num_rows) {
				$new = $res->row['used'] + 1;
				$this->db->query("UPDATE `" . DB_PREFIX . "ebay_category_history` SET `used` = '" . $new . "' WHERE `CategoryID` = '" . $original_id . "' LIMIT 1");
			} else {
				$this->db->query("INSERT INTO `" . DB_PREFIX . "ebay_category_history` SET `CategoryID` = '" . $original_id . "', `breadcrumb` = '" .   $this->db->escape(implode(' > ', array_reverse($breadcrumb))) . "', `used` = '1'");
			}
		}
	}

	public function getProductStock($id) {
		$res = $this->db->query("SELECT * FROM `" . DB_PREFIX . "product` WHERE `product_id` = '" . $this->db->escape($id) . "' LIMIT 1");

		if (isset($res->row['has_option']) && $res->row['has_option'] == 1) {
			if ($this->openbay->addonLoad('openstock')) {
				$this->load->model('extension/module/openstock');
				$this->load->model('tool/image');
				$variant = $this->model_setting_module_openstock->getVariants((int)$id);
			} else {
				$variant = 0;
			}
		} else {
			$variant = 0;
		}

		return array(
			'qty'           => $res->row['quantity'],
			'subtract'      => (int)$res->row['subtract'],
			'allocated'     => $this->openbay->ebay->getAllocatedStock($id),
			'variant'       => $variant
		);
	}

	public function getUsage() {
		return $this->openbay->ebay->call('report/accountUse/');
	}

	public function getPlans() {
		return $this->openbay->ebay->call('plan/getPlans/');
	}

	public function getMyPlan() {
		return $this->openbay->ebay->call('plan/myPlan/');
	}

	public function getLiveListingArray() {
		$qry = $this->db->query("SELECT `product_id`, `ebay_item_id` FROM `" . DB_PREFIX . "ebay_listing` WHERE `status` = 1");

		$data = array();
		if ($qry->num_rows) {
			foreach ($qry->rows as $row) {
				$data[$row['product_id']] = $row['ebay_item_id'];
			}
		}

		return $data;
	}

	public function verifyCredentials() {
		$this->request->post['domain'] = HTTPS_SERVER;

		$data = $this->openbay->ebay->call('account/validate/', $this->request->post, array(), 'json', 1);

		$return = array('error' => $this->openbay->ebay->lasterror, 'msg' => $this->openbay->ebay->lastmsg);

		if ($this->openbay->ebay->lasterror != true) {
            $return['data'] = $data;
		}

		return $return;
	}

	public function editSave($data) {
		$this->openbay->ebay->log('editSave() - start..');

		//get product id
		$product_id = $this->openbay->ebay->getProductId($data['itemId']);

		$this->openbay->ebay->log('editSave() - product_id: ' . $product_id);

		if ($data['variant'] == 0) {
			//save the reserve level
			$this->openbay->ebay->updateReserve($product_id, $data['itemId'], $data['qty_reserve']);

			//get the stock info
			$stock = $this->openbay->ebay->getProductStockLevel($product_id);

			//do the stock sync
			$this->openbay->ebay->putStockUpdate($data['itemId'], $stock['quantity']);

			//finish the revise item call
			return $this->openbay->ebay->call('listing/reviseItem/', $data);
		} else {
			$this->openbay->ebay->log('editSave() - variant item');

			$variant_data = array();
			$this->load->model('tool/image');
			$this->load->model('catalog/product');
			$this->load->model('extension/module/openstock');

			//get the options list for this product
			$options = $this->model_setting_module_openstock->getVariants($product_id);

			$variant_data['option_list'] = base64_encode(serialize($options[key($options)]['option_values']));

			$variant_data['groups']      = $data['optGroupArray'];
			$variant_data['related']     = $data['optGroupRelArray'];
			$variant_data['id']          = $data['itemId'];

			$stock_flag = false;

			foreach ($data['opt'] as $k => $opt) {
				//update the variant reserve level
				$this->openbay->ebay->updateReserve($product_id, $data['itemId'], $opt['reserve'], $opt['sku'], 1);

				//get the stock info
				$stock = $this->openbay->ebay->getProductStockLevel($product_id, $opt['sku']);

				$this->openbay->ebay->log('editSave() - stock: ' . serialize($stock));

				if ($stock['quantity'] > 0 || $stock == true) {
					$stock_flag = true;
				}

				// PRODUCT RESERVE LEVELS FOR VARIANT ITEMS (DOES NOT PASS THROUGH NORMAL SYSTEM)
				$reserve = $this->openbay->ebay->getReserve($product_id, $data['itemId'], $opt['sku']);

				$this->openbay->ebay->log('editSave() - reserve level: ' . $reserve);

				if ($reserve != false) {
					$this->openbay->ebay->log('editSave() / Variant (' . $opt['sku'] . ') - Reserve stock: ' . $reserve);

					if ($stock['quantity'] > $reserve) {
						$this->openbay->ebay->log('editSave() - Stock (' . $stock['quantity'] . ') is larger than reserve (' . $reserve . '), setting level to reserve');
						$stock['quantity'] = $reserve;
					}
				}

				$variant_data['opt'][$k]['sku']     	= $opt['sku'];
				$variant_data['opt'][$k]['qty']     	= $stock['quantity'];
				$variant_data['opt'][$k]['price']   	= number_format($opt['price'], 2, '.', '');

				// if any of the variants have 0 stock or no SKU set to inactive
				if ($opt['sku'] == '' || $variant_data['opt'][$k]['qty'] < 1) {
					$variant_data['opt'][$k]['active'] = 0;
				} else {
					$variant_data['opt'][$k]['active'] = $opt['active'];
				}


				$variant_option_values = $this->model_setting_module_openstock->getVariant($opt['product_option_variant_id']);

				foreach ($variant_option_values as $variant_option_value) {
					$variant_data['opt'][$k]['specifics'][] = array('name' => $variant_option_value['option_name'], 'value' => $variant_option_value['option_value_name']);
				}
			}

			$this->openbay->ebay->log('editSave() - Debug - ' . serialize($variant_data));

			//send to the api to process
			if ($stock_flag == true) {
				$this->openbay->ebay->log('editSave() - Sending to API');
				$response = $this->openbay->ebay->call('item/reviseVariants', $variant_data);
				return $response;
			} else {
				$this->openbay->ebay->log('editSave() - Ending item');
				$this->openbay->ebay->endItem($data['itemId']);
			}
		}
	}

	public function getProductAttributes($product_id) {
		$product_attribute_group_data = array();

		$product_attribute_group_query = $this->db->query("SELECT ag.attribute_group_id, agd.name FROM " . DB_PREFIX . "product_attribute pa LEFT JOIN " . DB_PREFIX . "attribute a ON (pa.attribute_id = a.attribute_id) LEFT JOIN " . DB_PREFIX . "attribute_group ag ON (a.attribute_group_id = ag.attribute_group_id) LEFT JOIN " . DB_PREFIX . "attribute_group_description agd ON (ag.attribute_group_id = agd.attribute_group_id) WHERE pa.product_id = '" . (int)$product_id . "' AND agd.language_id = '" . (int)$this->config->get('config_language_id') . "' GROUP BY ag.attribute_group_id ORDER BY ag.sort_order, agd.name");

		foreach ($product_attribute_group_query->rows as $product_attribute_group) {
			$product_attribute_data = array();

			$product_attribute_query = $this->db->query("SELECT a.attribute_id, ad.name, pa.text FROM " . DB_PREFIX . "product_attribute pa LEFT JOIN " . DB_PREFIX . "attribute a ON (pa.attribute_id = a.attribute_id) LEFT JOIN " . DB_PREFIX . "attribute_description ad ON (a.attribute_id = ad.attribute_id) WHERE pa.product_id = '" . (int)$product_id . "' AND a.attribute_group_id = '" . (int)$product_attribute_group['attribute_group_id'] . "' AND ad.language_id = '" . (int)$this->config->get('config_language_id') . "' AND pa.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY a.sort_order, ad.name");

			foreach ($product_attribute_query->rows as $product_attribute) {
				$product_attribute_data[] = array(
					'attribute_id' => $product_attribute['attribute_id'],
					'name'         => $product_attribute['name'],
					'text'         => $product_attribute['text']
				);
			}

			$product_attribute_group_data[] = array(
				'attribute_group_id' => $product_attribute_group['attribute_group_id'],
				'name'               => $product_attribute_group['name'],
				'attribute'          => $product_attribute_data
			);
		}

		return $product_attribute_group_data;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit