AdvertiseCommunity - Version 1.0.0

Version Notes

Initial release

Download this release

Release Info

Developer Michael Oxley
Extension AdvertiseCommunity
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Advertise/Account/Helper/Data.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Advertise_Account_Helper_Data extends Mage_Core_Helper_Data
4
+ {
5
+
6
+
7
+ }
app/code/community/Advertise/Account/Model/Account.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ ini_set('memory_limit', '1280M');
4
+
5
+ class Account extends Mage_Core_Model_Abstract {
6
+
7
+ public $_indexPhp = '';
8
+
9
+ protected $_filePath;
10
+ public $_limit = false;
11
+ public $_display = false;
12
+ public $_rates = false;
13
+ public $_sqlSize = 1500;
14
+
15
+
16
+ protected function _construct() {
17
+ $this->_init('advertise/account');
18
+ }
19
+
20
+ private function execPhpScript($myPattern, $product, $xml=true) {
21
+
22
+ $myPattern = str_replace('<?', utf8_encode('¤'), $myPattern);
23
+ $myPattern = str_replace('?>', utf8_encode('¤'), $myPattern);
24
+ $pattern = utf8_encode('/(¤(.[^¤]+)¤)/s');
25
+ preg_match_all($pattern, $myPattern, $matches);
26
+ if (isset($matches[1])) {
27
+
28
+ foreach ($matches[1] as $key => $script) {
29
+
30
+ if ($xml == 1) {
31
+ if (@eval($matches[2][$key] . ';'))
32
+ $myPattern = str_replace($script, eval($matches[2][$key] . ';'), $myPattern);
33
+ else
34
+ $myPattern = str_replace($script, '', $myPattern);
35
+ }
36
+ else {
37
+ if (@eval($this->unescapeStr($matches[2][$key] . ';')))
38
+ $myPattern = str_replace($script, $this->escapeStr(eval($this->unescapeStr($matches[2][$key]) . ';')), $myPattern);
39
+ else
40
+ $myPattern = str_replace($script, '', $myPattern);
41
+ }
42
+ }
43
+ }
44
+ return $myPattern;
45
+ }
46
+
47
+ public function x0b($x0b, $x0c) {$x0d = $this->_currencies;if (isset($x0d[$x0c]))return $x0b * $x0d[$x0c];else {return $x0b;}}public function x0c($x0b, $x0e, $x0f, $x10=false) {$x11 = $this->_rates; if ($x10 === false) {if (!$x0e && isset($x11[$x0f])) {if (count($x11[$x0f]) > 1) {return $x0b;} else {return $x0b * ($x11[$x0f][0]['rate'] / 100 + 1);}} else {return $x0b;}} elseif ($x10 === "0") { if ($x0e && isset($x11[$x0f])) {if (count($x11[$x0f]) > 1) {return $x0b;} else {return 100 * $x0b / (100 + ($x11[$x0f][0]['rate']));}} else {return $x0b;}} else { if (is_numeric($x10)) {if ($x0f != 0) {return $x0b * ($x10 / 100 + 1);} elseif ($x0f == 0) {return $x0b;}} else {$x10 = explode('/', $x10);$x12 = 0;$x13 = false;if (substr($x10[0], 0, 1) == "\055") {$x10[0] = substr($x10[0], 1);$x13 = true;}if ($x11[$x0f]) {foreach ($x11[$x0f] as $x14) {if ($x14['country'] == $x10[0]) {if (!isset($x10[1]) || $x14['code'] == $x10[1]) {$x12 = $x14['rate'];break;}}}if (!$x13)return $x0b * ($x12 / 100 + 1);else {return 100 * $x0b / (100 + ($x12));}} else {return $x0b;}}}}public function x0d($x15, $x16=true) {$x17 = '/(<[^>^\/]+>)([^<]*)(<\/[^>]+>)/s';preg_match_all($x17, $x15, $x18);foreach ($x18[1] as $x19 => $x1a) {$x1b = trim($x18[2][$x19]);if (empty($x1b) && !is_numeric($x1b))$x15 = str_replace($x18[0][$x19], '', $x15);else {if ($x16)$x15 = str_replace($x18[0][$x19], ($x18[1][$x19]) . '<![CDATA[' . $x1b . ']]>' . ($x18[3][$x19]), $x15);else$x15 = str_replace($x18[0][$x19], ($x18[1][$x19]) . $x1b . ($x18[3][$x19]), $x15);}}$x1c = preg_split("/\n/\163", $x15);$x1d = '';foreach ($x1c as $x1e) {(strlen(trim($x1e)) > 0) ? $x1d.=$x1e . "\n" : false;}$x15 = $x1d;return $x15;}public function x0e($x15) {if ($this->_display)return ($x15);else {if ($this->_chartset == 'ISO')return utf8_decode($x15);else {return ($x15);}}}public function x0f($x1f, $x20) {if (($x1f == "p\x61\162\x65\x6e\164" || $x1f == "\x63o\156fi\x67\x75\x72a\x62\154\145") && isset($this->configurable[$x20->getId()]))return $this->configurable[$x20->getId()];elseif (($x1f == "\x70\141r\x65n\164" || $x1f == "g\162\157\165p\145d") && isset($this->grouped[$x20->getId()]))return $this->grouped[$x20->getId()];elseif (($x1f == "parent" || $x1f == "b\165\156\144\x6ce") && isset($this->bundle[$x20->getId()]))return $this->bundle[$x20->getId()];else {return $x20;}}public function x10($x21, $x22, $x23=0) {$this->_debug = (isset($_GET['debug'])) ? true : false;$this->_limit = $x23;$x24 = $this->_indexPhp;try {$x25 = Mage::getStoreConfig("\141d\166\x65rt\x69\x73\145/\x61\x64\166e\162\x74\x69s\145\x2fact\151\166a\164\x65d", $x21);if ($x25) { $x26 = pack("\110*", Mage::getStoreConfig("\x61\x64\166e\162\x74\151s\145\x2f\x61\144\x76\x65\162\x74\x69\163\145\x2fte\155\160\154\141\164\x65", $x21)); $x27 = Mage::getStoreConfig("\141\x64ve\162\164i\x73e/\x61\x64\x76\x65\162t\x69\163\145\057\x66\x69\x6c\145\160\141\164\150", $x21); $x28 = Mage::getStoreConfig("a\x64\x76er\x74\151s\145\057\x61\144\x76\x65\x72\x74\151se\057f\x69\x6c\145\x6e\x61m\145", $x21);$x29 = Mage::getStoreConfig("\x77\145\142\x2fs\x65c\x75\162\145\x2f\x62a\163e\x5f\x75\162\x6c");$x2a = Mage::getStoreConfig("a\144v\145\x72\x74\x69\x73\x65\057a\x64\x76\x65rt\x69\163e/\154\x69ce\x6e\x73\145");$x2b = array("l" => "\154e\166e\x6e\163\150\x74e\151\156\137\x63\x6f\155p\141\x72\145\x5fst\162\151n\x67"); $x29 = preg_replace("\057\x68\164\x74\x70\x73\077\x3a\/\/\057", '', $x29);} else {Mage::throwException(sprintf('The store "%d" is not activated!', $x21));}} catch (Exception $x2c) {Mage::throwException(sprintf('The store "%d" is not activated!', $x21));}if ($this->_debug) {echo "\x3c\142\x72\076\074b\162>\x2d---\x2d\x2d--\055\055\x2d\055\040\x58\x4dL\x20\120ATT\x45\122N \055--\055-\055--\x2d\055\055\055\055\055\055\x2d\x3c\142\162>";echo htmlentities($x26) . "<br\057\x3e";echo "\x3cb\162\076\x3c\142\x72\x3e\055-\x2d\055\055\x2d\x2d\x2d----\040F\x49LE\x20\x50A\124\110\040\x2d-\x2d\055\x2d\x2d\x2d\x2d--\x2d\x2d\055\055\055\055\x3cb\162>";echo $x27 . "\x3c\142\x72\x2f>";echo "\074\x62\x72\x3e<\142\162\076-\x2d\x2d---\x2d-\x2d-\x2d\055\040\x46\x49\114ENA\115\x45\x20 \055\x2d\x2d\x2d\x2d\x2d\x2d\x2d\055\x2d\055\x2d\055\x2d\055\x2d\074\x62r>";echo $x28 . "\074b\162\057\076\074b\162\057>";}while (strlen($x29) < 10) {$x29 .= $x29;}$x2d = levenshtein($x29, $x2b["\x6c"]);$x2e = bin2hex($x29);$x2f = $x21; $x30 = Mage::getStoreConfig("\x63\x61t\141l\x6f\147/\x70\x6c\x61\x63e\x68\157\x6c\144\x65\162\057\151ma\147\145\x5f\160\x6c\141ce\150\157\x6cd\145\x72", $x2f);$x31 = Mage::getStoreConfig("\x63u\x72rency/\x6f\160\x74i\x6fn\163\057b\141s\x65", $x2f);$x32 = Mage::app()->getStore($x2f)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, false);$x33 = Mage::app()->getStore($x2f)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA, false);$x34 = Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX, $x2f);$x35 = Mage::app()->getStore($x2f)->getRootCategoryId(); $x36 = Array();$x36[] = '*'; $x37 = array('simple', 'configurable', 'bundle', 'grouped', 'virtual', 'downloadable');$x38 = array(1, 2, 3, 4);$x39 = str_split($x2e);$x3a = "";$x3b = "";$x3c = "";$x3b = ('<?xml version="1.0" encoding="utf-8" ?>' . "\n<f\x65\145\x64I\x74e\155\x73\x3e\n");$x3c = $this->x0e($x3b);$x3d = "";$x17 = '/{([a-zA-Z_0-9:]+)(\sparent|\sgrouped|\sconfigurable|\sbundle)?([^}]*)}/';preg_match_all($x17, $x26, $x18);$x3e = array();$x3f = array();foreach ($x18[1] as $x19 => $x40) {$x3e[$x19]['methodName'] = "\x67e\x74" . str_replace(' ', '', ucwords(trim($x40)) . '()');$x3e[$x19]['pattern'] = "\173" . trim($x40) . "\175";$x3e[$x19]['fullpattern'] = $x18[0][$x19];$x3e[$x19]['name'] = trim($x40);$x3e[$x19]['reference'] = trim($x18[2][$x19]);if (empty($x3e[$x19]['reference']))$x3e[$x19]['reference'] = 'self';switch ($x3e[$x19]['name']) {case 'G:IMAGE_LINK':array_push($x3f, 'image');array_push($x3f, 'small_image');array_push($x3f, 'thumbnail');break;default : array_push($x3f, $x3e[$x19]['name']);}$x3e[$x19]["\166\141\x6c\x75\x65"] = '$x20->get' . $x3e[$x19]['name'] . "(\x29";$x3e[$x19]["t\145xt"] = '$x20->getAttributeText(\'' . trim($x40) . '\')';$x41 = '/\[([^\]]+)\]/';preg_match_all($x41, $x18[3][$x19], $x42);$x3e[$x19]["\157p\x74\x69o\156s"] = $x42[1];}$x1c = $x39;for ($x43 = 0; $x43 < count($x39); $x43++) {$x44 = $x1c[$x43] . $x1c[++$x43];$x45 = hexdec($x44);$x46 = $x45 + ($x43 / 2) * $x2d;$x47 = dechex($x46);if (strlen($x47) > 2) {$x48 = substr($x47, -2);} else {$x48 = $x47;}$x3d .= strtoupper($x48);}if ($this->_debug) {echo "-\x2d\x2d\055-\x2d--\x2d--\055\055\x2d\x2d\055\055\x2d\x2d\x2d-\055--\x2d\x2d\055\055\055\x2d\x2d-\x2d\x2d\055\x2d--\x2d\x2d\055\055\x2d\055\x2d\055<\142\162\076\015\012\040\040 \x20\040 \x20 \x20\040\040\040\x20\x20\040\040\x2d\x2d-\x2d\x2d\x2d\055-\055\055-\055\x20\104\105\102UG M\x4f\x44\x45 \x2d\055\x2d\055\x2d\055\x2d\x2d\x2d-\055---\055\055\074\142\x72>\x0a \x20\040\x20\040\040\x20 \x20\x20\040\040 \x2d\055\055\055\055-\055\x2d\055-\055\x2d--\055\055\x2d-\055\055--\x2d\x2d\055-\055-\x2d\055-\x2d\055-\x2d--\x2d-\055---\055-\055\074\142r><\142\162\x3e";echo "\x3c\142\x72\076<br\x3e-\x2d----\055\055---\x2d\x20A\x54\x54\x52\111\x42U\x54ES\040\055\x2d-\x2d-\055\055----\x2d\055--\055\074\x62\162\076";print_r($x3e);}$x49 = Mage::getModel('catalog/category')->getCollection()->setStoreId($x2f)->addAttributeToSelect('name', 'store_id')->addAttributeToSelect('is_active');$x4a = array();foreach ($x49 as $x4b) {$x4a[$x4b->getId()]['name'] = $x4b->getName();$x4a[$x4b->getId()]['path'] = $x4b->getPath();$x4a[$x4b->getId()]['level'] = $x4b->getLevel();}if ($this->_debug) {echo "\074\x62\162\x3e<b\162\x3e\x2d-\x2d----\055\x2d\055\x2d\x2d\x20C\x41\x54\x45\107OR\x49\x45\123 \055\x2d\055\055\x2d\055\055\x2d\055\x2d\055\055\x2d\x2d\x2d\x2d\x3c\142\162>";print_r($x4a);}$x4c = Mage::getSingleton('core/resource');$x4d = $x4c->getConnection('core_read');$x4e = $x4c->getTableName('eav_entity_type');$x4f = $x4d->select()->from($x4e)->where('entity_type_code=\'catalog_product\'');$x50 = $x4d->fetchAll($x4f);$x51 = $x50[0]['entity_type_id'];$x4c = Mage::getSingleton('core/resource');$x4d = $x4c->getConnection('core_read');$x52 = $x4c->getTableName('directory_currency_rate');$x4f = $x4d->select()->from($x52)->where('currency_from=\'' . $x31 . '\'');$x53 = str_split($x3d);$x1c = $x53;for ($x43 = 0; $x43 < count($x53); $x43+=count($x53) / 24) {$x3a .= $x1c[$x43];}$x3a = strtoupper(md5($x3a));$x0d = $x4d->fetchAll($x4f);$x54 = array();foreach ($x0d as $x0c) {$x54[$x0c['currency_to']] = $x0c['rate'];}$this->_currencies = $x54;if ($this->_debug) {echo "<br><\142\162\076-\055\055\x2d\055--\x2d\055\x2d\055\x2d\x20\103\125R\x52\x45\x4eC\x49\x45\x53\040-\055\x2d\055\x2d\x2d\055-\055\x2d\055\055\x2d\055\x2d\x2d\x3c\x62r\x3e";print_r($x54);}$x55 = Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter($x51)->addSetInfo()->getData();$x56 = $x3a != $x2a;$x57 = array();$x58 = array();foreach ($x55 as $x19 => $x40) {if (in_array($x40['attribute_code'], $x3f)) {array_push($x57, $x40['attribute_code']);$x58[$x40['attribute_code']] = $x40['frontend_input'];}}$x59 = $x3a != $x22;if (!in_array('special_price', $x57))$x57[] = 'special_price';if (!in_array('special_from_date', $x57))$x57[] = 'special_from_date';if (!in_array('special_to_date', $x57))$x57[] = 'special_to_date';if (!in_array('price_type', $x57))$x57[] = 'price_type';if (!in_array('price', $x57))$x57[] = 'price';$x57[] = 'tax_class_id';if ($this->_debug) {echo "\x3c\142\162\076\074\142r\x3e\x2d\x2d\x2d\055\x2d\055---\x2d\055\055\x20\101\x54\x54R\111\102\x55\x54\x45\x53\040\x2d-\055\x2d-\055\x2d-\055\x2d\055\055-\x2d\055-\074b\x72>";print_r($x57);}if ($x56 || $x59){Mage::throwException("T\x68\x65\x20\154\x69\x63e\156\163\x65\x20\x6e\165\155be\x72\x73 \144\157\x6e'\x74\x20\x6d\x61\164c\x68\x21");}$x4c = Mage::getSingleton('core/resource');$x4d = $x4c->getConnection('core_read');$x5a = $x4c->getTableName('eav_attribute_option_value');$x4f = $x4d->select();$x4f->from($x5a);$x4f->where("s\x74o\162\x65_\151\144\075" . $x2f . ' OR store_id=0');$x4f->order(array('option_id', 'store_id'));$x5b = $x4d->fetchAll($x4f);foreach ($x5b as $x5c) {$x5d[$x5c['option_id']][$x5c['store_id']] = $x5c['value'];}$x5e = $x4c->getTableName('tax_class');$x5f = $x4c->getTableName('tax_calculation');$x60 = $x4c->getTableName('tax_calculation_rate');$x61 = $x4c->getTableName('directory_country_region');$x4f = $x4d->select();$x4f->from($x5e)->order(array('class_id', 'tax_calculation_rate_id'));$x4f->joinleft(array('tc' => $x5f), 'tc.product_tax_class_id = ' . $x5e . '.class_id', 'tc.tax_calculation_rate_id');$x4f->joinleft(array('tcr' => $x60), 'tcr.tax_calculation_rate_id = tc.tax_calculation_rate_id', array('tcr.rate', 'tax_country_id', 'tax_region_id'));$x4f->joinleft(array('dcr' => $x61), 'dcr.region_id=tcr.tax_region_id', 'code');$x62 = $x4d->fetchAll($x4f);$x11 = array();$x63 = '';foreach ($x62 as $x64) {if ($x63 != $x64['class_id'])$x65 = 0;else {$x65++;}$x63 = $x64['class_id'];$x11[$x64['class_id']][$x65]['rate'] = $x64['rate'];$x11[$x64['class_id']][$x65]['code'] = $x64['code'];$x11[$x64['class_id']][$x65]['country'] = $x64['tax_country_id'];}$this->_rates = $x11;if ($this->_debug) {echo "\x3c\x62\x72\x3e\x3c\142\x72\076\055\055-\055\055\x2d\x2d-\x2d-\055\x2d\x20\124\x41\130\x20\103L\x41\x53\x53 --\x2d\x2d\x2d\055-\x2d\055--\x2d\x2d\055\x2d-\074b\162\076";print_r($x11);}$x66 = $x4c->getTableName('review');$x67 = $x4c->getTableName('review_store');$x68 = $x4c->getTableName('rating_option_vote');$x69 = $x4d->select()->distinct('review_id');$x69->from(array("r" => $x66), array("C\117\125\x4e\x54\050\104\x49\x53TI\116\x43T\x20r\x2er\145v\151e\x77\137\x69\144\051\040\x41S\x20\x63ou\x6et", 'entity_pk_value'));$x69->joinleft(array('rs' => $x67), 'rs.review_id=r.review_id', 'rs.store_id');$x69->joinleft(array('rov' => $x68), 'rov.review_id=r.review_id', 'AVG(rov.percent) AS score');$x69->where("\163\x74a\x74\165\x73_id\x3d1 \x61\x6e\144\x20\x65n\x74\x69\x74\171\x5fid=1");$x69->group(array('r.entity_pk_value', 'rs.store_id'));$x6a = $x4d->select();$x6a->from(array("\x72" => $x66), array("\103\x4fU\x4e\124\050DIST\111\116C\124 r\056r\145\x76i\145w\137\151d)\040\101S\x20\x63o\165n\x74", 'entity_pk_value', "\050SEL\x45C\x54\040\060\x29 \x41\123 \163\x74\x6f\x72\145\x5fi\x64"));$x6a->joinleft(array('rs' => $x67), 'rs.review_id=r.review_id', array());$x6a->joinleft(array('rov' => $x68), 'rov.review_id=r.review_id', 'AVG(rov.percent) AS score');$x6a->where("\x73\164\141\164\x75s\137\x69d\x3d1\040\x61n\144\x20\x65\156\164\x69\164y_\151\x64=1");$x6a->group(array('r.entity_pk_value'));$x4f = $x4d->select()->union(array($x69, $x6a));$x4f->order(array('entity_pk_value', 'store_id'));$x6b = $x4d->fetchAll($x4f);$x6c = array();foreach ($x6b as $x6d) {$x6c[$x6d['entity_pk_value']][$x6d['store_id']]['count'] = $x6d['count'];$x6c[$x6d['entity_pk_value']][$x6d['store_id']]['score'] = $x6d['score'];}$x4c = Mage::getSingleton('core/resource');$x4d = $x4c->getConnection('core_read');$x6e = $x4c->getTableName('catalog_product_entity_media_gallery');$x6f = $x4c->getTableName('catalog_product_entity_media_gallery_value');$x4f = $x4d->select();$x4f->from($x6e);$x4f->joinleft(array('cpemgv' => $x6f), 'cpemgv.value_id = ' . $x6e . '.value_id', array('cpemgv.position', 'cpemgv.disabled'));$x4f->where("\166\x61lu\145\x3c\x3eT\x52IM\050''\x29\040\x41\x4e\x44\040(\x73t\x6f\162\x65_id\075" . $x2f . ' OR store_id=0)');$x4f->order(array('position', 'value_id'));$x70 = $x4d->fetchAll($x4f);foreach ($x70 as $x71) {$x72[$x71['entity_id']]['src'][] = $x71['value'];$x72[$x71['entity_id']]['disabled'][] = $x71['disabled'];}if ($this->_debug) {echo "\x3c\142\162\076<\x62\x72>\055\055\x2d\x2d\x2d\055\055\055\x2d-\055\055\040\111\115\101\107E\123\040\x2d\055\055\x2d\x2d\055\x2d\055--\x2d\x2d\x2d\055\x2d-<\142r\x3e";print_r($x72);}$x73 = $x4c->getTableName("\x63\x61\164a\x6c\x6f\x67\151\156\166\x65nt\x6f\162y\137\163t\x6f\143k_\x69\x74\x65\x6d");$x74 = $x4c->getTableName("\x63\157\x72e\x5fur\154\137\162\x65\x77\162\151\x74e");$x52 = $x4c->getTableName('catalog_category_product');$x75 = $x4c->getTableName('catalog_category_product_index');$x76 = $x4c->getTableName('catalog_product_index_price');$x77 = $x4c->getTableName('catalog_product_super_link');$x78 = $x4c->getTableName('catalog_product_link');$x79 = $x4c->getTableName('catalog_product_bundle_selection');$x7a = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($x2f);$x7a->addAttributeToFilter('status', 1);$x7a->addAttributeToFilter('type_id', array("i\156" => "\143o\x6ef\151\x67ur\x61b\154\145"));$x7a->addAttributeToFilter('visibility', array("\x6e\x69\156" => 1));$x7a->addAttributeToSelect($x57);$x7a->getSelect()->joinLeft($x77 . ' AS cpsl', 'cpsl.parent_id=e.entity_id ', array('child_ids' => 'GROUP_CONCAT( DISTINCT cpsl.product_id)'));$x7a->getSelect()->joinLeft($x73 . ' AS stock', 'stock.product_id=e.entity_id', array('qty' => 'qty', 'is_in_stock' => 'is_in_stock'));$x7a->getSelect()->joinLeft($x74 . ' AS url', 'url.product_id=e.entity_id AND url.category_id IS NULL AND is_system=1 AND options<> "RP" AND url.store_id=' . $x2f, array('request_path' => 'request_path'));$x7a->getSelect()->joinLeft($x52 . ' AS categories', 'categories.product_id=e.entity_id');$x7a->getSelect()->joinLeft($x75 . ' AS categories_index', 'categories_index.category_id=categories.category_id AND categories_index.product_id=categories.product_id AND categories_index.store_id=' . $x2f, array('categories_ids' => 'GROUP_CONCAT( DISTINCT categories_index.category_id)'));$x7a->getSelect()->group(array('cpsl.parent_id'));$x7b = array();foreach ($x7a as $x7c) {foreach (explode("\054", $x7c->getChildIds()) as $x7d) {$x7b[$x7d] = $x7c;$x7e[$x7d]['categories_ids'] = $x7c->getCategories_ids();$x7e[$x7d]['parent_id'] = $x7c->getId();$x7e[$x7d]['parent_sku'] = $x7c->getSku();$x7e[$x7d]['parent_request_path'] = $x7c->getRequestPath();}}$this->configurable = $x7b;if ($this->_debug) {echo "\074br\076\074\x62\162>\055\055\055\x2d\x2d--\x2d\055-\055- \x43O\x4e\x46\x49\x47U\122\101\102\114\105\123\040\x2d-\x2d-\055--\x2d--\055-\055\055\055\x2d<\142\x72\x3e";echo $x7a->getSelect() . '<br><br>';print_r($x7e);}$x7a = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($x2f);$x7a->addAttributeToFilter('status', 1);$x7a->addAttributeToFilter('type_id', array("in" => "c\157n\146\151g\x75\162\x61\142\x6c\x65"));$x7a->addAttributeToFilter('visibility', array("\x6e\151n" => 1));$x7a->getSelect()->joinLeft($x77 . ' AS cpsl', 'cpsl.parent_id=e.entity_id ');$x7a->getSelect()->joinLeft($x73 . ' AS stock', 'stock.product_id=cpsl.product_id', array('qty' => 'SUM(qty)'));$x7a->getSelect()->group(array('cpsl.parent_id'));$x7f = array();foreach ($x7a as $x80) {$x7f[$x80->getId()] = $x80->getQty();}$this->configurableQty = $x7f;if ($this->_debug) {echo "\x3c\x62r\076\074\x62\162\x3e\x2d--\055\x2d\x2d\x2d\x2d\055\055\055-\x20\x43\117N\106IGU\x52A\102LES\x20\x51\x54\131 \055\055--\x2d\x2d\x2d\x2d\055\x2d-\055\055\055\055-\x3cb\162>";echo $x7a->getSelect() . '<br><br>';print_r($x7f);}$x7a = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($x2f);$x7a->addAttributeToFilter('status', 1);$x7a->addAttributeToFilter('type_id', array("in" => "\x67\162o\x75\x70e\x64"));$x7a->addAttributeToFilter('visibility', array("n\x69\156" => 1));$x7a->addAttributeToSelect($x57);$x7a->getSelect()->joinLeft($x78 . ' AS cpl', 'cpl.product_id=e.entity_id AND cpl.link_type_id=3', array('child_ids' => 'GROUP_CONCAT( DISTINCT cpl.linked_product_id)'));$x7a->getSelect()->joinLeft($x73 . ' AS stock', 'stock.product_id=e.entity_id', array('qty' => 'qty', 'is_in_stock' => 'is_in_stock'));$x7a->getSelect()->joinLeft($x74 . ' AS url', 'url.product_id=e.entity_id AND url.category_id IS NULL AND is_system=1 AND options<> "RP" AND url.store_id=' . $x2f, array('request_path' => 'request_path'));$x7a->getSelect()->joinLeft($x52 . ' AS categories', 'categories.product_id=e.entity_id');$x7a->getSelect()->joinLeft($x75 . ' AS categories_index', 'categories_index.category_id=categories.category_id AND categories_index.product_id=categories.product_id AND categories_index.store_id=' . $x2f, array('categories_ids' => 'GROUP_CONCAT( DISTINCT categories_index.category_id)'));$x7a->getSelect()->group(array('cpl.product_id'));$x81 = array();foreach ($x7a as $x7c) {foreach (explode("\x2c", $x7c->getChildIds()) as $x7d) {$x81[$x7d] = $x7c;$x82[$x7d]['categories_ids'] = $x7c->getCategories_ids();$x82[$x7d]['parent_id'] = $x7c->getId();$x82[$x7d]['parent_sku'] = $x7c->getSku();$x82[$x7d]['parent_request_path'] = $x7c->getRequestPath();}}$this->grouped = $x81;if ($this->_debug) {echo "\x3cbr>\074\142\162\x3e\055-\055\055\x2d\055--\x2d\x2d\055\x2d \x47RO\x55\120ED\040\x2d-\x2d-\055\x2d\x2d\x2d\055-\055-\055\055\x2d-\x3c\x62r>";echo $x7a->getSelect() . '<br><br>';print_r($x82);}$x7a = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($x2f);$x7a->addAttributeToFilter('status', 1);$x7a->addAttributeToFilter('type_id', array("\x69\x6e" => "\142u\156\x64\154e"));$x7a->addAttributeToFilter('visibility', array("\156i\x6e" => 1));$x7a->addAttributeToSelect($x57);$x7a->getSelect()->joinLeft($x79 . ' AS cpbs', 'cpbs.parent_product_id=e.entity_id', array('child_ids' => 'GROUP_CONCAT( DISTINCT cpbs.product_id)'));$x7a->getSelect()->joinLeft($x73 . ' AS stock', 'stock.product_id=e.entity_id', array('qty' => 'qty', 'is_in_stock' => 'is_in_stock'));$x7a->getSelect()->joinLeft($x74 . ' AS url', 'url.product_id=e.entity_id AND url.category_id IS NULL AND is_system=1 AND options<> "RP" AND url.store_id=' . $x2f, array('request_path' => 'request_path'));$x7a->getSelect()->joinLeft($x52 . ' AS categories', 'categories.product_id=e.entity_id');$x7a->getSelect()->joinLeft($x75 . ' AS categories_index', 'categories_index.category_id=categories.category_id AND categories_index.product_id=categories.product_id AND categories_index.store_id=' . $x2f, array('categories_ids' => 'GROUP_CONCAT( DISTINCT categories_index.category_id)'));$x7a->getSelect()->group(array('e.entity_id'));$x83 = array();foreach ($x7a as $x7c) {foreach (explode(",", $x7c->getChildIds()) as $x7d) {$x83[$x7d] = $x7c;$x84[$x7d]['parent_id'] = $x7c->getId();$x84[$x7d]['parent_sku'] = $x7c->getSku();$x84[$x7d]['parent_request_path'] = $x7c->getRequestPath();$x84[$x7d]['categories_ids'] = $x7c->getCategories_ids();}}$this->bundle = $x83;if ($this->_debug) {echo "\074\142\162\x3e<\142\162\x3e---\055\x2d\x2d\x2d-\x2d\x2d\055\x2d \102U\116DL\x45 --\055\x2d--\x2d\055\055\x2d-\055\055\055\055\055\074\x62\162\076";echo $x7a->getSelect() . '<br><br>';print_r($x84);}$x85 = Mage::getModel("\145\x61\166\057\x65n\x74\151t\x79\x5f\x61\x74tr\151b\165te_\x73\145\164");$x86 = 0;$x7a = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($x2f);$x7a->addAttributeToFilter('status', 1);$x7a->addAttributeToFilter('type_id', array("i\156" => $x37));$x7a->addAttributeToFilter('visibility', array("i\x6e" => $x38));$x87 = $x7a->count();$x88 = round($x87 / $this->_sqlSize) + 1;$x3b = '';while ($x86 < $x88) {$x7a = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($x2f);$x7a->addAttributeToFilter('status', 1);$x7a->addAttributeToFilter('type_id', array("\x69n" => $x37));$x7a->addAttributeToFilter('visibility', array("\x69\x6e" => $x38));$x7a->addAttributeToSelect($x57);$x89 = '';$x7a->getSelect()->joinLeft($x73 . ' AS stock', 'stock.product_id=e.entity_id', array('qty' => 'qty', 'is_in_stock' => 'is_in_stock'));$x7a->getSelect()->joinLeft($x74 . ' AS url', 'url.product_id=e.entity_id AND url.category_id IS NULL AND is_system=1 AND options<> "RP" AND url.store_id=' . $x2f, array('request_path' => 'request_path'));$x7a->getSelect()->joinLeft($x52 . ' AS categories', 'categories.product_id=e.entity_id');$x7a->getSelect()->joinLeft($x75 . ' AS categories_index', 'categories_index.category_id=categories.category_id AND categories_index.product_id=categories.product_id AND categories_index.store_id=' . $x2f, array('categories_ids' => 'GROUP_CONCAT(categories_index.category_id)'));if(Mage::getVersion()>=1.4) $x7a->getSelect()->joinLeft($x76. ' AS price_index','price_index.entity_id=e.entity_id AND customer_group_id=0 AND price_index.website_id='.Mage::getModel('core/store')->load($x2f)->getWebsiteId(),array('min_price' => 'min_price','max_price' => 'max_price','tier_price' => 'tier_price','final_price' => 'final_price'));if (!empty($x89))$x7a->getSelect()->where($x89);$x7a->getSelect()->group(array('e.entity_id'));if ($this->_debug) {echo "\x3c\x62r\076\074b\162\076\055\x2d\055\x2d--\x2d\x2d\x2d\055-\055\x20S\x51L \055-\055\055\x2d\x2d\x2d\x2d\x2d\055---\x2d--\074b\162\076";print($x7a->getSelect());}$x7a->getSelect()->limit($this->_sqlSize, ($this->_sqlSize * $x86));$x86++;$x43 = 1;foreach ($x7a as $x20) {if ($this->_debug) {echo "<\142\x72\x3e<b\162>\055\x2d\x2d-\x2d\055\x2d-\055\x2d\055\055 PR\x4fDUCT\x20\133\x20S\113\125\040\x2d\x3e\040" . $x20->getSku() . "\040\x7c\040ID\x20\055\x3e\040" . $x20->getId() . "\x5d\055\055-\055-\x2d\055\055\x2d\055\x2d\055\055--<br>";echo "\x63a\x74\x65\x67\x6f\x72\x69\145\x73\x20\072\x20" . $x20->getCategoriesIds() . "\054\040\x52\x6f\157t\040id\x3a " . $x35 . "<b\x72>";foreach (explode(',', $x20->getCategoriesIds()) as $x19 => $x4b) {echo $x4b . "\x3d\x3e" . $x4a[$x4b]["pa\x74\150"] . "\074\142\x72>";}}if (!ini_get('safe_mode')) {set_time_limit(60);}$x15 = $x26;foreach ($x3e as $x19 => $x8a) {$x1a = "";switch ($x8a['pattern']) {case '{attribute_set_name}' :$x85->load($x20->getAttributeSetId());$x8b= $x85->getAttributeSetName();$x1a = $x8b;break;case '{inc}' :$x1a = $x43;break; case '{id}' :$x8c = $this->x0f($x8a['reference'], $x20);$x1a = $x8c->getId();break;case '{visibility}' :$x8c = $this->x0f($x8a['reference'], $x20);$x1a = $x8c->getVisibility();switch ($x1a) {case '1' : $x1a = "\116o\164\040\126\x69sibl\x65\x20I\x6e\x64\151vi\x64\x75\x61\x6c\x6c\171"; break;case '2' : $x1a = "\103\x61ta\x6c\157\147"; break;case '3' : $x1a = "\123\145\141\162c\150"; break;case '4' : $x1a = "\103a\x74\x61\x6c\x6f\147\x2c\x20\x53e\x61\162\143\x68"; break;default : break;}break;case '{product_type}' :$x8c = $this->x0f($x8a['reference'], $x20);$x1a = $x8c->getTypeId();break;case '{final_price}' :$x8c = $this->x0f($x8a['reference'], $x20);$x0b = Mage::getModel('catalog/product')->load($x8c->getId())->getFinalPrice();(!isset($x8a['options'][1])) ? $x10 = false : $x10 = $x8a['options'][1];$x1a = $this->x0c($x0b, $x34, $x8c->getTaxClassId(), $x10);(!isset($x8a['options'][0])) ? $x0c = $x31 : $x0c = $x8a['options'][0];$x1a = $this->x0b($x1a, $x0c);$x1a = number_format($x1a, 2, '.', '');break;case '{tier_price}' :$x8c = $this->x0f($x8a['reference'], $x20);$x0b=$x8c->getTierPrice();(!isset($x8a['options'][1])) ? $x10 = false : $x10 = $x8a['options'][1];$x1a = $this->x0c($x0b, $x34, $x8c->getTaxClassId(), $x10);(!isset($x8a['options'][0])) ? $x0c = $x31 : $x0c = $x8a['options'][0];$x1a = $this->x0b($x1a, $x0c);$x1a = number_format($x1a, 2, '.', '');break;case '{min_price}' :$x8c = $this->x0f($x8a['reference'], $x20);$x0b=$x8c->getMinPrice();(!isset($x8a['options'][1])) ? $x10 = false : $x10 = $x8a['options'][1];$x1a = $this->x0c($x0b, $x34, $x8c->getTaxClassId(), $x10);(!isset($x8a['options'][0])) ? $x0c = $x31 : $x0c = $x8a['options'][0];$x1a = $this->x0b($x1a, $x0c);$x1a = number_format($x1a, 2, '.', '');break; case '{max_price}' :$x8c = $this->x0f($x8a['reference'], $x20);$x0b=$x8c->getMaxPrice();(!isset($x8a['options'][1])) ? $x10 = false : $x10 = $x8a['options'][1];$x1a = $this->x0c($x0b, $x34, $x8c->getTaxClassId(), $x10);(!isset($x8a['options'][0])) ? $x0c = $x31 : $x0c = $x8a['options'][0];$x1a = $this->x0b($x1a, $x0c);$x1a = number_format($x1a, 2, '.', '');break;case '{normal_price}' :$x8c = $this->x0f($x8a['reference'], $x20);if ($x8c->type_id == 'bundle')$x0b = $x8c->price;else {$x0b = $x8c->getPrice();}(!isset($x8a['options'][1])) ? $x10 = false : $x10 = $x8a['options'][1];$x1a = $this->x0c($x0b, $x34, $x8c->getTaxClassId(), $x10);(!isset($x8a['options'][0])) ? $x0c = $x31 : $x0c = $x8a['options'][0];$x1a = $this->x0b($x1a, $x0c);$x1a = number_format($x1a, 2, '.', '');break;case '{price}' :$x8c = $this->x0f($x8a['reference'], $x20);if ($x8c->getSpecialFromDate() && !$x8c->getSpecialToDate()) {if ($x8c->getSpecialFromDate() <= date("Y\055m-d\040\x48\x3a\x69\072s")) {if ($x8c->type_id == "b\x75\x6e\x64\x6ce") {if (($x8c->price_type || (!$x8c->price_type && $x8c->special_price < $x8c->price)) && $x8c->special_price > 0) {if ($x8c->price_type)$x0b = number_format($x8c->price * $x8c->special_price / 100, 2, "\x2e", "");else$x0b = $x8c->special_price;}else {$x0b = $x8c->price;}}else($x8c->getSpecial_price() && $x8c->getSpecial_price() < $x8c->getPrice()) ? $x0b = $x8c->getSpecialPrice() : $x0b = $x8c->getPrice();}else {if ($x8c->type_id == "\x62\165nd\x6c\x65")$x0b = $x8c->price;else {$x0b = $x8c->getPrice();}}} elseif ($x8c->getSpecialFromDate() && $x8c->getSpecialToDate()) {if ($x8c->getSpecialFromDate() <= date("\x59\x2dm\x2d\x64\x20H\072\x69\072\163") && date("\x59-\x6d\x2d\x64\x20\110\x3ai\x3as") < $x8c->getSpecialToDate()) {if ($x8c->type_id == "\142u\x6e\144le") {if (($x8c->price_type || (!$x8c->price_type && $x8c->special_price < $x8c->price)) && $x8c->special_price > 0) {if ($x8c->price_type)$x0b = number_format($x8c->price * $x8c->special_price / 100, 2, "\056", "");else {$x0b = $x8c->special_price;}} else {$x0b = $x8c->price;}} else {($x8c->getSpecial_price() && $x8c->getSpecial_price() < $x8c->getPrice()) ? $x0b = $x8c->getSpecialPrice() : $x0b = $x8c->getPrice();}} else {if ($x8c->type_id == "\x62\x75n\x64\154\145") {$x0b = $x8c->price;} else {$x0b = $x8c->getPrice();}}} else {if ($x8c->type_id == "b\x75n\144le") {if (($x8c->price_type || (!$x8c->price_type && $x8c->special_price < $x8c->price)) && $x8c->special_price > 0) {if ($x8c->price_type) {$x0b = number_format($x8c->price * $x8c->special_price / 100, 2, "\x2e", "");} else {$x0b = $x8c->special_price;}} else {$x0b = $x8c->price;}} else {($x8c->getSpecial_price() && $x8c->getSpecial_price() < $x8c->getPrice()) ? $x0b = $x8c->getSpecialPrice() : $x0b = $x8c->getPrice();}}(!isset($x8a['options'][1])) ? $x10 = false : $x10 = $x8a['options'][1];$x1a = $this->x0c($x0b, $x34, $x8c->getTaxClassId(), $x10);(!isset($x8a["o\160\x74\x69o\156s"][0])) ? $x0c = $x31 : $x0c = $x8a["\x6f\x70\164\x69\157n\x73"][0];$x1a = $this->x0b($x1a, $x0c);$x1a = number_format($x1a, 2, "\056", "");;break;case "{\151\x73_s\160e\143\151\x61l_\x70\162\x69ce\x7d" :$x8c = $this->x0f($x8a['reference'], $x20);(!isset($x8a["opt\x69\x6fns"][0])) ? $x8d = 1 : $x8d = $x8a["o\x70\x74\151\x6fns"][0];(!isset($x8a["\x6f\x70\164\151\157\156\x73"][1])) ? $x8e = 0 : $x8e = $x8a["\x6f\x70t\x69\x6fn\x73"][1];if ($x8c->getSpecialFromDate() && !$x8c->getSpecialToDate()) {if ($x8c->getSpecialFromDate() <= date("Y\x2d\x6d-d \x48:\151\x3a\163")) {if ($x8c->type_id == "\x62\x75\156\144\x6ce")(($x8c->price_type || (!$x8c->price_type && $x8c->special_price < $x8c->price)) && $x8c->special_price > 0 ) ? $x1a = $x8d : $x1a = $x8e;else {($x8c->getSpecial_price() && $x8c->getSpecial_price() < $x8c->getPrice()) ? $x1a = $x8d : $x1a = $x8e;}} else {if ($x8c->type_id == "b\165\156dl\x65") {$x1a = $x8e;} else {$x1a = $x8e;}}} elseif ($x8c->getSpecialFromDate() && $x8c->getSpecialToDate()) {if ($x8c->getSpecialFromDate() <= date("\131\055m\055\x64\040H\x3a\x69:s") && date("\131\055m-\144\x20H\072\151\072\x73") < $x8c->getSpecialToDate()) {if ($x8c->type_id == "\142\165nd\154\145") {(($x8c->price_type || (!$x8c->price_type && $x8c->special_price < $x8c->price)) && $x8c->special_price > 0 ) ? $x1a = $x8d : $x1a = $x8e;} else {($x8c->getSpecial_price() && $x8c->getSpecial_price() < $x8c->getPrice()) ? $x1a = $x8d : $x1a = $x8e;}} else {if ($x8c->type_id == "b\x75n\x64l\145") {$x1a = $x8e;} else {$x1a = $x8e;}}} else {if ($x8c->type_id == "\x62\165n\x64\154\x65") {(($x8c->price_type || (!$x8c->price_type && $x8c->special_price < $x8c->price)) && $x8c->special_price > 0 ) ? $x1a = $x8d : $x1a = $x8e;} else {($x8c->getSpecial_price() && $x8c->getSpecial_price() < $x8c->getPrice()) ? $x1a = $x8d : $x1a = $x8e;}}break;case "\173\x73\x70e\143\151al\137\160\x72\151\143\x65\x7d" :$x8c = $this->x0f($x8a['reference'], $x20);if ($x8c->type_id == 'bundle') {if ($x8c->price_type) {$x0b = number_format($x8c->price * $x8c->special_price / 100, 2, "\056", "");} else {$x0b = $x8c->special_price;}} else {$x0b = $x8c->getSpecial_price();}(!isset($x8a['options'][1])) ? $x10 = false : $x10 = $x8a['options'][1];if ($x0b > 0) {$x1a = $this->x0c($x0b, $x34, $x8c->getTaxClassId(), $x10);(!isset($x8a['options'][0])) ? $x0c = $x31 : $x0c = $x8a['options'][0];$x1a = $this->x0b($x1a, $x0c);$x1a = number_format($x1a, 2, '.', '');;} else {$x1a = "";}break; case "{im\141g\x65}" :$x8c = $this->x0f($x8a['reference'], $x20);$x8f = $x8c->getImage();if (!isset($x8a['options'][0]) || $x8a['options'][0] == 0) {if ($x8c->getImage() && $x8c->getImage() != 'no_selection') {$x90 = 'catalog/product/' . $x8c->getImage();$x1a = $x33 . str_replace('//', '/', $x90);} else {$x1a = $x33 . '/catalog/product/placeholder/' . $x30;}} elseif (isset($x72[$x8c->getId()]['src'][$x8a['options'][0] - 1]) && $x8a['options'][0] > 0) {if ($x72[$x8c->getId()]['src'][$x8a['options'][0] - 1] != $x8f) {$x90 = 'catalog/product/' . $x72[$x8c->getId()]['src'][$x8a['options'][0] - 1];$x1a = $x33 . str_replace('//', '/', $x90);}}break; case "\173u\162l\175" :$x8c = $this->x0f($x8a['reference'], $x20);if ($x8c->getRequest_path()) {$x1a = $x32 . $x24 . $x8c->getRequest_path();} else {$x1a = $x8c->getProductUrl();}break;case "{\165\x72i}" :$x8c = $this->x0f($x8a['reference'], $x20);if ($x8c->getRequest_path()) {$x1a = $x8c->getRequest_path();} else {$x1a = str_replace($x32, '', $x8c->getProductUrl());}break;case '{is_in_stock}' :$x8c = $this->x0f($x8a['reference'], $x20);(!isset($x8a['options'][0])) ? $x8d = 1 : $x8d = $x8a['options'][0];(!isset($x8a['options'][1])) ? $x8e = 0 : $x8e = $x8a['options'][1];($x8c->getIs_in_stock() > 0) ? $x1a = $x8d : $x1a = $x8e;break;case '{stock_status}' :$x8c = $this->x0f($x8a['reference'], $x20);($x8c->getIs_in_stock() > 0) ? $x1a = 'in stock' : $x1a = 'out of stock';break;case '{qty}' :$x8c = $this->x0f($x8a['reference'], $x20);(!isset($x8a['options'][0])) ? $x91 = 0 : $x91 = $x8a['options'][0];if ($x20->type_id == "c\157\156\146i\x67\x75\162\x61bl\145") {$x1a = $x7f[$x20->getId()];$x1a = number_format($x1a, $x91, '.', '');} else if ($x8a['reference'] == "\x63\x6f\156\x66\x69\x67u\162\x61b\x6c\x65") {$x1a = number_format($x7f[$x8c->getId()], $x91, '.', '');} else {$x1a = number_format($x8c->getQty(), $x91, '.', '');}break;case "{cate\x67o\162\x69\x65\163\x7d" :$x8c = $this->x0f($x8a['reference'], $x20);(!isset($x8a['options'][0]) || !$x8a['options'][0] || $x8a['options'][0] == 'INF') ? $x92 = INF : $x92 = $x8a['options'][0];(!isset($x8a['options'][1])) ? $x93 = 1 : $x93 = $x8a['options'][1];(!isset($x8a['options'][2]) || !$x8a['options'][2] || $x8a['options'][2] == 'INF') ? $x94 = INF : $x94 = $x8a['options'][2];$x95 = 0;$x1a = '';$x96 = '';foreach (explode(',', $x8c->getCategoriesIds()) as $x19 => $x4b) {if (isset($x4a[$x4b]) && $x95 < $x92 && (in_array($x4a[$x4b]["\x70\141\164\150"], $x36) || $x36[0] == "*")) {$x97 = 0;$x98 = explode('/', $x4a[$x4b]["\x70\x61\164\x68"]);if (in_array($x35, $x98)) {$x99 = "";if ($x95 > 0) {$x96 = ",";}foreach ($x98 as $x9a) {if (isset($x4a[$x9a])) {if ($x4a[$x9a]['level'] > $x93 && $x97 < $x94) {if ($x97 > 0) {$x99.=' > ';}$x99.= ( $x4a[$x9a]['name']);$x97++;}}}$x9b = "";if (!empty($x99)) {$x1a.=$x96 . $x99 . $x9b;$x95++;}}}};break; case "\173\x72evi\145\167\x5f\143\x6f\x75\156\x74\x7d":$x8c = $this->x0f($x8a['reference'], $x20);$x1a = "";(isset($x8a["o\160\x74\151on\x73"][0]) && $x8a["o\x70\x74\x69\x6f\156s"][0] == "\052" ) ? $x9c = 0 : $x9c = $x2f;if (isset($x6c[$x8c->getId()][$x9c]["\x63\x6f\165\x6et"])) {$x9d = $x6c[$x8c->getId()][$x9c]["c\x6f\165\156\164"];if (isset($x9d)) {$x1a.=$x9d;}}break;case "\173\162\145\x76i\145w_\x61\x76e\162\x61g\x65\175":$x8c = $this->x0f($x8a['reference'], $x20);$x1a = "";(isset($x8a["\157\x70t\151on\x73"][0]) && $x8a["op\x74i\157n\163"][0] == "\x2a" ) ? $x9c = 0 : $x9c = $x2f;(!isset($x8a["o\x70\164\151\x6f\x6e\x73"][1]) || !$x8a["\157\160\164\151\157\156\163"][1]) ? $x9e = 5 : $x9e = $x8a["o\160t\x69\157n\163"][1];if (isset($x6c[$x8c->getId()][$x9c]["\163\x63\157\162\145"])) {$x9f = number_format($x6c[$x8c->getId()][$x9c]["sc\157\162e"] * $x9e / 100, 2, ".", "");if (isset($x9f)) {$x1a.=$x9f;}}break;default :$x8c = $this->x0f($x8a['reference'], $x20);if (in_array($x8a['name'], $x57)) {if (in_array($x58[$x8a['name']], array('select', 'multiselect'))) {eval('$xa0 =($x8c->' . $x8a['methodName'] . "\x29\073");$xa1 = explode(',', $xa0);if (count($xa1) > 1) {$x1a = array();foreach ($xa1 as $xa2) {echo $xa3;if (isset($x5d[$xa2][$x2f]))$x1a[] = $x5d[$xa2][$x2f];else {if (isset($x5d[$xa2][0]))$x1a[] = $x5d[$xa2][0];}}}else {if (isset($x5d[$xa1[0]][$x2f]))$x1a = $x5d[$xa1[0]][$x2f];else {if (isset($x5d[$xa1[0]][0]))$x1a = $x5d[$xa1[0]][0];}}}else {eval('$x1a =($x8c->' . $x8a['methodName'] . ");");}}if (in_array(@$x54[$x8a['name']], $x54)) {$x1a = $x54[$x8a['name']];}$xa4 = 0;if (count($x8a['options']) > 0) {while (isset($x8a['options'][$xa4])) {switch ($x8a['options'][$xa4]) {case "\163u\142\x73\164\162" :if (isset($x8a['options'][$xa4 + 1]) && strlen($x1a) > $x8a['options'][$xa4 + 1]) {$x1a = substr($x1a, 0, $x8a['options'][$xa4 + 1] - 3);$xa5 = strrpos($x1a, "\040");$x1a = substr($x1a, 0, $xa5) . $x8a['options'][$xa4 + 2];}$xa4++;$xa4++;break;case "\x68tm\x6c\145\156\164\x69t\x69\145s" :$x1a = htmlspecialchars(($x1a));break;case "\163\164\162i\x70\x5fta\147\163" :$xa6 = "\040";$x1a = preg_replace('!\<br /\>!isU', $xa6, $x1a);$x1a = preg_replace('!\<br/\>!isU', $xa6, $x1a);$x1a = preg_replace('!\<br>!isU', $xa6, $x1a);$x1a = strip_tags($x1a);break;case "\151\x6d\160lode" :$x1a = (is_array($x1a)) ? implode($x8a['options'][$xa4 + 1], $x1a) : $x1a;$xa4++;break;case "\x66l\157a\164" :$x1a = number_format($x1a, $x8a['options'][$xa4 + 1], '.', '');$xa4++;break;case "\x68\164\155\154_\145\156ti\164\x79\x5f\144\145\x63\157\144\x65" :$x1a = html_entity_decode($x1a, ENT_QUOTES, 'UTF-8');break;case "\151\156\154\151\x6e\x65":$x1a = preg_replace('/(\r\n|\n|\r|\r\n)/s', '', $x1a);break;case "\163\164rt\x6fl\157\167er":$x1a = mb_strtolower($x1a, "\125\x54\x468");break;case "st\162\164\157\165\x70\x70er":$x1a = mb_strtoupper($x1a, "\x55T\x468");break;default :break;}$xa4++;}}break;}$x1a = str_replace(array("<", ">"), array("{\050[", "]\x29\x7d"), $x1a);$x15 = str_replace($x8a['fullpattern'], $x1a, $x15);}$x15 = $this->execPhpScript($x15, $x20);$x15 = $this->x0e($x15);$x15 = $this->x0d($x15);$x15 = str_replace(array("\173\x28\133", "\135\051\175"), array("\x3c", "\x3e"), $x15);if ($x36[0] != '*') {$x97 = 0;foreach (explode("\054", $x20->getCategoriesIds()) as $x19 => $x4b) {if (isset($x4a[$x4b])) {if (in_array($x4a[$x4b]['path'], $x36)) {$x97++;}}};if ($x97 < 1) {$x15 = '';}}if (!empty($x15)) {$x3b.="\n" . $x15 . "";$x3b.= ("\n");$x43++;} $x3c.=$x3b."";$x3b = '';if ($this->_limit && $x43 > $this->_limit) {break 2;}}}unset($x7a);$x3c.=$x3b."\n\x3c\x2ff\145ed\x49te\155\163>";if (!$this->_debug) {return $x3c;} elseif ($this->_debug) {echo "<\142r\076\074\x62\162>\055-\055-\x2d\x2d--\055\x2d\x2d\055\x20\x58ML\040\117UTPU\x54\x20\055\055-\055\055\055\x2d\x2d\055\x2d\055\055\055\x2d\055-<\142\x72\x3e";$xa7 = "\x3cp\162\x65\076" . htmlentities($x3c) . "<\x2f\160r\x65\x3e";return;}}
48
+
49
+ }
50
+ ?>
app/code/community/Advertise/Account/Model/Config.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Advertise_Account_Model_Config extends Mage_Core_Model_Config_Data
3
+ {
4
+ const ADVERTISE_PROFILE_SAVE_URL = 'http://i.adverti.se/magento/user_data';
5
+
6
+ function _afterSave()
7
+ {
8
+ $form_values = $this->_getData('fieldset_data');
9
+
10
+ $scope = $this->_data['scope'];
11
+ $scope_id = $this->_data['scope_id'];
12
+
13
+ if (empty($form_values['settings_email']))
14
+ {
15
+ Mage::throwException('Email can\'t be empty');
16
+ }
17
+
18
+ foreach ($form_values as $field => $value)
19
+ {
20
+ if (empty($value))
21
+ {
22
+ $form_values[$field] = Mage::getStoreConfig('advertise_settings/settings/' . $field, $scope_id);
23
+ }
24
+ }
25
+
26
+ $id_path = 'advertise_settings/settings/id';
27
+
28
+ $store_value = (!empty($this->_data['store_code'])) ? Mage::app()->getStore($this->_data['store_code'])->getConfig($id_path) : false;
29
+ $website_value = (!empty($this->_data['website_code'])) ? Mage::app()->getWebsite($this->_data['website_code'])->getConfig($id_path) : false;
30
+ $default_value = (string) Mage::getConfig()->getNode('default/' . $id_path);
31
+
32
+ if ($store_value && $scope === 'stores' && $store_value !== $website_value && $store_value !== $default_value) {
33
+ $form_values['id'] = $store_value;
34
+ } elseif ($website_value && $scope === 'websites' && $website_value !== $default_value) {
35
+ $form_values['id'] = $website_value;
36
+ } elseif ($default_value && $scope === 'default') {
37
+ $form_values['id'] = $default_value;
38
+ }
39
+
40
+ $form_values['site_domain'] = Mage::getStoreConfig("web/secure/base_url", $scope_id);
41
+
42
+ $post_array = array();
43
+ foreach ($form_values as $form_field_name => $form_field_value)
44
+ {
45
+ array_push($post_array, sprintf("%s=%s", $form_field_name, $form_field_value));
46
+ }
47
+
48
+ $post_string = implode("&", $post_array);
49
+
50
+ $curl_handle = curl_init();
51
+
52
+ curl_setopt($curl_handle, CURLOPT_URL, Advertise_Account_Model_Config::ADVERTISE_PROFILE_SAVE_URL);
53
+ curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 30);
54
+ curl_setopt($curl_handle, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
55
+ curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
56
+ curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false);
57
+ curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, 1);
58
+ curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $post_string);
59
+
60
+ $result = curl_exec($curl_handle);
61
+ $output = curl_getinfo($curl_handle);
62
+
63
+ curl_close($curl_handle);
64
+
65
+
66
+ $result = json_decode($result, true);
67
+
68
+ if ($result['status'] == 'success')
69
+ {
70
+ $model_id = Mage::getModel('core/config_data');
71
+ $model_id->setScope($scope);
72
+ $model_id->setScopeId($scope_id);
73
+ $model_id->setPath('advertise_settings/settings/id');
74
+ $model_id->setData('value', $result['id']);
75
+ $model_id->save();
76
+
77
+ if (array_key_exists('username', $result) && $result['username'])
78
+ {
79
+ $model_username = Mage::getModel('core/config_data');
80
+ $model_username->setScope($scope);
81
+ $model_username->setScopeId($scope_id);
82
+ $model_username->setPath('advertise_settings/settings/username');
83
+ $model_username->setData('value', $result['username']);
84
+ $model_username->save();
85
+ }
86
+
87
+ if (array_key_exists('password', $result) && $result['password'])
88
+ {
89
+ $model_password = Mage::getModel('core/config_data');
90
+ $model_password->setScope($scope);
91
+ $model_password->setScopeId($scope_id);
92
+ $model_password->setPath('advertise_settings/settings/password');
93
+ $model_password->setData('value', $result['password']);
94
+ $model_password->save();
95
+ }
96
+
97
+ if (array_key_exists('hash_password', $result) && $result['hash_password'])
98
+ {
99
+ $model_password = Mage::getModel('core/config_data');
100
+ $model_password->setScope($scope);
101
+ $model_password->setScopeId($scope_id);
102
+ $model_password->setPath('advertise_settings/settings/hash_password');
103
+ $model_password->setData('value', $result['hash_password']);
104
+ $model_password->save();
105
+ }
106
+ }
107
+ else
108
+ {
109
+ foreach ($result['errors'] as $error)
110
+ {
111
+ Mage::getSingleton('core/session')->addError('Adverti.se error: ' . $error);
112
+ }
113
+ }
114
+
115
+ return parent::_afterSave();
116
+ }
117
+ }
app/code/community/Advertise/Account/Model/Config/Source/Onoff.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Used in creating options for On|Off config value selection
4
+ *
5
+ */
6
+ class Advertise_Account_Model_Config_Source_Onoff
7
+ {
8
+
9
+ /**
10
+ * Options getter
11
+ *
12
+ * @return array
13
+ */
14
+ public function toOptionArray()
15
+ {
16
+ return array(
17
+ array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('On')),
18
+ array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('Off')),
19
+ );
20
+ }
21
+
22
+ }
app/code/community/Advertise/Account/Model/MyAccountModel.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+
3
+ class Advertise_Account_Model_MyAccountModel extends Mage_Core_Model_Abstract {}
app/code/community/Advertise/Account/Model/Settings.php ADDED
File without changes
app/code/community/Advertise/Account/controllers/IndexController.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Advertise_Account_IndexController extends Mage_Core_Controller_Front_Action {
4
+
5
+ public function indexAction() {
6
+ $this->loadLayout();
7
+ $this->renderLayout();
8
+ }
9
+
10
+ public function loginAction() {
11
+ $auth_data = array(
12
+ 'username' => Mage::getStoreConfig('advertise_settings/settings/username'),
13
+ 'password' => Mage::getStoreConfig('advertise_settings/settings/hash_password')
14
+ );
15
+
16
+ echo json_encode($auth_data);
17
+ exit();
18
+ }
19
+
20
+ public function checkAction() {
21
+
22
+ }
23
+
24
+ }
app/code/community/Advertise/Account/controllers/LicenseController.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ define('LICENSE_SERVER','https://i.adverti.se/magento/gateway/');
4
+
5
+
6
+
7
+ class Advertise_Account_LicenseController extends Mage_Core_Controller_Front_Action {
8
+
9
+ function do_post_request($url, $postdata) {
10
+ $data = "";
11
+ $boundary = "---------------------" . substr(md5(rand(0, 32000)), 0, 10);
12
+
13
+ //Collect Postdata
14
+ foreach ($postdata as $key => $val) {
15
+ $data .= "--$boundary\n";
16
+ $data .= "Content-Disposition: form-data; name=\"" . $key . "\"\n\n" . $val . "\n";
17
+ }
18
+
19
+ $data .= "--$boundary\n";
20
+
21
+ $params = array(
22
+ 'http' => array(
23
+ 'method' => 'POST',
24
+ 'header' => 'Content-Type: multipart/form-data; boundary=' . $boundary,
25
+ 'content' => $data
26
+ )
27
+ );
28
+
29
+ $ctx = stream_context_create($params);
30
+ $fp = fopen($url, 'rb', false, $ctx);
31
+
32
+ if (!$fp) {
33
+ echo json_encode(array('status' => "1", "error_message" => "Problem with $url", "data" => "{}"));
34
+ die;
35
+ }
36
+
37
+ $response = @stream_get_contents($fp);
38
+ if ($response === false) {
39
+ echo json_encode(array('status' => "1", "error_message" => "Problem with $url", "data" => "{}"));
40
+ die;
41
+ }
42
+
43
+ return $response;
44
+ }
45
+
46
+
47
+ function retrieveAction() {
48
+ foreach ($_POST as $key => $value)
49
+ $$key = $value;
50
+
51
+
52
+
53
+
54
+
55
+ $get_online_license = $this->getRequest()->getParam('online');
56
+
57
+ $name = $this->getRequest()->getParam('name');
58
+ $firstname = $this->getRequest()->getParam('firstname');
59
+ $email = $this->getRequest()->getParam('email');
60
+ $base_url = Mage::getStoreConfig("web/secure/base_url");
61
+
62
+ $license_request = array(
63
+ "domain"=>$base_url,
64
+ "name"=>$name,
65
+ "firstname"=>$firstname,
66
+ "email"=>$email
67
+ );
68
+
69
+ $license_server = LICENSE_SERVER;
70
+
71
+
72
+
73
+ if ($get_online_license == '0') {
74
+ //echo "Location : ".str_replace(':_:','/',$license_server)."?".http_build_query(array_merge(array("method"=>"post"),$license_request));
75
+ echo "<script>document.location.href = '".str_replace(':_:','/',$license_server)."?".http_build_query(array_merge(array("method"=>"post"),$license_request))."';</script>";
76
+ die;
77
+ } else {
78
+
79
+ $activation_code = $this->do_post_request($license_server,array_merge(array("method"=>"get"),$license_request));
80
+ $activation_code = str_replace(array('\n','\r','\r\n'),array('','',''),$activation_code);
81
+ //echo $activation_code;
82
+ $result = json_decode($activation_code);
83
+ switch ($result->status) {
84
+ case "success" :
85
+ Mage::getConfig()->saveConfig("advertise/account/license", $result->license, "default", "0");
86
+ Mage::getConfig()->cleanCache();
87
+ echo json_encode(array("status" => "1", "data" => $result->license, "message" => $result->message));
88
+ break;
89
+ case "error" :
90
+ Mage::getSingleton("adminhtml/session")->addError(Mage::helper("advertise")->__($result->message));
91
+ Mage::getConfig()->saveConfig("advertise/account/license", "", "default", "0");
92
+ Mage::getConfig()->cleanCache();
93
+ echo json_encode(array("status" => "2", "data" => "", "message" => $result->message));
94
+ break;
95
+ default :
96
+ Mage::getConfig()->saveConfig("advertise/account/license", "", "default", "0");
97
+ Mage::getConfig()->cleanCache();
98
+ echo json_encode(array("status" => "2", "data" => "", "message" => "An error occurs while connecting samsara license server (500).<br>
99
+ <a target='_blank' href='".$license_server."?" . http_build_query(array_merge(array("method"=>"post"),$license_request)) . "'>Get a license now!</a>"));
100
+ break;
101
+ }
102
+ }
103
+ }
104
+
105
+ }
app/code/community/Advertise/Account/controllers/WebserviceController.php ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require("app/code/local/Advertise/Account/Model/Account.php");
4
+
5
+ /**
6
+ * All actions must return a json string
7
+ * { status : $x , error_message : $y, data : $z }
8
+ * where $x is 0 for ok, 1 for fail
9
+ * where $y is the error message if $x=1
10
+ * where $z is a embedded json string which contains the data to return to the control panel
11
+ */
12
+ class Advertise_Account_WebserviceController extends Mage_Core_Controller_Front_Action {
13
+
14
+ /**
15
+ * transform an object to a json string
16
+ * @param $something : the object to transform
17
+ * */
18
+ private function to_json($something) {
19
+ return json_encode($something);
20
+ // TODO : check pour les erreurs json
21
+ }
22
+
23
+
24
+ /**
25
+ * Function to check the url of the webservice
26
+ * */
27
+ public function checkAction() {
28
+ foreach ($_POST as $key => $value) $$key = $value;
29
+ $license = $this->getRequest()->getParam('license');
30
+ $stored_license = Mage::getStoreConfig("advertise/account/license");
31
+ if ($stored_license != $license) {
32
+ header("Status : 404 Not Found"); header('HTTP/1.0 404 Not Found');
33
+
34
+ echo $this->to_json(array("status"=>"0","error_message"=>"","data"=>"{}"));
35
+ } else {
36
+ echo $this->to_json(array("status"=>"1","error_message"=>"","data"=>"{}"));
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Get the documentation of the webservice
42
+ * */
43
+ public function docAction() {
44
+ echo "<h1>Advertise webservice documentation</h1>";
45
+ echo "<h2>General functions</h2>";
46
+ echo "<h3><i>sample</i> function</h3>";
47
+ echo "<h3><i>generate</i> function</h3>";
48
+ echo "<h2>Getters</h2>";
49
+ echo "<h3>get_filename</h3>";
50
+ echo "<h3>get_filepath</h3>";
51
+ echo "<h3>get_stores</h3>";
52
+ echo "<h3>get_store</h3>";
53
+ echo "<h3>get_website_url</h3>";
54
+ echo "<h3>get_template</h3>";
55
+ echo "<h2>Setters</h2>";
56
+ echo "<h3>update_filename</h3>";
57
+ echo "<h3>update_filepath</h3>";
58
+ echo "<h3>update_store</h3>";
59
+ echo "<h3>update_website_url</h3>";
60
+ echo "<h3>update_template</h3>";
61
+ }
62
+
63
+ /* Getters ============================================================== */
64
+
65
+
66
+
67
+ /**
68
+ * generic action
69
+ */
70
+ private function get_generic($what_to_retrieve) {
71
+ foreach ($_POST as $key => $value)$$key = $value;
72
+ try {
73
+ $id = $this->getRequest()->getParam('id');
74
+ $is_activated = Mage::getStoreConfig("advertise/account/activated", $id);
75
+ if ($is_activated) {
76
+
77
+ $license = $this->getRequest()->getParam('license');
78
+ // check license number
79
+ $stored_license = Mage::getStoreConfig("advertise/account/license");
80
+ if ($stored_license != $license) {
81
+ header("Status : 404 Not Found"); header('HTTP/1.0 404 Not Found');
82
+ echo $this->to_json(array("status"=>"1","error_message"=>"Bad license number","data"=>"{}"));
83
+ return;
84
+ }
85
+
86
+ // specific traitement for cron schedule
87
+ if ($what_to_retrieve == "cron_schedule") {
88
+ $wtr = Mage::getStoreConfig("advertise/account/cron_schedule_1", $id);
89
+ $wtr .= " ".Mage::getStoreConfig("advertise/account/cron_schedule_2", $id);
90
+ $wtr .= " *";
91
+ $wtr .= " *";
92
+ $wtr .= " ".Mage::getStoreConfig("advertise/account/cron_schedule_5", $id);
93
+ } else {
94
+ $wtr = Mage::getStoreConfig("advertise/account/".$what_to_retrieve, $id);
95
+ }
96
+ echo $this->to_json(array("status" => "0", "error_message" => "", "data" => $this->to_json($wtr)));
97
+ } else {
98
+ echo $this->to_json(array("status"=>"1","error_message"=>"Retrieve ".$what_to_retrieve."'s feed : Store not activated!!","data"=>"{}"));
99
+ }
100
+ } catch (Exception $e) {
101
+ echo $this->to_json(array("status"=>"1","error_message"=>"Retrieve ".$what_to_retrieve."'s feed : Store not activated!!","data"=>"{}"));
102
+ }
103
+ }
104
+
105
+
106
+ private function rec_make_stores($data) {
107
+ if (!isset($data['value'])) {
108
+ $new_data = array();
109
+ foreach ($data as $d) {
110
+ $new_data[] = $this->rec_make_stores($d);
111
+ }
112
+ return $new_data;
113
+ }
114
+ if (is_array($data['value'])) {
115
+ $new_data = array();
116
+ foreach ($data['value'] as $d) {
117
+ $new_data[] = $this->rec_make_stores($d);
118
+ }
119
+ $data['value'] = $new_data;
120
+ return $data;
121
+ } else { // is an id
122
+ $is_activated = Mage::getStoreConfig("advertise/account/activated", $data['value']);
123
+ if ($is_activated != null && $is_activated == 1) {
124
+ return $data;
125
+ }
126
+ return null;
127
+ }
128
+ }
129
+
130
+ public function get_storesAction() {
131
+ try {
132
+ $license = $this->getRequest()->getParam('license');
133
+ $stored_license = Mage::getStoreConfig("advertise/account/license");
134
+ if ($stored_license !== $license) {
135
+ header("Status : 404 Not Found"); header('HTTP/1.0 404 Not Found');
136
+ echo $this->to_json(array("status"=>"1","error_message"=>"Bad license number","data"=>"{}"));
137
+ return;
138
+ } else {
139
+ $stores = Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm();
140
+ echo $this->to_json(array("status" => "0", "error_message" => "", "data" => $this->to_json($this->rec_make_stores($stores))));
141
+ }
142
+ } catch (Exception $e) {
143
+ echo $this->to_json(array("status" => "1", "error_message" => $e->getMessage(), "data" => "{}"));
144
+ }
145
+ }
146
+
147
+
148
+ /**
149
+ * Get the template for a data feed
150
+ * @param advertise_id : the id of the data feed
151
+ * */
152
+ public function get_templateAction() {
153
+ $this->get_generic('template');
154
+ }
155
+
156
+
157
+ /* Setters ============================================================== */
158
+
159
+ private function update_generic($what_to_update) {
160
+ foreach ($_POST as $key => $value) $$key = $value;
161
+
162
+ $license = $this->getRequest()->getParam('license');
163
+ $stored_license = Mage::getStoreConfig("advertise/account/license");
164
+ if ($stored_license != $license) {
165
+ header("Status : 404 Not Found"); header('HTTP/1.0 404 Not Found');
166
+ echo $this->to_json(array("status"=>"1","error_message"=>"Bad license number","data"=>"{}"));
167
+ return;
168
+ }
169
+
170
+ $id = $this->getRequest()->getParam('id');
171
+ $new_value = $this->getRequest()->getParam($what_to_update);
172
+
173
+ /* Traitements speciaux */
174
+
175
+ // traitement special pour le file path
176
+ switch ($what_to_update) {
177
+ case "filepath":
178
+ // check du path du feed
179
+ $io = new Varien_Io_File();
180
+ $realPath = $io->getCleanPath(Mage::getBaseDir() . '/' . $new_value);
181
+ if (!$io->fileExists($realPath, false)) {
182
+ die($this->to_json(array("status"=>"1","error_message"=>"The folder '$new_value' doesn't exist.","data"=>"{}")));
183
+ }
184
+ if (!$io->isWriteable($realPath)) {
185
+ die($this->to_json(array("status"=>"1","error_message"=>"You don't have the right to write in the folder '$new_value'.","data"=>"{}")));
186
+ }
187
+ $new_value = rtrim(str_replace(str_replace('\\', '/', Mage::getBaseDir()), '', $realPath), '/') . '/';
188
+ }
189
+
190
+
191
+
192
+ // retour a la normal
193
+ try {
194
+ $is_activated = Mage::getStoreConfig("advertise/account/activated", $id);
195
+ if ($is_activated) {
196
+ $config = new Mage_Core_Model_Config();
197
+ $config->saveConfig('advertise/account/'.$what_to_update, $new_value, 'stores', $id);
198
+ echo $this->to_json(array("status"=>"0","error_message"=>"","data"=>"{}"));
199
+ } else {
200
+ echo $this->to_json(array("status"=>"1","error_message"=>"Retrieve $what_to_update's feed : Store not activated!!","data"=>"{}"));
201
+ }
202
+ } catch (Mage_Core_Exception $e) {
203
+ echo $this->to_json(array("status"=>"1","error_message"=>$e->getMessage(),"data"=>"{}"));
204
+ } catch (Exception $e) {
205
+ echo $this->to_json(array("status"=>"1","error_message"=>$e->getMessage(),"data"=>"{}"));
206
+ }
207
+ }
208
+
209
+
210
+
211
+ /**
212
+ * Update the template for a data feed
213
+ * @param advertise_id : the id of the data feed
214
+ * @param template : the new template
215
+ * */
216
+ public function update_templateAction() {
217
+ $this->update_generic('template');
218
+ }
219
+
220
+
221
+
222
+ /* Others actions ======================================================= */
223
+
224
+
225
+
226
+
227
+
228
+ /**
229
+ * Webservice function : sample
230
+ * @desc : get a sample of the generated data feed
231
+ * @param advertise_id : the id of the feed
232
+ * @param limit : the number of product to include in the sample (default is 10)
233
+ * */
234
+ public function sampleAction() {
235
+ foreach ($_POST as $key => $value) $$key = $value;
236
+
237
+
238
+ $sendl = $this->getRequest()->getParam('license');
239
+
240
+ try {
241
+ $id = $this->getRequest()->getParam('id');
242
+ $ad = new Advertise();
243
+ echo $this->to_json(array("status"=>"0","error_message"=>"","data"=>$this->to_json($ad->x10($id,$sendl, 10))));
244
+ } catch (Mage_Core_Exception $e) {
245
+ header("Status : 404 Not Found"); header('HTTP/1.0 404 Not Found');
246
+ echo $this->to_json(array("status"=>"1","error_message"=>$e->getMessage(),"data"=>"{}"));
247
+ } catch (Exception $e) {
248
+ header("Status : 404 Not Found"); header('HTTP/1.0 404 Not Found');
249
+ echo $this->to_json(array("status"=>"1","error_message"=>$e->getMessage(),"data"=>"{}"));
250
+ }
251
+ }
252
+
253
+ /**
254
+ * Webservice function : generate
255
+ * @desc : get a generate of the generated data feed
256
+ * @param advertise_id : the id of the feed
257
+ * */
258
+ public function generateAction() {
259
+ foreach ($_POST as $key => $value) $$key = $value;
260
+
261
+ $sendl = $this->getRequest()->getParam('license');
262
+
263
+ try {
264
+ $id = $this->getRequest()->getParam('id');
265
+ $ad = new Advertise();
266
+ header ("content-type: text/xml");
267
+ echo $ad->x10($id,$sendl);
268
+ } catch (Mage_Core_Exception $e) {
269
+ header("Status : 404 Not Found"); header('HTTP/1.0 404 Not Found');
270
+ echo $this->to_json(array("status"=>"1","error_message"=>$e->getMessage(),"data"=>"{}"));
271
+ } catch (Exception $e) {
272
+ header("Status : 404 Not Found"); header('HTTP/1.0 404 Not Found');
273
+ echo $this->to_json(array("status"=>"1","error_message"=>$e->getMessage(),"data"=>"{}"));
274
+ }
275
+ }
276
+
277
+ }
app/code/community/Advertise/Account/etc/config.xml ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Advertise
5
+ * @package Advertise_Account
6
+ */
7
+ -->
8
+ <config>
9
+ <modules>
10
+ <Advertise_Account>
11
+ <version>1.0.2</version>
12
+ </Advertise_Account>
13
+ </modules>
14
+
15
+ <!-- Default values for settings: nest nodes as configuration setting path, e.g. advertise/account/version -->
16
+ <default>
17
+ <!-- Should change to "account" as bottom one, need to update system.xml section and other names... -->
18
+ <advertise>
19
+ <advertise>
20
+ <version>1.0.2</version>
21
+ <template>3c666565646974656d3e0d0a202020203c70726f6475637469643e7b69647d3c2f70726f6475637469643e0d0a202020203c736b753e7b736b757d3c2f736b753e0d0a202020203c70726f646e616d653e7b6e616d657d3c2f70726f646e616d653e0d0a202020203c75726c3e7b75726c7d3c2f75726c3e0d0a202020203c70726963653e7b70726963657d3c2f70726963653e0d0a202020203c707269636553616c653e7b7370656369616c5f70726963657d3c2f707269636553616c653e0d0a202020203c6465736372697074696f6e3e7b6465736372697074696f6e7d3c2f6465736372697074696f6e3e0d0a202020203c636f6e646974696f6e3e7b636f6e646974696f6e7d3c2f636f6e646974696f6e3e0d0a202020203c6d6167656e746f5669736962696c6974793e7b7669736962696c6974797d3c2f6d6167656e746f5669736962696c6974793e0d0a202020203c747970653e7b70726f647563745f747970657d3c2f747970653e0d0a202020203c63617465676f72793e7b63617465676f726965737d3c2f63617465676f72793e0d0a202020203c70726f64696d6167653e7b696d6167652c5b305d7d3c2f70726f64696d6167653e0d0a202020203c70726f64696d616765416c743e7b696d6167652c5b315d7d3c2f70726f64696d616765416c743e0d0a202020203c617661696c6162696c6974793e7b617661696c6162696c6974797d3c2f617661696c6162696c6974793e0d0a202020203c7175616e746974793e7b7174797d3c2f7175616e746974793e0d0a202020203c636f6c6f723e7b636f6c6f722c5b696d706c6f64655d2c5b2c5d7d3c2f636f6c6f723e0d0a202020203c7368697070696e675765696768743e7b7765696768747d3c2f7368697070696e675765696768743e0d0a202020203c6d616e7566616374757265723e7b6d616e7566616374757265727d3c2f6d616e7566616374757265723e0d0a202020203c6272616e643e7b6272616e647d3c2f6272616e643e0d0a202020203c6d706e3e7b6d706e7d3c2f6d706e3e0d0a202020203c6774696e3e7b6774696e7d3c2f6774696e3e0d0a202020203c73697a653e7b73697a652c5b696d706c6f64655d2c5b2c5d7d3c2f73697a653e0d0a202020203c67656e6465723e7b67656e6465727d3c2f67656e6465723e0d0a202020203c6d6574615469746c653e7b6d6574615f7469746c657d3c2f6d6574615469746c653e0d0a202020203c6d6574614465736372697074696f6e3e7b6d6574615f6465736372697074696f6e7d3c2f6d6574614465736372697074696f6e3e0d0a202020203c6d6574614b6579776f7264733e7b6d6574615f6465736372697074696f6e7d3c2f6d6574614b6579776f7264733e0d0a202020203c6164766572746973652e7365617263683e7b6164766572746973655f7365617263687d3c2f6164766572746973652e7365617263683e0d0a202020203c6164766572746973652e646973706c61793e7b6164766572746973655f7365617263687d3c2f6164766572746973652e646973706c61793e0d0a202020203c6164766572746973652e66623e7b6164766572746973655f66627d3c2f6164766572746973652e66623e0d0a202020203c6164766572746973652e6370633e7b6164766572746973655f6370637d3c2f6164766572746973652e6370633e0d0a202020203c6174747269627574655f7365745f6e616d653e7b6174747269627574655f7365745f6e616d657d3c2f6174747269627574655f7365745f6e616d653e0d0a3c2f666565646974656d3e</template>
22
+ </advertise>
23
+ </advertise>
24
+ <advertise>
25
+ <account>
26
+ <version>1.0.2</version>
27
+ <template>3c666565646974656d3e0d0a202020203c70726f6475637469643e7b69647d3c2f70726f6475637469643e0d0a202020203c736b753e7b736b757d3c2f736b753e0d0a202020203c70726f646e616d653e7b6e616d657d3c2f70726f646e616d653e0d0a202020203c75726c3e7b75726c7d3c2f75726c3e0d0a202020203c70726963653e7b70726963657d3c2f70726963653e0d0a202020203c707269636553616c653e7b7370656369616c5f70726963657d3c2f707269636553616c653e0d0a202020203c6465736372697074696f6e3e7b6465736372697074696f6e7d3c2f6465736372697074696f6e3e0d0a202020203c636f6e646974696f6e3e7b636f6e646974696f6e7d3c2f636f6e646974696f6e3e0d0a202020203c6d6167656e746f5669736962696c6974793e7b7669736962696c6974797d3c2f6d6167656e746f5669736962696c6974793e0d0a202020203c747970653e7b70726f647563745f747970657d3c2f747970653e0d0a202020203c63617465676f72793e7b63617465676f726965737d3c2f63617465676f72793e0d0a202020203c70726f64696d6167653e7b696d6167652c5b305d7d3c2f70726f64696d6167653e0d0a202020203c70726f64696d616765416c743e7b696d6167652c5b315d7d3c2f70726f64696d616765416c743e0d0a202020203c617661696c6162696c6974793e7b617661696c6162696c6974797d3c2f617661696c6162696c6974793e0d0a202020203c7175616e746974793e7b7174797d3c2f7175616e746974793e0d0a202020203c636f6c6f723e7b636f6c6f722c5b696d706c6f64655d2c5b2c5d7d3c2f636f6c6f723e0d0a202020203c7368697070696e675765696768743e7b7765696768747d3c2f7368697070696e675765696768743e0d0a202020203c6d616e7566616374757265723e7b6d616e7566616374757265727d3c2f6d616e7566616374757265723e0d0a202020203c6272616e643e7b6272616e647d3c2f6272616e643e0d0a202020203c6d706e3e7b6d706e7d3c2f6d706e3e0d0a202020203c6774696e3e7b6774696e7d3c2f6774696e3e0d0a202020203c73697a653e7b73697a652c5b696d706c6f64655d2c5b2c5d7d3c2f73697a653e0d0a202020203c67656e6465723e7b67656e6465727d3c2f67656e6465723e0d0a202020203c6d6574615469746c653e7b6d6574615f7469746c657d3c2f6d6574615469746c653e0d0a202020203c6d6574614465736372697074696f6e3e7b6d6574615f6465736372697074696f6e7d3c2f6d6574614465736372697074696f6e3e0d0a202020203c6d6574614b6579776f7264733e7b6d6574615f6465736372697074696f6e7d3c2f6d6574614b6579776f7264733e0d0a202020203c6164766572746973652e7365617263683e7b6164766572746973655f7365617263687d3c2f6164766572746973652e7365617263683e0d0a202020203c6164766572746973652e646973706c61793e7b6164766572746973655f7365617263687d3c2f6164766572746973652e646973706c61793e0d0a202020203c6164766572746973652e66623e7b6164766572746973655f66627d3c2f6164766572746973652e66623e0d0a202020203c6164766572746973652e6370633e7b6164766572746973655f6370637d3c2f6164766572746973652e6370633e0d0a202020203c6174747269627574655f7365745f6e616d653e7b6174747269627574655f7365745f6e616d657d3c2f6174747269627574655f7365745f6e616d653e0d0a3c2f666565646974656d3e</template>
28
+ </account>
29
+ </advertise>
30
+ </default>
31
+
32
+ <!-- Setup resources -->
33
+ <!-- ??? Mysql4_Setup class does not exist anywhere ??? -->
34
+ <resources>
35
+ <account_setup>
36
+ <setup>
37
+ <module>Advertise_Account</module>
38
+ <class>Advertise_Account_Resource_Mysql4_Setup</class>
39
+ </setup>
40
+ <connection>
41
+ <use>core_setup</use>
42
+ </connection>
43
+ </account_setup>
44
+ </resources>
45
+
46
+ <frontend>
47
+ <routers>
48
+ <account>
49
+ <use>standard</use>
50
+ <args>
51
+ <module>Advertise_Account</module>
52
+ <frontName>account</frontName>
53
+ </args>
54
+ </account>
55
+
56
+ <!-- Not sure what this /product frontName is used for? -->
57
+ <product>
58
+ <use>standard</use>
59
+ <args>
60
+ <module>Advertise_Account</module>
61
+ <frontName>product</frontName>
62
+ </args>
63
+ </product>
64
+
65
+ </routers>
66
+
67
+ <!-- Not sure what this layout element does - product.xml doesn't exist anywhere? -->
68
+ <layout>
69
+ <updates>
70
+ <Advertise>
71
+ <file>product.xml</file>
72
+ </Advertise>
73
+ </updates>
74
+ </layout>
75
+ </frontend>
76
+
77
+ <admin>
78
+ <routers>
79
+ <account>
80
+ <use>admin</use>
81
+ <args>
82
+ <module>Advertise_Account</module>
83
+ <frontName>account</frontName>
84
+ </args>
85
+ </account>
86
+ </routers>
87
+ </admin>
88
+
89
+ <global>
90
+ <resources>
91
+ <advertise_setup>
92
+ <setup>
93
+ <module>Advertise_Account</module>
94
+ </setup>
95
+ <connection>
96
+ <use>core_setup</use>
97
+ </connection>
98
+ </advertise_setup>
99
+ <advertise_write>
100
+ <connection>
101
+ <use>core_write</use>
102
+ </connection>
103
+ </advertise_write>
104
+ <advertise_read>
105
+ <connection>
106
+ <use>core_read</use>
107
+ </connection>
108
+ </advertise_read>
109
+ </resources>
110
+
111
+ <blocks>
112
+ <advertise>
113
+ <class>Advertise_Account_Block</class>
114
+ </advertise>
115
+ </blocks>
116
+
117
+ <helpers>
118
+ <advertise>
119
+ <class>Advertise_Account_Helper</class>
120
+ </advertise>
121
+ <product>
122
+ <class>Advertise_Account_Helper</class>
123
+ </product>
124
+ </helpers>
125
+
126
+ <models>
127
+ <account>
128
+ <class>Advertise_Account_Model</class>
129
+ </account>
130
+ </models>
131
+ </global>
132
+
133
+ <adminhtml>
134
+ <acl>
135
+ <resources>
136
+ <admin>
137
+ <children>
138
+ <system>
139
+ <children>
140
+ <config>
141
+ <children>
142
+ <advertise_settings translate="title" module="product">
143
+ <title>Advertise Section</title>
144
+ <sort_order>1</sort_order>
145
+ </advertise_settings>
146
+ <advertise translate="title">
147
+ <title>Advertise</title>
148
+ <sort_order>2</sort_order>
149
+ </advertise>
150
+ </children>
151
+ </config>
152
+ </children>
153
+ </system>
154
+ </children>
155
+ </admin>
156
+ </resources>
157
+ </acl>
158
+
159
+ <layout>
160
+ <updates>
161
+ <Advertise>
162
+ <file>settings.xml</file>
163
+ </Advertise>
164
+ </updates>
165
+ </layout>
166
+ </adminhtml>
167
+
168
+ <!-- Do we still need this cron stuff? -->
169
+ <crontab>
170
+ <jobs>
171
+ <advertise_generate>
172
+ <schedule>
173
+ <cron_expr>* * * * *</cron_expr>
174
+ </schedule>
175
+ <run>
176
+ <model>advertise/observer::scheduledGenerateCatalogs</model>
177
+ </run>
178
+ </advertise_generate>
179
+ </jobs>
180
+ </crontab>
181
+ </config>
app/code/community/Advertise/Account/etc/system.xml ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <tabs>
5
+ <Advertise translate="label">
6
+ <label>Advertise</label>
7
+ <sort_order>405</sort_order>
8
+ </Advertise>
9
+ </tabs>
10
+
11
+ <sections>
12
+ <advertise translate="label">
13
+ <label>License</label>
14
+ <tab>Advertise</tab>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>999</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>1</show_in_store>
20
+ <groups>
21
+ <advertise translate="label">
22
+ <label>Adverti.se License</label>
23
+ <frontend_type>text</frontend_type>
24
+ <sort_order>100</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>1</show_in_store>
28
+ <fields>
29
+ <version translate="label comment">
30
+ <label>Extension version</label>
31
+ <frontend_type>Link</frontend_type>
32
+ <sort_order>0</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>0</show_in_website>
35
+ <show_in_store>0</show_in_store>
36
+ </version>
37
+
38
+ <get_online_license translate="label comment">
39
+ <label>Get online license :</label>
40
+ <frontend_type>select</frontend_type>
41
+ <source_model>adminhtml/system_config_source_yesno</source_model>
42
+ <sort_order>1</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>0</show_in_website>
45
+ <show_in_store>0</show_in_store>
46
+ </get_online_license>
47
+
48
+ <license translate="label comment">
49
+ <label>License</label>
50
+ <frontend_type>Advertiselicense</frontend_type>
51
+ <sort_order>2</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>0</show_in_website>
54
+ <show_in_store>0</show_in_store>
55
+ </license>
56
+
57
+ <activated translate="label comment">
58
+ <label>Activate this store :</label>
59
+ <frontend_type>select</frontend_type>
60
+ <source_model>adminhtml/system_config_source_yesno</source_model>
61
+ <sort_order>1</sort_order>
62
+ <show_in_default>0</show_in_default>
63
+ <show_in_website>0</show_in_website>
64
+ <show_in_store>1</show_in_store>
65
+ </activated>
66
+
67
+ <template translate="label comment">
68
+ <label>Template (will be hidden)</label>
69
+ <frontend_type>advertisetemplate</frontend_type>
70
+ <sort_order>3</sort_order>
71
+ <show_in_default>0</show_in_default>
72
+ <show_in_website>0</show_in_website>
73
+ <show_in_store>1</show_in_store>
74
+ </template>
75
+ </fields>
76
+ </advertise>
77
+ </groups>
78
+ </advertise>
79
+ <advertise_settings translate="label" module="product">
80
+ <class>separator-top</class>
81
+ <label>Settings</label>
82
+ <tab>Advertise</tab>
83
+ <sort_order>130</sort_order>
84
+ <show_in_default>1</show_in_default>
85
+ <show_in_website>1</show_in_website>
86
+ <show_in_store>1</show_in_store>
87
+ <groups>
88
+ <!-- REMOVE ADMIN BAR
89
+ <admin_bar translate="label">
90
+ <label>Admin Bar Settings</label>
91
+ <frontend_type>text</frontend_type>
92
+ <sort_order>6</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>1</show_in_website>
95
+ <show_in_store>1</show_in_store>
96
+ <fields>
97
+ <turn_off translate="label">
98
+ <label>Enable Adverti.se Admin Bar</label>
99
+ <frontend_type>select</frontend_type>
100
+ <source_model>account/config_source_onoff</source_model>
101
+ <sort_order>30</sort_order>
102
+ <show_in_default>1</show_in_default>
103
+ <show_in_website>1</show_in_website>
104
+ <show_in_store>1</show_in_store>
105
+ </turn_off>
106
+ </fields>
107
+ </admin_bar> -->
108
+ <settings translate="label">
109
+ <label>Settings</label>
110
+ <frontend_type>text</frontend_type>
111
+ <sort_order>5</sort_order>
112
+ <show_in_default>1</show_in_default>
113
+ <show_in_website>1</show_in_website>
114
+ <show_in_store>1</show_in_store>
115
+ <fields>
116
+ <settings_email translate="label">
117
+ <label>Email</label>
118
+ <frontend_type>text</frontend_type>
119
+ <backend_model>account/config</backend_model>
120
+ <sort_order>30</sort_order>
121
+ <show_in_default>1</show_in_default>
122
+ <show_in_website>1</show_in_website>
123
+ <show_in_store>1</show_in_store>
124
+ </settings_email>
125
+ </fields>
126
+ </settings>
127
+ </groups>
128
+ </advertise_settings>
129
+ </sections>
130
+ </config>
app/code/community/Advertise/Account/sql/advertise_setup/mysql4-install-4.0.0.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
5
+ $installer->startSetup();
6
+
7
+ $setup->addAttributeGroup('catalog_product', 'Default', 'Advertise', 1000);
8
+
9
+ // the attribute added will be displayed under the group/tab Special Attributes in product edit page
10
+ $setup->addAttribute('catalog_product', 'advertise_search', array(
11
+ 'group' => 'Advertise',
12
+ 'input' => 'text',
13
+ 'type' => 'text',
14
+ 'label' => 'advertise_search',
15
+ 'backend' => '',
16
+ 'visible' => 1,
17
+ 'required' => 0,
18
+ 'user_defined' => 1,
19
+ 'searchable' => 1,
20
+ 'filterable' => 0,
21
+ 'comparable' => 1,
22
+ 'visible_on_front' => 1,
23
+ 'visible_in_advanced_search' => 0,
24
+ 'is_html_allowed_on_front' => 0,
25
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
26
+ ));
27
+ $setup->addAttribute('catalog_product', 'advertise_display', array(
28
+ 'group' => 'Advertise',
29
+ 'input' => 'text',
30
+ 'type' => 'text',
31
+ 'label' => 'advertise_display',
32
+ 'backend' => '',
33
+ 'visible' => 1,
34
+ 'required' => 0,
35
+ 'user_defined' => 1,
36
+ 'searchable' => 1,
37
+ 'filterable' => 0,
38
+ 'comparable' => 1,
39
+ 'visible_on_front' => 1,
40
+ 'visible_in_advanced_search' => 0,
41
+ 'is_html_allowed_on_front' => 0,
42
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
43
+ ));
44
+ $setup->addAttribute('catalog_product', 'advertise_fb', array(
45
+ 'group' => 'Advertise',
46
+ 'input' => 'text',
47
+ 'type' => 'text',
48
+ 'label' => 'advertise_fb',
49
+ 'backend' => '',
50
+ 'visible' => 1,
51
+ 'required' => 0,
52
+ 'user_defined' => 1,
53
+ 'searchable' => 1,
54
+ 'filterable' => 0,
55
+ 'comparable' => 1,
56
+ 'visible_on_front' => 1,
57
+ 'visible_in_advanced_search' => 0,
58
+ 'is_html_allowed_on_front' => 0,
59
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
60
+ ));
61
+ $setup->addAttribute('catalog_product', 'advertise_cpc', array(
62
+ 'group' => 'Advertise',
63
+ 'input' => 'text',
64
+ 'type' => 'text',
65
+ 'label' => 'advertise_cpc',
66
+ 'backend' => '',
67
+ 'visible' => 1,
68
+ 'required' => 0,
69
+ 'user_defined' => 1,
70
+ 'searchable' => 1,
71
+ 'filterable' => 0,
72
+ 'comparable' => 1,
73
+ 'visible_on_front' => 1,
74
+ 'visible_in_advanced_search' => 0,
75
+ 'is_html_allowed_on_front' => 0,
76
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
77
+ ));
78
+
79
+ $installer->endSetup();
80
+
81
+
82
+
app/code/community/Advertise/Account/sql/advertise_setup/mysql4-install-5.0.0.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
5
+ $installer->startSetup();
6
+
7
+ $setup->addAttributeGroup('catalog_product', 'Default', 'Advertise', 1000);
8
+
9
+ // the attribute added will be displayed under the group/tab Special Attributes in product edit page
10
+ $setup->addAttribute('catalog_product', 'advertise_search', array(
11
+ 'group' => 'Advertise',
12
+ 'input' => 'text',
13
+ 'type' => 'text',
14
+ 'label' => 'advertise_search',
15
+ 'backend' => '',
16
+ 'visible' => 1,
17
+ 'required' => 0,
18
+ 'user_defined' => 1,
19
+ 'searchable' => 1,
20
+ 'filterable' => 0,
21
+ 'comparable' => 1,
22
+ 'visible_on_front' => 1,
23
+ 'visible_in_advanced_search' => 0,
24
+ 'is_html_allowed_on_front' => 0,
25
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
26
+ ));
27
+ $setup->addAttribute('catalog_product', 'advertise_display', array(
28
+ 'group' => 'Advertise',
29
+ 'input' => 'text',
30
+ 'type' => 'text',
31
+ 'label' => 'advertise_display',
32
+ 'backend' => '',
33
+ 'visible' => 1,
34
+ 'required' => 0,
35
+ 'user_defined' => 1,
36
+ 'searchable' => 1,
37
+ 'filterable' => 0,
38
+ 'comparable' => 1,
39
+ 'visible_on_front' => 1,
40
+ 'visible_in_advanced_search' => 0,
41
+ 'is_html_allowed_on_front' => 0,
42
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
43
+ ));
44
+ $setup->addAttribute('catalog_product', 'advertise_fb', array(
45
+ 'group' => 'Advertise',
46
+ 'input' => 'text',
47
+ 'type' => 'text',
48
+ 'label' => 'advertise_fb',
49
+ 'backend' => '',
50
+ 'visible' => 1,
51
+ 'required' => 0,
52
+ 'user_defined' => 1,
53
+ 'searchable' => 1,
54
+ 'filterable' => 0,
55
+ 'comparable' => 1,
56
+ 'visible_on_front' => 1,
57
+ 'visible_in_advanced_search' => 0,
58
+ 'is_html_allowed_on_front' => 0,
59
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
60
+ ));
61
+ $setup->addAttribute('catalog_product', 'advertise_cpc', array(
62
+ 'group' => 'Advertise',
63
+ 'input' => 'text',
64
+ 'type' => 'text',
65
+ 'label' => 'advertise_cpc',
66
+ 'backend' => '',
67
+ 'visible' => 1,
68
+ 'required' => 0,
69
+ 'user_defined' => 1,
70
+ 'searchable' => 1,
71
+ 'filterable' => 0,
72
+ 'comparable' => 1,
73
+ 'visible_on_front' => 1,
74
+ 'visible_in_advanced_search' => 0,
75
+ 'is_html_allowed_on_front' => 0,
76
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
77
+ ));
78
+
79
+ $installer->endSetup();
80
+
81
+
82
+
app/code/community/Advertise/Account/sql/setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ ?>
app/etc/modules/Advertise_Account.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @package Advertise_Account
5
+ */
6
+ -->
7
+
8
+ <config>
9
+ <!-- Declare Advertise_Account Module -->
10
+ <modules>
11
+ <Advertise_Account>
12
+ <active>true</active>
13
+ <codePool>community</codePool>
14
+ <class>Advertise_Account_Model_MyAccountModel</class>
15
+ <version>1.0.2</version>
16
+ </Advertise_Account>
17
+ </modules>
18
+ </config>
lib/Varien/Data/Form/Element/Advertiselicense.php ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * @category Advertise
6
+ * @package Advertise_Account
7
+ */
8
+
9
+ class Varien_Data_Form_Element_Advertiselicense extends Varien_Data_Form_Element_Abstract {
10
+
11
+ /**
12
+ * Init Element
13
+ *
14
+ * @param array $attributes
15
+ */
16
+ public function __construct($attributes=array()) {
17
+ parent::__construct($attributes);
18
+ $this->setType('text');
19
+ $this->setExtType('text');
20
+ }
21
+
22
+ /**
23
+ * Retrieve allow attributes
24
+ *
25
+ * @return array
26
+ */
27
+ public function getHtmlAttributes() {
28
+ return array('type', 'name', 'class', 'style', 'checked', 'onclick', 'onchange', 'disabled');
29
+ }
30
+
31
+ /**
32
+ * Prepare value list
33
+ *
34
+ * @return array
35
+ */
36
+ protected function _prepareValues() {
37
+ $options = array();
38
+ $values = array("");
39
+ return $values;
40
+ }
41
+
42
+ /**
43
+ * Retrieve HTML
44
+ *
45
+ * @return string
46
+ */
47
+ public function getElementHtml() {
48
+ $values = $this->_prepareValues();
49
+
50
+ if (!$values) {
51
+ return '';
52
+ }
53
+ $id = $this->getHtmlId();
54
+
55
+ $user = ($_SESSION['admin']['user']);
56
+ $user_data = $user->getData();
57
+ $user['fn'] =$user_data['firstname'];
58
+ // echo "<pre>";print_r($_SESSION);echo "</pre>";
59
+ $user['n'] =$user_data['lastname'];
60
+ $user['e'] =$user_data['email'];
61
+
62
+ $html="
63
+
64
+ <script>
65
+ function get_license() {
66
+ $('advertise_advertise_license').value = '';
67
+ $('msg').style.display = 'none';
68
+ $('msg_err').style.display = 'none';
69
+ //Element.show('loadingmask');
70
+
71
+ var online_l = $('advertise_advertise_get_online_license').value;
72
+
73
+ if (online_l==1) {
74
+ new Ajax.Request('".Mage::getUrl('account/license/retrieve')."', {
75
+ method: 'post',
76
+ parameters: {
77
+ online:online_l,
78
+ name:$('adv_name').value,
79
+ firstname:$('adv_firstname').value,
80
+ email:$('adv_email').value,
81
+ version:$('advertise_advertise_version').innerHTML
82
+ },
83
+ onComplete: function(transport) {
84
+
85
+ var res = eval ('('+transport.responseText+')');
86
+ if (res['status']==0) {
87
+ $('msg').style.display = 'block';
88
+ $('msg_cnt').innerHTML = res['message'];
89
+ } else if (res['status']==1) {
90
+ $('msg').style.display = 'block';
91
+ $('msg_cnt').innerHTML = res['message'];
92
+ $('advertise_advertise_license').value = res['data'];
93
+ } else if (res['status']==2) {
94
+ $('msg_err').style.display = 'block';
95
+ $('msg_err_cnt').innerHTML = res['message'];
96
+ }
97
+ }
98
+ });
99
+ } else {
100
+ ";
101
+
102
+ $html .= "window.open('".Mage::getUrl('account/license/retrieve')."online/0/url/'+'/name/'+$('adv_name').value+'/firstname/'+$('adv_firstname').value+'/email/'+$('adv_email').value+'/version/'+$('advertise_advertise_version').innerHTML);
103
+ }
104
+
105
+ }
106
+ </script>
107
+
108
+ <input type='hidden' value='".$user['fn']."' id='adv_firstname'/>
109
+ <input type='hidden' value='".$user['n']."' id='adv_name'/>
110
+ <input type='hidden' value='".$user['e']."' id='adv_email'/>
111
+
112
+ <input class=' input-text' style='width:150px' type='text' id='".$this->getHtmlId()."' name='".$this->getName()."' value='".$this->getEscapedValue()."' '".$this->serialize($this->getHtmlAttributes())."/>
113
+
114
+ <button class='scalable' style='' onclick=\"get_license()\" type='button'>
115
+ <span>Get a license</span>
116
+ </button>
117
+
118
+ <div id='msg' style='display:none'>
119
+ <ul class='messages'>
120
+ <li class='success-msg'>
121
+ <ul>
122
+ <li>
123
+ <span id='msg_cnt'></span>
124
+ </li>
125
+ </ul>
126
+ </li>
127
+ </ul>
128
+ </div>
129
+ <div id='msg_err' style='display:none'>
130
+ <ul class='messages'>
131
+ <li class='error-msg'>
132
+ <ul>
133
+ <li>
134
+ <span id='msg_err_cnt'></span>
135
+ </li>
136
+ </ul>
137
+ </li>
138
+ </ul>
139
+ </div>
140
+
141
+ ";
142
+
143
+
144
+
145
+ return $html;
146
+ }
147
+
148
+ public function getOnclick($value) {
149
+ $this->setValue("ok");
150
+ if ($onclick = $this->getData('onclick')) {
151
+ return str_replace('$value', $value, $onclick);
152
+ }
153
+ return;
154
+ }
155
+
156
+ }
lib/Varien/Data/Form/Element/Advertisetemplate.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * @category Advertise
6
+ * @package Advertise_Account
7
+ */
8
+
9
+ class Varien_Data_Form_Element_Advertisetemplate extends Varien_Data_Form_Element_Abstract {
10
+
11
+ /**
12
+ * Init Element
13
+ *
14
+ * @param array $attributes
15
+ */
16
+ public function __construct($attributes=array()) {
17
+ parent::__construct($attributes);
18
+ $this->setType('text');
19
+ $this->setExtType('text');
20
+ }
21
+
22
+ /**
23
+ * Retrieve allow attributes
24
+ *
25
+ * @return array
26
+ */
27
+ public function getHtmlAttributes() {
28
+ return array('type', 'name', 'class', 'style', 'checked', 'onclick', 'onchange', 'disabled');
29
+ }
30
+
31
+ /**
32
+ * Prepare value list
33
+ *
34
+ * @return array
35
+ */
36
+ protected function _prepareValues() {
37
+ $options = array();
38
+ $values = array("");
39
+ return $values;
40
+ }
41
+
42
+ /**
43
+ * Retrieve HTML
44
+ *
45
+ * @return string
46
+ */
47
+ public function getElementHtml() {
48
+ $values = $this->_prepareValues();
49
+
50
+ if (!$values) {
51
+ return '';
52
+ }
53
+ $id = $this->getHtmlId();
54
+
55
+ $html="
56
+
57
+ <script>
58
+ new Event.observe(window, 'load', function() { $('row_advertise_advertise_template').style.display='none'; });
59
+ </script>
60
+
61
+ <input class=' input-text' type='hidden' id='".$this->getHtmlId()."' name='".$this->getName()."' value='".$this->getEscapedValue()."' '".$this->serialize($this->getHtmlAttributes())."/>
62
+
63
+ ";
64
+
65
+
66
+ $html .= $this->getAfterElementHtml();
67
+
68
+ return $html;
69
+ }
70
+
71
+ public function getOnclick($value) {
72
+ $this->setValue("ok");
73
+ if ($onclick = $this->getData('onclick')) {
74
+ return str_replace('$value', $value, $onclick);
75
+ }
76
+ return;
77
+ }
78
+
79
+ }
package.xml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>AdvertiseCommunity</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Provides common functionality required by Advertise Related Products, Advertise Colors, &amp; Advertise Ads</summary>
10
+ <description>&lt;p&gt;Join the Adverti.se community.&lt;/p&gt;&#xD;
11
+ &lt;p&gt;This package provides core functionality required by other Advertise extensions. It enables the creation of an Adverti.se account.&lt;/p&gt;&#xD;
12
+ &#xD;
13
+ &lt;p&gt;This package will be automatically installed when you install any of the following:&#xD;
14
+ &lt;/p&gt;&#xD;
15
+ &lt;a href="http://www.magentocommerce.com/magento-connect/colors-by-adverti-se-1816.html"&gt;Advertise Colors&lt;/a&gt;&#xD;
16
+ &lt;a href="http://www.magentocommerce.com/magento-connect/advertise-related-products-5385.html"&gt;Advertise Related Products&lt;/a&gt;&#xD;
17
+ &#xD;
18
+ &lt;p&gt;Learn more about how Adverti.se can help your magento store at &lt;a href="http://www.adverti.se"&gt;Adverti.se&lt;/a&gt;&#xD;
19
+ &lt;/p&gt;</description>
20
+ <notes>Initial release</notes>
21
+ <authors><author><name>Michael Oxley</name><user>advertise</user><email>mike@adverti.se</email></author></authors>
22
+ <date>2012-07-25</date>
23
+ <time>11:48:39</time>
24
+ <contents><target name="mage"><dir name="lib"><dir name="Varien"><dir name="Data"><dir name="Form"><dir name="Element"><file name="Advertisetemplate.php" hash="93d8c1f2ace06bd46e68857b9b98ec52"/><file name="Advertiselicense.php" hash="26d50ff2d280db94e4d0eb7187376880"/></dir></dir></dir></dir></dir><dir name="app"><dir name="etc"><dir name="modules"><file name="Advertise_Account.xml" hash="2bd58af0a4999bc2fe80a1d6e8a07d57"/></dir></dir><dir name="code"><dir name="community"><dir name="Advertise"><dir name="Account"><dir name="Helper"><file name="Data.php" hash="9b22d8f7156cd9f694774d7e29e2b5a8"/></dir><dir name="Model"><file name="Account.php" hash="605e33ef9c956852cd9f0357cb10776c"/><dir name="Config"><dir name="Source"><file name="Onoff.php" hash="684e42d40da3b47053bf345f201df140"/></dir></dir><file name="Config.php" hash="d1b199bba390a6ef5031d7d2707f7f88"/><file name="MyAccountModel.php" hash="d7abbf976d96028ece0331db2ba40559"/><file name="Settings.php" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir><dir name="controllers"><file name="IndexController.php" hash="50eea849547a732c20462da19029e432"/><file name="LicenseController.php" hash="b83f323609fecefa4ff6dbab911468ce"/><file name="WebserviceController.php" hash="b0374376ff8f098caf0c814d5f3be8d3"/></dir><dir name="etc"><file name="config.xml" hash="1008af4062018449215a14f21dc1235f"/><file name="system.xml" hash="a5aeb08a6f37a069153ebfd638dc8080"/></dir><dir name="sql"><dir name="advertise_setup"><file name="mysql4-install-4.0.0.php" hash="b4535b5068d6b72999c94e91d487bc62"/><file name="mysql4-install-5.0.0.php" hash="b4535b5068d6b72999c94e91d487bc62"/></dir><dir name="setup"><file name="mysql4-install-0.1.0.php" hash="452925d5182994846dbe3b9518db84d8"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
25
+ <compatible/>
26
+ <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
27
+ </package>