Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- *
- * @ This file is created by http://DeZender.Net
- * @ deZender (PHP5 Decoder for ionCube Encoder)
- *
- * @ Version : 3.5.0.0
- * @ Author : DeZender
- * @ Release on : 22.06.2018
- * @ Official site : http://DeZender.Net
- *
- */
- if (!defined('MODULE_NAME')) {
- define('MODULE_NAME', 'export_to_instagram');
- }
- define('AUTHOR_LINK', '');
- set_time_limit(0);
- date_default_timezone_set('UTC');
- if (!class_exists('str_lib')) {
- class str_lib
- {
- public function str_lib_conv()
- {
- $str_lib = 'nazarspece';
- echo 'licensed to ' . $str_lib;
- }
- }
- }
- if (!function_exists('icdk')) {
- function icdk($a)
- {
- return md5(md5($a) . 'HGF+_)(()HG*^&^gghfddhkU&*H');
- }
- }
- class ModelExtensionModuleAwExportToInstagram extends Model
- {
- public $server = false;
- public $_files = array();
- public $_handles = array();
- private $use_proxy = false;
- private $proxy_list = false;
- private static $pro = false;
- private static $actived = false;
- private static $cookies = '';
- private static $server_connect = false;
- private $username = null;
- private $password = null;
- private $uuid = null;
- private $adid = null;
- private $phone_id = null;
- private $max_size = 1080;
- private $ig_url = 'https://i.instagram.com/api/v1/';
- private $ig_headers = array();
- private $headers_add = array();
- private $sig_key_version = 4;
- private $ig_sig_key = 'ac5f26ee05af3e40a81b94b78d762dc8287bcdd8254fe86d0971b2aded8884a4';
- private $ig_version = '64.0.0.14.96';
- private $ig_version_code = '125398467';
- private $user_agent_format = 'Instagram %s Android (%s/%s; %s; %s; %s; %s; %s; %s; %s; %s)';
- private $content_type = 'application/x-www-form-urlencoded; charset=UTF-8';
- private $boundary_chars = '-_1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
- private $device_id = null;
- private $device_string = null;
- private $device = array();
- private $devices = array('18/4.3; 320dpi; 720x1280; Xiaomi; HM 1SW; armani; qcom', '24/7.0; 380dpi; 1080x1920; OnePlus; ONEPLUS A3010; OnePlus3T; qcom', '23/6.0.1; 640dpi; 1440x2392; LGE/lge; RS988; h1; h1', '24/7.0; 640dpi; 1440x2560; HUAWEI; LON-L29; HWLON; hi3660', '23/6.0.1; 640dpi; 1440x2560; ZTE; ZTE A2017U; ailsa_ii; qcom', '23/6.0.1; 640dpi; 1440x2560; samsung; SM-G935F; hero2lte; samsungexynos8890', '17/4.2.2; 240dpi; 1080x1920; samsung; SM-G350; cs02; hawaii_ss_cs02', '23/6.0.1; 640dpi; 1440x2560; samsung; SM-G930F; herolte; samsungexynos8890');
- public function createTables()
- {
- $sql = 'CREATE TABLE IF NOT EXISTS `aw_export_to_instagram` (`id` INT(11) NOT NULL, PRIMARY KEY (`id`)) CHARSET=utf8 COLLATE utf8_general_ci';
- $this->db->query($sql);
- $sql = 'CREATE TABLE IF NOT EXISTS `aw_export_to_instagram_cronlist` (`id` int(11) NOT NULL, PRIMARY KEY (`id`)) CHARSET=utf8 COLLATE utf8_general_ci';
- $this->db->query($sql);
- $sql = 'CREATE TABLE IF NOT EXISTS `aw_export_to_instagram_profiles` (`id` int(11) NOT NULL, PRIMARY KEY (`id`)) CHARSET=utf8 COLLATE utf8_general_ci';
- $this->db->query($sql);
- $sql = 'CREATE TABLE IF NOT EXISTS `aw_export_to_instagram_settings` (`id` int(11) NOT NULL, PRIMARY KEY (`id`)) CHARSET=utf8 COLLATE utf8_general_ci';
- $this->db->query($sql);
- $sql = 'CREATE TABLE IF NOT EXISTS `aw_export_to_instagram_templates` (`id` int(11) NOT NULL, PRIMARY KEY (`id`)) CHARSET=utf8 COLLATE utf8_general_ci';
- $this->db->query($sql);
- $tablesInfo = $this->alterTables();
- foreach ($tablesInfo as $tablename => $tableInfo) {
- if (empty($tableInfo)) {
- continue;
- }
- $tablename = 'aw_export_to_instagram' . $tablename;
- $sql = 'ALTER TABLE `' . $tablename . '`';
- $this->db->query($sql . ' CHANGE `id` `id` INT(11) NOT NULL AUTO_INCREMENT');
- foreach ($tableInfo as $fieldname => $field) {
- $alterinfo = $sql . sprintf($field, $fieldname);
- $notexists = "SELECT '" . $fieldname . "' FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '" . DB_DATABASE . "' AND TABLE_NAME = '" . $tablename . "' AND COLUMN_NAME = '" . $fieldname . "'";
- $isexists = $this->db->query($notexists);
- if (!$isexists->num_rows) {
- $this->db->query($alterinfo);
- }
- }
- }
- }
- protected function alterTables()
- {
- return array('' => array('profile_id' => ' ADD `%s` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'shortcode' => ' ADD `%s` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'media_id' => ' ADD `%s` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'product_id' => ' ADD `%s` int(11) NOT NULL', 'date' => ' ADD `%s` int(64) NOT NULL', 'group' => ' ADD `%s` int(11) NOT NULL', 'status_id' => ' ADD `%s` int(1) NOT NULL'), '_cronlist' => array('cron_token' => 'ADD `%s` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'name' => 'ADD `%s` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'product_quantity' => 'ADD `%s` int(3) NOT NULL', 'group_product_quantity' => 'ADD `%s` int(3) NOT NULL', 'product_sort' => 'ADD `%s` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'is_nostock' => 'ADD `%s` int(1) NOT NULL', 'is_noprice' => 'ADD `%s` int(1) NOT NULL', 'is_disabled' => 'ADD `%s` int(1) NOT NULL', 'categories_id' => 'ADD `%s` text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'manufacturers_id' => 'ADD `%s` text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'products_id' => 'ADD `%s` text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'stores_id' => 'ADD `%s` text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'profiles_id' => 'ADD `%s` text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'export_action' => 'ADD `%s` int(1) NOT NULL DEFAULT 1', 'send_notifications' => 'ADD `%s` int(1) NOT NULL', 'task' => 'ADD `%s` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'status_id' => 'ADD `%s` int(1) NOT NULL'), '_profiles' => array('profile_id' => 'ADD `%s` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'status_id' => 'ADD `%s` int(1) NOT NULL', 'stores_id' => 'ADD `%s` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'login' => 'ADD `%s` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'password' => 'ADD `%s` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'pk' => 'ADD `%s` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'cookies' => 'ADD `%s` text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'settings' => 'ADD `%s` text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'time_logon' => 'ADD `%s` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL'), '_settings' => array('store_id' => 'ADD `%s` int(11) NOT NULL', 'is_album' => 'ADD `%s` int(1) NOT NULL DEFAULT 1', 'is_resize' => 'ADD `%s` int(1) NOT NULL DEFAULT 1', 'is_crop' => 'ADD `%s` int(1) NOT NULL DEFAULT 2', 'is_crop_ratio' => 'ADD `%s` int(1) NOT NULL DEFAULT 1', 'is_watermark' => 'ADD `%s` int(1) NOT NULL', 'use_is_all_stores' => 'ADD `%s` int(1) NOT NULL', 'compression_quality' => 'ADD `%s` int(3) NOT NULL', 'background' => 'ADD `%s` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'watermark' => 'ADD `%s` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'watermark_size' => 'ADD `%s` int(3) NOT NULL DEFAULT 100', 'watermark_quality' => 'ADD `%s` int(3) NOT NULL DEFAULT 80', 'watermark_position' => 'ADD `%s` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'cover' => 'ADD `%s` int(1) NOT NULL', 'cover_gap' => 'ADD `%s` int(3) NOT NULL DEFAULT 50', 'cover_custom' => 'ADD `%s` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'group_caption' => 'ADD `%s` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'use_template' => 'ADD `%s` int(1) NOT NULL', 'is_seo_url' => 'ADD `%s` int(1) NOT NULL', 'template_id' => 'ADD `%s` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'category_template_id' => 'ADD `%s` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'language_id' => 'ADD `%s` int(11) NOT NULL', 'currency' => 'ADD `%s` varchar(5) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'is_crop_description' => 'ADD `%s` int(1) NOT NULL DEFAULT 1', 'is_remove_spaces' => 'ADD `%s` int(1) NOT NULL DEFAULT 1', 'use_shortlinks' => 'ADD `%s` int(1) NOT NULL', 'location' => 'ADD `%s` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'location_id' => 'ADD `%s` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'use_ds_all_stores' => 'ADD `%s` int(1) NOT NULL', 'store_tags' => 'ADD `%s` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'tags_random' => 'ADD `%s` int(3) NOT NULL'), '_templates' => array('template_id' => 'ADD `%s` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'name' => 'ADD `%s` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL', 'template' => 'ADD `%s` text CHARACTER SET utf8mb4 NOT NULL', 'is_option_price' => 'ADD `%s` int(1) NOT NULL', 'status_id' => 'ADD `%s` int(1) NOT NULL'));
- }
- public function getProfiles($filter = array())
- {
- $profiles = array();
- $sql = 'SELECT * FROM `aw_' . MODULE_NAME . '_profiles`';
- if (isset($filter['filter_profile_id'])) {
- $sql .= " WHERE profile_id = '" . $this->db->escape($filter['filter_profile_id']) . "'";
- }
- if (!$this->pro) {
- $sql .= ' LIMIT 1';
- }
- $query = $this->db->query($sql);
- foreach ($query->rows as $profile) {
- $profile['stores_id'] = json_decode($profile['stores_id'], true);
- if (!$this->user->hasPermission('modify', 'extension/module/aw_' . MODULE_NAME)) {
- $profile['password'] = '';
- }
- $profiles[] = $profile;
- }
- if (isset($filter['filter_profile_id'])) {
- return current($profiles);
- }
- return $profiles;
- }
- public function getStores($filter = array())
- {
- $stores = array();
- $stores[0] = array('store_id' => 0, 'name' => $this->language->get('text_main_store_name'));
- if (!$this->pro) {
- return $stores;
- }
- $sql = 'SELECT * FROM `' . DB_PREFIX . 'store`';
- $query = $this->db->query($sql);
- foreach ($query->rows as $store) {
- if (100 <= count($stores)) {
- break;
- }
- $stores[$store['store_id']] = array('store_id' => $store['store_id'], 'name' => $store['name']);
- }
- return $stores;
- }
- public function getStoreByIdSettings($store_id = 0, $filter = array())
- {
- $sql = 'SELECT * FROM `' . DB_PREFIX . "setting` WHERE store_id = '" . (int) $store_id . "'";
- if (!empty($filter['filter_code'])) {
- $sql .= " AND `code` = '" . $this->db->escape($filter['filter_code']) . "'";
- }
- if (!empty($filter['filter_key'])) {
- $sql .= " AND `key` = '" . $this->db->escape($filter['filter_key']) . "'";
- }
- $query = $this->db->query($sql);
- return $query->rows;
- }
- public function getLanguageIdByCode($code)
- {
- $sql = 'SELECT * FROM `' . DB_PREFIX . "language` WHERE code = '" . $this->db->escape($code) . "'";
- $query = $this->db->query($sql);
- return $query->row['language_id'];
- }
- public function getSettings($filter = array())
- {
- $sql = 'SELECT * FROM `aw_' . MODULE_NAME . '_settings`';
- if (isset($filter['filter_store_id'])) {
- $sql .= " WHERE store_id = '" . $this->db->escape($filter['filter_store_id']) . "'";
- }
- if (!$this->pro) {
- $sql .= ' LIMIT 1';
- }
- $query = $this->db->query($sql);
- if (isset($filter['filter_store_id'])) {
- return $query->row;
- }
- return $query->rows;
- }
- public function getTemplates($filter = array())
- {
- $sql = 'SELECT * FROM `aw_' . MODULE_NAME . '_templates`';
- if (isset($filter['filter_template_id'])) {
- $sql .= " WHERE template_id = '" . $this->db->escape($filter['filter_template_id']) . "'";
- }
- if (!$this->pro) {
- $sql .= ' LIMIT 1';
- }
- $query = $this->db->query($sql);
- if (isset($filter['filter_template_id'])) {
- return $query->row;
- }
- return $query->rows;
- }
- public function getCronlist($filter = array())
- {
- $cronlist = array();
- $sql = 'SELECT * FROM `aw_' . MODULE_NAME . '_cronlist`';
- if (isset($filter['filter_task_token'])) {
- $sql .= " WHERE task = '" . $this->db->escape($filter['filter_task_token']) . "'";
- }
- if (!$this->pro) {
- $sql .= ' LIMIT 0';
- }
- $query = $this->db->query($sql);
- foreach ($query->rows as $cronvalues) {
- $cronvalues['categories'] = array();
- $cronvalues['categories_id'] = json_decode($cronvalues['categories_id'], true);
- if (0 < count($cronvalues['categories_id'])) {
- $cronvalues['categories'] = $this->getCategories(array('filter_category_id' => $cronvalues['categories_id']));
- }
- $cronvalues['manufacturers'] = array();
- $cronvalues['manufacturers_id'] = json_decode($cronvalues['manufacturers_id'], true);
- if (0 < count($cronvalues['manufacturers_id'])) {
- $cronvalues['manufacturers'] = $this->getManufacturers(array('filter_manufacturer_id' => $cronvalues['manufacturers_id']));
- }
- $cronvalues['products'] = array();
- $cronvalues['products_id'] = json_decode($cronvalues['products_id'], true);
- if (0 < count($cronvalues['products_id'])) {
- $cronvalues['products'] = $this->getProducts(array('limit' => count($cronvalues['products_id']), 'filter_product_id' => $cronvalues['products_id']));
- }
- $cronvalues['stores_id'] = json_decode($cronvalues['stores_id'], true);
- $cronvalues['profiles_id'] = json_decode($cronvalues['profiles_id'], true);
- $cronlist[] = $cronvalues;
- }
- if (isset($filter['filter_task_token'])) {
- return current($cronlist);
- }
- return $cronlist;
- }
- public function getCategories($filter, $select = '')
- {
- $sql = 'SELECT cp.category_id' . $select . ", GROUP_CONCAT(cd1.name ORDER BY cp.level SEPARATOR ' > ') AS name FROM " . DB_PREFIX . 'category_path cp LEFT JOIN ' . DB_PREFIX . 'category c1 ON (cp.category_id = c1.category_id) LEFT JOIN ' . DB_PREFIX . 'category c2 ON (cp.path_id = c2.category_id) LEFT JOIN ' . DB_PREFIX . 'category_description cd1 ON (cp.path_id = cd1.category_id) LEFT JOIN ' . DB_PREFIX . 'category_description cd2 ON (cp.category_id = cd2.category_id)';
- if (!empty($filter['filter_product_id'])) {
- $sql .= ' LEFT JOIN ' . DB_PREFIX . 'product_to_category p2c ON (p2c.category_id = cp.category_id)';
- }
- $sql .= ' WHERE';
- if (isset($filter['filter_language_id'])) {
- $sql .= " cd1.language_id = '" . (int) $filter['filter_language_id'] . "' AND cd2.language_id = '" . (int) $filter['filter_language_id'] . "'";
- } else {
- $sql .= " cd1.language_id = '" . (int) $this->config->get('config_language_id') . "' AND cd2.language_id = '" . (int) $this->config->get('config_language_id') . "'";
- }
- if (!empty($filter['filter_product_id'])) {
- $sql .= ' AND p2c.main_category = 1 AND p2c.product_id = ' . (int) $filter['filter_product_id'];
- }
- if (!empty($filter['filter_name'])) {
- $sql .= " AND cd2.name LIKE '%" . $this->db->escape($filter['filter_name']) . "%'";
- }
- if (!empty($filter['filter_category_id'])) {
- $sql .= ' AND';
- if (is_array($filter['filter_category_id'])) {
- $sql .= ' (';
- foreach ($filter['filter_category_id'] as $category_id) {
- $sql .= " cd2.category_id = '" . (int) $category_id . "' OR";
- }
- $sql = trim($sql, ' OR') . ')';
- } else {
- $sql .= " cd2.category_id = '" . (int) $filter['filter_category_id'] . "'";
- }
- }
- $sql .= ' GROUP BY cp.category_id LIMIT 0,10';
- $query = $this->db->query($sql);
- return $query->rows;
- }
- public function getCategoriesIdByProductId($product_id)
- {
- $sql = 'SELECT cp.path_id as category_id FROM `' . DB_PREFIX . 'product_to_category` p2c LEFT JOIN `' . DB_PREFIX . "category_path` cp ON (p2c.category_id = cp.category_id) WHERE p2c.product_id = '" . (int) $product_id . "' ORDER BY cp.level ASC";
- $query = $this->db->query($sql);
- $categories_id = array();
- foreach ($query->rows as $row) {
- $categories_id[] = $row['category_id'];
- }
- return $categories_id;
- }
- public function getManufacturers($filter = array())
- {
- $sql = 'SELECT m.manufacturer_id, m.name FROM ' . DB_PREFIX . 'manufacturer m WHERE';
- if (isset($filter['filter_name'])) {
- $sql .= " m.name LIKE '" . $this->db->escape($filter['filter_name']) . "%'";
- }
- if (isset($filter['filter_manufacturer_id'])) {
- $sql .= (isset($filter['filter_name']) ? ' AND' : '');
- if (is_array($filter['filter_manufacturer_id'])) {
- $sql .= ' (';
- foreach ($filter['filter_manufacturer_id'] as $manufacturer_id) {
- $sql .= " m.manufacturer_id = '" . (int) $manufacturer_id . "' OR";
- }
- $sql = trim($sql, ' OR') . ')';
- } else {
- $sql .= " m.manufacturer_id = '" . (int) $filter['filter_manufacturer_id'] . "'";
- }
- }
- $sql .= ' LIMIT 0,10';
- $query = $this->db->query($sql);
- if (isset($filter['filter_manufacturer_id']) && !is_array($filter['filter_manufacturer_id'])) {
- return $query->row;
- }
- return $query->rows;
- }
- public function getProducts($filter, $select = '')
- {
- $sql = 'SELECT p.product_id, p.status, p.sku, pd.name' . ((0 < strlen($select) ? ', ' . $select : '')) . ' FROM ' . DB_PREFIX . 'product p LEFT JOIN ' . DB_PREFIX . 'product_description pd ON (p.product_id = pd.product_id)';
- if (!empty($filter['filter_category_id'])) {
- .....................................................................
- ....................................
- ..........
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement