Пример #1
0
 function actUpload()
 {
     global $get;
     $num = '';
     if (isset($_FILES['upload']) && $_FILES['upload']['name']) {
         $name = md5_file($_FILES['upload']['tmp_name']) . '.' . file_ext($_FILES['upload']['name']);
         $path = '/storage/temp/' . $name;
         move_uploaded_file($_FILES['upload']['tmp_name'], ROOT . $path);
     }
     if (isset($_FILES['upload1']) && $_FILES['upload1']['name']) {
         $num = '1';
         $name = md5_file($_FILES['upload1']['tmp_name']) . '.' . file_ext($_FILES['upload1']['name']);
         $path = '/storage/temp/' . $name;
         move_uploaded_file($_FILES['upload1']['tmp_name'], ROOT . $path);
     }
     echo printJSONP(array('msg' => 'Сохранено', 'path' => $path, 'num' => $num), $get->get('cb'));
     exit;
 }
Пример #2
0
 function actSave()
 {
     global $ST, $get, $post;
     $id = $post->getInt('id');
     $data = array('content' => $post->get('content'), 'description' => $post->get('description'), 'title' => $post->get('title'), 'author' => $post->get('author'), 'date' => dte($post->get('date'), 'Y-m-d'), 'state' => $post->get('state'), 'category' => $post->getInt('category'), 'position' => $post->getInt('position'), 'gallery' => $post->getInt('gallery'), 'type' => $this->getType());
     $img_out = "";
     if (!empty($_FILES['upload']['name']) && isImg($_FILES['upload']['name'])) {
         $img = $this->cfg('NEWS_IMAGE_PATH') . '/' . md5($_FILES['upload']['tmp_name']) . "." . file_ext($_FILES['upload']['name']);
         move_uploaded_file($_FILES['upload']['tmp_name'], ROOT . $img);
         $data['img'] = $img;
         $img_out = scaleImg($img, 'w200');
     }
     if ($post->getInt('clear')) {
         $data['img'] = '';
     }
     if ($id) {
         $ST->update('sc_news', $data, "id=" . $id);
     } else {
         $id = $ST->insert('sc_news', $data);
     }
     $ST->delete('sc_relation', "parent={$id} AND type='public'");
     foreach ($post->getArray('public_rel') as $v) {
         $ST->insert('sc_relation', array('parent' => $id, 'type' => 'public', 'child' => $v));
     }
     $msg = "Сохранено";
     if (true) {
         $content = '';
         $content .= '<small>' . date('d.m.Y') . '</small> ';
         $content .= '<strong>' . $post->getHtml('title') . '</strong><br />';
         $content .= '<span>' . $post->getHtml('description') . '</span><br />';
         $content .= '<a href="http://' . $this->cfg('SITE') . '/' . $post->get('type') . '/' . $id . '/">подробнее...</a>';
         if ($post->exists('save_and_send')) {
             $mail = new Mail();
             $mail->setFromMail(array($this->cfg('SITE'), $this->cfg('mail')));
             $key = 'http://' . $this->cfg('SITE') . '/cabinet/unsubscribe/?key=' . md5($this->getUser('mail') . $this->getType() . 'unsubscribe') . '&type=' . $this->getType() . '&mail=' . $this->getUser('mail');
             $key = '<a href="' . $key . '">' . $key . '</a>';
             $mail->setTemplate('letter_' . $this->getType(), array('FROM_SITE' => $this->cfg('SITE'), 'CONTENT' => $content, 'BODY' => $post->get('content'), 'TITLE' => $post->get('title')));
             $mail->xsend($this->getUser('mail'), array('UNSUBSCRIBE' => $key));
         } elseif ($post->exists('save_and_send_all')) {
             $q = "SELECT distinct mail,id FROM sc_subscribe WHERE type LIKE '%" . $this->getType() . "%' \r\n\t\t\t\tAND NOT EXISTS(SELECT mailid FROM sc_news_sendlog WHERE id=mailid AND newsid={$id}){$this->getMailFilter()}";
             if ($post->getInt('pack')) {
                 $q .= " LIMIT {$post->getInt('pack')}";
             }
             $rs = $ST->select($q);
             $mail = new Mail();
             //				$mail->setFromMail($this->getConfig('mail'));
             $mail->setFromMail(array($this->cfg('SITE'), $this->cfg('mail')));
             $mail->setTemplate('letter_' . $this->getType(), array('FROM_SITE' => $this->cfg('SITE'), 'CONTENT' => $content, 'BODY' => $post->get('content'), 'TITLE' => $post->get('title')));
             $n = 0;
             while ($rs->next()) {
                 if (check_mail($m = trim($rs->get('mail')))) {
                     $key = 'http://' . $this->cfg('SITE') . '/cabinet/unsubscribe/?key=' . md5($rs->get('mail') . $this->getType() . 'unsubscribe') . '&type=' . $this->getType() . '&mail=' . $rs->get('mail');
                     $key = '<a href="' . $key . '">' . $key . '</a>';
                     $mail->xsend($m, array('UNSUBSCRIBE' => $key));
                     $ST->insert('sc_news_sendlog', array('mailid' => $rs->get('id'), 'newsid' => $id));
                     $n++;
                 } else {
                     $ST->delete('sc_subscribe', "mail='" . SQL::slashes($rs->get('mail')) . "'");
                 }
             }
             $msg .= " отправлено {$n}";
         }
     }
     echo printJSONP(array('msg' => $msg, 'id' => $id, 'img' => $img_out));
     exit;
 }
Пример #3
0
 function actSave()
 {
     global $post;
     $id = $post->getInt('u_id');
     $data = array('login' => $post->get('login'), 'status' => $post->get('status'), 'name' => $post->get('name'), 'company' => $post->get('company'), 'phone' => $post->get('phone'), 'city' => $post->get('city'), 'address' => $post->get('address'), 'mail' => $post->get('mail'), 'avat' => $post->get('avat'), 'balance' => $post->getFloat('balance'), 'discount' => $post->getFloat('discount'), 'hide' => 0, 'type' => $post->get('type'));
     $password = $post->remove('password');
     $avat_path = $post->remove('avat_path');
     $msg = 'Сохранено';
     $img_out = "";
     if (!empty($_FILES['upload']['name']) && isImg($_FILES['upload']['name'])) {
         $img = $this->cfg('AVATAR_PATH') . '/' . md5($_FILES['upload']['tmp_name']) . "." . file_ext($_FILES['upload']['name']);
         move_uploaded_file($_FILES['upload']['tmp_name'], ROOT . $img);
         $data['avat'] = $img;
         $img_out = scaleImg($img, 'w200');
     }
     if ($post->getInt('clear')) {
         $data['avat'] = '';
     }
     $err = array();
     $rs = DB::select("SELECT * FROM sc_users WHERE login='******'login')) . "' AND u_id<>{$id}");
     if ($rs->next()) {
         $err['login'] = '******';
     }
     if (!$err) {
         if ($id === 0) {
             $data[] = "password=MD5('" . trim($password) . "')";
             $id = DB::insert('sc_users', $data, 'u_id');
         } else {
             if (trim($password)) {
                 $data[] = "password=MD5('" . trim($password) . "')";
             }
             DB::update('sc_users', $data, 'u_id=' . $id);
         }
         echo printJSONP(array('msg' => $msg, 'u_id' => $id, 'img' => $img_out));
         exit;
     } else {
         echo printJSONP(array('err' => $err));
         exit;
     }
 }
Пример #4
0
 function actSave()
 {
     global $post;
     $id = $post->getInt('u_id');
     $data = array('login' => $post->get('login'), 'name' => $post->get('name'), 'company' => $post->get('company'), 'phone' => $post->get('phone'), 'city' => $post->get('city'), 'address' => $post->get('address'), 'img_format' => $post->getInt('img_format'), 'mail' => $post->get('mail'), 'balance' => $post->getFloat('balance'), 'discount' => $post->getFloat('discount'), 'type' => 'vendor');
     $msg = 'Сохранено';
     $img_out = "";
     if (!empty($_FILES['upload']['name']) && isImg($_FILES['upload']['name'])) {
         $img = $this->cfg('AVATAR_PATH') . '/' . md5($_FILES['upload']['tmp_name']) . "." . file_ext($_FILES['upload']['name']);
         move_uploaded_file($_FILES['upload']['tmp_name'], ROOT . $img);
         $data['avat'] = $img;
         $img_out = scaleImg($img, 'w200');
     }
     if ($post->getInt('clear')) {
         $data['avat'] = '';
     }
     $err = array();
     $rs = DB::select("SELECT * FROM sc_users WHERE login='******'login')) . "' AND u_id<>{$id}");
     if ($rs->next()) {
         $err['login'] = '******';
     }
     if (!$err) {
         if ($id === 0) {
             $id = DB::insert('sc_users', $data, 'u_id');
         } else {
             DB::update('sc_users', $data, 'u_id=' . $id);
         }
         $rs = DB::select("SELECT * FROM sc_users_vendor WHERE vendor_id={$id}");
         $ext_data = array('info' => $post->get('info'), 'html' => $post->get('html'), 'comment' => $post->get('comment'), 'adm_comment' => $post->get('adm_comment'));
         $ext_data['images'] = $post->getArray('images');
         if ($img_pos = $post->getArray('pos')) {
             //Сортировка картинок
             asort($img_pos);
             $temp_img = array();
             foreach ($img_pos as $k => $v) {
                 $temp_img[] = $ext_data['images'][$k];
             }
             $ext_data['images'] = $temp_img;
         }
         foreach ($_FILES['images_upload']['error'] as $k => $err) {
             if ($err != 0) {
                 continue;
             }
             if (isset($_FILES['images_upload']['tmp_name'][$k]) && isImg($name = $_FILES['images_upload']['name'][$k])) {
                 $path = $this->cfg('AVATAR_PATH') . '/' . md5_file($_FILES['images_upload']['tmp_name'][$k]) . '.' . file_ext($name);
                 if (!file_exists(ROOT . $path)) {
                     rename($_FILES['images_upload']['tmp_name'][$k], ROOT . $path);
                 }
                 if (!in_array($path, $ext_data['images'])) {
                     $ext_data['images'][] = $path;
                 }
             }
         }
         $ext_data['images'] = implode(',', $images = $ext_data['images']);
         if ($rs->next()) {
             DB::update('sc_users_vendor', $ext_data, "vendor_id={$id}");
         } else {
             $ext_data['vendor_id'] = $id;
             DB::insert('sc_users_vendor', $ext_data);
         }
         DB::delete("sc_relation", "type='vend_gal' AND parent={$id}");
         foreach ($post->getArray('gallery') as $g) {
             DB::insert('sc_relation', array('type' => 'vend_gal', 'parent' => $id, 'child' => $g));
         }
         echo printJSONP(array('msg' => $msg, 'u_id' => $id, 'img' => $img_out, 'images' => $images));
         exit;
     } else {
         echo printJSONP(array('err' => $err));
         exit;
     }
 }
Пример #5
0
 function actUpload()
 {
     if (isset($_FILES['upload'])) {
         $name = md5_file($_FILES['upload']['tmp_name']) . '.' . substr($_FILES['upload']['name'], -3);
         $path = '/storage/temp/' . $name;
         move_uploaded_file($_FILES['upload']['tmp_name'], ROOT . $path);
         $html = $this->galHtml($path);
     }
     echo printJSONP(array('msg' => 'Сохранено', 'path' => $path, 'html' => $html));
     exit;
 }
Пример #6
0
 function actSendPublic()
 {
     global $post;
     $error = array();
     if (!trim($post->get('name'))) {
         $error['name'] = 'Введите ФИО';
     }
     if (!trim($post->get('comment'))) {
         $error['comment'] = 'Введите сообщение';
     }
     if (!$this->checkCapture($post->get('capture'), $post->get('type'))) {
         $error['capture'] = "Введите правильный код!";
     }
     if (empty($error)) {
         $data = array('name' => $post->get('name'), 'comment' => $post->get('comment'), 'ip' => $_SERVER['REMOTE_ADDR'], 'browser' => $_SERVER['HTTP_USER_AGENT'], 'file' => $post->get('url'), 'status' => 0);
         if ($post->getInt('author')) {
             $data['comment'] = 'Я автор' . "\n" . $data['comment'];
         }
         if (isset($_FILES['file']) && $_FILES['file']['name'] && isDoc($_FILES['file']['name']) && filesize($_FILES['file']['tmp_name']) < 1024 * 1024 * 10) {
             $name = md5_file($_FILES['file']['tmp_name']) . '.' . file_ext($_FILES['file']['name']);
             $path = 'storage/files/' . $name;
             move_uploaded_file($_FILES['file']['tmp_name'], $path);
             $data['file'] = "/{$path}";
         }
         if ($post->exists('type')) {
             $data['type'] = $post->get('type');
         }
         DB::insert('sc_feedback', $data);
         $mail_contacts = '';
         $this->sendTemplateMail($this->cfg('MAIL_CONTACTS') . '; ' . $mail_contacts, 'notice_feedback', $data);
         $this->noticeICQ($this->cfg('ICQ'), 'Новое сообщение на сайте');
         echo printJSONP(array('msg' => 'OK'));
         exit;
     } else {
         echo printJSONP(array('err' => $error));
         exit;
     }
 }
Пример #7
0
 function actApplyMans()
 {
     global $ST, $post;
     if (isset($_FILES['img'])) {
         $img = array();
         foreach ($_FILES['img']['name'] as $id => $name) {
             if (isImg($name)) {
                 $path = 'storage/manufecturer/' . $id . "_" . time() . "." . file_ext($name);
                 if (file_exists($path)) {
                     rename($path, $path . '.' . time());
                 }
                 move_uploaded_file($_FILES['img']['tmp_name'][$id], $path);
                 $ST->update('sc_manufacturer', array('img' => "/" . $path), "id={$id}");
                 $img[$id] = "/" . $path;
             }
         }
         echo printJSONP(array('msg' => 'Обновлено!', 'img' => $img));
         exit;
     }
     $names = $post->get('name');
     if ($sort = $post->get('sort')) {
         foreach ($sort as $id => $val) {
             $ST->update('sc_manufacturer', array('sort' => (int) $val, 'name' => $names[$id]), "id={$id}");
         }
     }
     echo printJSON(array('msg' => 'Обновлено!'));
     exit;
 }
Пример #8
0
 function actUploadFile()
 {
     global $post;
     move_uploaded_file($_FILES['userfile']['tmp_name'], $post->get('file_name'));
     echo printJSONP(array('msg' => 'Загружено'));
     exit;
 }
Пример #9
0
 function actImpImgZip()
 {
     global $ST, $post;
     $loaded = 0;
     $unloaded = array();
     $t = time();
     $images = array();
     if (!empty($_FILES['img_zip']['tmp_name']) && preg_match('/\\.zip$/i', $_FILES['img_zip']['name'])) {
         $zip = new ZipArchive();
         if ($zip->open($_FILES['img_zip']['tmp_name']) === TRUE) {
             $img_dir = "import/{$t}";
             if (!file_exists($img_dir)) {
                 mkdir($img_dir);
             }
             $zip->extractTo($img_dir);
             $zip->close();
             $d = opendir($img_dir);
             while ($f = readdir($d)) {
                 if (isImg($f) && preg_match('/^(\\d+)[_\\d]*/', $f, $res)) {
                     if (empty($images[$res[1]])) {
                         $images[$res[1]] = array();
                     }
                     $images[$res[1]][] = $f;
                 }
             }
             closedir($d);
             $fld = 'id';
             if (in_array($post->get('link'), array('id', 'ext_id', 'product'))) {
                 $fld = $post->get('link');
             }
             foreach ($images as $id => $imglist) {
                 $rs = $ST->select("SELECT * FROM sc_shop_item WHERE {$fld}={$id}");
                 if ($rs->next()) {
                     $data = array();
                     foreach ($imglist as $n => $i) {
                         $file_name = md5($img_dir . '/' . $i) . '.' . file_ext($img_dir . '/' . $i);
                         $file_path = ltrim("{$this->cfg('CATALOG_PATH')}/goods/{$file_name}", '/');
                         if (file_exists($file_path)) {
                             unlink($file_path);
                         }
                         rename("{$img_dir}/{$i}", $file_path);
                         if ($n == 0) {
                             $data['img'] = "/{$file_path}";
                         } else {
                             $data['img_add'][] = "/{$file_path}";
                         }
                     }
                     if ($data) {
                         if (!empty($data['img_add'])) {
                             $data['img_add'] = implode(',', $data['img_add']);
                         }
                         $ST->update('sc_shop_item', $data, "id={$rs->getInt('id')}");
                         $loaded++;
                     }
                 } else {
                     foreach ($imglist as $n => $i) {
                         unlink("{$img_dir}/{$i}");
                     }
                     $unloaded[] = $id;
                 }
             }
             rmdir($img_dir);
         }
         $result = date('Y-m-d H:i:s') . " - Загружено {$loaded}; Не загружено [" . count($unloaded) . '] ' . implode(', ', $unloaded) . "\n";
         file_put_contents(CATALOG_DIR . '/log.txt', $result, FILE_APPEND);
     } else {
         $result = date('Y-m-d H:i:s') . " - Файл не загружен ";
     }
     echo printJSONP(array('msg' => $result));
     exit;
 }
Пример #10
0
 function actUpload()
 {
     global $get;
     if (isset($_FILES['upload'])) {
         $name = md5_file($_FILES['upload']['tmp_name']) . '.' . file_ext($_FILES['upload']['name']);
         $path = '/storage/temp/' . $name;
         move_uploaded_file($_FILES['upload']['tmp_name'], ROOT . $path);
         $img = scaleImg($path, $get->get('size'));
         if ($get->get('resize') == 'true') {
             $path = scaleImg($path, $get->get('size'));
         }
     }
     echo printJSONP(array('msg' => 'Сохранено', 'path' => $path, 'img' => $img), $get->get('cb'));
     exit;
 }