├── .gitignore
├── 1.5
├── admin
│ ├── controller
│ │ └── module
│ │ │ └── apimodule.php
│ ├── language
│ │ ├── english
│ │ │ └── module
│ │ │ │ └── apimodule.php
│ │ └── russian
│ │ │ └── module
│ │ │ └── apimodule.php
│ └── view
│ │ └── template
│ │ └── module
│ │ └── apimodule.tpl
├── catalog
│ ├── controller
│ │ └── module
│ │ │ └── apimodule.php
│ └── model
│ │ └── module
│ │ └── apimodule.php
└── vqmod
│ └── xml
│ └── apimodule.xml
├── 2.0
├── full
│ ├── README.md
│ ├── apimobile-2.0-opencart-2.0._.ocmod.zip
│ ├── install.php
│ ├── install.xml
│ ├── readme.txt
│ └── upload
│ │ ├── admin
│ │ ├── controller
│ │ │ └── module
│ │ │ │ └── apimodule.php
│ │ ├── language
│ │ │ ├── en-gb
│ │ │ │ └── module
│ │ │ │ │ └── apimodule.php
│ │ │ ├── english
│ │ │ │ └── module
│ │ │ │ │ └── apimodule.php
│ │ │ ├── ru-RU
│ │ │ │ └── module
│ │ │ │ │ └── apimodule.php
│ │ │ └── russian
│ │ │ │ └── module
│ │ │ │ └── apimodule.php
│ │ └── view
│ │ │ └── template
│ │ │ └── module
│ │ │ └── apimodule.tpl
│ │ └── catalog
│ │ ├── controller
│ │ └── module
│ │ │ └── apimodule.php
│ │ └── model
│ │ └── module
│ │ └── apimodule.php
└── patch
│ ├── README.md
│ ├── apimobile2.0.ocmod.zip
│ ├── install.php
│ ├── install.xml
│ ├── readme.txt
│ └── upload
│ ├── admin
│ ├── language
│ │ ├── en-gb
│ │ │ └── module
│ │ │ │ └── apimodule.php
│ │ ├── english
│ │ │ └── module
│ │ │ │ └── apimodule.php
│ │ ├── ru-RU
│ │ │ └── module
│ │ │ │ └── apimodule.php
│ │ └── russian
│ │ │ └── module
│ │ │ └── apimodule.php
│ └── view
│ │ └── template
│ │ └── module
│ │ └── apimodule.tpl
│ └── catalog
│ ├── controller
│ └── module
│ │ └── apimodule.php
│ └── model
│ └── module
│ └── apimodule.php
├── 2.3
├── full
│ ├── README.md
│ ├── apimobile-2.0-opencart-2.3._.ocmod.zip
│ ├── install.php
│ ├── install.xml
│ ├── readme.txt
│ └── upload
│ │ ├── admin
│ │ ├── controller
│ │ │ └── extension
│ │ │ │ └── module
│ │ │ │ └── apimodule.php
│ │ ├── language
│ │ │ ├── en-gb
│ │ │ │ └── extension
│ │ │ │ │ └── module
│ │ │ │ │ └── apimodule.php
│ │ │ ├── ru-RU
│ │ │ │ └── module
│ │ │ │ │ └── apimodule.php
│ │ │ └── russian
│ │ │ │ ├── extension
│ │ │ │ └── module
│ │ │ │ │ └── apimodule.php
│ │ │ │ └── module
│ │ │ │ └── apimodule.php
│ │ └── view
│ │ │ └── template
│ │ │ └── extension
│ │ │ └── module
│ │ │ └── apimodule.tpl
│ │ └── catalog
│ │ ├── controller
│ │ └── module
│ │ │ └── apimodule.php
│ │ └── model
│ │ └── module
│ │ └── apimodule.php
└── patch
│ ├── README.md
│ ├── apimobile2.0.ocmod.zip
│ ├── install.php
│ ├── install.xml
│ ├── readme.txt
│ └── upload
│ ├── admin
│ ├── language
│ │ ├── en-gb
│ │ │ └── extension
│ │ │ │ └── module
│ │ │ │ └── apimodule.php
│ │ ├── ru-RU
│ │ │ └── module
│ │ │ │ └── apimodule.php
│ │ └── russian
│ │ │ ├── extension
│ │ │ └── module
│ │ │ │ └── apimodule.php
│ │ │ └── module
│ │ │ └── apimodule.php
│ └── view
│ │ └── template
│ │ └── extension
│ │ └── module
│ │ └── apimodule.tpl
│ └── catalog
│ ├── controller
│ └── module
│ │ └── apimodule.php
│ └── model
│ └── module
│ └── apimodule.php
├── 3.0
├── full
│ ├── README.md
│ ├── apimobile-2.0-opencart-3.0._.ocmod.zip
│ ├── install.xml
│ ├── readme.txt
│ └── upload
│ │ ├── admin
│ │ ├── controller
│ │ │ └── extension
│ │ │ │ └── module
│ │ │ │ └── apimodule.php
│ │ ├── language
│ │ │ ├── en-gb
│ │ │ │ └── extension
│ │ │ │ │ └── module
│ │ │ │ │ └── apimodule.php
│ │ │ ├── ru-RU
│ │ │ │ └── extension
│ │ │ │ │ └── module
│ │ │ │ │ └── apimodule.php
│ │ │ └── russian
│ │ │ │ └── extension
│ │ │ │ └── module
│ │ │ │ └── apimodule.php
│ │ └── view
│ │ │ └── template
│ │ │ └── extension
│ │ │ └── module
│ │ │ └── apimodule.twig
│ │ └── catalog
│ │ ├── controller
│ │ └── extension
│ │ │ └── module
│ │ │ └── apimodule.php
│ │ └── model
│ │ └── extension
│ │ └── module
│ │ └── apimodule.php
└── patch
│ ├── README.md
│ ├── apimobile2.0.ocmod.zip
│ ├── install.php
│ ├── install.xml
│ ├── readme.txt
│ └── upload
│ ├── admin
│ ├── language
│ │ ├── en-gb
│ │ │ └── extension
│ │ │ │ └── module
│ │ │ │ └── apimodule.php
│ │ ├── ru-RU
│ │ │ └── extension
│ │ │ │ └── module
│ │ │ │ └── apimodule.php
│ │ └── russian
│ │ │ └── extension
│ │ │ └── module
│ │ │ └── apimodule.php
│ └── view
│ │ └── template
│ │ └── extension
│ │ └── module
│ │ └── apimodule.twig
│ └── catalog
│ ├── controller
│ └── extension
│ │ └── module
│ │ └── apimodule.php
│ └── model
│ └── extension
│ └── module
│ └── apimodule.php
├── Images
├── Step 1a.jpg
├── Step 2.2.png
├── step 0.jpg
├── step 1.png
├── step 2.6.png
├── step 2a.jpg
├── step 3a.jpg
├── step 4a.jpg
├── step 5a.jpg
├── step 6a.jpg
└── step 7.png
├── README.md
├── apimobile-2.0-opencart-1.5._.zip
├── apimobile-2.0-opencart-2.0._.ocmod.zip
├── apimobile-2.0-opencart-2.3._.ocmod.zip
├── apimobile-2.0-opencart-3.0._.ocmod.zip
├── install.php
├── readme.txt
└── upload
├── admin
└── controller
│ └── module
│ └── apimodule.php
└── catalog
└── controller
└── module
└── apimodule.php
/.gitignore:
--------------------------------------------------------------------------------
1 | /.git
2 | /.idea
3 | .DS*
4 |
--------------------------------------------------------------------------------
/1.5/admin/controller/module/apimodule.php:
--------------------------------------------------------------------------------
1 | registry);
13 | $this->API_VERSION = $api->getVersion();
14 | $this->OPENCART_VERSION = substr(VERSION,0,3);
15 | }
16 |
17 | public function checkVersion(){
18 | $return = false;
19 |
20 | $curl_handle = curl_init();
21 | curl_setopt($curl_handle, CURLOPT_URL,'https://opencartapp.pro/app/index.php?opencart_version='.$this->OPENCART_VERSION);
22 | curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
23 | curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
24 | curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0');
25 | $json = curl_exec($curl_handle);
26 | curl_close($curl_handle);
27 | $version = json_decode($json,1);
28 |
29 | if($this->API_VERSION <(float)$version['version']){
30 | $return = $version['version'];
31 | }
32 | return $return;
33 | }
34 |
35 | public function index() {
36 | $this->load->language('module/apimodule');
37 |
38 | $this->document->setTitle($this->language->get('heading_title'));
39 |
40 | $this->load->model('setting/setting');
41 |
42 | if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
43 |
44 | $this->model_setting_setting->editSetting('apimodule', $this->request->post);
45 |
46 | $this->session->data['success'] = $this->language->get('text_success');
47 |
48 | $this->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));
49 | }
50 |
51 |
52 |
53 | $this->data['heading_title'] = $this->language->get('heading_title');
54 |
55 | $this->data['text_edit'] = $this->language->get('text_edit');
56 | $this->data['text_enabled'] = $this->language->get('text_enabled');
57 | $this->data['text_disabled'] = $this->language->get('text_disabled');
58 |
59 | $this->data['entry_status'] = $this->language->get('entry_status');
60 | $this->data['entry_store'] = $this->language->get('entry_store');
61 | $this->data['text_default'] = $this->language->get('text_default');
62 |
63 | $this->data['button_save'] = $this->language->get('button_save');
64 | $this->data['button_cancel'] = $this->language->get('button_cancel');
65 | $this->data['button_update'] = $this->language->get('button_update');
66 |
67 | if (isset($this->error['warning'])) {
68 | $this->data['error_warning'] = $this->error['warning'];
69 | } else {
70 | $this->data['error_warning'] = '';
71 | }
72 |
73 | $this->data['breadcrumbs'] = array();
74 |
75 | $this->data['breadcrumbs'][] = array(
76 | 'text' => $this->language->get('text_home'),
77 | 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
78 | 'separator' => false
79 | );
80 |
81 | $this->data['breadcrumbs'][] = array(
82 | 'text' => $this->language->get('text_module'),
83 | 'href' => $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'),
84 | 'separator' => ' :: '
85 | );
86 |
87 | $this->data['breadcrumbs'][] = array(
88 | 'text' => $this->language->get('heading_title'),
89 | 'href' => $this->url->link('module/apimodule', 'token=' . $this->session->data['token'], 'SSL'),
90 | 'separator' => ' :: '
91 | );
92 |
93 |
94 | $this->data['action'] = $this->url->link('module/apimodule', 'token=' . $this->session->data['token'], 'SSL');
95 |
96 | $this->data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL');
97 |
98 | if (isset($this->request->post['apimodule_status'])) {
99 | $this->data['apimodule_status'] = $this->request->post['apimodule_status'];
100 | } else {
101 | $this->data['apimodule_status'] = $this->config->get('apimodule_status');
102 | }
103 |
104 | $this->load->model('setting/store');
105 | $this->data['stores'] = $this->model_setting_store->getStores();
106 | if (isset($this->request->post['apimodule_store'])) {
107 | $this->data['apimodule_store'] = $this->request->post['apimodule_store'];
108 | } else {
109 | if ( is_null($this->config->get('apimodule_store')) ) {
110 | $this->data['apimodule_store'] = array(0);
111 | } else {
112 | $this->data['apimodule_store'] = $this->config->get('apimodule_store');
113 | }
114 | }
115 |
116 | if (!extension_loaded('zip')) {
117 | $this->data['ext'] = "not installed zip extension for update";
118 | }else{
119 | $this->data['ext'] = "";
120 | }
121 |
122 |
123 |
124 | if (isset($this->session->data['error'])) {
125 | $this->data['error'] = $this->session->data['error'];
126 |
127 | unset($this->session->data['error']);
128 | } else {
129 | $this->data['error'] = '';
130 | }
131 |
132 | $this->load->model('design/layout');
133 |
134 | $this->data['layouts'] = $this->model_design_layout->getLayouts();
135 |
136 | $this->template = 'module/apimodule.tpl';
137 | $this->children = array(
138 | 'common/header',
139 | 'common/footer'
140 | );
141 |
142 | $this->data['version'] = $version = $this->checkVersion();
143 | $this->data['update'] = $this->url->link('extension/module/apimodule/update&v='.$version, 'token=' . $this->session->data['token'], 'SSL');
144 |
145 | $this->response->setOutput($this->render());
146 | }
147 |
148 | protected function validate() {
149 | if (!$this->user->hasPermission('modify', 'module/apimodule')) {
150 | $this->error['warning'] = $this->language->get('error_permission');
151 | }
152 |
153 | if (!$this->error) {
154 | return true;
155 | } else {
156 | return false;
157 | }
158 | }
159 |
160 | private $path = "update";
161 | private $fileName = "";
162 |
163 | public function update() {
164 |
165 | if(isset($_GET['v'])) {
166 | //apimobile1.8.ocmod.zip
167 | $this->fileName = "apimobile" . $_GET['v'] .".ocmod.zip";
168 | //$file = file_get_contents("https://opencartapp.pro/app/".$this->OPENCART_VERSION.'/'.$this->fileName);
169 | // If no temp directory exists create it
170 |
171 |
172 | $ch = curl_init();
173 | curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
174 | curl_setopt($ch, CURLOPT_HEADER, 0);
175 | curl_setopt($ch, CURLOPT_FAILONERROR, 1);
176 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
177 | curl_setopt($ch, CURLOPT_URL, "https://opencartapp.pro/app/".$this->OPENCART_VERSION.'/'.$this->fileName);
178 | $file = curl_exec($ch);
179 | curl_close($ch);
180 |
181 | if (!is_dir(DIR_UPLOAD . $this->path)) {
182 | mkdir(DIR_UPLOAD . $this->path, 0777);
183 | }
184 |
185 | $new_path = DIR_UPLOAD . $this->path ."/" . $this->fileName;
186 | if(!file_exists($new_path)) {
187 | file_put_contents( $new_path, $file );
188 | }
189 |
190 | $this->installPatch();
191 | }else{
192 | $this->error['warning'] = "Not version";
193 | }
194 | return $this->error;
195 | }
196 |
197 |
198 | public function install() {
199 |
200 | $this->db->query("CREATE TABLE IF NOT EXISTS " . DB_PREFIX."user_token_mob_api (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, user_id INT NOT NULL, token VARCHAR(32) NOT NULL )");
201 | $this->db->query("CREATE TABLE IF NOT EXISTS " . DB_PREFIX."user_device_mob_api (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, user_id INT NOT NULL, device_token VARCHAR(500) , os_type VARCHAR(20))");
202 |
203 | $this->load->model('setting/setting');
204 | $this->model_setting_setting->editSetting('apimodule', ['apimodule_store' => ['0']]);
205 |
206 | }
207 |
208 | private function installPatch() {
209 |
210 | $this->unzip();
211 | $ftp = $this->ftp();
212 | if(isset($ftp['error'])){
213 | $this->session->data['error'] = $ftp['error'];
214 | $this->response->redirect($this->url->link('module/apimodule', 'token=' . $this->session->data['token'], 'SSL'));
215 | }
216 | $this->php();
217 | $this->sql();
218 |
219 | $this->clear();
220 | $this->session->data['success'] = "Модуль успешно обновлен";
221 | $this->response->redirect($this->url->link('extension/extension', 'token=' . $this->session->data['token'], 'SSL'));
222 |
223 | }
224 |
225 |
226 | public function unzip() {
227 | $this->load->language('extension/installer');
228 |
229 | $json = array();
230 | // Sanitize the filename
231 | $file = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path) . '/'.$this->fileName;
232 |
233 | if (!file_exists($file)) {
234 | $json['error'] = $this->language->get('error_file');
235 | }
236 |
237 | if (!$json) {
238 | // Unzip the files
239 | $zip = new ZipArchive();
240 |
241 | if ($zip->open($file)) {
242 | $zip->extractTo(DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ));
243 | // echo DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path );
244 |
245 | $zip->close();
246 | } else {
247 | $json['error'] = $this->language->get('error_unzip');
248 | }
249 |
250 | // Remove Zip
251 | unlink($file);
252 | }
253 |
254 | }
255 |
256 | public function ftp() {
257 | $this->load->language('extension/installer');
258 |
259 | $json = array();
260 |
261 | // Check FTP status
262 | if (!$this->config->get('config_ftp_status')) {
263 | $json['error'] = $this->language->get('error_ftp_status');
264 | }
265 |
266 | $directory = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ) . '/upload/';
267 |
268 | if (!is_dir($directory)) {
269 | $json['error'] = $this->language->get('error_directory');
270 | }
271 |
272 | if (!$json) {
273 | // Get a list of files ready to upload
274 | $files = array();
275 |
276 | $path = array($directory . '*');
277 |
278 | while (count($path) != 0) {
279 | $next = array_shift($path);
280 |
281 | foreach ((array)glob($next) as $file) {
282 | if (is_dir($file)) {
283 | $path[] = $file . '/*';
284 | }
285 |
286 | $files[] = $file;
287 | }
288 | }
289 |
290 | // Connect to the site via FTP
291 | $connection = ftp_connect($this->config->get('config_ftp_hostname'), $this->config->get('config_ftp_port'));
292 |
293 | if ($connection) {
294 | $login = ftp_login($connection, $this->config->get('config_ftp_username'), $this->config->get('config_ftp_password'));
295 |
296 | if ($login) {
297 | if ($this->config->get('config_ftp_root')) {
298 | $root = ftp_chdir($connection, $this->config->get('config_ftp_root'));
299 | } else {
300 | $root = ftp_chdir($connection, '/');
301 | }
302 |
303 | if ($root) {
304 | foreach ($files as $file) {
305 | $destination = substr($file, strlen($directory));
306 |
307 | // Upload everything in the upload directory
308 | // Many people rename their admin folder for security purposes which I believe should be an option during installation just like setting the db prefix.
309 | // the following code would allow you to change the name of the following directories and any extensions installed will still go to the right directory.
310 | if (substr($destination, 0, 5) == 'admin') {
311 | $destination = basename(DIR_APPLICATION) . substr($destination, 5);
312 | }
313 |
314 | if (substr($destination, 0, 7) == 'catalog') {
315 | $destination = basename(DIR_CATALOG) . substr($destination, 7);
316 | }
317 |
318 | if (substr($destination, 0, 5) == 'image') {
319 | $destination = basename(DIR_IMAGE) . substr($destination, 5);
320 | }
321 |
322 | if (substr($destination, 0, 6) == 'system') {
323 | $destination = basename(DIR_SYSTEM) . substr($destination, 6);
324 | }
325 |
326 | if (is_dir($file)) {
327 | $list = ftp_nlist($connection, substr($destination, 0, strrpos($destination, '/')));
328 |
329 | // Basename all the directories because on some servers they don't return the fulll paths.
330 | $list_data = array();
331 |
332 | foreach ($list as $list) {
333 | $list_data[] = basename($list);
334 | }
335 |
336 | if (!in_array(basename($destination), $list_data)) {
337 | if (!ftp_mkdir($connection, $destination)) {
338 | $json['error'] = sprintf($this->language->get('error_ftp_directory'), $destination);
339 | }
340 | }
341 | }
342 |
343 | if (is_file($file)) {
344 | if (!ftp_put($connection, $destination, $file, FTP_BINARY)) {
345 | $json['error'] = sprintf($this->language->get('error_ftp_file'), $file);
346 | }
347 | }
348 | }
349 | } else {
350 | $json['error'] = sprintf($this->language->get('error_ftp_root'), $root);
351 | }
352 | } else {
353 | $json['error'] = sprintf($this->language->get('error_ftp_login'), $this->config->get('config_ftp_username'));
354 | }
355 |
356 | ftp_close($connection);
357 | } else {
358 | $json['error'] = sprintf($this->language->get('error_ftp_connection'), $this->config->get('config_ftp_hostname'), $this->config->get('config_ftp_port'));
359 | }
360 | }
361 | return $json;
362 | }
363 |
364 | public function sql() {
365 | $this->load->language('extension/installer');
366 |
367 | $json = array();
368 |
369 | $file = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ) . '/install.sql';
370 |
371 | if (!file_exists($file)) {
372 | $json['error'] = $this->language->get('error_file');
373 | }
374 |
375 | if (!$json) {
376 | $lines = file($file);
377 |
378 | if ($lines) {
379 | try {
380 | $sql = '';
381 |
382 | foreach ($lines as $line) {
383 | if ($line && (substr($line, 0, 2) != '--') && (substr($line, 0, 1) != '#')) {
384 | $sql .= $line;
385 |
386 | if (preg_match('/;\s*$/', $line)) {
387 | $sql = str_replace(" `oc_", " `" . DB_PREFIX, $sql);
388 |
389 | $this->db->query($sql);
390 |
391 | $sql = '';
392 | }
393 | }
394 | }
395 | } catch(Exception $exception) {
396 | $json['error'] = sprintf($this->language->get('error_exception'), $exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
397 | }
398 | }
399 | }
400 | }
401 |
402 | public function xml() {
403 | $this->load->language('extension/installer');
404 |
405 | $json = array();
406 |
407 | $file = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ) . '/install.xml';
408 |
409 | if (!file_exists($file)) {
410 | $json['error'] = $this->language->get('error_file');
411 | }
412 |
413 | if (!$json) {
414 | $this->load->model('extension/modification');
415 |
416 | // If xml file just put it straight into the DB
417 | $xml = file_get_contents($file);
418 |
419 | if ($xml) {
420 | try {
421 | $dom = new DOMDocument('1.0', 'UTF-8');
422 | $dom->loadXml($xml);
423 |
424 | $name = $dom->getElementsByTagName('name')->item(0);
425 |
426 | if ($name) {
427 | $name = $name->nodeValue;
428 | } else {
429 | $name = '';
430 | }
431 |
432 | $code = $dom->getElementsByTagName('code')->item(0);
433 |
434 | if ($code) {
435 | $code = $code->nodeValue;
436 |
437 | // Check to see if the modification is already installed or not.
438 | $modification_info = $this->model_extension_modification->getModificationByCode($code);
439 |
440 | if ($modification_info) {
441 | $json['error'] = sprintf($this->language->get('error_exists'), $modification_info['name']);
442 | }
443 | } else {
444 | $json['error'] = $this->language->get('error_code');
445 | }
446 |
447 | $author = $dom->getElementsByTagName('author')->item(0);
448 |
449 | if ($author) {
450 | $author = $author->nodeValue;
451 | } else {
452 | $author = '';
453 | }
454 |
455 | $version = $dom->getElementsByTagName('version')->item(0);
456 |
457 | if ($version) {
458 | $version = $version->nodeValue;
459 | } else {
460 | $version = '';
461 | }
462 |
463 | $link = $dom->getElementsByTagName('link')->item(0);
464 |
465 | if ($link) {
466 | $link = $link->nodeValue;
467 | } else {
468 | $link = '';
469 | }
470 |
471 | $modification_data = array(
472 | 'name' => $name,
473 | 'code' => $code,
474 | 'author' => $author,
475 | 'version' => $version,
476 | 'link' => $link,
477 | 'xml' => $xml,
478 | 'status' => 1
479 | );
480 |
481 | if (!$json) {
482 | $this->model_extension_modification->addModification($modification_data);
483 | }
484 | } catch(Exception $exception) {
485 | $json['error'] = sprintf($this->language->get('error_exception'), $exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
486 | }
487 | }
488 | }
489 | }
490 |
491 | public function php() {
492 | $this->load->language('extension/installer');
493 |
494 | $json = array();
495 |
496 | if (!$this->user->hasPermission('modify', 'extension/installer')) {
497 | $json['error'] = $this->language->get('error_permission');
498 | }
499 |
500 | $file = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ) . '/install.php';
501 |
502 | if (!file_exists($file)) {
503 | $json['error'] = $this->language->get('error_file');
504 | }
505 |
506 | if (!$json) {
507 | try {
508 | include($file);
509 | } catch(Exception $exception) {
510 | $json['error'] = sprintf($this->language->get('error_exception'), $exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
511 | }
512 | }
513 |
514 | }
515 |
516 | public function remove() {
517 | $this->load->language('extension/installer');
518 |
519 | $json = array();
520 |
521 | $directory = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path );
522 |
523 | if (!is_dir($directory)) {
524 | $json['error'] = $this->language->get('error_directory');
525 | }
526 |
527 | if (!$json) {
528 | // Get a list of files ready to upload
529 | $files = array();
530 |
531 | $path = array($directory);
532 |
533 | while (count($path) != 0) {
534 | $next = array_shift($path);
535 |
536 | // We have to use scandir function because glob will not pick up dot files.
537 | foreach (array_diff(scandir($next), array('.', '..')) as $file) {
538 | $file = $next . '/' . $file;
539 |
540 | if (is_dir($file)) {
541 | $path[] = $file;
542 | }
543 |
544 | $files[] = $file;
545 | }
546 | }
547 |
548 | rsort($files);
549 |
550 | foreach ($files as $file) {
551 | if (is_file($file)) {
552 | unlink($file);
553 | } elseif (is_dir($file)) {
554 | rmdir($file);
555 | }
556 | }
557 |
558 | if (file_exists($directory)) {
559 | rmdir($directory);
560 | }
561 |
562 | $json['success'] = $this->language->get('text_success');
563 | }
564 |
565 | }
566 |
567 | public function clear() {
568 | $this->load->language('extension/installer');
569 |
570 | $json = array();
571 |
572 | if (!$json) {
573 | $directories = glob(DIR_UPLOAD . 'update', GLOB_ONLYDIR);
574 |
575 | foreach ($directories as $directory) {
576 | // Get a list of files ready to upload
577 | $files = array();
578 |
579 | $path = array($directory);
580 |
581 | while (count($path) != 0) {
582 | $next = array_shift($path);
583 |
584 | // We have to use scandir function because glob will not pick up dot files.
585 | foreach (array_diff(scandir($next), array('.', '..')) as $file) {
586 | $file = $next . '/' . $file;
587 |
588 | if (is_dir($file)) {
589 | $path[] = $file;
590 | }
591 |
592 | $files[] = $file;
593 | }
594 | }
595 |
596 | rsort($files);
597 |
598 | foreach ($files as $file) {
599 | if (is_file($file)) {
600 | unlink($file);
601 | } elseif (is_dir($file)) {
602 | rmdir($file);
603 | }
604 | }
605 |
606 | if (file_exists($directory)) {
607 | rmdir($directory);
608 | }
609 | }
610 |
611 | $json['success'] = $this->language->get('text_clear');
612 | }
613 | }
614 | }
615 |
--------------------------------------------------------------------------------
/1.5/admin/language/english/module/apimodule.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/1.5/vqmod/xml/apimodule.xml:
--------------------------------------------------------------------------------
1 |
2 | Apimodule
3 | 1.0.0
4 | 1.0.9
5 | Pinta
6 |
7 |
8 |
9 |
10 | data['vouchers'] = array();
12 | ]]>
13 |
14 | load->model('module/apimodule');
16 | $this->model_module_apimodule->sendNotifications($order_id);
17 | ]]>
18 |
19 |
20 |
21 |
22 |
23 | model_user_user->deleteUser($user_id);]]>
24 | db->query($sql);
27 | $sql = "DELETE FROM `" . DB_PREFIX . "user_device_mob_api` WHERE user_id = ". $user_id;
28 | $query = $this->db->query($sql); ]]>
29 |
30 |
31 |
--------------------------------------------------------------------------------
/2.0/full/README.md:
--------------------------------------------------------------------------------
1 | OPENCART-MOBILE-ADMIN
2 | =====================
3 | Модуль для Opencart версии 2.0.0.0 и выше, содержащий API для управления интернет-магазином с мобильного устройста.
4 | ***
5 |
6 | Перед установкой убедитесь, что OpenCart Extension Installer настроен правильно,
7 | особенно FTP настройки.
8 | Если при установке появляется ошибка - установите дополнение: [https://www.opencart.com](https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=18892) и попробуйте снова.
9 |
10 | ***
11 | ### Установка производится через OCMOD:
12 | ***
13 | 1. Для установки перейдите в админ панель;
14 | 2. Перейдите "Модули->установка расширений";
15 | 3. Нажмите "загрузить файл" и выберите **apimobile.ocmod.zip**.
16 |
17 | ***
18 | ### ВАЖНО!!!
19 |
20 | Модуль не работает если включён режим обслуживания.
21 | ***
22 |
23 | #### Используйте эту ссылку для скачивания аппликации:
24 |
--------------------------------------------------------------------------------
/2.0/full/apimobile-2.0-opencart-2.0._.ocmod.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/2.0/full/apimobile-2.0-opencart-2.0._.ocmod.zip
--------------------------------------------------------------------------------
/2.0/full/install.php:
--------------------------------------------------------------------------------
1 | db->query("DROP TABLE IF EXISTS `" . DB_PREFIX."user_token_mob_api` ");
3 | $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX."user_device_mob_api` ");
4 | $this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX."user_token_mob_api` (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, user_id INT NOT NULL, token VARCHAR(32) NOT NULL )");
5 | $this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX."user_device_mob_api` (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, user_id INT NOT NULL, device_token VARCHAR(500) , os_type VARCHAR(50))");
6 |
7 | $this->load->model('setting/setting');
8 |
9 | $this->model_setting_setting->editSetting('apimodule', ['apimodule_status'=>1,'version'=>1.7]);
10 | if(VERSION == '2.0.0.0' ){
11 | $this->load->model('tool/event');
12 | $this->model_tool_event->deleteEvent('apimodule');
13 | $this->model_tool_event->addEvent('apimodule', 'post.order.history.add', 'module/apimodule/sendNotifications');
14 | }elseif(VERSION == '2.0.0.0a1' || VERSION == '2.0.0.0a2'){
15 | $this->load->model('tool/event');
16 | $this->model_tool_event->deleteHandler('apimodule');
17 | $this->model_tool_event->setHandler('apimodule', 'post.order.history.add', 'module/apimodule/sendNotifications');
18 | }elseif(VERSION == '2.2.0.0'){
19 | $this->load->model('extension/event');
20 | $this->model_extension_event->deleteEvent('apimodule');
21 | $this->model_extension_event->addEvent('apimodule', 'catalog/model/checkout/order/addOrderHistory/after', 'module/apimodule/sendNotifi_2_2_0_0');
22 | }else{
23 | //$this->load->model('extension/event');
24 | //$this->model_extension_event->deleteEvent('apimodule');
25 | //$this->model_extension_event->addEvent('apimodule', 'post.order.history.add', 'module/apimodule/sendNotifications');
26 | }
27 |
28 |
29 |
30 | ?>
--------------------------------------------------------------------------------
/2.0/full/install.xml:
--------------------------------------------------------------------------------
1 |
2 | Check update apimodule
3 | 2.0
4 | http://opencartapp.com
5 | Pinta
6 | apimodule_ocmod
7 |
8 |
9 |
10 | load->controller('extension/module/apimodule/checkVersion');
15 | }else{
16 | $version = $this->load->controller('module/apimodule/checkVersion');
17 | }
18 |
19 | if ($this->API_VERSION <(float)$version) {
20 | $data['update_module'] = "Обновите модуль OPENCART-MOBILE-ADMIN до версии ".$version." или скачайте по ссылке скачать ";
21 | } else {
22 | $data['update_module'] = '';
23 | }
24 | ]]>
25 |
26 |
27 |
28 |
29 | ]]>
30 |
32 |
33 |
34 |
35 |
36 | ]]>
37 |
38 |
39 |
40 |
41 | model_user_user->deleteUser($user_id);]]>
42 | db->query($sql);
45 | $sql = "DELETE FROM `" . DB_PREFIX . "user_device_mob_api` WHERE user_id = ". $user_id;
46 | $query = $this->db->query($sql); ]]>
47 |
48 |
49 |
50 |
51 |
52 | model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('cod_order_status_id')); ]]>
53 | load->model('module/apimodule');
56 | $this->model_module_apimodule->sendNotifications( $this->session->data['order_id'] );
57 |
58 | ]]>
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/2.0/full/readme.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/2.0/full/readme.txt
--------------------------------------------------------------------------------
/2.0/full/upload/admin/controller/module/apimodule.php:
--------------------------------------------------------------------------------
1 | registry);
14 | $this->API_VERSION = $api->getVersion();
15 | $this->OPENCART_VERSION = substr(VERSION,0,3);
16 | }
17 |
18 | public function checkVersion() {
19 | $return = false;
20 |
21 | $curl_handle = curl_init();
22 | curl_setopt($curl_handle, CURLOPT_URL,'https://opencartapp.pro/app/index.php?opencart_version='.$this->OPENCART_VERSION);
23 | curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
24 | curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
25 | curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0');
26 | $json = curl_exec($curl_handle);
27 | curl_close($curl_handle);
28 | $version = json_decode($json,1);
29 |
30 | if ($this->API_VERSION <(float)$version['version']) {
31 | $return = $version['version'];
32 | }
33 | return $return;
34 | }
35 |
36 | public function index() {
37 | $this->load->language('module/apimodule');
38 |
39 | $this->document->setTitle($this->language->get('heading_title'));
40 |
41 | $this->load->model('setting/setting');
42 |
43 | if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
44 | $this->model_setting_setting->editSetting('apimodule', $this->request->post);
45 |
46 | $this->session->data['success'] = $this->language->get('text_success');
47 |
48 | $this->response->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));
49 | }
50 |
51 | $data['heading_title'] = $this->language->get('heading_title');
52 |
53 | $data['text_edit'] = $this->language->get('text_edit');
54 | $data['text_enabled'] = $this->language->get('text_enabled');
55 | $data['text_disabled'] = $this->language->get('text_disabled');
56 | $data['text_default'] = $this->language->get('text_default');
57 | $data['entry_store'] = $this->language->get('entry_store');
58 |
59 | $data['entry_status'] = $this->language->get('entry_status');
60 |
61 | $data['button_save'] = $this->language->get('button_save');
62 | $data['button_cancel'] = $this->language->get('button_cancel');
63 | $data['button_update'] = $this->language->get('button_update');
64 |
65 | if (isset($this->error['warning'])) {
66 | $data['error_warning'] = $this->error['warning'];
67 | } else {
68 | $data['error_warning'] = '';
69 | }
70 |
71 | $data['breadcrumbs'] = array();
72 |
73 | $data['breadcrumbs'][] = array(
74 | 'text' => $this->language->get('text_home'),
75 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL')
76 | );
77 |
78 | $data['breadcrumbs'][] = array(
79 | 'text' => $this->language->get('text_module'),
80 | 'href' => $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL')
81 | );
82 |
83 | $data['breadcrumbs'][] = array(
84 | 'text' => $this->language->get('heading_title'),
85 | 'href' => $this->url->link('module/apimodule', 'token=' . $this->session->data['token'], 'SSL')
86 | );
87 |
88 | $data['action'] = $this->url->link('module/apimodule', 'token=' . $this->session->data['token'], 'SSL');
89 |
90 | $data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL');
91 |
92 | if (isset($this->request->post['apimodule_status'])) {
93 | $data['apimodule_status'] = $this->request->post['apimodule_status'];
94 | } else {
95 | $data['apimodule_status'] = $this->config->get('apimodule_status');
96 | }
97 |
98 | $this->load->model('setting/store');
99 | $data['stores'] = $this->model_setting_store->getStores();
100 | if (isset($this->request->post['apimodule_store'])) {
101 | $data['apimodule_store'] = $this->request->post['apimodule_store'];
102 | } else {
103 | if (is_null($this->config->get('apimodule_store'))) {
104 | $data['apimodule_store'] = array(0);
105 | } else {
106 | $data['apimodule_store'] = $this->config->get('apimodule_store');
107 | }
108 | }
109 |
110 | if (!extension_loaded('zip')) {
111 | $data['ext'] = "not installed zip extension for update";
112 | } else {
113 | $data['ext'] = "";
114 | }
115 |
116 | if (isset($this->session->data['error'])) {
117 | $data['error'] = $this->session->data['error'];
118 | unset($this->session->data['error']);
119 | } else {
120 | $data['error'] = '';
121 | }
122 |
123 | $data['header'] = $this->load->controller('common/header');
124 | $data['column_left'] = $this->load->controller('common/column_left');
125 | $data['footer'] = $this->load->controller('common/footer');
126 |
127 | $data['version'] = $version = $this->checkVersion();
128 | $data['current_version'] = $this->API_VERSION;
129 | $data['update'] = $this->url->link('module/apimodule/update&v='.$version, 'token=' . $this->session->data['token'], 'SSL');
130 |
131 | $this->response->setOutput($this->load->view('module/apimodule.tpl', $data));
132 | }
133 |
134 | protected function validate() {
135 | if (!$this->user->hasPermission('modify', 'module/apimodule')) {
136 | $this->error['warning'] = $this->language->get('error_permission');
137 | }
138 |
139 | return !$this->error;
140 | }
141 |
142 | private $path = "update";
143 |
144 | private $fileName = "";
145 |
146 | public function update() {
147 | if (isset($_GET['v'])) {
148 | //apimobile1.8.ocmod.zip
149 | $this->fileName = "apimobile" . $_GET['v'] .".ocmod.zip";
150 | //$file = file_get_contents("https://opencartapp.pro/app/".$this->OPENCART_VERSION.'/'.$this->fileName);
151 | // If no temp directory exists create it
152 |
153 | $ch = curl_init();
154 | curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
155 | curl_setopt($ch, CURLOPT_HEADER, 0);
156 | curl_setopt($ch, CURLOPT_FAILONERROR, 1);
157 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
158 | curl_setopt($ch, CURLOPT_URL, "https://opencartapp.pro/app/".$this->OPENCART_VERSION.'/'.$this->fileName);
159 | $file = curl_exec($ch);
160 | curl_close($ch);
161 |
162 | if (!is_dir(DIR_UPLOAD . $this->path)) {
163 | mkdir(DIR_UPLOAD . $this->path, 0777);
164 | }
165 |
166 | $new_path = DIR_UPLOAD . $this->path ."/" . $this->fileName;
167 | if(!file_exists($new_path)) {
168 | file_put_contents( $new_path, $file );
169 | }
170 |
171 | $this->installPatch();
172 | }else{
173 | $this->error['warning'] = "Not version";
174 | }
175 | return $this->error;
176 | }
177 |
178 |
179 | public function install() {
180 |
181 | $this->db->query("CREATE TABLE IF NOT EXISTS " . DB_PREFIX."user_token_mob_api (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, user_id INT NOT NULL, token VARCHAR(32) NOT NULL )");
182 | $this->db->query("CREATE TABLE IF NOT EXISTS " . DB_PREFIX."user_device_mob_api (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, user_id INT NOT NULL, device_token VARCHAR(500) , os_type VARCHAR(20))");
183 |
184 | $this->load->model('setting/setting');
185 |
186 | $this->model_setting_setting->editSetting('apimodule', ['apimodule_status'=>1,'version'=>1.7,'apimodule_store' => ['0']]);
187 |
188 | if(VERSION == '2.0.0.0'){
189 | $this->load->model('tool/event');
190 | $this->model_tool_event->addEvent('apimodule', 'post.order.history.add', 'module/apimodule/sendNotifications');
191 | }else{
192 | //$this->load->model('extension/event');
193 | //$this->model_extension_event->addEvent('apimodule', 'post.order.history.add', 'module/apimodule/sendNotifications');
194 | }
195 |
196 | }
197 | private function installPatch() {
198 | $this->unzip();
199 | $ftp = $this->ftp();
200 | if(isset($ftp['error'])){
201 | $this->session->data['error'] = $ftp['error'];
202 | $this->response->redirect($this->url->link('module/apimodule', 'token=' . $this->session->data['token'], 'SSL'));
203 | }
204 | $this->php();
205 | $this->sql();
206 |
207 | $this->clear();
208 | $this->session->data['success'] = "Модуль успешно обновлен";
209 | $this->response->redirect($this->url->link('extension/extension', 'token=' . $this->session->data['token'], 'SSL'));
210 | }
211 |
212 |
213 | public function unzip() {
214 | $this->load->language('extension/installer');
215 |
216 | $json = array();
217 | // Sanitize the filename
218 | $file = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path) . '/'.$this->fileName;
219 |
220 | if (!file_exists($file)) {
221 | $json['error'] = $this->language->get('error_file');
222 | }
223 |
224 | if (!$json) {
225 | // Unzip the files
226 | $zip = new ZipArchive();
227 |
228 | if ($zip->open($file)) {
229 | $zip->extractTo(DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ));
230 | // echo DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path );
231 |
232 | $zip->close();
233 | } else {
234 | $json['error'] = $this->language->get('error_unzip');
235 | }
236 |
237 | // Remove Zip
238 | unlink($file);
239 | }
240 |
241 | }
242 |
243 | public function localcopy() {
244 | $this->load->language('extension/installer');
245 |
246 | $json = array();
247 |
248 | if (!$this->user->hasPermission('modify', 'extension/installer')) {
249 | $json['error'] = $this->language->get('error_permission');
250 | }
251 |
252 | if (VERSION == '2.0.0.0') {
253 | $directory = DIR_DOWNLOAD . str_replace(array('../', '..\\', '..'), '', $this->path) . '/upload/';
254 | } else {
255 | $directory = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path) . '/upload/';
256 | }
257 |
258 | if (!is_dir($directory)) {
259 | $json['error'] = $this->language->get('error_directory');
260 | }
261 |
262 | if (!$json) {
263 | // Get a list of files ready to upload
264 | $files = array();
265 |
266 | $path = array($directory . '*');
267 |
268 | while (count($path) != 0) {
269 | $next = array_shift($path);
270 |
271 | foreach (glob($next) as $file) {
272 | if (is_dir($file)) {
273 | $path[] = $file . '/*';
274 | }
275 |
276 | $files[] = $file;
277 | }
278 | }
279 |
280 | $root = dirname(DIR_APPLICATION).'/';
281 |
282 | foreach ($files as $file) {
283 | // Upload everything in the upload directory
284 | $destination = substr($file, strlen($directory));
285 |
286 | // Update from newer OpenCart versions:
287 | if (substr($destination, 0, 5) == 'admin') {
288 | $destination = DIR_APPLICATION . substr($destination, 5);
289 | } else if (substr($destination, 0, 7) == 'catalog') {
290 | $destination = DIR_CATALOG . substr($destination, 0,7);
291 | } else if (substr($destination, 0, 5) == 'image') {
292 | $destination = DIR_IMAGE . substr($destination, 5);
293 | } else if (substr($destination, 0, 6) == 'system') {
294 | $destination = DIR_SYSTEM . substr($destination, 6);
295 | } else {
296 | $destination = $root.$destination;
297 | }
298 |
299 | if (is_dir($file)) {
300 | if (!file_exists($destination)) {
301 | if (!mkdir($destination)) {
302 | $json['error'] = sprintf($this->language->get('error_ftp_directory'), $destination);
303 | }
304 | }
305 | }
306 |
307 | if (is_file($file)) {
308 | if (!copy($file, $destination)) {
309 | $json['error'] = sprintf($this->language->get('error_ftp_file'), $file);
310 | }
311 | }
312 | }
313 | }
314 |
315 | /*$this->response->addHeader('Content-Type: application/json');
316 | $this->response->setOutput(json_encode($json));*/
317 | }
318 |
319 | public function ftp() {
320 | $this->load->language('extension/installer');
321 |
322 | $json = array();
323 |
324 | // Check FTP status
325 | if (!$this->config->get('config_ftp_status')) {
326 | $json['error'] = $this->language->get('error_ftp_status');
327 | }
328 |
329 | $directory = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ) . '/upload/';
330 |
331 | if (!is_dir($directory)) {
332 | $json['error'] = $this->language->get('error_directory');
333 | }
334 |
335 | if (!$json) {
336 | // Get a list of files ready to upload
337 | $files = array();
338 |
339 | $path = array($directory . '*');
340 |
341 | while (count($path) != 0) {
342 | $next = array_shift($path);
343 |
344 | foreach ((array)glob($next) as $file) {
345 | if (is_dir($file)) {
346 | $path[] = $file . '/*';
347 | }
348 |
349 | $files[] = $file;
350 | }
351 | }
352 |
353 | // Connect to the site via FTP
354 | $connection = ftp_connect($this->config->get('config_ftp_hostname'), $this->config->get('config_ftp_port'));
355 |
356 | if ($connection) {
357 | $login = ftp_login($connection, $this->config->get('config_ftp_username'), $this->config->get('config_ftp_password'));
358 |
359 | if ($login) {
360 | if ($this->config->get('config_ftp_root')) {
361 | $root = ftp_chdir($connection, $this->config->get('config_ftp_root'));
362 | } else {
363 | $root = ftp_chdir($connection, '/');
364 | }
365 |
366 | if ($root) {
367 | foreach ($files as $file) {
368 | $destination = substr($file, strlen($directory));
369 |
370 | // Upload everything in the upload directory
371 | // Many people rename their admin folder for security purposes which I believe should be an option during installation just like setting the db prefix.
372 | // the following code would allow you to change the name of the following directories and any extensions installed will still go to the right directory.
373 | if (substr($destination, 0, 5) == 'admin') {
374 | $destination = basename(DIR_APPLICATION) . substr($destination, 5);
375 | }
376 |
377 | if (substr($destination, 0, 7) == 'catalog') {
378 | $destination = basename(DIR_CATALOG) . substr($destination, 7);
379 | }
380 |
381 | if (substr($destination, 0, 5) == 'image') {
382 | $destination = basename(DIR_IMAGE) . substr($destination, 5);
383 | }
384 |
385 | if (substr($destination, 0, 6) == 'system') {
386 | $destination = basename(DIR_SYSTEM) . substr($destination, 6);
387 | }
388 |
389 | if (is_dir($file)) {
390 | $list = ftp_nlist($connection, substr($destination, 0, strrpos($destination, '/')));
391 |
392 | // Basename all the directories because on some servers they don't return the fulll paths.
393 | $list_data = array();
394 |
395 | foreach ($list as $list) {
396 | $list_data[] = basename($list);
397 | }
398 |
399 | if (!in_array(basename($destination), $list_data)) {
400 | if (!ftp_mkdir($connection, $destination)) {
401 | $json['error'] = sprintf($this->language->get('error_ftp_directory'), $destination);
402 | }
403 | }
404 | }
405 |
406 | if (is_file($file)) {
407 | if (!ftp_put($connection, $destination, $file, FTP_BINARY)) {
408 | $json['error'] = sprintf($this->language->get('error_ftp_file'), $file);
409 | }
410 | }
411 | }
412 | } else {
413 | $json['error'] = sprintf($this->language->get('error_ftp_root'), $root);
414 | }
415 | } else {
416 | $json['error'] = sprintf($this->language->get('error_ftp_login'), $this->config->get('config_ftp_username'));
417 | }
418 |
419 | ftp_close($connection);
420 | } else {
421 | $json['error'] = sprintf($this->language->get('error_ftp_connection'), $this->config->get('config_ftp_hostname'), $this->config->get('config_ftp_port'));
422 | }
423 | }
424 | return $json;
425 | }
426 |
427 | public function sql() {
428 | $this->load->language('extension/installer');
429 |
430 | $json = array();
431 |
432 | $file = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ) . '/install.sql';
433 |
434 | if (!file_exists($file)) {
435 | $json['error'] = $this->language->get('error_file');
436 | }
437 |
438 | if (!$json) {
439 | $lines = file($file);
440 |
441 | if ($lines) {
442 | try {
443 | $sql = '';
444 |
445 | foreach ($lines as $line) {
446 | if ($line && (substr($line, 0, 2) != '--') && (substr($line, 0, 1) != '#')) {
447 | $sql .= $line;
448 |
449 | if (preg_match('/;\s*$/', $line)) {
450 | $sql = str_replace(" `oc_", " `" . DB_PREFIX, $sql);
451 |
452 | $this->db->query($sql);
453 |
454 | $sql = '';
455 | }
456 | }
457 | }
458 | } catch(Exception $exception) {
459 | $json['error'] = sprintf($this->language->get('error_exception'), $exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
460 | }
461 | }
462 | }
463 | }
464 |
465 | public function xml() {
466 | $this->load->language('extension/installer');
467 |
468 | $json = array();
469 |
470 | $file = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ) . '/install.xml';
471 |
472 | if (!file_exists($file)) {
473 | $json['error'] = $this->language->get('error_file');
474 | }
475 |
476 | if (!$json) {
477 | $this->load->model('extension/modification');
478 |
479 | // If xml file just put it straight into the DB
480 | $xml = file_get_contents($file);
481 |
482 | if ($xml) {
483 | try {
484 | $dom = new DOMDocument('1.0', 'UTF-8');
485 | $dom->loadXml($xml);
486 |
487 | $name = $dom->getElementsByTagName('name')->item(0);
488 |
489 | if ($name) {
490 | $name = $name->nodeValue;
491 | } else {
492 | $name = '';
493 | }
494 |
495 | $code = $dom->getElementsByTagName('code')->item(0);
496 |
497 | if ($code) {
498 | $code = $code->nodeValue;
499 |
500 | // Check to see if the modification is already installed or not.
501 | $modification_info = $this->model_extension_modification->getModificationByCode($code);
502 |
503 | if ($modification_info) {
504 | $json['error'] = sprintf($this->language->get('error_exists'), $modification_info['name']);
505 | }
506 | } else {
507 | $json['error'] = $this->language->get('error_code');
508 | }
509 |
510 | $author = $dom->getElementsByTagName('author')->item(0);
511 |
512 | if ($author) {
513 | $author = $author->nodeValue;
514 | } else {
515 | $author = '';
516 | }
517 |
518 | $version = $dom->getElementsByTagName('version')->item(0);
519 |
520 | if ($version) {
521 | $version = $version->nodeValue;
522 | } else {
523 | $version = '';
524 | }
525 |
526 | $link = $dom->getElementsByTagName('link')->item(0);
527 |
528 | if ($link) {
529 | $link = $link->nodeValue;
530 | } else {
531 | $link = '';
532 | }
533 |
534 | $modification_data = array(
535 | 'name' => $name,
536 | 'code' => $code,
537 | 'author' => $author,
538 | 'version' => $version,
539 | 'link' => $link,
540 | 'xml' => $xml,
541 | 'status' => 1
542 | );
543 |
544 | if (!$json) {
545 | $this->model_extension_modification->addModification($modification_data);
546 | }
547 | } catch(Exception $exception) {
548 | $json['error'] = sprintf($this->language->get('error_exception'), $exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
549 | }
550 | }
551 | }
552 | }
553 |
554 | public function php() {
555 | $this->load->language('extension/installer');
556 |
557 | $json = array();
558 |
559 | if (!$this->user->hasPermission('modify', 'extension/installer')) {
560 | $json['error'] = $this->language->get('error_permission');
561 | }
562 |
563 | $file = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ) . '/install.php';
564 |
565 | if (!file_exists($file)) {
566 | $json['error'] = $this->language->get('error_file');
567 | }
568 |
569 | if (!$json) {
570 | try {
571 | include($file);
572 | } catch(Exception $exception) {
573 | $json['error'] = sprintf($this->language->get('error_exception'), $exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
574 | }
575 | }
576 |
577 | }
578 |
579 | public function remove() {
580 | $this->load->language('extension/installer');
581 |
582 | $json = array();
583 |
584 | $directory = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path );
585 |
586 | if (!is_dir($directory)) {
587 | $json['error'] = $this->language->get('error_directory');
588 | }
589 |
590 | if (!$json) {
591 | // Get a list of files ready to upload
592 | $files = array();
593 |
594 | $path = array($directory);
595 |
596 | while (count($path) != 0) {
597 | $next = array_shift($path);
598 |
599 | // We have to use scandir function because glob will not pick up dot files.
600 | foreach (array_diff(scandir($next), array('.', '..')) as $file) {
601 | $file = $next . '/' . $file;
602 |
603 | if (is_dir($file)) {
604 | $path[] = $file;
605 | }
606 |
607 | $files[] = $file;
608 | }
609 | }
610 |
611 | rsort($files);
612 |
613 | foreach ($files as $file) {
614 | if (is_file($file)) {
615 | unlink($file);
616 | } elseif (is_dir($file)) {
617 | rmdir($file);
618 | }
619 | }
620 |
621 | if (file_exists($directory)) {
622 | rmdir($directory);
623 | }
624 |
625 | $json['success'] = $this->language->get('text_success');
626 | }
627 |
628 | }
629 |
630 | public function clear() {
631 | $this->load->language('extension/installer');
632 |
633 | $json = array();
634 |
635 | if (!$json) {
636 | $directories = glob(DIR_UPLOAD . 'update', GLOB_ONLYDIR);
637 |
638 | foreach ($directories as $directory) {
639 | // Get a list of files ready to upload
640 | $files = array();
641 |
642 | $path = array($directory);
643 |
644 | while (count($path) != 0) {
645 | $next = array_shift($path);
646 |
647 | // We have to use scandir function because glob will not pick up dot files.
648 | foreach (array_diff(scandir($next), array('.', '..')) as $file) {
649 | $file = $next . '/' . $file;
650 |
651 | if (is_dir($file)) {
652 | $path[] = $file;
653 | }
654 |
655 | $files[] = $file;
656 | }
657 | }
658 |
659 | rsort($files);
660 |
661 | foreach ($files as $file) {
662 | if (is_file($file)) {
663 | unlink($file);
664 | } elseif (is_dir($file)) {
665 | rmdir($file);
666 | }
667 | }
668 |
669 | if (file_exists($directory)) {
670 | rmdir($directory);
671 | }
672 | }
673 |
674 | $json['success'] = $this->language->get('text_clear');
675 | }
676 | }
677 | }
678 |
--------------------------------------------------------------------------------
/2.0/full/upload/admin/language/en-gb/module/apimodule.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/2.0/patch/README.md:
--------------------------------------------------------------------------------
1 | OPENCART-MOBILE-ADMIN
2 | =====================
3 | Модуль для Opencart версии 2.0.0.0 и выше, содержащий API для управления интернет-магазином с мобильного устройста.
4 | ***
5 |
6 | Перед установкой убедитесь, что OpenCart Extension Installer настроен правильно,
7 | особенно FTP настройки.
8 | Если при установке появляется ошибка - установите дополнение: [https://www.opencart.com](https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=18892) и попробуйте снова.
9 |
10 | ***
11 | ### Установка производится через OCMOD:
12 | ***
13 | 1. Для установки перейдите в админ панель;
14 | 2. Перейдите "Модули->установка расширений";
15 | 3. Нажмите "загрузить файл" и выберите **apimobile.ocmod.zip**.
16 |
17 | ***
18 | ### ВАЖНО!!!
19 |
20 | Модуль не работает если включён режим обслуживания.
21 | ***
22 |
23 | #### Используйте эту ссылку для скачивания аппликации:
24 |
--------------------------------------------------------------------------------
/2.0/patch/apimobile2.0.ocmod.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/2.0/patch/apimobile2.0.ocmod.zip
--------------------------------------------------------------------------------
/2.0/patch/install.php:
--------------------------------------------------------------------------------
1 | db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX."user_token_mob_api` (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, user_id INT NOT NULL, token VARCHAR(32) NOT NULL )");
3 | $this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX."user_device_mob_api` (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, user_id INT NOT NULL, device_token VARCHAR(500) , os_type VARCHAR(50))");
4 |
5 | $this->load->model('setting/setting');
6 |
7 | $this->model_setting_setting->editSetting('apimodule', ['apimodule_status'=>1,'version'=>1.7]);
8 | if(VERSION == '2.0.0.0' ){
9 | $this->load->model('tool/event');
10 | $this->model_tool_event->deleteEvent('apimodule');
11 | $this->model_tool_event->addEvent('apimodule', 'post.order.history.add', 'module/apimodule/sendNotifications');
12 | }elseif(VERSION == '2.0.0.0a1' || VERSION == '2.0.0.0a2'){
13 | $this->load->model('tool/event');
14 | $this->model_tool_event->deleteHandler('apimodule');
15 | $this->model_tool_event->setHandler('apimodule', 'post.order.history.add', 'module/apimodule/sendNotifications');
16 | }elseif(VERSION == '2.2.0.0'){
17 | $this->load->model('extension/event');
18 | $this->model_extension_event->deleteEvent('apimodule');
19 | $this->model_extension_event->addEvent('apimodule', 'catalog/model/checkout/order/addOrderHistory/after', 'module/apimodule/sendNotifi_2_2_0_0');
20 | }else{
21 | //$this->load->model('extension/event');
22 | //$this->model_extension_event->deleteEvent('apimodule');
23 | //$this->model_extension_event->addEvent('apimodule', 'post.order.history.add', 'module/apimodule/sendNotifications');
24 | }
25 |
26 |
27 |
28 | ?>
--------------------------------------------------------------------------------
/2.0/patch/install.xml:
--------------------------------------------------------------------------------
1 |
2 | Check update apimodule
3 | 2.0
4 | http://opencartapp.com
5 | Pinta
6 | apimodule_ocmod
7 |
8 |
9 |
10 | load->controller('extension/module/apimodule/checkVersion');
15 | }else{
16 | $version = $this->load->controller('module/apimodule/checkVersion');
17 | }
18 |
19 | if ($this->API_VERSION <(float)$version) {
20 | $data['update_module'] = "Обновите модуль OPENCART-MOBILE-ADMIN до версии ".$version." или скачайте по ссылке скачать ";
21 | } else {
22 | $data['update_module'] = '';
23 | }
24 | ]]>
25 |
26 |
27 |
28 |
29 | ]]>
30 |
32 |
33 |
34 |
35 |
36 | ]]>
37 |
38 |
39 |
40 |
41 | model_user_user->deleteUser($user_id);]]>
42 | db->query($sql);
45 | $sql = "DELETE FROM `" . DB_PREFIX . "user_device_mob_api` WHERE user_id = ". $user_id;
46 | $query = $this->db->query($sql); ]]>
47 |
48 |
49 |
50 |
51 |
52 | model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('cod_order_status_id')); ]]>
53 | load->model('module/apimodule');
56 | $this->model_module_apimodule->sendNotifications( $this->session->data['order_id'] );
57 |
58 | ]]>
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/2.0/patch/readme.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/2.0/patch/readme.txt
--------------------------------------------------------------------------------
/2.0/patch/upload/admin/language/en-gb/module/apimodule.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/2.3/full/README.md:
--------------------------------------------------------------------------------
1 | OPENCART-MOBILE-ADMIN
2 | =====================
3 | Модуль для Opencart версии 2.0.0.0 и выше, содержащий API для управления интернет-магазином с мобильного устройста.
4 | ***
5 |
6 | Перед установкой убедитесь, что OpenCart Extension Installer настроен правильно,
7 | особенно FTP настройки.
8 | Если при установке появляется ошибка - установите дополнение: [https://www.opencart.com](https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=18892) и попробуйте снова.
9 |
10 | ***
11 | ### Установка производится через OCMOD:
12 | ***
13 | 1. Для установки перейдите в админ панель;
14 | 2. Перейдите "Модули->установка расширений";
15 | 3. Нажмите "загрузить файл" и выберите **apimobile.ocmod.zip**.
16 |
17 | ***
18 | ### ВАЖНО!!!
19 |
20 | Модуль не работает если включён режим обслуживания.
21 | ***
22 |
23 | #### Используйте эту ссылку для скачивания аппликации:
24 |
--------------------------------------------------------------------------------
/2.3/full/apimobile-2.0-opencart-2.3._.ocmod.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/2.3/full/apimobile-2.0-opencart-2.3._.ocmod.zip
--------------------------------------------------------------------------------
/2.3/full/install.php:
--------------------------------------------------------------------------------
1 | db->query("DROP TABLE IF EXISTS `" . DB_PREFIX."user_token_mob_api` ");
4 | $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX."user_device_mob_api` ");
5 | $this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX."user_token_mob_api` (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, user_id INT NOT NULL, token VARCHAR(32) NOT NULL )");
6 | $this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX."user_device_mob_api` (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, user_id INT NOT NULL, device_token VARCHAR(500) , os_type VARCHAR(20))");
7 |
8 | $this->load->model('setting/setting');
9 |
10 | $this->model_setting_setting->editSetting('apimodule', ['apimodule_status'=>1,'version'=>1.7]);
11 | if(VERSION == '2.0.0.0'){
12 | $this->load->model('tool/event');
13 | $this->model_tool_event->deleteEvent('apimodule');
14 | $this->model_tool_event->addEvent('apimodule', 'post.order.history.add', 'module/apimodule/sendNotifications');
15 | }else{
16 | //$this->load->model('extension/event');
17 | //$this->model_extension_event->deleteEvent('apimodule');
18 | //$this->model_extension_event->addEvent('apimodule', 'catalog/model/checkout/order/addOrderHistory/after', 'module/apimodule/sendNotifications');
19 | }
20 |
21 | ?>
--------------------------------------------------------------------------------
/2.3/full/install.xml:
--------------------------------------------------------------------------------
1 |
2 | Check update apimodule
3 | 2.0
4 | https://opencartapp.pro
5 | Pinta
6 | apimodule_ocmod
7 |
8 |
9 |
10 | load->controller('extension/module/apimodule/checkVersion');
16 | }else{
17 | $version = $this->load->controller('module/apimodule/checkVersion');
18 | }
19 |
20 | if ($this->API_VERSION <(float)$version) {
21 | $data['update_module'] = "Обновите модуль OPENCART-MOBILE-ADMIN до версии ".$version." или скачайте по ссылке скачать ";
22 | } else {
23 | $data['update_module'] = '';
24 | }
25 | ]]>
26 |
27 |
28 |
29 |
30 | ]]>
31 |
33 |
34 |
35 |
36 |
37 | ]]>
38 |
39 |
40 |
41 |
42 | model_user_user->deleteUser($user_id);]]>
43 | db->query($sql);
46 | $sql = "DELETE FROM `" . DB_PREFIX . "user_device_mob_api` WHERE user_id = ". $user_id;
47 | $query = $this->db->query($sql); ]]>
48 |
49 |
50 |
51 |
52 |
53 | model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('cod_order_status_id')); ]]>
54 | load->model('module/apimodule');
57 | $this->model_module_apimodule->sendNotifications( $this->session->data['order_id'] );
58 |
59 | ]]>
60 |
61 |
62 |
63 |
64 |
65 |
66 | model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('bank_transfer_order_status_id'), $comment, true); ]]>
67 |
68 | load->model('module/apimodule');
71 | $this->model_module_apimodule->sendNotifications( $this->session->data['order_id'] );
72 |
73 | ]]>
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/2.3/full/readme.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/2.3/full/readme.txt
--------------------------------------------------------------------------------
/2.3/full/upload/admin/controller/extension/module/apimodule.php:
--------------------------------------------------------------------------------
1 | registry);
13 |
14 | $this->API_VERSION = $api->getVersion();
15 | $this->OPENCART_VERSION = substr(VERSION,0,3);
16 | }
17 |
18 | public function checkVersion(){
19 | $return = false;
20 |
21 | $curl_handle = curl_init();
22 | curl_setopt($curl_handle, CURLOPT_URL,'https://opencartapp.pro/app/index.php?opencart_version='.$this->OPENCART_VERSION);
23 | curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
24 | curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
25 | curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0');
26 | $json = curl_exec($curl_handle);
27 | curl_close($curl_handle);
28 | $version = json_decode($json,1);
29 |
30 | if($this->API_VERSION <(float)$version['version']){
31 | $return = $version['version'];
32 | }
33 | return $return;
34 | }
35 | public function index() {
36 | $this->load->language('module/apimodule');
37 |
38 | $this->document->setTitle($this->language->get('heading_title'));
39 |
40 | $this->load->model('setting/setting');
41 |
42 | if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
43 |
44 | $this->model_setting_setting->editSetting('apimodule', $this->request->post);
45 |
46 | $this->session->data['success'] = $this->language->get('text_success');
47 |
48 | //$this->response->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));
49 | $this->response->redirect($this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=module', true));
50 | }
51 |
52 |
53 | $data['heading_title'] = $this->language->get('heading_title');
54 |
55 | $data['text_edit'] = $this->language->get('text_edit');
56 | $data['text_enabled'] = $this->language->get('text_enabled');
57 | $data['text_disabled'] = $this->language->get('text_disabled');
58 | $data['text_default'] = $this->language->get('text_default');
59 | $data['entry_store'] = $this->language->get('entry_store');
60 | $data['entry_status'] = $this->language->get('entry_status');
61 |
62 | $data['button_save'] = $this->language->get('button_save');
63 | $data['button_cancel'] = $this->language->get('button_cancel');
64 | $data['button_update'] = $this->language->get('button_update');
65 |
66 | if (isset($this->error['warning'])) {
67 | $data['error_warning'] = $this->error['warning'];
68 | } else {
69 | $data['error_warning'] = '';
70 | }
71 |
72 | $data['breadcrumbs'] = array();
73 |
74 | $data['breadcrumbs'][] = array(
75 | 'text' => $this->language->get('text_home'),
76 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL')
77 | );
78 |
79 | $data['breadcrumbs'][] = array(
80 | 'text' => $this->language->get('text_module'),
81 | 'href' => $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL')
82 | );
83 |
84 | $data['breadcrumbs'][] = array(
85 | 'text' => $this->language->get('heading_title'),
86 | 'href' => $this->url->link('extension/module/apimodule', 'token=' . $this->session->data['token'], 'SSL')
87 | );
88 |
89 | $data['action'] = $this->url->link('extension/module/apimodule', 'token=' . $this->session->data['token'], 'SSL');
90 |
91 | $data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL');
92 |
93 | if (isset($this->request->post['apimodule_status'])) {
94 | $data['apimodule_status'] = $this->request->post['apimodule_status'];
95 | } else {
96 | $data['apimodule_status'] = $this->config->get('apimodule_status');
97 | }
98 |
99 | $this->load->model('setting/store');
100 | $data['stores'] = $this->model_setting_store->getStores();
101 | if (isset($this->request->post['apimodule_store'])) {
102 | $data['apimodule_store'] = $this->request->post['apimodule_store'];
103 | } else {
104 | if ( is_null($this->config->get('apimodule_store')) )
105 | $data['apimodule_store'] = array(0);
106 | else
107 | $data['apimodule_store'] = $this->config->get('apimodule_store');
108 | }
109 |
110 | if (!extension_loaded('zip')) {
111 | $data['ext'] = "not installed zip extension for update";
112 | }else{
113 | $data['ext'] = "";
114 | }
115 |
116 | if (isset($this->session->data['error'])) {
117 | $data['error'] = $this->session->data['error'];
118 |
119 | unset($this->session->data['error']);
120 | } else {
121 | $data['error'] = '';
122 | }
123 |
124 | $data['header'] = $this->load->controller('common/header');
125 | $data['column_left'] = $this->load->controller('common/column_left');
126 | $data['footer'] = $this->load->controller('common/footer');
127 |
128 | $data['version'] = $version = $this->checkVersion();
129 | $data['current_version'] = $this->API_VERSION;
130 | $data['update'] = $this->url->link('extension/module/apimodule/update&v='.$version, 'token=' . $this->session->data['token'], 'SSL');
131 |
132 |
133 | $this->response->setOutput($this->load->view('extension/module/apimodule.tpl', $data));
134 | }
135 |
136 | protected function validate() {
137 | if (!$this->user->hasPermission('modify', 'extension/module/apimodule')) {
138 | $this->error['warning'] = $this->language->get('error_permission');
139 | }
140 |
141 | return !$this->error;
142 | }
143 | private $path = "update";
144 | private $fileName = "";
145 |
146 | public function update() {
147 |
148 | if(isset($_GET['v'])) {
149 | //apimobile1.8.ocmod.zip
150 | $this->fileName = "apimobile" . $_GET['v'] .".ocmod.zip";
151 | //$file = file_get_contents("https://opencartapp.pro/app/".$this->OPENCART_VERSION.'/'.$this->fileName);
152 | // If no temp directory exists create it
153 |
154 |
155 | $ch = curl_init();
156 | curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
157 | curl_setopt($ch, CURLOPT_HEADER, 0);
158 | curl_setopt($ch, CURLOPT_FAILONERROR, 1);
159 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
160 | curl_setopt($ch, CURLOPT_URL, "https://opencartapp.pro/app/".$this->OPENCART_VERSION.'/'.$this->fileName);
161 | $file = curl_exec($ch);
162 | curl_close($ch);
163 |
164 | if (!is_dir(DIR_UPLOAD . $this->path)) {
165 | mkdir(DIR_UPLOAD . $this->path, 0777);
166 | }
167 |
168 | $new_path = DIR_UPLOAD . $this->path ."/" . $this->fileName;
169 | if(!file_exists($new_path)) {
170 | file_put_contents( $new_path, $file );
171 | }
172 |
173 | $this->installPatch();
174 | }else{
175 | $this->error['warning'] = "Not version";
176 | }
177 | return $this->error;
178 | }
179 |
180 |
181 | public function install() {
182 |
183 | $this->db->query("CREATE TABLE IF NOT EXISTS " . DB_PREFIX."user_token_mob_api (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, user_id INT NOT NULL, token VARCHAR(32) NOT NULL )");
184 | $this->db->query("CREATE TABLE IF NOT EXISTS " . DB_PREFIX."user_device_mob_api (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, user_id INT NOT NULL, device_token VARCHAR(500) , os_type VARCHAR(20))");
185 |
186 | $this->load->model('setting/setting');
187 |
188 | $this->model_setting_setting->editSetting('apimodule', ['apimodule_status'=>1,'version'=>1.7,'apimodule_store' => ['0']]);
189 |
190 | if(VERSION == '2.0.0.0'){
191 | $this->load->model('tool/event');
192 | $this->model_tool_event->addEvent('apimodule', 'post.order.history.add', 'module/apimodule/sendNotifications');
193 | }else{
194 | //$this->load->model('extension/event');
195 | //$this->model_extension_event->addEvent('apimodule', 'post.order.history.add', 'module/apimodule/sendNotifications');
196 | }
197 |
198 | }
199 | private function installPatch() {
200 |
201 | $this->unzip();
202 | $ftp = $this->ftp();
203 | if(isset($ftp['error'])){
204 | $this->session->data['error'] = $ftp['error'];
205 | $this->response->redirect($this->url->link('module/apimodule', 'token=' . $this->session->data['token'], 'SSL'));
206 | }
207 | $this->php();
208 | $this->sql();
209 |
210 | $this->clear();
211 | $this->session->data['success'] = "Модуль успешно обновлен";
212 | $this->response->redirect($this->url->link('extension/extension', 'token=' . $this->session->data['token'], 'SSL'));
213 |
214 | }
215 |
216 |
217 | public function unzip() {
218 | $this->load->language('extension/installer');
219 |
220 | $json = array();
221 | // Sanitize the filename
222 | $file = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path) . '/'.$this->fileName;
223 |
224 | if (!file_exists($file)) {
225 | $json['error'] = $this->language->get('error_file');
226 | }
227 |
228 | if (!$json) {
229 | // Unzip the files
230 | $zip = new ZipArchive();
231 |
232 | if ($zip->open($file)) {
233 | $zip->extractTo(DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ));
234 | // echo DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path );
235 |
236 | $zip->close();
237 | } else {
238 | $json['error'] = $this->language->get('error_unzip');
239 | }
240 |
241 | // Remove Zip
242 | unlink($file);
243 | }
244 |
245 | }
246 |
247 | public function ftp() {
248 | $this->load->language('extension/installer');
249 |
250 | $json = array();
251 |
252 | // Check FTP status
253 | if (!$this->config->get('config_ftp_status')) {
254 | $json['error'] = $this->language->get('error_ftp_status');
255 | }
256 |
257 | $directory = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ) . '/upload/';
258 |
259 | if (!is_dir($directory)) {
260 | $json['error'] = $this->language->get('error_directory');
261 | }
262 |
263 | if (!$json) {
264 | // Get a list of files ready to upload
265 | $files = array();
266 |
267 | $path = array($directory . '*');
268 |
269 | while (count($path) != 0) {
270 | $next = array_shift($path);
271 |
272 | foreach ((array)glob($next) as $file) {
273 | if (is_dir($file)) {
274 | $path[] = $file . '/*';
275 | }
276 |
277 | $files[] = $file;
278 | }
279 | }
280 |
281 | // Connect to the site via FTP
282 | $connection = ftp_connect($this->config->get('config_ftp_hostname'), $this->config->get('config_ftp_port'));
283 |
284 | if ($connection) {
285 | $login = ftp_login($connection, $this->config->get('config_ftp_username'), $this->config->get('config_ftp_password'));
286 |
287 | if ($login) {
288 | if ($this->config->get('config_ftp_root')) {
289 | $root = ftp_chdir($connection, $this->config->get('config_ftp_root'));
290 | } else {
291 | $root = ftp_chdir($connection, '/');
292 | }
293 |
294 | if ($root) {
295 | foreach ($files as $file) {
296 | $destination = substr($file, strlen($directory));
297 |
298 | // Upload everything in the upload directory
299 | // Many people rename their admin folder for security purposes which I believe should be an option during installation just like setting the db prefix.
300 | // the following code would allow you to change the name of the following directories and any extensions installed will still go to the right directory.
301 | if (substr($destination, 0, 5) == 'admin') {
302 | $destination = basename(DIR_APPLICATION) . substr($destination, 5);
303 | }
304 |
305 | if (substr($destination, 0, 7) == 'catalog') {
306 | $destination = basename(DIR_CATALOG) . substr($destination, 7);
307 | }
308 |
309 | if (substr($destination, 0, 5) == 'image') {
310 | $destination = basename(DIR_IMAGE) . substr($destination, 5);
311 | }
312 |
313 | if (substr($destination, 0, 6) == 'system') {
314 | $destination = basename(DIR_SYSTEM) . substr($destination, 6);
315 | }
316 |
317 | if (is_dir($file)) {
318 | $list = ftp_nlist($connection, substr($destination, 0, strrpos($destination, '/')));
319 |
320 | // Basename all the directories because on some servers they don't return the fulll paths.
321 | $list_data = array();
322 |
323 | foreach ($list as $list) {
324 | $list_data[] = basename($list);
325 | }
326 |
327 | if (!in_array(basename($destination), $list_data)) {
328 | if (!ftp_mkdir($connection, $destination)) {
329 | $json['error'] = sprintf($this->language->get('error_ftp_directory'), $destination);
330 | }
331 | }
332 | }
333 |
334 | if (is_file($file)) {
335 | if (!ftp_put($connection, $destination, $file, FTP_BINARY)) {
336 | $json['error'] = sprintf($this->language->get('error_ftp_file'), $file);
337 | }
338 | }
339 | }
340 | } else {
341 | $json['error'] = sprintf($this->language->get('error_ftp_root'), $root);
342 | }
343 | } else {
344 | $json['error'] = sprintf($this->language->get('error_ftp_login'), $this->config->get('config_ftp_username'));
345 | }
346 |
347 | ftp_close($connection);
348 | } else {
349 | $json['error'] = sprintf($this->language->get('error_ftp_connection'), $this->config->get('config_ftp_hostname'), $this->config->get('config_ftp_port'));
350 | }
351 | }
352 | return $json;
353 | }
354 |
355 | public function sql() {
356 | $this->load->language('extension/installer');
357 |
358 | $json = array();
359 |
360 | $file = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ) . '/install.sql';
361 |
362 | if (!file_exists($file)) {
363 | $json['error'] = $this->language->get('error_file');
364 | }
365 |
366 | if (!$json) {
367 | $lines = file($file);
368 |
369 | if ($lines) {
370 | try {
371 | $sql = '';
372 |
373 | foreach ($lines as $line) {
374 | if ($line && (substr($line, 0, 2) != '--') && (substr($line, 0, 1) != '#')) {
375 | $sql .= $line;
376 |
377 | if (preg_match('/;\s*$/', $line)) {
378 | $sql = str_replace(" `oc_", " `" . DB_PREFIX, $sql);
379 |
380 | $this->db->query($sql);
381 |
382 | $sql = '';
383 | }
384 | }
385 | }
386 | } catch(Exception $exception) {
387 | $json['error'] = sprintf($this->language->get('error_exception'), $exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
388 | }
389 | }
390 | }
391 | }
392 |
393 | public function xml() {
394 | $this->load->language('extension/installer');
395 |
396 | $json = array();
397 |
398 | $file = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ) . '/install.xml';
399 |
400 | if (!file_exists($file)) {
401 | $json['error'] = $this->language->get('error_file');
402 | }
403 |
404 | if (!$json) {
405 | $this->load->model('extension/modification');
406 |
407 | // If xml file just put it straight into the DB
408 | $xml = file_get_contents($file);
409 |
410 | if ($xml) {
411 | try {
412 | $dom = new DOMDocument('1.0', 'UTF-8');
413 | $dom->loadXml($xml);
414 |
415 | $name = $dom->getElementsByTagName('name')->item(0);
416 |
417 | if ($name) {
418 | $name = $name->nodeValue;
419 | } else {
420 | $name = '';
421 | }
422 |
423 | $code = $dom->getElementsByTagName('code')->item(0);
424 |
425 | if ($code) {
426 | $code = $code->nodeValue;
427 |
428 | // Check to see if the modification is already installed or not.
429 | $modification_info = $this->model_extension_modification->getModificationByCode($code);
430 |
431 | if ($modification_info) {
432 | $json['error'] = sprintf($this->language->get('error_exists'), $modification_info['name']);
433 | }
434 | } else {
435 | $json['error'] = $this->language->get('error_code');
436 | }
437 |
438 | $author = $dom->getElementsByTagName('author')->item(0);
439 |
440 | if ($author) {
441 | $author = $author->nodeValue;
442 | } else {
443 | $author = '';
444 | }
445 |
446 | $version = $dom->getElementsByTagName('version')->item(0);
447 |
448 | if ($version) {
449 | $version = $version->nodeValue;
450 | } else {
451 | $version = '';
452 | }
453 |
454 | $link = $dom->getElementsByTagName('link')->item(0);
455 |
456 | if ($link) {
457 | $link = $link->nodeValue;
458 | } else {
459 | $link = '';
460 | }
461 |
462 | $modification_data = array(
463 | 'name' => $name,
464 | 'code' => $code,
465 | 'author' => $author,
466 | 'version' => $version,
467 | 'link' => $link,
468 | 'xml' => $xml,
469 | 'status' => 1
470 | );
471 |
472 | if (!$json) {
473 | $this->model_extension_modification->addModification($modification_data);
474 | }
475 | } catch(Exception $exception) {
476 | $json['error'] = sprintf($this->language->get('error_exception'), $exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
477 | }
478 | }
479 | }
480 | }
481 |
482 | public function php() {
483 | $this->load->language('extension/installer');
484 |
485 | $json = array();
486 |
487 | if (!$this->user->hasPermission('modify', 'extension/installer')) {
488 | $json['error'] = $this->language->get('error_permission');
489 | }
490 |
491 | $file = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ) . '/install.php';
492 |
493 | if (!file_exists($file)) {
494 | $json['error'] = $this->language->get('error_file');
495 | }
496 |
497 | if (!$json) {
498 | try {
499 | include($file);
500 | } catch(Exception $exception) {
501 | $json['error'] = sprintf($this->language->get('error_exception'), $exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
502 | }
503 | }
504 |
505 | }
506 |
507 | public function remove() {
508 | $this->load->language('extension/installer');
509 |
510 | $json = array();
511 |
512 | $directory = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path );
513 |
514 | if (!is_dir($directory)) {
515 | $json['error'] = $this->language->get('error_directory');
516 | }
517 |
518 | if (!$json) {
519 | // Get a list of files ready to upload
520 | $files = array();
521 |
522 | $path = array($directory);
523 |
524 | while (count($path) != 0) {
525 | $next = array_shift($path);
526 |
527 | // We have to use scandir function because glob will not pick up dot files.
528 | foreach (array_diff(scandir($next), array('.', '..')) as $file) {
529 | $file = $next . '/' . $file;
530 |
531 | if (is_dir($file)) {
532 | $path[] = $file;
533 | }
534 |
535 | $files[] = $file;
536 | }
537 | }
538 |
539 | rsort($files);
540 |
541 | foreach ($files as $file) {
542 | if (is_file($file)) {
543 | unlink($file);
544 | } elseif (is_dir($file)) {
545 | rmdir($file);
546 | }
547 | }
548 |
549 | if (file_exists($directory)) {
550 | rmdir($directory);
551 | }
552 |
553 | $json['success'] = $this->language->get('text_success');
554 | }
555 |
556 | }
557 |
558 | public function clear() {
559 | $this->load->language('extension/installer');
560 |
561 | $json = array();
562 |
563 | if (!$json) {
564 | $directories = glob(DIR_UPLOAD . 'update', GLOB_ONLYDIR);
565 |
566 | foreach ($directories as $directory) {
567 | // Get a list of files ready to upload
568 | $files = array();
569 |
570 | $path = array($directory);
571 |
572 | while (count($path) != 0) {
573 | $next = array_shift($path);
574 |
575 | // We have to use scandir function because glob will not pick up dot files.
576 | foreach (array_diff(scandir($next), array('.', '..')) as $file) {
577 | $file = $next . '/' . $file;
578 |
579 | if (is_dir($file)) {
580 | $path[] = $file;
581 | }
582 |
583 | $files[] = $file;
584 | }
585 | }
586 |
587 | rsort($files);
588 |
589 | foreach ($files as $file) {
590 | if (is_file($file)) {
591 | unlink($file);
592 | } elseif (is_dir($file)) {
593 | rmdir($file);
594 | }
595 | }
596 |
597 | if (file_exists($directory)) {
598 | rmdir($directory);
599 | }
600 | }
601 |
602 | $json['success'] = $this->language->get('text_clear');
603 | }
604 | }
605 | }
606 |
--------------------------------------------------------------------------------
/2.3/full/upload/admin/language/en-gb/extension/module/apimodule.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/2.3/patch/README.md:
--------------------------------------------------------------------------------
1 | OPENCART-MOBILE-ADMIN
2 | =====================
3 | Модуль для Opencart версии 2.0.0.0 и выше, содержащий API для управления интернет-магазином с мобильного устройста.
4 | ***
5 |
6 | Перед установкой убедитесь, что OpenCart Extension Installer настроен правильно,
7 | особенно FTP настройки.
8 | Если при установке появляется ошибка - установите дополнение: [https://www.opencart.com](https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=18892) и попробуйте снова.
9 |
10 | ***
11 | ### Установка производится через OCMOD:
12 | ***
13 | 1. Для установки перейдите в админ панель;
14 | 2. Перейдите "Модули->установка расширений";
15 | 3. Нажмите "загрузить файл" и выберите **apimobile.ocmod.zip**.
16 |
17 | ***
18 | ### ВАЖНО!!!
19 |
20 | Модуль не работает если включён режим обслуживания.
21 | ***
22 |
23 | #### Используйте эту ссылку для скачивания аппликации:
24 |
--------------------------------------------------------------------------------
/2.3/patch/apimobile2.0.ocmod.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/2.3/patch/apimobile2.0.ocmod.zip
--------------------------------------------------------------------------------
/2.3/patch/install.php:
--------------------------------------------------------------------------------
1 | db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX."user_token_mob_api` (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, user_id INT NOT NULL, token VARCHAR(32) NOT NULL )");
3 | $this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX."user_device_mob_api` (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, user_id INT NOT NULL, device_token VARCHAR(500) , os_type VARCHAR(20))");
4 |
5 | $this->load->model('setting/setting');
6 |
7 | $this->model_setting_setting->editSetting('apimodule', ['apimodule_status'=>1,'version'=>1.7]);
8 | if(VERSION == '2.0.0.0'){
9 | $this->load->model('tool/event');
10 | $this->model_tool_event->deleteEvent('apimodule');
11 | $this->model_tool_event->addEvent('apimodule', 'post.order.history.add', 'module/apimodule/sendNotifications');
12 | }else{
13 | //$this->load->model('extension/event');
14 | //$this->model_extension_event->deleteEvent('apimodule');
15 | //$this->model_extension_event->addEvent('apimodule', 'catalog/model/checkout/order/addOrderHistory/after', 'module/apimodule/sendNotifications');
16 | }
17 |
18 | ?>
--------------------------------------------------------------------------------
/2.3/patch/install.xml:
--------------------------------------------------------------------------------
1 |
2 | Check update apimodule
3 | 2.0
4 | https://opencartapp.pro
5 | Pinta
6 | apimodule_ocmod
7 |
8 |
9 |
10 | load->controller('extension/module/apimodule/checkVersion');
16 | }else{
17 | $version = $this->load->controller('module/apimodule/checkVersion');
18 | }
19 |
20 | if ($this->API_VERSION <(float)$version) {
21 | $data['update_module'] = "Обновите модуль OPENCART-MOBILE-ADMIN до версии ".$version." или скачайте по ссылке скачать ";
22 | } else {
23 | $data['update_module'] = '';
24 | }
25 | ]]>
26 |
27 |
28 |
29 |
30 | ]]>
31 |
33 |
34 |
35 |
36 |
37 | ]]>
38 |
39 |
40 |
41 |
42 | model_user_user->deleteUser($user_id);]]>
43 | db->query($sql);
46 | $sql = "DELETE FROM `" . DB_PREFIX . "user_device_mob_api` WHERE user_id = ". $user_id;
47 | $query = $this->db->query($sql); ]]>
48 |
49 |
50 |
51 |
52 |
53 | model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('cod_order_status_id')); ]]>
54 | load->model('module/apimodule');
57 | $this->model_module_apimodule->sendNotifications( $this->session->data['order_id'] );
58 |
59 | ]]>
60 |
61 |
62 |
63 |
64 |
65 |
66 | model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('bank_transfer_order_status_id'), $comment, true); ]]>
67 |
68 | load->model('module/apimodule');
71 | $this->model_module_apimodule->sendNotifications( $this->session->data['order_id'] );
72 |
73 | ]]>
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/2.3/patch/readme.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/2.3/patch/readme.txt
--------------------------------------------------------------------------------
/2.3/patch/upload/admin/language/en-gb/extension/module/apimodule.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/3.0/full/README.md:
--------------------------------------------------------------------------------
1 | OPENCART-MOBILE-ADMIN
2 | =====================
3 | Модуль для Opencart версии 2.0.0.0 и выше, содержащий API для управления интернет-магазином с мобильного устройста.
4 | ***
5 |
6 | Перед установкой убедитесь, что OpenCart Extension Installer настроен правильно,
7 | особенно FTP настройки.
8 | Если при установке появляется ошибка - установите дополнение: [https://www.opencart.com](https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=18892) и попробуйте снова.
9 |
10 | ***
11 | ### Установка производится через OCMOD:
12 | ***
13 | 1. Для установки перейдите в админ панель;
14 | 2. Перейдите "Модули->установка расширений";
15 | 3. Нажмите "загрузить файл" и выберите **apimobile.ocmod.zip**.
16 |
17 | ***
18 | ### ВАЖНО!!!
19 |
20 | Модуль не работает если включён режим обслуживания.
21 | ***
22 |
23 | #### Используйте эту ссылку для скачивания аппликации:
24 |
--------------------------------------------------------------------------------
/3.0/full/apimobile-2.0-opencart-3.0._.ocmod.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/3.0/full/apimobile-2.0-opencart-3.0._.ocmod.zip
--------------------------------------------------------------------------------
/3.0/full/install.xml:
--------------------------------------------------------------------------------
1 |
2 | Check update apimodule
3 | 2.0
4 | https://opencartapp.pro
5 | Pinta
6 | apimodule_ocmod
7 |
8 |
9 |
10 | load->controller('extension/module/apimodule/checkVersion');
16 | }else{
17 | $version = $this->load->controller('extension/module/apimodule/checkVersion');
18 | }
19 |
20 | if ($this->API_VERSION <(float)$version) {
21 | $data['update_module'] = "Обновите модуль OPENCART-MOBILE-ADMIN до версии ".$version." или скачайте по ссылке скачать ";
22 | } else {
23 | $data['update_module'] = '';
24 | }
25 | ]]>
26 |
27 |
28 |
29 |
30 | ]]>
31 |
33 |
34 |
35 |
36 |
37 | ]]>
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('payment_cod_order_status_id')); ]]>
60 | load->model('extension/module/apimodule');
63 | $this->model_extension_module_apimodule->sendNotifications( $this->session->data['order_id'] );
64 |
65 | ]]>
66 |
67 |
68 |
69 |
70 |
71 |
72 | model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('payment_bank_transfer_order_status_id'), $comment, true); ]]>
73 |
74 | load->model('extension/module/apimodule');
77 | $this->model_extension_module_apimodule->sendNotifications($this->session->data['order_id'] );
78 |
79 | ]]>
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/3.0/full/readme.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/3.0/full/readme.txt
--------------------------------------------------------------------------------
/3.0/full/upload/admin/controller/extension/module/apimodule.php:
--------------------------------------------------------------------------------
1 | registry);
13 |
14 | $this->API_VERSION = $api->getVersion();
15 | $this->OPENCART_VERSION = substr(VERSION,0,3);
16 | }
17 |
18 | public function checkVersion(){
19 | $return = false;
20 |
21 | $curl_handle = curl_init();
22 | curl_setopt($curl_handle, CURLOPT_URL,'https://opencartapp.pro/app/index.php?opencart_version='.$this->OPENCART_VERSION);
23 | curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
24 | curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
25 | curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0');
26 | $json = curl_exec($curl_handle);
27 | curl_close($curl_handle);
28 | $version = json_decode($json,1);
29 |
30 | if($this->API_VERSION <(float)$version['version']){
31 | $return = $version['version'];
32 | }
33 | return $return;
34 | }
35 | public function index() {
36 | $this->load->language('extension/module/apimodule');
37 |
38 | $this->document->setTitle($this->language->get('heading_title'));
39 |
40 | $this->load->model('setting/setting');
41 |
42 | if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
43 | $this->model_setting_setting->editSetting('module_apimodule', $this->request->post);
44 |
45 | $this->session->data['success'] = $this->language->get('text_success');
46 |
47 | $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true));
48 | }
49 |
50 |
51 |
52 | $data['heading_title'] = $this->language->get('heading_title');
53 |
54 | $data['text_edit'] = $this->language->get('text_edit');
55 | $data['text_enabled'] = $this->language->get('text_enabled');
56 | $data['text_disabled'] = $this->language->get('text_disabled');
57 | $data['text_default'] = $this->language->get('text_default');
58 | $data['entry_store'] = $this->language->get('entry_store');
59 |
60 | $data['entry_status'] = $this->language->get('entry_status');
61 |
62 | $data['button_save'] = $this->language->get('button_save');
63 | $data['button_cancel'] = $this->language->get('button_cancel');
64 | $data['button_update'] = $this->language->get('button_update');
65 |
66 | if (isset($this->error['warning'])) {
67 | $data['error_warning'] = $this->error['warning'];
68 | } else {
69 | $data['error_warning'] = '';
70 | }
71 |
72 | $data['breadcrumbs'] = array();
73 |
74 | $data['breadcrumbs'][] = array(
75 | 'text' => $this->language->get('text_home'),
76 | 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
77 | );
78 |
79 | $data['breadcrumbs'][] = array(
80 | 'text' => $this->language->get('text_module'),
81 | 'href' => $this->url->link('extension/module', 'user_token=' . $this->session->data['user_token'], true)
82 | );
83 |
84 | $data['breadcrumbs'][] = array(
85 | 'text' => $this->language->get('heading_title'),
86 | 'href' => $this->url->link('extension/module/apimodule', 'user_token=' . $this->session->data['user_token'], true)
87 | );
88 |
89 | $data['action'] = $this->url->link('extension/module/apimodule', 'user_token=' . $this->session->data['user_token'], true);
90 |
91 | $data['cancel'] = $this->url->link('extension/module', 'user_token=' . $this->session->data['user_token'], true);
92 |
93 |
94 |
95 | if (isset($this->request->post['module_apimodule_status'])) {
96 | $data['module_apimodule_status'] = $this->request->post['module_apimodule_status'];
97 | } else {
98 | $data['module_apimodule_status'] = $this->config->get('module_apimodule_status');
99 | }
100 |
101 | $this->load->model('setting/store');
102 | $data['stores'] = $this->model_setting_store->getStores();
103 | if (isset($this->request->post['apimodule_store'])) {
104 | $data['module_apimodule_store'] = $this->request->post['module_apimodule_store'];
105 | } else {
106 | $data['module_apimodule_store'] = $this->config->get('module_apimodule_store');
107 | }
108 |
109 |
110 | if (!extension_loaded('zip')) {
111 | $data['ext'] = "not installed zip extension for update";
112 | }else{
113 | $data['ext'] = "";
114 | }
115 |
116 | if (isset($this->session->data['error'])) {
117 | $data['error'] = $this->session->data['error'];
118 |
119 | unset($this->session->data['error']);
120 | } else {
121 | $data['error'] = '';
122 | }
123 |
124 | $data['header'] = $this->load->controller('common/header');
125 | $data['column_left'] = $this->load->controller('common/column_left');
126 | $data['footer'] = $this->load->controller('common/footer');
127 |
128 | $data['version'] = $version = $this->checkVersion();
129 | $data['current_version'] = $this->API_VERSION;
130 | $data['update'] = $this->url->link('extension/module/apimodule/update&v='.$version, 'user_token=' . $this->session->data['user_token'], true);
131 |
132 | $this->response->setOutput($this->load->view('extension/module/apimodule', $data));
133 | }
134 |
135 | protected function validate() {
136 | if (!$this->user->hasPermission('modify', 'extension/module/apimodule')) {
137 | $this->error['warning'] = $this->language->get('error_permission');
138 | }
139 |
140 | return !$this->error;
141 | }
142 | private $path = "update";
143 | private $fileName = "";
144 |
145 | public function update() {
146 |
147 | if(isset($_GET['v'])) {
148 | //apimobile1.8.ocmod.zip
149 | $this->fileName = "apimobile" . $_GET['v'] .".ocmod.zip";
150 | //$file = file_get_contents("https://opencartapp.pro/app/".$this->OPENCART_VERSION.'/'.$this->fileName);
151 | // If no temp directory exists create it
152 |
153 | $ch = curl_init();
154 | curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
155 | curl_setopt($ch, CURLOPT_HEADER, 0);
156 | curl_setopt($ch, CURLOPT_FAILONERROR, 1);
157 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
158 | curl_setopt($ch, CURLOPT_URL, "https://opencartapp.pro/app/".$this->OPENCART_VERSION.'/'.$this->fileName);
159 | $file = curl_exec($ch);
160 | curl_close($ch);
161 |
162 | if (!is_dir(DIR_UPLOAD . $this->path)) {
163 | mkdir(DIR_UPLOAD . $this->path, 0777);
164 | }
165 |
166 | $new_path = DIR_UPLOAD . $this->path ."/" . $this->fileName;
167 | if(!file_exists($new_path)) {
168 | file_put_contents( $new_path, $file );
169 | }
170 |
171 | $this->installPatch();
172 | }else{
173 | $this->error['warning'] = "Not version";
174 | }
175 | return $this->error;
176 | }
177 |
178 |
179 | public function install() {
180 | $this->db->query("CREATE TABLE IF NOT EXISTS " . DB_PREFIX."user_token_mob_api (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, user_id INT NOT NULL, token VARCHAR(32) NOT NULL )");
181 | $this->db->query("CREATE TABLE IF NOT EXISTS " . DB_PREFIX."user_device_mob_api (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, user_id INT NOT NULL, device_token VARCHAR(500) , os_type VARCHAR(20))");
182 |
183 | $this->load->model('setting/setting');
184 |
185 | $this->model_setting_setting->editSetting('apimodule', ['module_apimodule_status'=>1,'version'=>1.7,'module_apimodule_store' => ['0']]);
186 | if(VERSION == '2.0.0.0'){
187 | $this->load->model('tool/event');
188 | $this->model_tool_event->addEvent('apimodule', 'post.order.history.add', 'module/apimodule/sendNotifications');
189 | }else{
190 | // $this->load->model('setting/event');
191 | // $this->model_setting_event->addEvent('apimodule', 'catalog/model/checkout/order/addOrderHistory/after', 'extension/module/apimodule/sendNotifications');
192 | }
193 |
194 | }
195 |
196 | private function installPatch() {
197 |
198 | $this->unzip();
199 | $ftp = $this->ftp();
200 | if(isset($ftp['error'])){
201 | $this->session->data['error'] = $ftp['error'];
202 | $this->response->redirect($this->url->link('extension/module/apimodule', 'user_token=' . $this->session->data['user_token'], true));
203 | }
204 | $this->php();
205 | $this->sql();
206 |
207 | $this->clear();
208 | $this->session->data['success'] = "Модуль успешно обновлен";
209 | $this->response->redirect($this->url->link('extension/extension', 'user_token=' . $this->session->data['user_token'], true));
210 |
211 | }
212 |
213 |
214 | public function unzip() {
215 | $this->load->language('extension/installer');
216 |
217 | $json = array();
218 | // Sanitize the filename
219 | $file = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path) . '/'.$this->fileName;
220 |
221 | if (!file_exists($file)) {
222 | $json['error'] = $this->language->get('error_file');
223 | }
224 |
225 | if (!$json) {
226 | // Unzip the files
227 | $zip = new ZipArchive();
228 |
229 | if ($zip->open($file)) {
230 | $zip->extractTo(DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ));
231 | // echo DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path );
232 |
233 | $zip->close();
234 | } else {
235 | $json['error'] = $this->language->get('error_unzip');
236 | }
237 |
238 | // Remove Zip
239 | unlink($file);
240 | }
241 |
242 | }
243 |
244 | public function ftp() {
245 | $this->load->language('extension/installer');
246 |
247 | $json = array();
248 |
249 | // Check FTP status
250 | if (!$this->config->get('config_ftp_status')) {
251 | $json['error'] = $this->language->get('error_ftp_status');
252 | }
253 |
254 | $directory = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ) . '/upload/';
255 |
256 | if (!is_dir($directory)) {
257 | $json['error'] = $this->language->get('error_directory');
258 | }
259 |
260 | if (!$json) {
261 | // Get a list of files ready to upload
262 | $files = array();
263 |
264 | $path = array($directory . '*');
265 |
266 | while (count($path) != 0) {
267 | $next = array_shift($path);
268 |
269 | foreach ((array)glob($next) as $file) {
270 | if (is_dir($file)) {
271 | $path[] = $file . '/*';
272 | }
273 |
274 | $files[] = $file;
275 | }
276 | }
277 |
278 | // Connect to the site via FTP
279 | $connection = ftp_connect($this->config->get('config_ftp_hostname'), $this->config->get('config_ftp_port'));
280 |
281 | if ($connection) {
282 | $login = ftp_login($connection, $this->config->get('config_ftp_username'), $this->config->get('config_ftp_password'));
283 |
284 | if ($login) {
285 | if ($this->config->get('config_ftp_root')) {
286 | $root = ftp_chdir($connection, $this->config->get('config_ftp_root'));
287 | } else {
288 | $root = ftp_chdir($connection, '/');
289 | }
290 |
291 | if ($root) {
292 | foreach ($files as $file) {
293 | $destination = substr($file, strlen($directory));
294 |
295 | // Upload everything in the upload directory
296 | // Many people rename their admin folder for security purposes which I believe should be an option during installation just like setting the db prefix.
297 | // the following code would allow you to change the name of the following directories and any extensions installed will still go to the right directory.
298 | if (substr($destination, 0, 5) == 'admin') {
299 | $destination = basename(DIR_APPLICATION) . substr($destination, 5);
300 | }
301 |
302 | if (substr($destination, 0, 7) == 'catalog') {
303 | $destination = basename(DIR_CATALOG) . substr($destination, 7);
304 | }
305 |
306 | if (substr($destination, 0, 5) == 'image') {
307 | $destination = basename(DIR_IMAGE) . substr($destination, 5);
308 | }
309 |
310 | if (substr($destination, 0, 6) == 'system') {
311 | $destination = basename(DIR_SYSTEM) . substr($destination, 6);
312 | }
313 |
314 | if (is_dir($file)) {
315 | $list = ftp_nlist($connection, substr($destination, 0, strrpos($destination, '/')));
316 |
317 | // Basename all the directories because on some servers they don't return the fulll paths.
318 | $list_data = array();
319 |
320 | foreach ($list as $list) {
321 | $list_data[] = basename($list);
322 | }
323 |
324 | if (!in_array(basename($destination), $list_data)) {
325 | if (!ftp_mkdir($connection, $destination)) {
326 | $json['error'] = sprintf($this->language->get('error_ftp_directory'), $destination);
327 | }
328 | }
329 | }
330 |
331 | if (is_file($file)) {
332 | if (!ftp_put($connection, $destination, $file, FTP_BINARY)) {
333 | $json['error'] = sprintf($this->language->get('error_ftp_file'), $file);
334 | }
335 | }
336 | }
337 | } else {
338 | $json['error'] = sprintf($this->language->get('error_ftp_root'), $root);
339 | }
340 | } else {
341 | $json['error'] = sprintf($this->language->get('error_ftp_login'), $this->config->get('config_ftp_username'));
342 | }
343 |
344 | ftp_close($connection);
345 | } else {
346 | $json['error'] = sprintf($this->language->get('error_ftp_connection'), $this->config->get('config_ftp_hostname'), $this->config->get('config_ftp_port'));
347 | }
348 | }
349 | return $json;
350 | }
351 |
352 | public function sql() {
353 | $this->load->language('extension/installer');
354 |
355 | $json = array();
356 |
357 | $file = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ) . '/install.sql';
358 |
359 | if (!file_exists($file)) {
360 | $json['error'] = $this->language->get('error_file');
361 | }
362 |
363 | if (!$json) {
364 | $lines = file($file);
365 |
366 | if ($lines) {
367 | try {
368 | $sql = '';
369 |
370 | foreach ($lines as $line) {
371 | if ($line && (substr($line, 0, 2) != '--') && (substr($line, 0, 1) != '#')) {
372 | $sql .= $line;
373 |
374 | if (preg_match('/;\s*$/', $line)) {
375 | $sql = str_replace(" `oc_", " `" . DB_PREFIX, $sql);
376 |
377 | $this->db->query($sql);
378 |
379 | $sql = '';
380 | }
381 | }
382 | }
383 | } catch(Exception $exception) {
384 | $json['error'] = sprintf($this->language->get('error_exception'), $exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
385 | }
386 | }
387 | }
388 | }
389 |
390 | public function xml() {
391 | $this->load->language('extension/installer');
392 |
393 | $json = array();
394 |
395 | $file = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ) . '/install.xml';
396 |
397 | if (!file_exists($file)) {
398 | $json['error'] = $this->language->get('error_file');
399 | }
400 |
401 | if (!$json) {
402 | $this->load->model('extension/modification');
403 |
404 | // If xml file just put it straight into the DB
405 | $xml = file_get_contents($file);
406 |
407 | if ($xml) {
408 | try {
409 | $dom = new DOMDocument('1.0', 'UTF-8');
410 | $dom->loadXml($xml);
411 |
412 | $name = $dom->getElementsByTagName('name')->item(0);
413 |
414 | if ($name) {
415 | $name = $name->nodeValue;
416 | } else {
417 | $name = '';
418 | }
419 |
420 | $code = $dom->getElementsByTagName('code')->item(0);
421 |
422 | if ($code) {
423 | $code = $code->nodeValue;
424 |
425 | // Check to see if the modification is already installed or not.
426 | $modification_info = $this->model_extension_modification->getModificationByCode($code);
427 |
428 | if ($modification_info) {
429 | $json['error'] = sprintf($this->language->get('error_exists'), $modification_info['name']);
430 | }
431 | } else {
432 | $json['error'] = $this->language->get('error_code');
433 | }
434 |
435 | $author = $dom->getElementsByTagName('author')->item(0);
436 |
437 | if ($author) {
438 | $author = $author->nodeValue;
439 | } else {
440 | $author = '';
441 | }
442 |
443 | $version = $dom->getElementsByTagName('version')->item(0);
444 |
445 | if ($version) {
446 | $version = $version->nodeValue;
447 | } else {
448 | $version = '';
449 | }
450 |
451 | $link = $dom->getElementsByTagName('link')->item(0);
452 |
453 | if ($link) {
454 | $link = $link->nodeValue;
455 | } else {
456 | $link = '';
457 | }
458 |
459 | $modification_data = array(
460 | 'name' => $name,
461 | 'code' => $code,
462 | 'author' => $author,
463 | 'version' => $version,
464 | 'link' => $link,
465 | 'xml' => $xml,
466 | 'status' => 1
467 | );
468 |
469 | if (!$json) {
470 | $this->model_extension_modification->addModification($modification_data);
471 | }
472 | } catch(Exception $exception) {
473 | $json['error'] = sprintf($this->language->get('error_exception'), $exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
474 | }
475 | }
476 | }
477 | }
478 |
479 | public function php() {
480 | $this->load->language('extension/installer');
481 |
482 | $json = array();
483 |
484 | if (!$this->user->hasPermission('modify', 'extension/installer')) {
485 | $json['error'] = $this->language->get('error_permission');
486 | }
487 |
488 | $file = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ) . '/install.php';
489 |
490 | if (!file_exists($file)) {
491 | $json['error'] = $this->language->get('error_file');
492 | }
493 |
494 | if (!$json) {
495 | try {
496 | include($file);
497 | } catch(Exception $exception) {
498 | $json['error'] = sprintf($this->language->get('error_exception'), $exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
499 | }
500 | }
501 |
502 | }
503 |
504 | public function remove() {
505 | $this->load->language('extension/installer');
506 |
507 | $json = array();
508 |
509 | $directory = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path );
510 |
511 | if (!is_dir($directory)) {
512 | $json['error'] = $this->language->get('error_directory');
513 | }
514 |
515 | if (!$json) {
516 | // Get a list of files ready to upload
517 | $files = array();
518 |
519 | $path = array($directory);
520 |
521 | while (count($path) != 0) {
522 | $next = array_shift($path);
523 |
524 | // We have to use scandir function because glob will not pick up dot files.
525 | foreach (array_diff(scandir($next), array('.', '..')) as $file) {
526 | $file = $next . '/' . $file;
527 |
528 | if (is_dir($file)) {
529 | $path[] = $file;
530 | }
531 |
532 | $files[] = $file;
533 | }
534 | }
535 |
536 | rsort($files);
537 |
538 | foreach ($files as $file) {
539 | if (is_file($file)) {
540 | unlink($file);
541 | } elseif (is_dir($file)) {
542 | rmdir($file);
543 | }
544 | }
545 |
546 | if (file_exists($directory)) {
547 | rmdir($directory);
548 | }
549 |
550 | $json['success'] = $this->language->get('text_success');
551 | }
552 |
553 | }
554 |
555 | public function clear() {
556 | $this->load->language('extension/installer');
557 |
558 | $json = array();
559 |
560 | if (!$json) {
561 | $directories = glob(DIR_UPLOAD . 'update', GLOB_ONLYDIR);
562 |
563 | foreach ($directories as $directory) {
564 | // Get a list of files ready to upload
565 | $files = array();
566 |
567 | $path = array($directory);
568 |
569 | while (count($path) != 0) {
570 | $next = array_shift($path);
571 |
572 | // We have to use scandir function because glob will not pick up dot files.
573 | foreach (array_diff(scandir($next), array('.', '..')) as $file) {
574 | $file = $next . '/' . $file;
575 |
576 | if (is_dir($file)) {
577 | $path[] = $file;
578 | }
579 |
580 | $files[] = $file;
581 | }
582 | }
583 |
584 | rsort($files);
585 |
586 | foreach ($files as $file) {
587 | if (is_file($file)) {
588 | unlink($file);
589 | } elseif (is_dir($file)) {
590 | rmdir($file);
591 | }
592 | }
593 |
594 | if (file_exists($directory)) {
595 | rmdir($directory);
596 | }
597 | }
598 |
599 | $json['success'] = $this->language->get('text_clear');
600 | }
601 | }
602 | }
603 |
--------------------------------------------------------------------------------
/3.0/full/upload/admin/language/en-gb/extension/module/apimodule.php:
--------------------------------------------------------------------------------
1 |
3 |
33 |
34 | {% if error_warning %}
35 |
{{ error_warning }}
36 |
37 |
38 | {% endif %}
39 | {% if error %}
40 |
41 |
42 |
43 | {% endif %}
44 |
45 |
46 |
{{ text_edit }}
47 |
48 |
104 |
105 |
106 |
107 | {{ footer }}
108 |
--------------------------------------------------------------------------------
/3.0/patch/README.md:
--------------------------------------------------------------------------------
1 | OPENCART-MOBILE-ADMIN
2 | =====================
3 | Модуль для Opencart версии 2.0.0.0 и выше, содержащий API для управления интернет-магазином с мобильного устройста.
4 | ***
5 |
6 | Перед установкой убедитесь, что OpenCart Extension Installer настроен правильно,
7 | особенно FTP настройки.
8 | Если при установке появляется ошибка - установите дополнение: [https://www.opencart.com](https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=18892) и попробуйте снова.
9 |
10 | ***
11 | ### Установка производится через OCMOD:
12 | ***
13 | 1. Для установки перейдите в админ панель;
14 | 2. Перейдите "Модули->установка расширений";
15 | 3. Нажмите "загрузить файл" и выберите **apimobile.ocmod.zip**.
16 |
17 | ***
18 | ### ВАЖНО!!!
19 |
20 | Модуль не работает если включён режим обслуживания.
21 | ***
22 |
23 | #### Используйте эту ссылку для скачивания аппликации:
24 |
--------------------------------------------------------------------------------
/3.0/patch/apimobile2.0.ocmod.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/3.0/patch/apimobile2.0.ocmod.zip
--------------------------------------------------------------------------------
/3.0/patch/install.php:
--------------------------------------------------------------------------------
1 | db->query("DROP TABLE IF EXISTS `" . DB_PREFIX."user_token_mob_api` ");
4 | $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX."user_device_mob_api` ");
5 | $this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX."user_token_mob_api` (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, user_id INT NOT NULL, token VARCHAR(32) NOT NULL )");
6 | $this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX."user_device_mob_api` (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, user_id INT NOT NULL, device_token VARCHAR(500) , os_type VARCHAR(20))");
7 |
8 | $this->load->model('setting/setting');
9 |
10 | $this->model_setting_setting->editSetting('module_apimodule', ['module_apimodule_status'=>1,'version'=>1.7]);
11 | if(VERSION == '2.0.0.0'){
12 | $this->load->model('tool/event');
13 | $this->model_tool_event->deleteEvent('apimodule');
14 | $this->model_tool_event->addEvent('apimodule', 'post.order.history.add', 'extension/module/apimodule/sendNotifications');
15 | }else{
16 | $this->load->model('extension/event');
17 | $this->model_extension_event->deleteEvent('apimodule');
18 | $this->model_extension_event->addEvent('apimodule', 'catalog/model/checkout/order/addOrderHistory/after', 'extension/module/apimodule/sendNotifications');
19 | }
20 |
21 | ?>
--------------------------------------------------------------------------------
/3.0/patch/install.xml:
--------------------------------------------------------------------------------
1 |
2 | Check update apimodule
3 | 2.0
4 | https://opencartapp.pro
5 | Pinta
6 | apimodule_ocmod
7 |
8 |
9 |
10 | load->controller('extension/module/apimodule/checkVersion');
16 | }else{
17 | $version = $this->load->controller('extension/module/apimodule/checkVersion');
18 | }
19 |
20 | if ($this->API_VERSION <(float)$version) {
21 | $data['update_module'] = "Обновите модуль OPENCART-MOBILE-ADMIN до версии ".$version." или скачайте по ссылке скачать ";
22 | } else {
23 | $data['update_module'] = '';
24 | }
25 | ]]>
26 |
27 |
28 |
29 |
30 | ]]>
31 |
33 |
34 |
35 |
36 |
37 | ]]>
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('payment_cod_order_status_id')); ]]>
60 | load->model('extension/module/apimodule');
63 | $this->model_extension_module_apimodule->sendNotifications( $this->session->data['order_id'] );
64 |
65 | ]]>
66 |
67 |
68 |
69 |
70 |
71 |
72 | model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('payment_bank_transfer_order_status_id'), $comment, true); ]]>
73 |
74 | load->model('extension/module/apimodule');
77 | $this->model_extension_module_apimodule->sendNotifications($this->session->data['order_id'] );
78 |
79 | ]]>
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/3.0/patch/readme.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/3.0/patch/readme.txt
--------------------------------------------------------------------------------
/3.0/patch/upload/admin/language/en-gb/extension/module/apimodule.php:
--------------------------------------------------------------------------------
1 |
3 |
33 |
34 | {% if error_warning %}
35 |
{{ error_warning }}
36 |
37 |
38 | {% endif %}
39 | {% if error %}
40 |
41 |
42 |
43 | {% endif %}
44 |
45 |
46 |
{{ text_edit }}
47 |
48 |
104 |
105 |
106 |
107 | {{ footer }}
108 |
--------------------------------------------------------------------------------
/Images/Step 1a.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/Images/Step 1a.jpg
--------------------------------------------------------------------------------
/Images/Step 2.2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/Images/Step 2.2.png
--------------------------------------------------------------------------------
/Images/step 0.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/Images/step 0.jpg
--------------------------------------------------------------------------------
/Images/step 1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/Images/step 1.png
--------------------------------------------------------------------------------
/Images/step 2.6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/Images/step 2.6.png
--------------------------------------------------------------------------------
/Images/step 2a.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/Images/step 2a.jpg
--------------------------------------------------------------------------------
/Images/step 3a.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/Images/step 3a.jpg
--------------------------------------------------------------------------------
/Images/step 4a.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/Images/step 4a.jpg
--------------------------------------------------------------------------------
/Images/step 5a.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/Images/step 5a.jpg
--------------------------------------------------------------------------------
/Images/step 6a.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/Images/step 6a.jpg
--------------------------------------------------------------------------------
/Images/step 7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/Images/step 7.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | OPENCART-MOBILE-ADMIN
2 | =====================
3 | Opencart extension for 1.5 and higher, contains API for managing store from smartphone.
4 | View and process orders, push-notification of new orders, quick access to clients of your store.
5 | ***
6 |
7 | ### Installation
8 | ***
9 | Installation process is different for some OpenCart versions, before installation check the manual:
10 | ### Manual for OpenCart 1.5 and higher
11 | #### To install extension on your website, you need to:
12 | 1. Follow the link https://github.com/pintawebware/opencart-mobile-admin/releases and download the extension according to the version of your store
13 | 
14 |
15 | 2. Install Vqmod to your website. If Vqmod is already installed - skip to next step.
16 | 1. Follow the link: https://github.com/vqmod/vqmod/releases
17 | 2. Download release with the “Latest Release” mark (at the time of writing - 2.6.1)
18 | 
19 | 3. Login into your website via any FTP-client (for example, Filezilla)
20 | 4. In the window “Remote site” open the root of your website
21 | 5. In the window “Local site” open the folder with unpacked archiveм
22 | 6. Right mouse button click on folder called “vqmod”, in the opened menu hit “Upload”
23 | 
24 | 7. Open in your web-browser following link: http://your-cool-site.com/vqmod/install/
25 | > If you got the message “VQMOD HAS BEEN INSTALLED ON YOUR SYSTEM!” - it means that you have successfully installed vqmod, go to the next step.
26 | If your got the message "VQMOD ALREADY INSTALLED!" - it means that you have already installed vqmod on your site, go to the next step.
27 | The message "ONE OR MORE FILES COULD NOT BE WRITTEN" - says that you do not have permissions on some files, please contact with your system administrator to proceed.
28 |
29 | 3. Unpack downloaded archive into any directory
30 | 4. Login into your website via any FTP-client (for example, Filezilla)
31 | 5. In the window “Remote site” open the root of your site
32 | 6. In the window “Local site” open the directory that contains unpacked archive data.
33 | 7. Pick extracted data and hit “Upload”
34 | 
35 | 8. The installation of extension is completed, for the next step you can install application using Google Play or iTunes.
36 |
37 |
38 | ### Manual for OpenCart 2.0 and higher
39 | > For the module to work, you need a version of php 5.4 and higher.
40 | For online stores owners on OpenCart version 2 and above. After installing the module on some intermediate versions, the website can go into development mode. Be sure, after installing the module, check the settings, the development mode should be turned off! To check, go to System - Settings - Edit (current site) - Server tab.
41 | 
42 | #### To install extension on your website, you need to:
43 | 1. Follow the link https://github.com/pintawebware/opencart-mobile-admin/releases and download the extension according to the version of your store
44 | 
45 | 2. Login to your store as “Administrator” and go to Extensions -> Extension installer
46 | 
47 | 3. Press Upload and choose extension-archive that you have downloaded previously
48 | 
49 | 4. Next step to install the extension, press “Continue”
50 | 
51 | 5. The installation process will begin, and when its finished you will see “Success: The extension has been installed!” message.
52 | 
53 | 6. After installation, go to the "Extensions" - "Modifications", select "Check update apimodule" and click on the update button.
54 | 
55 | 7.The installation of extension is completed, for the next step you can install application using.
56 |
57 | #### Use this link to download applications:
58 | * [Google Play](https://play.google.com/store/apps/details?id=com.pinta.opencart.opencartmobileadmin)
59 | * [AppStore](https://itunes.apple.com/ua/app/opencart-mobile-admin/id1213731316?l=ru&mt=8)
60 |
61 | Before installation for some OpenCart version, please check that OpenCart Extension Installer is configured properly,
62 | especially FTP configs.
63 | In case of installation error - download this additional extension: [https://www.opencart.com](https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=18892) and try again.
64 |
65 | ***
66 | ### ATTENTION!!!
67 | Installation extension for some OpenCart 2.0 and higher your website may switch to the Maintenance Mode, for proper work of store and application make sure that Maintenance Mode is turned off.
68 | To make sure: System -> Settings -> Edit -> Server -> Maintenance Mode
69 | ***
70 |
--------------------------------------------------------------------------------
/apimobile-2.0-opencart-1.5._.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/apimobile-2.0-opencart-1.5._.zip
--------------------------------------------------------------------------------
/apimobile-2.0-opencart-2.0._.ocmod.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/apimobile-2.0-opencart-2.0._.ocmod.zip
--------------------------------------------------------------------------------
/apimobile-2.0-opencart-2.3._.ocmod.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/apimobile-2.0-opencart-2.3._.ocmod.zip
--------------------------------------------------------------------------------
/apimobile-2.0-opencart-3.0._.ocmod.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/apimobile-2.0-opencart-3.0._.ocmod.zip
--------------------------------------------------------------------------------
/install.php:
--------------------------------------------------------------------------------
1 | db->query("CREATE TABLE IF NOT EXISTS " . DB_PREFIX."user_token_mob_api (id INT NOT NULL PRIMARY KEY, user_id INT NOT NULL, token VARCHAR(32) NOT NULL )");
4 | $this->db->query("CREATE TABLE IF NOT EXISTS " . DB_PREFIX."user_device_mob_api (id INT NOT NULL PRIMARY KEY, user_id INT NOT NULL, device_token VARCHAR(500) , os_type VARCHAR(50))");
5 |
6 | $this->load->model('setting/setting');
7 |
8 | $this->model_setting_setting->editSetting('apimodule', ['apimodule_status'=>1,'version'=>1.7]);
9 | if(VERSION == '2.0.0.0' || VERSION == '2.0.0.0a1'){
10 | $this->load->model('tool/event');
11 | $this->model_tool_event->addEvent('apimodule', 'post.order.history.add', 'module/apimodule/sendNotifications');
12 | }elseif(VERSION == '2.0.0.0a1'){
13 | $this->load->model('tool/event');
14 | $this->model_tool_event->setHandler('apimodule', 'post.order.history.add', 'module/apimodule/sendNotifications');
15 | }else{
16 | $this->load->model('extension/event');
17 | $this->model_extension_event->addEvent('apimodule', 'post.order.history.add', 'module/apimodule/sendNotifications');
18 | }
19 |
20 |
21 |
22 | ?>
--------------------------------------------------------------------------------
/readme.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pintawebware/opencart-mobile-admin/d024e2aefee7ea19bd1ada83b04c95b9c0c67ba5/readme.txt
--------------------------------------------------------------------------------
/upload/admin/controller/module/apimodule.php:
--------------------------------------------------------------------------------
1 | API_VERSION <(float)$version['version']){
11 | $return = $version['version'];
12 | }
13 | return $return;
14 | }
15 | public function index() {
16 | $this->load->language('module/apimodule');
17 |
18 | $this->document->setTitle($this->language->get('heading_title'));
19 |
20 | $this->load->model('setting/setting');
21 |
22 | if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
23 |
24 | $this->model_setting_setting->editSetting('apimodule', $this->request->post);
25 |
26 | $this->session->data['success'] = $this->language->get('text_success');
27 |
28 | $this->response->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));
29 | }
30 |
31 |
32 | $data['heading_title'] = $this->language->get('heading_title');
33 |
34 | $data['text_edit'] = $this->language->get('text_edit');
35 | $data['text_enabled'] = $this->language->get('text_enabled');
36 | $data['text_disabled'] = $this->language->get('text_disabled');
37 |
38 | $data['entry_status'] = $this->language->get('entry_status');
39 |
40 | $data['button_save'] = $this->language->get('button_save');
41 | $data['button_cancel'] = $this->language->get('button_cancel');
42 | $data['button_update'] = $this->language->get('button_update');
43 |
44 | if (isset($this->error['warning'])) {
45 | $data['error_warning'] = $this->error['warning'];
46 | } else {
47 | $data['error_warning'] = '';
48 | }
49 |
50 | $data['breadcrumbs'] = array();
51 |
52 | $data['breadcrumbs'][] = array(
53 | 'text' => $this->language->get('text_home'),
54 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL')
55 | );
56 |
57 | $data['breadcrumbs'][] = array(
58 | 'text' => $this->language->get('text_module'),
59 | 'href' => $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL')
60 | );
61 |
62 | $data['breadcrumbs'][] = array(
63 | 'text' => $this->language->get('heading_title'),
64 | 'href' => $this->url->link('module/apimodule', 'token=' . $this->session->data['token'], 'SSL')
65 | );
66 |
67 | $data['action'] = $this->url->link('module/apimodule', 'token=' . $this->session->data['token'], 'SSL');
68 |
69 | $data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL');
70 |
71 | if (isset($this->request->post['apimodule_status'])) {
72 | $data['apimodule_status'] = $this->request->post['apimodule_status'];
73 | } else {
74 | $data['apimodule_status'] = $this->config->get('apimodule_status');
75 | }
76 |
77 | $data['header'] = $this->load->controller('common/header');
78 | $data['column_left'] = $this->load->controller('common/column_left');
79 | $data['footer'] = $this->load->controller('common/footer');
80 |
81 | $data['version'] = $version = $this->checkVersion();
82 | $data['update'] = $this->url->link('module/apimodule/update&v='.$version, 'token=' . $this->session->data['token'], 'SSL');
83 |
84 |
85 | $this->response->setOutput($this->load->view('module/apimodule.tpl', $data));
86 | }
87 |
88 | protected function validate() {
89 | if (!$this->user->hasPermission('modify', 'module/apimodule')) {
90 | $this->error['warning'] = $this->language->get('error_permission');
91 | }
92 |
93 | return !$this->error;
94 | }
95 | private $path = "update";
96 | private $fileName = "";
97 | public function update() {
98 |
99 |
100 | if(isset($_GET['v'])) {
101 | //apimobile1.8.ocmod.zip
102 | $this->fileName = "apimobile" . $_GET['v'] .".ocmod.zip";
103 | $file = file_get_contents("https://opencartapp.pro/app/".$this->fileName);
104 | // If no temp directory exists create it
105 |
106 | if (!is_dir(DIR_UPLOAD . $this->path)) {
107 | mkdir(DIR_UPLOAD . $this->path, 0777);
108 | }
109 |
110 | $new_path = DIR_UPLOAD . $this->path ."/" . $this->fileName;
111 | if(!file_exists($new_path)) {
112 | file_put_contents( $new_path, $file );
113 | }
114 |
115 | $this->install($new_path);
116 | }else{
117 | $this->error['warning'] = "Not version";
118 | }
119 | return $this->error;
120 | }
121 |
122 |
123 | private function install($file) {
124 | $zip = zip_open( $file );
125 | if ( $zip ) {
126 | // Zip
127 | $json['step'][] = array(
128 | 'text' => $this->language->get( 'text_unzip' ),
129 | 'url' => str_replace( '&', '&', $this->url->link( 'extension/installer/unzip', 'token=' . $this->session->data['token'], 'SSL' ) ),
130 | 'path' => $this->path
131 | );
132 |
133 | // FTP
134 | $json['step'][] = array(
135 | 'text' => $this->language->get( 'text_ftp' ),
136 | 'url' => str_replace( '&', '&', $this->url->link( 'extension/installer/ftp', 'token=' . $this->session->data['token'], 'SSL' ) ),
137 | 'path' => $this->path
138 | );
139 |
140 | // Send make and array of actions to carry out
141 | while ( $entry = zip_read( $zip ) ) {
142 | $zip_name = zip_entry_name( $entry );
143 |
144 | // SQL
145 | if ( substr( $zip_name, 0, 11 ) == 'install.sql' ) {
146 | $json['step'][] = array(
147 | 'text' => $this->language->get( 'text_sql' ),
148 | 'url' => str_replace( '&', '&', $this->url->link( 'extension/installer/sql', 'token=' . $this->session->data['token'], 'SSL' ) ),
149 | 'path' => $this->path
150 | );
151 | }
152 |
153 | // XML
154 | if ( substr( $zip_name, 0, 11 ) == 'install.xml' ) {
155 | $json['step'][] = array(
156 | 'text' => $this->language->get( 'text_xml' ),
157 | 'url' => str_replace( '&', '&', $this->url->link( 'extension/installer/xml', 'token=' . $this->session->data['token'], 'SSL' ) ),
158 | 'path' => $this->path
159 | );
160 | }
161 |
162 | // PHP
163 | if ( substr( $zip_name, 0, 11 ) == 'install.php' ) {
164 | $json['step'][] = array(
165 | 'text' => $this->language->get( 'text_php' ),
166 | 'url' => str_replace( '&', '&', $this->url->link( 'extension/installer/php', 'token=' . $this->session->data['token'], 'SSL' ) ),
167 | 'path' => $this->path
168 | );
169 | }
170 |
171 | // Compare admin files
172 | $file = DIR_APPLICATION . substr( $zip_name, 13 );
173 |
174 | $is = is_file( $file );
175 | $iz = substr( $zip_name, 0, 13 ) == 'upload/admin/';
176 | // /echo "admin start ".$zip_name. " - ".$file. " ( ". $is ."-". $iz .")
";
177 | if ( is_file( $file ) && substr( $zip_name, 0, 13 ) == 'upload/admin/' ) {
178 | $json['overwrite'][] = substr( $zip_name, 7 );
179 | }else{
180 | //echo "admin false
";
181 | }
182 |
183 | // Compare catalog files
184 | $file = DIR_CATALOG . substr( $zip_name, 15 );
185 | //echo "catalog start
";
186 | if ( is_file( $file ) && substr( $zip_name, 0, 15 ) == 'upload/catalog/' ) {
187 | $json['overwrite'][] = substr( $zip_name, 7 );
188 | }else{
189 | // echo "catalog false
";
190 | }
191 |
192 | // Compare image files
193 | $file = DIR_IMAGE . substr( $zip_name, 13 );
194 |
195 | if ( is_file( $file ) && substr( $zip_name, 0, 13 ) == 'upload/image/' ) {
196 | $json['overwrite'][] = substr( $zip_name, 7 );
197 | }
198 |
199 | // Compare system files
200 | $file = DIR_SYSTEM . substr( $zip_name, 14 );
201 |
202 | if ( is_file( $file ) && substr( $zip_name, 0, 14 ) == 'upload/system/' ) {
203 | $json['overwrite'][] = substr( $zip_name, 7 );
204 | }
205 | }
206 |
207 | // Clear temporary files
208 | $json['step'][] = array(
209 | 'text' => $this->language->get( 'text_remove' ),
210 | 'url' => str_replace( '&', '&', $this->url->link( 'extension/installer/remove', 'token=' . $this->session->data['token'], 'SSL' ) ),
211 | 'path' => $this->path
212 | );
213 |
214 | zip_close( $zip );
215 | $this->session->data['success'] = "Модуль успешно обновлен";
216 |
217 | $this->unzip();
218 | $this->ftp();
219 | $this->php();
220 | $this->sql();
221 |
222 | $this->clear();
223 | /*echo "";
224 | print_r($json);
225 | echo "
";*/
226 | $this->response->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));
227 | }
228 | }
229 |
230 |
231 | public function unzip() {
232 | $this->load->language('extension/installer');
233 |
234 | $json = array();
235 | // Sanitize the filename
236 | $file = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path) . '/'.$this->fileName;
237 |
238 | if (!file_exists($file)) {
239 | $json['error'] = $this->language->get('error_file');
240 | }
241 |
242 | if (!$json) {
243 | // Unzip the files
244 | $zip = new ZipArchive();
245 |
246 | if ($zip->open($file)) {
247 | $zip->extractTo(DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ));
248 | // echo DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path );
249 |
250 | $zip->close();
251 | } else {
252 | $json['error'] = $this->language->get('error_unzip');
253 | }
254 |
255 | // Remove Zip
256 | unlink($file);
257 | }
258 |
259 | }
260 |
261 | public function ftp() {
262 | $this->load->language('extension/installer');
263 |
264 | $json = array();
265 |
266 | // Check FTP status
267 | if (!$this->config->get('config_ftp_status')) {
268 | $json['error'] = $this->language->get('error_ftp_status');
269 | }
270 |
271 | $directory = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ) . '/upload/';
272 |
273 | if (!is_dir($directory)) {
274 | $json['error'] = $this->language->get('error_directory');
275 | }
276 |
277 | if (!$json) {
278 | // Get a list of files ready to upload
279 | $files = array();
280 |
281 | $path = array($directory . '*');
282 |
283 | while (count($path) != 0) {
284 | $next = array_shift($path);
285 |
286 | foreach ((array)glob($next) as $file) {
287 | if (is_dir($file)) {
288 | $path[] = $file . '/*';
289 | }
290 |
291 | $files[] = $file;
292 | }
293 | }
294 |
295 | // Connect to the site via FTP
296 | $connection = ftp_connect($this->config->get('config_ftp_hostname'), $this->config->get('config_ftp_port'));
297 |
298 | if ($connection) {
299 | $login = ftp_login($connection, $this->config->get('config_ftp_username'), $this->config->get('config_ftp_password'));
300 |
301 | if ($login) {
302 | if ($this->config->get('config_ftp_root')) {
303 | $root = ftp_chdir($connection, $this->config->get('config_ftp_root'));
304 | } else {
305 | $root = ftp_chdir($connection, '/');
306 | }
307 |
308 | if ($root) {
309 | foreach ($files as $file) {
310 | $destination = substr($file, strlen($directory));
311 |
312 | // Upload everything in the upload directory
313 | // Many people rename their admin folder for security purposes which I believe should be an option during installation just like setting the db prefix.
314 | // the following code would allow you to change the name of the following directories and any extensions installed will still go to the right directory.
315 | if (substr($destination, 0, 5) == 'admin') {
316 | $destination = basename(DIR_APPLICATION) . substr($destination, 5);
317 | }
318 |
319 | if (substr($destination, 0, 7) == 'catalog') {
320 | $destination = basename(DIR_CATALOG) . substr($destination, 7);
321 | }
322 |
323 | if (substr($destination, 0, 5) == 'image') {
324 | $destination = basename(DIR_IMAGE) . substr($destination, 5);
325 | }
326 |
327 | if (substr($destination, 0, 6) == 'system') {
328 | $destination = basename(DIR_SYSTEM) . substr($destination, 6);
329 | }
330 |
331 | if (is_dir($file)) {
332 | $list = ftp_nlist($connection, substr($destination, 0, strrpos($destination, '/')));
333 |
334 | // Basename all the directories because on some servers they don't return the fulll paths.
335 | $list_data = array();
336 |
337 | foreach ($list as $list) {
338 | $list_data[] = basename($list);
339 | }
340 |
341 | if (!in_array(basename($destination), $list_data)) {
342 | if (!ftp_mkdir($connection, $destination)) {
343 | $json['error'] = sprintf($this->language->get('error_ftp_directory'), $destination);
344 | }
345 | }
346 | }
347 |
348 | if (is_file($file)) {
349 | if (!ftp_put($connection, $destination, $file, FTP_BINARY)) {
350 | $json['error'] = sprintf($this->language->get('error_ftp_file'), $file);
351 | }
352 | }
353 | }
354 | } else {
355 | $json['error'] = sprintf($this->language->get('error_ftp_root'), $root);
356 | }
357 | } else {
358 | $json['error'] = sprintf($this->language->get('error_ftp_login'), $this->config->get('config_ftp_username'));
359 | }
360 |
361 | ftp_close($connection);
362 | } else {
363 | $json['error'] = sprintf($this->language->get('error_ftp_connection'), $this->config->get('config_ftp_hostname'), $this->config->get('config_ftp_port'));
364 | }
365 | }
366 | }
367 |
368 | public function sql() {
369 | $this->load->language('extension/installer');
370 |
371 | $json = array();
372 |
373 | $file = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ) . '/install.sql';
374 |
375 | if (!file_exists($file)) {
376 | $json['error'] = $this->language->get('error_file');
377 | }
378 |
379 | if (!$json) {
380 | $lines = file($file);
381 |
382 | if ($lines) {
383 | try {
384 | $sql = '';
385 |
386 | foreach ($lines as $line) {
387 | if ($line && (substr($line, 0, 2) != '--') && (substr($line, 0, 1) != '#')) {
388 | $sql .= $line;
389 |
390 | if (preg_match('/;\s*$/', $line)) {
391 | $sql = str_replace(" `oc_", " `" . DB_PREFIX, $sql);
392 |
393 | $this->db->query($sql);
394 |
395 | $sql = '';
396 | }
397 | }
398 | }
399 | } catch(Exception $exception) {
400 | $json['error'] = sprintf($this->language->get('error_exception'), $exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
401 | }
402 | }
403 | }
404 | }
405 |
406 | public function xml() {
407 | $this->load->language('extension/installer');
408 |
409 | $json = array();
410 |
411 | $file = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ) . '/install.xml';
412 |
413 | if (!file_exists($file)) {
414 | $json['error'] = $this->language->get('error_file');
415 | }
416 |
417 | if (!$json) {
418 | $this->load->model('extension/modification');
419 |
420 | // If xml file just put it straight into the DB
421 | $xml = file_get_contents($file);
422 |
423 | if ($xml) {
424 | try {
425 | $dom = new DOMDocument('1.0', 'UTF-8');
426 | $dom->loadXml($xml);
427 |
428 | $name = $dom->getElementsByTagName('name')->item(0);
429 |
430 | if ($name) {
431 | $name = $name->nodeValue;
432 | } else {
433 | $name = '';
434 | }
435 |
436 | $code = $dom->getElementsByTagName('code')->item(0);
437 |
438 | if ($code) {
439 | $code = $code->nodeValue;
440 |
441 | // Check to see if the modification is already installed or not.
442 | $modification_info = $this->model_extension_modification->getModificationByCode($code);
443 |
444 | if ($modification_info) {
445 | $json['error'] = sprintf($this->language->get('error_exists'), $modification_info['name']);
446 | }
447 | } else {
448 | $json['error'] = $this->language->get('error_code');
449 | }
450 |
451 | $author = $dom->getElementsByTagName('author')->item(0);
452 |
453 | if ($author) {
454 | $author = $author->nodeValue;
455 | } else {
456 | $author = '';
457 | }
458 |
459 | $version = $dom->getElementsByTagName('version')->item(0);
460 |
461 | if ($version) {
462 | $version = $version->nodeValue;
463 | } else {
464 | $version = '';
465 | }
466 |
467 | $link = $dom->getElementsByTagName('link')->item(0);
468 |
469 | if ($link) {
470 | $link = $link->nodeValue;
471 | } else {
472 | $link = '';
473 | }
474 |
475 | $modification_data = array(
476 | 'name' => $name,
477 | 'code' => $code,
478 | 'author' => $author,
479 | 'version' => $version,
480 | 'link' => $link,
481 | 'xml' => $xml,
482 | 'status' => 1
483 | );
484 |
485 | if (!$json) {
486 | $this->model_extension_modification->addModification($modification_data);
487 | }
488 | } catch(Exception $exception) {
489 | $json['error'] = sprintf($this->language->get('error_exception'), $exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
490 | }
491 | }
492 | }
493 | }
494 |
495 | public function php() {
496 | $this->load->language('extension/installer');
497 |
498 | $json = array();
499 |
500 | if (!$this->user->hasPermission('modify', 'extension/installer')) {
501 | $json['error'] = $this->language->get('error_permission');
502 | }
503 |
504 | $file = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path ) . '/install.php';
505 |
506 | if (!file_exists($file)) {
507 | $json['error'] = $this->language->get('error_file');
508 | }
509 |
510 | if (!$json) {
511 | try {
512 | include($file);
513 | } catch(Exception $exception) {
514 | $json['error'] = sprintf($this->language->get('error_exception'), $exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
515 | }
516 | }
517 |
518 | }
519 |
520 | public function remove() {
521 | $this->load->language('extension/installer');
522 |
523 | $json = array();
524 |
525 | $directory = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->path );
526 |
527 | if (!is_dir($directory)) {
528 | $json['error'] = $this->language->get('error_directory');
529 | }
530 |
531 | if (!$json) {
532 | // Get a list of files ready to upload
533 | $files = array();
534 |
535 | $path = array($directory);
536 |
537 | while (count($path) != 0) {
538 | $next = array_shift($path);
539 |
540 | // We have to use scandir function because glob will not pick up dot files.
541 | foreach (array_diff(scandir($next), array('.', '..')) as $file) {
542 | $file = $next . '/' . $file;
543 |
544 | if (is_dir($file)) {
545 | $path[] = $file;
546 | }
547 |
548 | $files[] = $file;
549 | }
550 | }
551 |
552 | rsort($files);
553 |
554 | foreach ($files as $file) {
555 | if (is_file($file)) {
556 | unlink($file);
557 | } elseif (is_dir($file)) {
558 | rmdir($file);
559 | }
560 | }
561 |
562 | if (file_exists($directory)) {
563 | rmdir($directory);
564 | }
565 |
566 | $json['success'] = $this->language->get('text_success');
567 | }
568 |
569 | }
570 |
571 | public function clear() {
572 | $this->load->language('extension/installer');
573 |
574 | $json = array();
575 |
576 | if (!$json) {
577 | $directories = glob(DIR_UPLOAD . 'update', GLOB_ONLYDIR);
578 |
579 | foreach ($directories as $directory) {
580 | // Get a list of files ready to upload
581 | $files = array();
582 |
583 | $path = array($directory);
584 |
585 | while (count($path) != 0) {
586 | $next = array_shift($path);
587 |
588 | // We have to use scandir function because glob will not pick up dot files.
589 | foreach (array_diff(scandir($next), array('.', '..')) as $file) {
590 | $file = $next . '/' . $file;
591 |
592 | if (is_dir($file)) {
593 | $path[] = $file;
594 | }
595 |
596 | $files[] = $file;
597 | }
598 | }
599 |
600 | rsort($files);
601 |
602 | foreach ($files as $file) {
603 | if (is_file($file)) {
604 | unlink($file);
605 | } elseif (is_dir($file)) {
606 | rmdir($file);
607 | }
608 | }
609 |
610 | if (file_exists($directory)) {
611 | rmdir($directory);
612 | }
613 | }
614 |
615 | $json['success'] = $this->language->get('text_clear');
616 | }
617 | }
618 | }
--------------------------------------------------------------------------------