....................................../////.===Shadow-Here===./////................................................ > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < ------------------------------------------------------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RIFF¤ WEBPVP8 ˜ ðÑ *ôô>‘HŸK¥¤"§£±¨àð enü¹%½_F‘åè¿2ºQú³íªú`N¿­3ÿƒügµJžaÿ¯ÿ°~¼ÎùnúîÞÖô•òíôÁÉß®Sm¥Ü/ ‡ó˜f£Ùà<˜„xëJ¢Ù€SO3x<ªÔ©4¿+ç¶A`q@Ì“Úñè™ÍÿJÌ´ª-˜ÆtÊÛL]Ïq*‘Ý”ì#ŸÌÏãY]@ê`¿ /ªfkØB4·®£ó z—Üw¥Pxù–ÞLШKÇN¾AkÙTf½è'‰g gÆv›Øuh~ a˜Z— ïj*á¥t d£“uÒ ¨`K˜¹ßþ]b>˜]_ÏÔ6W—è2r4x•íÖ…"ƒÖNîä!¦å Ú}ýxGøÌ —@ ;ÆÚŠ=ɾ1ý8lªË¥ô ^yf®Œ¢u&2©nÙÇ›ñÂñŒ³ aPo['½»øFùà­+4ê“$!lövlüÞ=;N®3ð‚õ›DÉKòÞ>ÄÍ ¥ˆuߤ#ˆ$6ù™¥îЇy’ÍB¼ çxÛ;X"WL£R÷͝*ó-¶Zu}º.s¸sšXqù–DþÿvªhüïwyŸ ¯é³lÀ:KCûÄ£Ëá\…­ ~—ýóî ¼ûûÜTÓüÇy…ŽÆvc»¾×U ñ¸žþоP÷¦ó:Ò¨¨5;Ð#&#ÖúñläÿÁœ GxÉ­/ñ‡áQðìYÉtÒw޼GÔ´zàÒò ð*ëzƒ•4~H]Ø‹f ñÓÈñ`NåWçs'ÆÏW^ø¹!XžµmQ5ÃËoLœÎ: ÞËÍ¥J ù…î èo£ßPÎñ¶ž8.Œ]ʵ~5›ÙË-ù*8ÙÖß±~ ©¹rÓê‚j¶d¸{^Q'˜±Crß ÚH—#¥¥QlÀ×ëã‡DÜ«èî þ&Çæžî;ŽÏºò6ÒLÃXy&ZŒ'j‚¢Ù€IßÚù+–MGi‰*jE€‘JcÜ ÓÌ EÏÚj]o˜ Þr <¾U ûŪæÍ/šÝH¥˜b”¼ ÁñßX GP›ï2›4WŠÏà×£…íÓk†¦H·ÅíMh–*nó÷à]ÁjCº€b7<ب‹¨5車bp2:Á[UªM„QŒçiNMa#<5›áËó¸HýÊ"…×Éw¹¦ì2º–x<›»a±¸3Weü®FÝ⑱ö–î–³|LPÈ~çð~Çå‡|º kD¢µÏàÆAI %1À% ¹Ò – ”ϝS¦‰4&¶£°à Öý”û_Ò Áw°A«Å€?mÇÛgHÉ/8)á¾ÛìáöŽP í¨PŸNÙµº¦‡§Ùš"ÿ«>+ªÕ`Ê÷‡‚ß Õû˜þãÇ-PÍ.¾XV‘€ dÜ"þ4¹ ±Oú‘©t¥¦FªÄÃÄ•b‚znýu½—#cDs˜ÃiÑOˆñ×QO=*IAÊ,¶ŽZƒ;‡wøXè%EÐk:F±Ú” .Ѽ+Áu&Ç`."pÈÉw o&¿dE6‘’EqTuK@Ì¥ã™À(Êk(h‰,H}RÀIXÛš3µ1©_OqÚÒJAñ$ÊÙÜ;D3çŒ[þùœh¬Ã³™ö6ç†NY".Ú‰ï[ªŸŒ '²Ð öø_¨ÂÉ9ué¶³ÒŠõTàîMØ#û¯gN‡bÙ놚X„ö …ÉeüÌ^J ‹€.œ$Æ)βÄeæW#óüßĺŸ€ ÀzwV 9oä»f4V*uB «Ë†¹ì¯žR霓æHXa=&“I4K;¯ç‹h×·"UŠ~<•╪Vêª&ÍSÃÆÅ?ÔqÎ*mTM ˜›µwêd#[C¡©§‘D<©àb†–ÁœøvH/,í:¯( ²£|4-„Æövv„Yͼ™^Á$ˆ„¢Û[6yB.åH*V¨æ?$=˜Ñ€•ñ·­(VlŸ‘ nÀt8W÷´Bûba?q9ú¶Xƒl«ÿ\ù¶’þòUÐj/õ¢Ìµ³g$ƒÎR!¸»|Oߍë’BhîÚÑ¢ñåŒJ„®„£2Ð3•ô02Nt…!£Í]Ïc½Qÿ?ˆ<&ÃA¾Ú,JˆijÌ#5yz„‰Î|ÊŽ5QÏ:‹ÐaóVÔxW—CpeÏzÐïíçôÿÅ_[hãsÐ_/ŽTÝ?BîˆííV$<¿i>²F¬_Eß¿ †bÊŒº­ÿ®Z H“C}”¬,Mp ý/Bá£w>˜YV°aƒúh+cŠ- r/[%|üUMHäQ°X»|û/@|°¥Ð !BÔ Ç¢Ä©š+Õì D«7ìN¶ŽðÔ " ƶ’ÖçtA‰Û×}{tþz­¾GÍ›k¹OEJR$ Â׃ «ëÁ"oÉôž$oUK(Ä)Ãz³Ê-‹êN[Ò3Œñbï8P 4ƒ×q¢bo|?<ÛX¬òÄͰL–±›(™ûG?ýË©ÚÄ–ÂDØÐ_Ç¡ô ¾–ÄÏø ×e8Ë©$ÄF¹Å‹ì[©óìl:F¾f´‹‹Xì²ï®\¬ôùƒ ÿat¥óèÒùHß0äe‚;ü×h:ÆWðHž=Ã8骣"kœ'Y?³}Tûè€>?0l›e1Lòñ„aæKÆw…hÖŠùW…ÈÆÄ0ši·›[pcwËþñiêíY/~-Á5˜!¿†A›™Mÿþ(±“t@â“ö2­´TG5yé]çå僳 .·ÍïçÝ7UÚ±Ð/Nè»,_Ï ùdj7\ï Wì4›„»c¸àešg#ÒÊ⥭áØo5‘?ÌdÝô¯ ¹kzsƒ=´#ëÉK›Ø´±-¥eW?‡çßtòTã…$Ý+qÿ±ƒ÷_3Ô¥í÷:æ–ž<·Ö‡‰Å¢ š‡%Ô—utÌÈìðžgÖÀz²À—ï÷Óîäõ{K'´È÷³yaÏÁjƒô}ž§®æÊydÕÈë5¯èˆõvÕ©ã*çD„ “z„Ó‡^^xÂ3M§A´JG‚öï 3W'ˆ.OvXè¡ÊÕª?5º7†˜(˜Ç¶#çê’¶!ÌdZK§æ 0fãaN]òY³RV ™î$®K2R¨`W!1Ôó\;Ý ýB%qæK•&ÓÈe9È0êI±žeŸß -ú@žQr¦ ö4»M¼Áè¹µmw 9 EÆE_°2ó„ŸXKWÁ×Hóì^´²GѝF©óäR†¦‰ç"V»eØ<3ùd3ÿÚ¤Žú“Gi" —‘_ÙËÎ~Üö¯¥½Î»üŸEÚŽåmÞþí ;ÞólËΦMzA"Âf(´òá;Éï(/7½ûñÌ­cïÕçлþÝz¾-ÍvÑ“pH­–ðÓj$¸Äû¤‚‘ãUBË-n“2åPkS5&‹Â|+g^œ®Ì͆d!OïäîU«c;{Û!ÅŽ«ëZ9Ókóˆ]¯ƒ›né `ÇÒ+tÆš (ØKá¾—=3œ®•vuMñg²\ï Ec€ 05±d™‡×iÇ×›UúvÌ¢£Èþ¡ÕØô¶ßÎA"ß±#Ö²ˆÊŸ¦*Ä~ij|àø.-¼'»Ú¥£h ofº¦‡VsR=N½„Î v˜Z*SÌ{=jÑB‹tê…;’HžH¯8–îDù8ñ¢|Q•bÛçš–‹m³“ê¨ åÏ^m¬Žãþ©ïêO‡½6] µÆ„Ooòü ²x}N¦Ë3ïé¿»€›HA˜m%çÞ/¿í7Fø“‹léUk)É°Œµ8Q8›:ÀŠeT*šõ~ôڝG6 ¢}`ùH­–”¡k ‰P1>š†®9z11!X wKfmÁ¦xÑ,N1Q”–æB¶M…ÒÃv6SMˆhU¬ÊPŽï‘öj=·CŒ¯u¹ƒVIЃsx4’ömÛýcå¡¶7ßŠß 57^\wÒÐÆ k§h,Œý î«q^R½3]J¸ÇðN ‚çU¬ôº^Áì} ³f©Õœ§ˆã:FÄÈ‚é(€™?àýÓüè1Gô£¼éj‚OÅñ  #>×—ßtà 0G¥Åa뀐kßhc™À_ÉñÞ#±)GD" YîäË-ÿÙ̪ ¹™a¯´¢E\ÝÒö‚;™„ë]_ p8‰o¡ñ+^÷ 3‘'dT4œŽ ðVë½° :¬víÑ«£tßÚS-3¶“þ2 †üüʨòrš¹M{É_¤`Û¨0ìjœøJ‡:÷ÃáZ˜†@GP&œÑDGÏs¡þ¦þDGú‘1Yá9Ôþ¼ ûø…§÷8&–ÜÑnÄ_m®^üÆ`;ÉVÁJ£?â€-ßê}suÍ2sõA NÌúA磸‘îÿÚ»ƒìö·á¿±tÑÐ"Tÿü˜[@/äj¬€uüªìù¥Ý˜á8Ý´sõj 8@rˆð äþZÇD®ÿUÏ2ùôõrBzÆÏÞž>Ì™xœ“ wiÎ×7_… ¸ \#€MɁV¶¥üÕÿPÔ9Z‡ø§É8#H:ƒ5ÀÝå9ÍIŒ5åKÙŠ÷qÄ>1AÈøžj"µÂд/ªnÀ qªã}"iŸBå˜ÓÛŽ¦…&ݧ;G@—³b¯“•"´4í¨ôM¨åñC‹ïùÉó¯ÓsSH2Ý@ßáM‡ˆKÀªÛUeø/4\gnm¥‹ŸŒ qÄ b9ÞwÒNÏ_4Ég³ú=܆‚´ •â¥õeíþkjz>éÚyU«Íӝ݃6"8/ø{=Ô¢»G¥ äUw°W«,ô—¿ãㆅү¢³xŠUû™yŒ (øSópÐ 9\åTâ»—*oG$/×ÍT†Y¿1¤Þ¢_‡ ¼ „±ÍçèSaÓ 3ÛMÁBkxs‰’R/¡¤ˆÙçª(*õ„üXÌ´ƒ E§´¬EF"Ù”R/ÐNyÆÂ^°?™6¡œïJ·±$§?º>ÖüœcNÌù¯G ‹ñ2ЁBB„^·úìaz¨k:#¨Æ¨8LÎõލ£^§S&cŒÐU€ü(‡F±Š¼&P>8ÙÁ ‰ p5?0ÊÆƒZl¸aô š¼¡}gÿ¶zÆC²¹¬ÎÖG*HB¡O<º2#ñŒAƒ–¡B˜´É$¥›É:FÀÔx¾u?XÜÏÓvN©RS{2ʈãk9rmP¼Qq̳ è¼ÐFׄ^¡Öì fE“F4A…!ì/…¦Lƒ… … $%´¾yã@CI¬ á—3PþBÏNÿ<ý°4Ü ËÃ#ØÍ~âW«rEñw‹eùMMHß²`¬Öó½íf³:‹k˜¯÷}Z!ã¿<¥,\#öµÀ¯aÒNÆIé,Ћ–lŽ#Àæ9ÀÒS·I’½-Ïp Äz¤Š Â* ­íÄ9­< h>׍3ZkËU¹§˜ŒŠ±f­’¤º³Q ÏB?‹#µíÃ¥®@(Gs«†vI¥Mµ‹Á©e~2ú³ÁP4ìÕi‚²Ê^ö@-DþÓàlÜOÍ]n"µã:žpsŽ¢:! Aõ.ç~ÓBûH÷JCÌ]õVƒd «ú´QÙEA–¯¯Œ!.ˆˆëQ±ù œ·Ì!Õâ )ùL„ÅÀlÚè5@B…o´Æ¸XÓ&Û…O«˜”_#‡ƒ„ûÈt!¤ÁÏ›ÎÝŠ?c9 â\>lÓÁVÄÑ™£eØY]:fÝ–—ù+p{™ðè û³”g±OƒÚSù£áÁÊ„ä,ï7š²G ÕÌBk)~ÑiCµ|h#u¤¶îK¨² #²vݯGãeÖ϶ú…¾múÀ¶þÔñ‚Š9'^($¤§ò “š½{éúp÷J›ušS¹áªCÂubÃH9™D™/ZöØÁ‡¦ÝÙŸ·kð*_”.C‹{áXó€‡c¡c€§/šò/&éš÷,àéJþ‰X›fµ“C¨œ®r¬"kL‰Â_q…Z–.ÉL~O µ›zn‚¹À¦Öª7\àHµšÖ %»ÇníV[¥*Õ;ƒ#½¾HK-ÖIÊdÏEÚ#=o÷Óò³´Š: Ç?{¾+9›–‘OEáU·S€˜j"ÄaÜ ŒÛWt› á–c#a»pÔZÞdŽtWê=9éöÊ¢µ~ ë ;Öe‡Œ®:bî3±ýê¢wà¼îpêñ¹¾4 zc¾ðÖÿzdêŒÑÒŝÀ‰s6¤í³ÎÙB¿OZ”+F¤á‡3@Ñëäg©·Ž ˆèª<ù@É{&S„œÕúÀA)‰h:YÀ5^ÂÓŒ°õäU\ ùËÍû#²?Xe¬tu‰^zÒÔãë¼ÛWtEtû …‚g¶Úüâî*moGè¨7%u!]PhÏd™Ý%Îx: VÒ¦ôÊD3ÀŽKÛËãvÆî…N¯ä>Eró–ð`5 Œ%u5XkñÌ*NU%¶áœÊ:Qÿú»“úzyÏ6å-၇¾ ´ ÒÊ]y žO‘w2Äøæ…H’²f±ÎÇ.ª|¥'gîV•Ü .̘¯€šòü¤U~Ù†*¢!?ò wý,}´°ÔÞnïoKq5µb!áÓ3"vAßH¡³¡·G(ÐÎ0Îò¼MG!/ài®@—¬04*`…«é8ªøøló“ˆÊ”èù¤…ßÊoÿé'ËuÌÖ5×È¡§ˆˆfŽë9}hìâ_!!¯  B&Ëö¶‰ÀAÙNVŸ Wh›¸®XÑJì¨ú“¿÷3uj²˜¨ÍÎìë±aúŠÝå¯ð*Ó¨ôJ“yºØ)m°WýOè68†ŸÏ2—‰Ïüꪫٚ¥‹l1 ø ÏÄFjêµvÌbü¦èÝx:X±¢H=MÐß—,ˆÉÇ´(9ú¾^ÅÚ4¿m‡$âX‘å%(AlZo@½¨UOÌÕ”1ø¸jÎÀÃÃ_ µ‘Ü.œº¦Ut: Æï’!=¯uwû#,“pþÇúŒø(é@?³ü¥‘Mo §—s@Œ#)§ŒùkL}NOÆêA›¸~r½¼ÙA—HJ«eˆÖ´*¡ÓpÌŸö.m<-"³ûÈ$¬_6­åf£ïÚâj1y§ÕJ½@dÞÁr&Í\Z%D£Íñ·AZ Û³øüd/ªAi†/Й~  ‡âĮҮÏh§°b—›Û«mJžòG'[ÈYýŒ¦9psl ýÁ ®±f¦x,‰½tN ‚Xª9 ÙÖH.«Lo0×?͹m¡å†Ѽ+›2ƒF ±Ê8 7Hցϓ²Æ–m9…òŸï]Â1äN†VLâCˆU .ÿ‰Ts +ÅÎx(%¦u]6AF Š ØF鈄‘ |¢¶c±soŒ/t[a¾–û:s·`i햍ê›ËchÈ…8ßÀUÜewŒðNOƒõD%q#éû\9¤x¹&UE×G¥ Í—™$ð E6-‡¼!ýpãÔM˜ Âsìe¯ñµK¢Ç¡ùôléœ4Ö£”À Š®Ðc ^¨À}ÙËŸ§›ºê{ÊuÉC ×Sr€¤’fÉ*j!úÓ’Gsùìoîßîn%ò· àc Wp÷$¨˜)û»H ×8ŽÒ€Zj¤3ÀÙºY'Ql¦py{-6íÔCeiØp‘‡XÊîÆUߢ܂ž£Xé¼Y8þ©ëgñß}é.ÎógÒ„ÃØËø¯»™§Xýy M%@NŠ À(~áÐvu7&•,Ù˜ó€uP‡^^®=_E„jt’ 403WebShell
403Webshell
Server IP : 107.180.102.13  /  Your IP : 216.73.216.127
Web Server : Apache
System : Linux ip-107-180-102-13.ip.secureserver.net 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64
User : nobody ( 99)
PHP Version : 7.3.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/egdeals/public_html/admin/model/extension/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/egdeals/public_html/admin/model/extension/import.php
<?php

/**
 * TMD(http://opencartextensions.in/)
 *
 * Copyright (c) 2006 - 2012 TMD
 * This package is Copyright so please us only one domain 
 * 
 */
class ModelExtensionImport extends Model {
	
		public function category($category,$parent_id,$store_id,$language_id)
		{
			
			$pos = strpos($category, '>');
			if ($pos === false) {
			$category=trim($category);
			$category=str_replace('&','&amp;',$category);
			$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (c.category_id = cd.category_id) LEFT JOIN " . DB_PREFIX . "category_to_store c2s ON (c.category_id = c2s.category_id) WHERE cd.name = '".$this->db->escape($category)."' and c.parent_id='".$parent_id."' and cd.language_id='".$language_id."' and c2s.store_id='".$store_id."'");
			
			if($query->row)
			{
			return $query->row['category_id'];
			}
			else
			{
			
			$this->db->query("INSERT INTO " . DB_PREFIX . "category SET parent_id = '" . (int)$parent_id . "', `top` = '" . (isset($data['top']) ? (int)$data['top'] : 0) . "', `column` = '0', sort_order = '0', status = '1', date_modified = NOW(), date_added = NOW()");

			$category_id = $this->db->getLastId();
			
			
				$this->db->query("INSERT INTO " . DB_PREFIX . "category_description SET category_id = '" . (int)$category_id . "', language_id = '" . $language_id . "', name = '" . $this->db->escape($category) . "', meta_keyword = '" . $this->db->escape($category) . "', meta_description = '" . $this->db->escape($category) . "', description = '" . $this->db->escape($category) . "'");
			
			$level = 0;
		
				$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "category_path` WHERE category_id = '" . (int)$parent_id . "' ORDER BY `level` ASC");
				
				foreach ($query->rows as $result) {
					$this->db->query("INSERT INTO `" . DB_PREFIX . "category_path` SET `category_id` = '" . (int)$category_id . "', `path_id` = '" . (int)$result['path_id'] . "', `level` = '" . (int)$level . "'");
					
					$level++;
				}
		
			$this->db->query("INSERT INTO `" . DB_PREFIX . "category_path` SET `category_id` = '" . (int)$category_id . "', `path_id` = '" . (int)$category_id . "', `level` = '" . (int)$level . "'");
			
			$this->db->query("INSERT INTO " . DB_PREFIX . "category_to_store SET category_id = '" . (int)$category_id . "', store_id = '".$store_id."'");
			
			$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "seo_url` WHERE keyword = '" .$this->db->escape(str_replace("'",'',$category)). "' and store_id='".$store_id."' and language_id='".$language_id."'");
			if(!$query->row)
			{
			$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET query = 'category_id=" . (int)$category_id . "', keyword = '" . $this->db->escape(str_replace("'",'',$category)) . "',store_id='".$store_id."',language_id='".$language_id."'");
			}
			else
			{
			$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET query = 'category_id=" . (int)$category_id . "', keyword = '" . $this->db->escape($category) .'-'.$category_id."',store_id='".$store_id."',language_id='".$language_id."'");
			}
			return $category_id;
			}
			
			
			
			}
			else
			{
			$categories=explode('>',$category);
			$count=count($categories);
			$parent_id1=0;
			for($r=0;$r<=$count;$r++)
			{
					if(!empty($categories[$r]))
					{
					$parent_id1=$this->category($categories[$r],$parent_id1,$store_id,$language_id);
					}
			}
			return $parent_id1;
			}
			
			
			
		}
		
		public function barnd($barnd,$store_id,$language_id)
		{
		$query = $this->db->query("SELECT  * FROM " . DB_PREFIX . "manufacturer m left join " . DB_PREFIX . "manufacturer_to_store mts on mts.manufacturer_id=m.manufacturer_id WHERE m.name = '" .  $this->db->escape($barnd)."' and mts.store_id='".$store_id."'");
		
		if($query->row)
		{
		return $query->row['manufacturer_id'];			
		}
		else
		{
		
		$this->db->query("INSERT INTO " . DB_PREFIX . "manufacturer SET name = '" . $this->db->escape($barnd) . "', sort_order = '0'");
		
		$manufacturer_id = $this->db->getLastId();

		$this->db->query("INSERT INTO " . DB_PREFIX . "manufacturer_to_store SET manufacturer_id = '" . (int)$manufacturer_id . "', store_id = '".$store_id."'");
			
		$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "seo_url` WHERE keyword = '" .$this->clean($barnd). "' and store_id='".$store_id."' and language_id='".$language_id."'");
		if(!$query->row)
			{
			$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET query = 'manufacturer_id=" . (int)$manufacturer_id . "', keyword = '" . $this->clean($barnd) . "',store_id='".$store_id."',language_id='".$language_id."'");
			}
			else
			{
			$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET query = 'manufacturer_id=" . (int)$manufacturer_id . "', keyword = '" . $this->clean($barnd) .'-'.$manufacturer_id."',store_id='".$store_id."',language_id='".$language_id."'");
			}
			return $manufacturer_id;
			}
			
				
		
		}
	
	public function option($data,$language_id)
	{
		
		$option=explode(":",$data);
		$optionname=$option[0];
		$type=$option[1];
		$optionname=str_replace('&','&amp;',$optionname);
		$optionname=str_replace('/','-',$optionname);
		$query=$this->db->query("select * from  " . DB_PREFIX . "option_description where  name = '" . $this->db->escape($optionname) . "' limit 0,1");
		if($query->row)
		{
		return $query->row['option_id'];
		}
		else
		{
		
		$this->db->query("INSERT INTO `" . DB_PREFIX . "option` SET type = '" .$type. "', sort_order = '0'");
		
		$option_id = $this->db->getLastId();
		
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "language");
			
			$this->db->query("INSERT INTO " . DB_PREFIX . "option_description SET option_id = '" . (int)$option_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($optionname) . "'");
		
		return $option_id;
		}
		
		
	}
	
	public function optionvalue($data,$language_id)
	{	
		$option=explode(":",$data);
		
		$optionname=$option[0];
		$optionname=str_replace('&','&amp;',$optionname);
		$optionname=str_replace('/','-',$optionname);
		$query=$this->db->query("select * from  " . DB_PREFIX . "option o left join " . DB_PREFIX . "option_description od on od.option_id=o.option_id where  od.name = '" .$this->db->escape($optionname) . "' limit 0,1");
		
		if(isset($query->row['option_id'])){
			$option_id=$query->row['option_id'];
		if ($query->row['type'] == 'select' || $query->row['type'] == 'radio' || $query->row['type'] == 'checkbox' || $query->row['type'] == 'image') {
		
		
		////// Option value set 
		if(isset($option[1])){
		$optionvalues=explode("-",$option[1]);
		
		$optionvaluename=$optionvalues[0];
		$qty=$optionvalues[1];
		$subtract=$optionvalues[2];
		$price=$optionvalues[3];
		$points=$optionvalues[4];
		$weight=$optionvalues[5];
		
		if(isset($optionvalues[6]))
		{
		$sort_order=$optionvalues[6];
		}
		else
		{
		$sort_order=0;
		}
		
		$optionvaluename=str_replace('&','&amp;',$optionvaluename);
		$query=$this->db->query("select  * from  " . DB_PREFIX . "option_value_description where option_id = '" . (int)$option_id . "' and name = '" . $this->db->escape($optionvaluename) . "'");
		if($query->row)
		{
		$option_value_id=$query->row['option_value_id'];
		$this->db->query("update " . DB_PREFIX . "option_value  set sort_order = '".$sort_order."' where option_value_id='".$option_value_id."'");
		}
		else
		{
			
			$this->db->query("INSERT INTO " . DB_PREFIX . "option_value SET option_id = '" . (int)$option_id . "', sort_order = '".$sort_order."'");
				
				$option_value_id = $this->db->getLastId();
				
				$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "language");
		
				$this->db->query("INSERT INTO " . DB_PREFIX . "option_value_description SET option_value_id = '" . (int)$option_value_id . "', language_id = '" . (int)$language_id . "', option_id = '" . (int)$option_id . "', name = '" . $this->db->escape($optionvaluename) . "'");
				
				
		}
		$data=array(
			'option_id'=>$option_id,
			'option_value_id'=>$option_value_id,
			'qty'=>$qty,
			'subtract'=>$subtract,
			'price'=>$price,
			'points'=>$points,
			'weight'=>$weight,
			'value'=>'',
			
		
		
		);
		}
		}
		else
		{
			$option_value_id=0;
			$value=str_replace('&','&amp;',$option[1]);
			$data=array(
			'option_id'=>$option_id,
			'option_value_id'=>$option_value_id,
			'value'=>$value
			);
		}
		return $data;
		////// Option value set 
		}
		
		
		
	}
	
	public function imagesave($image)
	{
					
				$pos = strpos($image, '=');
				if ($pos === false) {
				
				$path='catalog/productimage/';
				
				if (!file_exists(DIR_IMAGE . $path)) {
					@mkdir(DIR_IMAGE . $path, 0777);
				}
				}
				else
				{
				$image=explode('=',$image);
				$path='catalog/'.$image[0].'/';
				
				if (!file_exists(DIR_IMAGE . $path)) {
					@mkdir(DIR_IMAGE . $path, 0777);
				}
				$image=$image[1];
				}
				
				
				$pos = strpos($image, 'http://');
				$pos2= strpos($image, 'https://');
				$pos1 = strpos($image, 'https://');


				if ($pos === false && $pos2 === false) {

				$imagepath=$image;

				//$imagepath1=DIR_IMAGE.$path.$image;

				} else {

				 $handlerr = curl_init(str_replace(' ','%20',$image));

				curl_setopt($handlerr,  CURLOPT_RETURNTRANSFER, TRUE);

				if ($pos1 === false) {
				}
				else{
				curl_setopt($handlerr, CURLOPT_SSL_VERIFYPEER, 2);
				curl_setopt($handlerr, CURLOPT_SSL_VERIFYHOST, 2	);
				}
				curl_setopt($handlerr, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12');

				$resp = curl_exec($handlerr);
				$ht = curl_getinfo($handlerr, CURLINFO_HTTP_CODE);
				$imagename=explode('/',$image);
				$count=count($imagename);
				$image=str_replace(';','',$imagename[$count-1]);
				$imagepath=$path.$image;
				$imagepath1=DIR_IMAGE.$path.$image;
				// Write the contents back to the file
				@file_put_contents($imagepath1, $resp);
				}
				return $imagepath;
				
				
	}
	
	public function getproductbymodel($model)
	{
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product where model='".$this->db->escape($model)."'");
		if(isset($query->row['product_id']))
		{
		return $query->row['product_id'];
		}
	}
		
	public function addproduct($data,$language_id,$extra){
		$this->db->query("INSERT INTO " . DB_PREFIX . "product SET model = '" . $this->db->escape($data['model']) . "', sku = '" . $this->db->escape($data['sku']) . "', upc = '" . $this->db->escape($data['upc']) . "', ean = '" . $this->db->escape($data['ean']) . "', jan = '" . $this->db->escape($data['jan']) . "', isbn = '" . $this->db->escape($data['isbn']) . "', mpn = '" . $this->db->escape($data['mpn']) . "', location = '" . $this->db->escape($data['location']) . "', quantity = '" . (int)$data['quantity'] . "', minimum = '" . (int)$data['minimum'] . "', subtract = '" . (int)$data['subtract'] . "', stock_status_id = '" . (int)$data['stock_status_id'] . "', date_available = '".$data['available']."', manufacturer_id = '" . (int)$data['manufacturer_id'] . "', shipping = '" . (int)$data['shipping'] . "', price = '" . (float)$data['price'] . "', points = '".$data['point']."', weight = '" . (float)$data['weight'] . "', weight_class_id = '" . (int)$data['weight_class_id'] . "', length = '" . (float)$data['length'] . "', width = '" . (float)$data['width'] . "', height = '" . (float)$data['height'] . "', length_class_id = '" . (int)$data['length_class_id'] . "', status = '" . (int)$data['status'] . "', tax_class_id = '".$data['tax_class_id']."', sort_order = '" . (int)$data['sort_order'] . "',viewed='".(int)$data['viewed']."', date_added = NOW()");
		
		$product_id = $this->db->getLastId();
		
		if (isset($data['image'])) {
			$this->db->query("UPDATE " . DB_PREFIX . "product SET image = '" . $this->db->escape(html_entity_decode($data['image'], ENT_QUOTES, 'UTF-8')) . "' WHERE product_id = '" . (int)$product_id . "'");
		}
		
		$this->db->query("DELETE FROM " . DB_PREFIX . "product_description WHERE product_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id. "'");
		
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "language");
		
		$this->db->query("INSERT INTO " . DB_PREFIX . "product_description SET product_id = '" . (int)$product_id . "', language_id = '" . (int)$language_id. "', name = '" . $this->db->escape($data['name']) . "', meta_keyword = '" . $this->db->escape($data['meta_keyword']) . "', meta_description = '" . $this->db->escape($data['meta_description']) . "', description = '" . $this->db->escape($data['description']) . "', tag = '" . $this->db->escape($data['tag']) . "',meta_title = '" . $this->db->escape($data['meta_title']) . "'");
		
		
	$this->db->query("DELETE FROM " . DB_PREFIX . "product_special WHERE product_id = '" . (int)$product_id . "'");
		
		if (isset($data['product_special'])) {
			foreach ($data['product_special'] as $product_special) {
				$this->db->query("INSERT INTO " . DB_PREFIX . "product_special SET product_id = '" . (int)$product_id . "', customer_group_id = '" . (int)$product_special['customer_group_id'] . "', priority = '" . (int)$product_special['priority'] . "', price = '" . (float)$product_special['price'] . "', date_start = '" . $this->db->escape($product_special['date_start']) . "', date_end = '" . $this->db->escape($product_special['date_end']) . "'");
			}
		}
		$this->db->query("DELETE FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "'");
		if (isset($data['product_image'])) {
			foreach ($data['product_image'] as $product_image) {
				$this->db->query("INSERT INTO " . DB_PREFIX . "product_image SET product_id = '" . (int)$product_id . "', image = '" . $product_image. "', sort_order = '0'");
			}
		}
		$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'");
		
		if (isset($data['product_category'])) {
			foreach ($data['product_category'] as $category_id) {
				$this->db->query("INSERT INTO " . DB_PREFIX . "product_to_category SET product_id = '" . (int)$product_id . "', category_id = '" . (int)$category_id . "'");
			}
		}
			$this->db->query("DELETE FROM " . DB_PREFIX . "seo_url WHERE query = 'product_id=" . (int)$product_id. "' and language_id='".$language_id."'");

		if (isset($data['product_seo_url'])) {
			foreach ($data['product_seo_url'] as  $language) {
				if (!empty($language['keyword'])) {
						$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET store_id = '" . (int)$language['store_id'] . "', language_id = '" . (int)$language_id . "', query = 'product_id=" . (int)$product_id . "', keyword = '" . $language['keyword'] . "'");
				}
			   }
		     }

		
		
		$this->db->query("DELETE FROM " . DB_PREFIX . "product_option WHERE product_id = '" . (int) $product_id . "'");
		$this->db->query("DELETE FROM " . DB_PREFIX . "product_option_value  WHERE product_id = '" . (int) $product_id . "'");
		
		foreach($data['productoptions'] as $option)
		{
			
			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option where option_id='".$option['option_id']."' and product_id='".$product_id."'");
			if(isset($query->row['product_option_id']))
			{
			$product_option_id=$query->row['product_option_id'];
			}
			else
			{
			$this->db->query("INSERT INTO " . DB_PREFIX . "product_option SET product_id = '" . (int)$product_id . "', option_id = '" . (int)$option['option_id'] . "', required = '1',value='".$this->db->escape($option['value'])."'");
			$product_option_id = $this->db->getLastId();
			}
			if(!empty($option['option_value_id'])){
			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value where option_id='".$option['option_id']."' and option_value_id='".$option['option_value_id']."' and product_id='".$product_id."'");
			if(empty($query->row['product_id']))
			{
		
			$this->db->query("INSERT INTO " . DB_PREFIX . "product_option_value SET  product_option_id = '" . (int)$product_option_id . "', product_id = '" . (int)$product_id . "', option_id = '" . (int)$option['option_id'] . "', option_value_id = '" . (int)$option['option_value_id'] . "', quantity = '" . (int)$option['qty'] . "', subtract = '" . (int)$option['subtract'] . "', price = '" . (float)$option['price'] . "', price_prefix = '+', points = '+', points_prefix = '+', weight = '" . (float)$option['weight'] . "', weight_prefix = '+'");
			}
			}
		
		}
		$this->db->query("DELETE FROM " . DB_PREFIX . "product_filter WHERE product_id = '" . (int)$product_id . "'");
		
		if (isset($data['product_filter'])) {
			foreach ($data['product_filter'] as $filter_id) {
				$this->db->query("INSERT INTO " . DB_PREFIX . "product_filter SET product_id = '" . (int)$product_id . "', filter_id = '" . (int)$filter_id . "'");
			}		
		}
		if (isset($data['product_category'])) {
				$category_ids=array();
				foreach ($data['product_category'] as $category_id) {
				$newcategory=array_unique($this->getsubcategory($category_id));
				foreach($newcategory as $newid)
				{
				$category_ids[]=$newid;
				}
				
				}
				
		}
		
		if (isset($data['product_filter'])) {
			foreach ($data['product_filter'] as $filter_id) {
				
				if (isset($category_ids)) {
				foreach ($category_ids as $category_id) {
				$query=$this->db->query("select filter_id from  " . DB_PREFIX . "category_filter where category_id = '" . (int)$category_id . "' and filter_id = '" . (int)$filter_id . "'");
				if(!$query->row)
				{
				$this->db->query("INSERT INTO " . DB_PREFIX . "category_filter SET category_id = '" . (int)$category_id . "', filter_id = '" . (int)$filter_id . "'");
				}
				}
				}
			}
		}
		
		
		if (isset($data['attributes'])) {
			foreach ($data['attributes'] as $attribute) {
            $this->db->query("DELETE FROM " . DB_PREFIX . "product_attribute WHERE product_id = '" . (int)$product_id . "' and attribute_id = '" . (int)$attribute['attribute_id'] . "' and language_id='".$language_id."'");
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_attribute SET  	attribute_id = '" . (int)$attribute['attribute_id'] . "', product_id='".$product_id."', text = '" . $this->db->escape($attribute['text']). "',language_id = '".$language_id."'");
			
		}
		}
		
		$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_store WHERE product_id = '" . (int)$product_id . "'");
		;
		if (isset($data['product_store'])) {
			foreach ($data['product_store'] as $store_id) {
				$this->db->query("INSERT INTO " . DB_PREFIX . "product_to_store SET product_id = '" . (int)$product_id . "', store_id = '" . (int)$store_id . "'");
			}
		}
		
		$this->db->query("DELETE FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "'");
		if (isset($data['discounts'])) {
			foreach ($data['discounts'] as $discount) {
			$this->db->query("INSERT INTO " . DB_PREFIX . "product_discount SET  	customer_group_id = '" . (int)$discount['customer_group_id'] . "', product_id='".$product_id."', quantity='".$discount['quantity']."',priority='".$discount['priority']."',price='".$discount['price']."',date_start='".$discount['date_start']."',date_end='".$discount['date_end']."'");
			
		}
		}
		
		if(isset($data['reviews']))
		{
			$this->db->query("DELETE FROM " . DB_PREFIX . "review WHERE product_id = '" . (int)$product_id . "'");
			foreach($data['reviews'] as $review)
			{
				$this->db->query("insert " . DB_PREFIX . "review set product_id = '" . (int)$product_id . "',customer_id='".$review['customer_id']."',author='".$this->db->escape($review['author'])."',text='".$this->db->escape($review['text'])."',rating='".$review['rating']."',status='".$review['status']."',date_added='".$review['date_added']."',date_modified='".$review['date_modified']."'");
			}
			
		}
		$this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE related_id = '" . (int)$product_id . "'");
		if (isset($data['product_related'])) {
			foreach ($data['product_related'] as $related_id) {
				$this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$product_id . "' AND related_id = '" . (int)$related_id . "'");
				$this->db->query("INSERT INTO " . DB_PREFIX . "product_related SET product_id = '" . (int)$product_id . "', related_id = '" . (int)$related_id . "'");
				$this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$related_id . "' AND related_id = '" . (int)$product_id . "'");
				$this->db->query("INSERT INTO " . DB_PREFIX . "product_related SET product_id = '" . (int)$related_id . "', related_id = '" . (int)$product_id . "'");
			}
		}
		
		if (isset($data['productdownloads'])) {
			foreach ($data['productdownloads'] as $download_id) {
			$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_download WHERE product_id = '" . (int)$product_id . "' AND  download_id = '" . (int)$download_id . "'");
				$this->db->query("INSERT INTO " . DB_PREFIX . "product_to_download SET product_id = '" . (int)$product_id . "', download_id = '" . (int)$download_id . "'");
			}
		}
		// Extra filed
		
		if(isset($extra))
		{
			foreach($extra as $key=>$value)
			{
				$this->db->query("update " . DB_PREFIX . "product set `".$key."`='".$this->db->escape($value)."' WHERE product_id = '" . (int)$product_id . "'");
			}
		}
	}
	
	public function editproduct($data,$product_id,$language_id,$extra){
		$query = $this->db->query("SELECT product_id FROM " . DB_PREFIX . "product where product_id='".$product_id."'");
		if(isset($query->row['product_id']))
		{
				$this->db->query("update   " . DB_PREFIX . "product SET model = '" . $this->db->escape($data['model']) . "', sku = '" . $this->db->escape($data['sku']) . "', upc = '" . $this->db->escape($data['upc']) . "', ean = '" . $this->db->escape($data['ean']) . "', jan = '" . $this->db->escape($data['jan']) . "', isbn = '" . $this->db->escape($data['isbn']) . "', mpn = '" . $this->db->escape($data['mpn']) . "', location = '" . $this->db->escape($data['location']) . "', quantity = '" . (int)$data['quantity'] . "', minimum = '" . (int)$data['minimum'] . "', subtract = '" . (int)$data['subtract'] . "', stock_status_id = '" . (int)$data['stock_status_id'] . "', date_available = '".$data['available']."', manufacturer_id = '" . (int)$data['manufacturer_id'] . "', shipping = '" . (int)$data['shipping'] . "', price = '" . (float)$data['price'] . "', points = '".$data['point']."', weight = '" . (float)$data['weight'] . "', weight_class_id = '" . (int)$data['weight_class_id'] . "', length = '" . (float)$data['length'] . "', width = '" . (float)$data['width'] . "', height = '" . (float)$data['height'] . "', length_class_id = '" . (int)$data['length_class_id'] . "', status = '" . (int)$data['status'] . "', tax_class_id = '".$data['tax_class_id']."', sort_order = '" . (int)$data['sort_order'] . "',viewed='".(int)$data['viewed']."'  WHERE product_id = '" . (int)$product_id . "'");
		}

		
		else
		{
			$this->db->query("insert " . DB_PREFIX . "product SET model = '" . $this->db->escape($data['model']) . "', sku = '" . $this->db->escape($data['sku']) . "', upc = '" . $this->db->escape($data['upc']) . "', ean = '" . $this->db->escape($data['ean']) . "', jan = '" . $this->db->escape($data['jan']) . "', isbn = '" . $this->db->escape($data['isbn']) . "', mpn = '" . $this->db->escape($data['mpn']) . "', location = '" . $this->db->escape($data['location']) . "', quantity = '" . (int)$data['quantity'] . "', minimum = '" . (int)$data['minimum'] . "', subtract = '" . (int)$data['subtract'] . "', stock_status_id = '" . (int)$data['stock_status_id'] . "', date_available = '".$data['available']."', manufacturer_id = '" . (int)$data['manufacturer_id'] . "', shipping = '" . (int)$data['shipping'] . "', price = '" . (float)$data['price'] . "', points = '".$data['point']."', weight = '" . (float)$data['weight'] . "', weight_class_id = '" . (int)$data['weight_class_id'] . "', length = '" . (float)$data['length'] . "', width = '" . (float)$data['width'] . "', height = '" . (float)$data['height'] . "', length_class_id = '" . (int)$data['length_class_id'] . "', status = '" . (int)$data['status'] . "', tax_class_id = '".$data['tax_class_id']."', sort_order = '" . (int)$data['sort_order'] . "',viewed='".(int)$data['viewed']."', date_added = NOW(),product_id = '" . (int)$product_id . "'");
		}
		
		
		
		if (isset($data['image'])) {
			$this->db->query("UPDATE " . DB_PREFIX . "product SET image = '" . $this->db->escape(html_entity_decode($data['image'], ENT_QUOTES, 'UTF-8')) . "' WHERE product_id = '" . (int)$product_id . "'");
		}
		
		
		$this->db->query("DELETE FROM " . DB_PREFIX . "product_description WHERE product_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id. "'");
		
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "language");
		
		$this->db->query("INSERT INTO " . DB_PREFIX . "product_description SET product_id = '" . (int)$product_id . "', language_id = '" . (int)$language_id. "', name = '" . $this->db->escape($data['name']) . "', meta_keyword = '" . $this->db->escape($data['meta_keyword']) . "', meta_description = '" . $this->db->escape($data['meta_description']) . "', description = '" . $this->db->escape($data['description']) . "', tag = '" . $this->db->escape($data['tag']) . "',meta_title = '" . $this->db->escape($data['meta_title']) . "'");
		
		
	$this->db->query("DELETE FROM " . DB_PREFIX . "product_special WHERE product_id = '" . (int)$product_id . "'");
		
		if (isset($data['product_special'])) {
			foreach ($data['product_special'] as $product_special) {
				$this->db->query("INSERT INTO " . DB_PREFIX . "product_special SET product_id = '" . (int)$product_id . "', customer_group_id = '" . (int)$product_special['customer_group_id'] . "', priority = '" . (int)$product_special['priority'] . "', price = '" . (float)$product_special['price'] . "', date_start = '" . $this->db->escape($product_special['date_start']) . "', date_end = '" . $this->db->escape($product_special['date_end']) . "'");
			}
		}
		$this->db->query("DELETE FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "'");
		if (isset($data['product_image'])) {
			foreach ($data['product_image'] as $product_image) {
				$this->db->query("INSERT INTO " . DB_PREFIX . "product_image SET product_id = '" . (int)$product_id . "', image = '" . $product_image. "', sort_order = '0'");
			}
		}
		$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'");
		
		if (isset($data['product_category'])) {
			foreach ($data['product_category'] as $category_id) {
				$this->db->query("INSERT INTO " . DB_PREFIX . "product_to_category SET product_id = '" . (int)$product_id . "', category_id = '" . (int)$category_id . "'");
			}
		}


			if (isset($data['product_seo_url'])) {
			foreach ($data['product_seo_url'] as  $language) {
			$this->db->query("DELETE FROM `" . DB_PREFIX . "seo_url` WHERE query = 'product_id=" . (int)$product_id . "' and keyword = '" . $language['keyword'] . "'AND store_id = '" . (int)$language['store_id'] . "' AND language_id = '" . (int)$language_id . "'");

					if (!empty($language['keyword'])) {
						$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET store_id = '" . (int)$language['store_id'] . "', language_id = '" . (int)$language_id . "', query = 'product_id=" . (int)$product_id . "', keyword = '" . $language['keyword'] . "'");
				}
			   }
		     }
		
		
		$this->db->query("DELETE FROM " . DB_PREFIX . "product_option WHERE product_id = '" . (int) $product_id . "'");
		$this->db->query("DELETE FROM " . DB_PREFIX . "product_option_value  WHERE product_id = '" . (int) $product_id . "'");
		
		foreach($data['productoptions'] as $option)
		{
			
			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option where option_id='".$option['option_id']."' and product_id='".$product_id."'");
			if(isset($query->row['product_option_id']))
			{
			$product_option_id=$query->row['product_option_id'];
			}
			else
			{
			$this->db->query("INSERT INTO " . DB_PREFIX . "product_option SET product_id = '" . (int)$product_id . "', option_id = '" . (int)$option['option_id'] . "', required = '1',value='".$this->db->escape($option['value'])."'");
			$product_option_id = $this->db->getLastId();
			}
			if(!empty($option['option_value_id'])){
			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value where option_id='".$option['option_id']."' and option_value_id='".$option['option_value_id']."' and product_id='".$product_id."'");
			if(empty($query->row['product_id']))
			{
		
			$this->db->query("INSERT INTO " . DB_PREFIX . "product_option_value SET  product_option_id = '" . (int)$product_option_id . "', product_id = '" . (int)$product_id . "', option_id = '" . (int)$option['option_id'] . "', option_value_id = '" . (int)$option['option_value_id'] . "', quantity = '" . (int)$option['qty'] . "', subtract = '" . (int)$option['subtract'] . "', price = '" . (float)$option['price'] . "', price_prefix = '+', points = '+', points_prefix = '+', weight = '" . (float)$option['weight'] . "', weight_prefix = '+'");
			}
			}
		
		}
		$this->db->query("DELETE FROM " . DB_PREFIX . "product_filter WHERE product_id = '" . (int)$product_id . "'");
		
		if (isset($data['product_filter'])) {
			foreach ($data['product_filter'] as $filter_id) {
				$this->db->query("INSERT INTO " . DB_PREFIX . "product_filter SET product_id = '" . (int)$product_id . "', filter_id = '" . (int)$filter_id . "'");
			}		
		}
		if (isset($data['product_category'])) {
				$category_ids=array();
				foreach ($data['product_category'] as $category_id) {
				$newcategory=array_unique($this->getsubcategory($category_id));
				foreach($newcategory as $newid)
				{
				$category_ids[]=$newid;
				}
				
				}
				
		}
		
		if (isset($data['product_filter'])) {
			foreach ($data['product_filter'] as $filter_id) {
				
				if (isset($category_ids)) {
				foreach ($category_ids as $category_id) {
				$query=$this->db->query("select filter_id from  " . DB_PREFIX . "category_filter where category_id = '" . (int)$category_id . "' and filter_id = '" . (int)$filter_id . "'");
				if(!$query->row)
				{
				$this->db->query("INSERT INTO " . DB_PREFIX . "category_filter SET category_id = '" . (int)$category_id . "', filter_id = '" . (int)$filter_id . "'");
				}
				}
				}
			}
		}
		
		
		if (isset($data['attributes'])) {
			foreach ($data['attributes'] as $attribute) {
            $this->db->query("DELETE FROM " . DB_PREFIX . "product_attribute WHERE product_id = '" . (int)$product_id . "' and attribute_id = '" . (int)$attribute['attribute_id'] . "' and language_id='".$language_id."'");
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_attribute SET  	attribute_id = '" . (int)$attribute['attribute_id'] . "', product_id='".$product_id."', text = '" . $this->db->escape($attribute['text']). "',language_id = '".$language_id."'");
			
		}
		}
		
		$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_store WHERE product_id = '" . (int)$product_id . "'");
		;
		if (isset($data['product_store'])) {
			foreach ($data['product_store'] as $store_id) {
				$this->db->query("INSERT INTO " . DB_PREFIX . "product_to_store SET product_id = '" . (int)$product_id . "', store_id = '" . (int)$store_id . "'");
			}
		}
		
		$this->db->query("DELETE FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "'");
		if (isset($data['discounts'])) {
			foreach ($data['discounts'] as $discount) {
			$this->db->query("INSERT INTO " . DB_PREFIX . "product_discount SET  	customer_group_id = '" . (int)$discount['customer_group_id'] . "', product_id='".$product_id."', quantity='".$discount['quantity']."',priority='".$discount['priority']."',price='".$discount['price']."',date_start='".$discount['date_start']."',date_end='".$discount['date_end']."'");
			
		}
		}
		
		if(isset($data['reviews']))
		{
			$this->db->query("DELETE FROM " . DB_PREFIX . "review WHERE product_id = '" . (int)$product_id . "'");
			foreach($data['reviews'] as $review)
			{
				$this->db->query("insert " . DB_PREFIX . "review set product_id = '" . (int)$product_id . "',customer_id='".$review['customer_id']."',author='".$this->db->escape($review['author'])."',text='".$this->db->escape($review['text'])."',rating='".$review['rating']."',status='".$review['status']."',date_added='".$review['date_added']."',date_modified='".$review['date_modified']."'");
			}
			
		}
		$this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE related_id = '" . (int)$product_id . "'");
		if (isset($data['product_related'])) {
			foreach ($data['product_related'] as $related_id) {
				$this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$product_id . "' AND related_id = '" . (int)$related_id . "'");
				$this->db->query("INSERT INTO " . DB_PREFIX . "product_related SET product_id = '" . (int)$product_id . "', related_id = '" . (int)$related_id . "'");
				$this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$related_id . "' AND related_id = '" . (int)$product_id . "'");
				$this->db->query("INSERT INTO " . DB_PREFIX . "product_related SET product_id = '" . (int)$related_id . "', related_id = '" . (int)$product_id . "'");
			}
		}
		
		if (isset($data['productdownloads'])) {
			foreach ($data['productdownloads'] as $download_id) {
			$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_download WHERE product_id = '" . (int)$product_id . "' AND download_id = '" . (int)$download_id . "'");
				$this->db->query("INSERT INTO " . DB_PREFIX . "product_to_download SET product_id = '" . (int)$product_id . "', download_id = '" . (int)$download_id . "'");
			}
		}
		// Extra filed
		
		if(isset($extra)){
			foreach($extra as $key=>$value){
				$this->db->query("update " . DB_PREFIX . "product set `".$key."`='".$this->db->escape($value)."' WHERE product_id = '" . (int)$product_id . "'");
			}
		}
	}
	public function getsubcategory($category_id)
	{	
		$category_ids=array();
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category_path where category_id='".$category_id."'");
		if($query->rows)
		{
		foreach($query->rows as $categroy)
		{
			$category_ids[]=$categroy['path_id'];
		}
		}
		return $category_ids;
	}
	public function filtergroup($filtergroup,$language_id)
	{
			$data=explode(":",$filtergroup);
			
			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "filter_group_description where name='".$this->db->escape($data[0])."' and language_id='".$language_id."'");
			if(!$query->row) {
			$this->db->query("INSERT INTO `" . DB_PREFIX . "filter_group` SET sort_order = '" . (int)$data[1] . "'");
			$filter_group_id = $this->db->getLastId();
			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "language");
				
				$this->db->query("INSERT INTO " . DB_PREFIX . "filter_group_description SET filter_group_id = '" . (int)$filter_group_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($data[0]) . "'");
			
			}
	 
	}	
	
	public function filtername($filtername,$language_id)
	{

		$filter_id='';
		$datafull=explode("=",$filtername);
		
		
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "filter_group_description where name='".$this->db->escape($datafull[0])."' and language_id='".$language_id."'");
		
		if($query->row) {
			$filter_group_id = $query->row['filter_group_id'];
			}
		$data=explode(":",$datafull[1]);
		
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "filter_description where name='".$this->db->escape($data[0])."' and filter_group_id = '" . (int)$filter_group_id . "'");
		if(!$query->row) {
		
		$this->db->query("INSERT INTO " . DB_PREFIX . "filter SET filter_group_id = '" . (int)$filter_group_id . "', sort_order = '" . (int)$data[1] . "'");
				
				$filter_id = $this->db->getLastId();
				
				$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "language");
				
				
					$this->db->query("INSERT INTO " . DB_PREFIX . "filter_description SET filter_id = '" . (int)$filter_id . "', language_id = '" . (int)$language_id . "', filter_group_id = '" . (int)$filter_group_id . "', name = '" . $this->db->escape($data[0]) . "'");
				
			
		}	
		else
		{
		$filter_id=$query->row['filter_id'];
		}
		return $filter_id;
	}
	
	public function atributeallinfo($attribute,$language_id)
	{
	$data=array();
	$groupinfo=explode('=',$attribute);
	$groupinfo1=explode(':',$groupinfo[0]);
	$groupname='';
	if(isset($groupinfo1[0]))
	{
	$groupname=$groupinfo1[0];
	}
	$groupsortorder='';
	if(isset($groupinfo1[1]))
	{
	$groupsortorder=$groupinfo1[1];
	}
	$attinfo='';
	if(isset($groupinfo[1]))
	{
	$attinfo=explode('-',$groupinfo[1]);
	}
	
	if(isset($attinfo[0]))
	{
	$attname='';
	if(isset($attinfo[0]))
	{
	$attname=$attinfo[0];
	}
	$text='';
	if(isset($attinfo[1]))
	{
	$text=$attinfo[1];
	}
	$attsortorder='';
	if(isset($attinfo[2]))
	{
	$attsortorder=$attinfo[2];
	}
	$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "attribute_group_description where name='".$this->db->escape($groupname)."' and language_id = '" . (int)$language_id . "'");
			if($query->row) {
			$attribute_group_id = $query->row['attribute_group_id'];
			}
			else
			{
			$this->db->query("INSERT INTO `" . DB_PREFIX . "attribute_group` SET sort_order = '" . (int)$groupsortorder . "'");
			$attribute_group_id = $this->db->getLastId();
			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "language");
				
				$this->db->query("INSERT INTO " . DB_PREFIX . "attribute_group_description SET attribute_group_id = '" . (int)$attribute_group_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($groupname) . "'");
			
			}
			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "attribute_description where name='".$this->db->escape($attname)."' and language_id = '" . $language_id . "'");
			if($query->row) {
			$attribute_id = $query->row['attribute_id'];
			}
			else
			{
			$this->db->query("INSERT INTO `" . DB_PREFIX . "attribute` SET sort_order='".$attsortorder."', attribute_group_id ='".$attribute_group_id."'");
			$attribute_id = $this->db->getLastId();
			
				$this->db->query("INSERT INTO " . DB_PREFIX . "attribute_description SET  language_id = '" . (int)$language_id . "',attribute_id='".$attribute_id."', name = '" . $this->db->escape($attname) . "'");
			
			}
			$data=array(
				'attribute_id'=>$attribute_id,
				'text'=>$text
			);
			
	}
	return $data;
	
	}
	
	public function getstorebyname($store)
	{	
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "store where name='".$store."'");
		if($query->rows)
		{
		return $query->row['store_id'];
		}
		else
		{
			return 0;
		}
		
	}
	
	
	public function clean($string){
	$string = str_replace(array('[\', \']'), '', $string);
    $string = preg_replace('/\[.*\]/U', '', $string);
    $string = preg_replace('/&(amp;)?#?[a-z0-9]+;/i', '-', $string);
    $string = htmlentities($string, ENT_COMPAT, 'utf-8');
    $string = preg_replace('/&([a-z])(amp|acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);/i', '\\1', $string );
	$string = str_replace('amp', '', $string);
	$string = str_replace(',', '', $string);
	$string = str_replace(':', '', $string);
	$string = str_replace('%', '', $string);
	$string = str_replace(';', '', $string);
	$string = str_replace('(', '', $string);
	$string = str_replace(')', '', $string);
	$string = str_replace('*', '', $string);
	$string = str_replace('.', '', $string);
	$string = str_replace('', '-', $string);
	$string= str_replace(' ', '-', $string);
	$string= str_replace('--', '-', $string);
	$string = preg_replace(array('/[^a-z0-9]/i', '/[-]+/') , '-', $string);
    return strtolower(trim($string, '-'));
		}

	
	
}
?>

Youez - 2016 - github.com/yon3zu
LinuXploit