Пример #1
0
 public function editFont($id = '')
 {
     $file = dirname(ROOT) . DS . 'data' . DS . 'fonts.json';
     include_once ROOT . DS . 'includes' . DS . 'functions.php';
     include_once ROOT . DS . 'includes' . DS . 'upload.php';
     $dg = new dg();
     $fonts = $dg->readFile($file);
     $fonts = json_decode($fonts, true);
     $font = $fonts['fonts']['fonts'];
     $data = array();
     $data['error'] = '';
     $data['id'] = $id;
     // get categories.
     $cate_font = ROOT . DS . 'data' . DS . 'font_categories.json';
     $cate = $dg->readFile($cate_font);
     $cates = json_decode($cate, true);
     $data['categories'] = $cates;
     // post data.
     if (isset($_POST['title']) && $_POST['title'] != '') {
         $title = $_POST['title'];
         //upload.
         $path = dirname(ROOT) . DS . 'data' . DS . 'fonts';
         if (!file_exists($path)) {
             mkdir($path, 0755);
         }
         $up = new upload();
         $up->permission = 755;
         $up->path = $path;
         $up->file_size = 2097152;
         // 2mb.
         $count = 0;
         $result = array();
         if (count($_FILES) == 3) {
             foreach ($_FILES as $key => $value) {
                 if (isset($_FILES[$key]['name']) && $_FILES[$key]['name'] != '') {
                     $checkname = array('~', '`', '!', '@', '#', '$', '%', '^', '&', '(', ')', '+', '=', '[', ']', '{', '}', ':', ' ', ',', '\'', ';');
                     $up->file_name = str_replace($checkname, '', $_FILES[$key]['name']);
                     if ($count == 0) {
                         $up->file_type[0] = 'woff';
                         $val = $up->file($_FILES[$key]);
                         if ($val['error'] == 1) {
                             $data['error'] = $val['msg'];
                             break;
                         }
                         $result[$count] = $val;
                     } elseif ($count == 1) {
                         $up->file_type[0] = 'ttf';
                         $up->file_type[1] = 'TTF';
                         $val = $up->file($_FILES[$key]);
                         if ($val['error'] == 1) {
                             $data['error'] = $val['msg'];
                             if (file_exists($result[0]['full_path'])) {
                                 unlink($result[0]['full_path']);
                             }
                             break;
                         }
                         $result[$count] = $val;
                     } else {
                         $up->file_type[0] = 'jpg';
                         $up->file_type[1] = 'png';
                         $up->file_type[2] = 'gif';
                         $up->file_type[3] = 'jpeg';
                         $val = $up->file($_FILES[$key]);
                         if ($val['error'] == 1) {
                             $data['error'] = $val['msg'];
                             if (file_exists($result[0]['full_path'])) {
                                 unlink($result[0]['full_path']);
                             }
                             if (file_exists($result[1]['full_path'])) {
                                 unlink($result[1]['full_path']);
                             }
                             break;
                         }
                         $result[$count] = $val;
                     }
                 }
                 $count++;
             }
         }
         //process.
         $subtitle = '';
         $cate_id = '';
         $catename = '';
         if (isset($_POST['subtitle'])) {
             $subtitle = $_POST['subtitle'];
         }
         if (isset($_POST['cate_id'])) {
             $cate_id = $_POST['cate_id'];
         }
         if ($catename == '' && isset($cates[$cate_id])) {
             $catename = $cates[$cate_id];
         }
         if ($id != '') {
             if (count($font) && $data['error'] == '') {
                 $font_out = array();
                 foreach ($font as $key => $val) {
                     if ($val['id'] == $id && $val['type'] == '') {
                         $filename = $val['filename'];
                         $path = $val['path'];
                         $thumb = $val['thumb'];
                         if ($data['error'] == '' && count($result) == 3) {
                             $filename = array('woff' => $result[0]['file_name'], 'ttf' => $result[1]['file_name']);
                             $filename = json_encode($filename);
                             $path = $path;
                             $thumb = $result[2]['file_name'];
                         }
                         $font_out[$key] = array('id' => $val['id'], 'title' => $_POST['title'], 'subtitle' => $subtitle, 'filename' => $filename, 'path' => 'data/fonts', 'thumb' => $thumb, 'shop_id' => '', 'cate_id' => $cate_id, 'published' => '1', 'catename' => $catename, 'type' => '');
                     } else {
                         $font_out[$key] = $val;
                     }
                 }
                 // out data.
                 $out['status'] = '1';
                 $out['fonts']['google_fonts'] = $fonts['fonts']['google_fonts'];
                 $out['fonts']['fonts'] = $font_out;
                 // get cates.
                 foreach ($cates as $k => $v) {
                     $out['fonts']['cateFonts'][$k]['fonts'] = $this->updateFonts($out['fonts']['fonts'], $k, $v, 'catefont');
                     $out['fonts']['categories'][$k] = $this->updateCate($k, $v);
                 }
                 $res = json_encode($out);
             }
         } else {
             if ($data['error'] == '' && count($result) == 3) {
                 // get last id.
                 if (count($font)) {
                     $font_end = end($fonts['fonts']['fonts']);
                     $font_id = $font_end['id'] + 1;
                 } else {
                     $font_id = 0;
                 }
                 //add a font.
                 $filename = array('woff' => $result[0]['file_name'], 'ttf' => $result[1]['file_name']);
                 $font[] = array('id' => (string) $font_id, 'title' => $_POST['title'], 'subtitle' => $subtitle, 'filename' => json_encode($filename), 'path' => 'data/fonts', 'thumb' => $result[2]['file_name'], 'shop_id' => '', 'cate_id' => $cate_id, 'published' => '1', 'catename' => $catename, 'type' => '');
                 // out data.
                 $out['status'] = '1';
                 $out['fonts']['google_fonts'] = $fonts['fonts']['google_fonts'];
                 $out['fonts']['fonts'] = $font;
                 // get cates.
                 foreach ($cates as $key => $val) {
                     $out['fonts']['cateFonts'][$key]['fonts'] = $this->updateFonts($out['fonts']['fonts'], $key, $val, 'catefont');
                     $out['fonts']['categories'][$key] = $this->updateCate($key, $val);
                 }
                 $res = json_encode($out);
             } elseif ($data['error'] == '') {
                 $data['error'] = lang('fonts_add_font_file_error_msg', true);
             }
         }
         if (isset($res) && $res != '') {
             $dg->WriteFile($file, $res);
             if ($id == '') {
                 $data['msg'] = lang('fonts_add_font_file_success_msg', true);
             } else {
                 $data['msg'] = lang('fonts_edit_font_file_success_msg', true);
             }
         }
     }
     if (empty($subtitle)) {
         $subtitle = '';
     }
     if (empty($title)) {
         $title = '';
     }
     $data['font'] = array('title' => $title, 'subtitle' => $subtitle, 'filename' => '', 'path' => '', 'cate_id' => '', 'thumb' => '');
     if ($id == '') {
         $data['title'] = lang('breadcrumb_add_font', true);
     } else {
         $fonts = $dg->readFile($file);
         $fonts = json_decode($fonts, true);
         $font = $fonts['fonts']['fonts'];
         foreach ($font as $key => $val) {
             if ($val['id'] == $id && $val['type'] == '') {
                 $data['font'] = array('title' => $val['title'], 'subtitle' => $val['subtitle'], 'filename' => $val['filename'], 'path' => $val['path'], 'cate_id' => $val['cate_id'], 'thumb' => $val['thumb']);
             }
         }
         $data['title'] = lang('breadcrumb_edit_font', true);
     }
     $data['sub_title'] = lang('breadcrumb_manager', true);
     $this->view('edit_font', $data);
 }
Пример #2
0
 public function ajax($index = 1, $cateid = 0)
 {
     include_once ROOT . DS . 'includes' . DS . 'functions.php';
     $dg = new dg();
     $data = array();
     if ($index < 1) {
         $index = 1;
     }
     $data['cateid'] = $cateid;
     $data['page'] = 1;
     $data['title'] = 'Manager';
     $data['sub_title'] = 'Images of Design';
     $dgClass = new dg();
     $arts = array();
     $file = dirname(ROOT) . DS . 'data' . DS . 'arts.json';
     $setting = dirname(ROOT) . DS . 'data' . DS . 'settings.json';
     $data['currency_symbol'] = '$';
     if (file_exists($file)) {
         $str = $dg->readFile($file);
         $setting = $dg->readFile($setting);
         $settings = json_decode($setting);
         $rows = json_decode($str);
         if ($cateid > 0) {
             $array = array();
             $count = 0;
             for ($i = 0; $i < $rows->count; $i++) {
                 if (empty($rows->arts[$i])) {
                     continue;
                 }
                 if ($rows->arts[$i]->cate_id == $cateid) {
                     $count++;
                     $array[] = $rows->arts[$i];
                 }
             }
             $rows->count = $count;
             $rows->arts = $array;
         }
         if ($rows->count > 30) {
             $min = ($index - 1) * 30;
             $max = $index * 30;
             for ($i = $min; $i < $max; $i++) {
                 if (empty($rows->arts[$i])) {
                     break;
                 }
                 $arts[] = $rows->arts[$i];
             }
         } else {
             $arts = $rows->arts;
         }
         if ($rows->count % 30 == 0) {
             $data['page'] = $rows->count / 30;
         } else {
             $data['page'] = (int) ($rows->count / 30) + 1;
         }
         $data['currency_symbol'] = $settings->currency_symbol;
     }
     $data['arts'] = $arts;
     $data['index'] = $index;
     $this->modal('ajax_clipart', $data);
 }
Пример #3
0
 public function register()
 {
     $dgClass = new dg();
     if ($this->session('login') !== false) {
         $dgClass->redirect('index.php/dashboard');
     }
     $error = lang('user_login_register_error_msg', true);
     if (!empty($_POST)) {
         $email = $_POST['email'];
         $password = $_POST['password'];
         // check install
         include_once ROOT . DS . 'config' . DS . 'config.php';
         if ($config['email'] != 'YOUR_EMAIL' && $config['password'] != 'YOUR_PASSWORD' || $email == '' || $password == '') {
             $dgClass->redirect('index.php/user/index/1');
         }
         // get file
         $file = ROOT . DS . 'config' . DS . 'config-temp.php';
         $content = $dgClass->readFile($file);
         if ($content === false) {
             $dgClass->redirect('index.php/user/index/2');
         }
         $content = str_replace('YOUR_EMAIL', $email, $content);
         $content = str_replace('YOUR_PASSWORD', $password, $content);
         $check = $dgClass->WriteFile(ROOT . DS . 'config' . DS . 'config.php', $content);
         if ($check === false) {
             $dgClass->redirect('index.php/user/index/3');
         }
         setcookie('temail', $email, time() + 86400 * 30, '/');
         setcookie('tpassword', $password, time() + 86400 * 30, '/');
         $dgClass->redirect('index.php/user/index/200');
     } else {
         $dgClass->redirect('index.php/user/index');
     }
 }
Пример #4
0
 public function removeLanguage()
 {
     include_once ROOT . DS . 'includes' . DS . 'functions.php';
     $dg = new dg();
     $file = dirname(ROOT) . DS . 'data' . DS . 'languages.json';
     $languages = $dg->readFile($file);
     $languages = json_decode($languages, true);
     if (isset($_POST['checkb'])) {
         foreach ($_POST['checkb'] as $id) {
             if (isset($languages[$id])) {
                 if (isset($languages[$id]['code']) && file_exists(dirname(ROOT) . DS . 'data' . DS . $languages[$id]['file'])) {
                     unlink(dirname(ROOT) . DS . 'data' . DS . $languages[$id]['file']);
                     if (is_dir(dirname(ROOT) . DS . 'addons' . DS . 'language' . DS . $languages[$id]['code'])) {
                         unlink(dirname(ROOT) . DS . 'addons' . DS . 'language' . DS . $languages[$id]['code']);
                     }
                 }
                 unset($languages[$id]);
             }
         }
         $data_languages = $languages;
         $languages = array();
         foreach ($data_languages as $val) {
             $languages[] = $val;
         }
         $res = json_encode($languages);
         $dg->WriteFile($file, $res);
     }
     $this->languages('load');
     return;
 }
Пример #5
0
 public function installed()
 {
     $path = dirname(ROOT) . DS . 'addons' . DS . 'install';
     include_once ROOT . DS . 'includes' . DS . 'functions.php';
     $dg = new dg();
     $addons = array();
     $keys = array();
     if (file_exists($path)) {
         if ($handle = opendir($path)) {
             while (false !== ($entry = readdir($handle))) {
                 if (!in_array($entry, array(".", "..")) && file_exists($path . DS . $entry)) {
                     $product_id = str_replace('.json', '', $entry);
                     $file = $dg->readFile($path . DS . $entry);
                     if ($file != false) {
                         $addon = json_decode($file);
                         $addon->new_version = $addon->version;
                         $addon->product_id = $product_id;
                         if (isset($addon->key) && $addon->key != '') {
                             $args = array('woo_sl_action' => 'plugin_update', 'licence_key' => $addon->key, 'product_unique_id' => $product_id, 'domain' => $_SERVER['HTTP_HOST']);
                             $result = $dg->sendPostData($this->api_url, $args);
                             if ($result != false && $result != '') {
                                 $content = json_decode($result);
                                 if (isset($content[0]) && isset($content[0]->status) && isset($content[0]->message) && $content[0]->status == 'success') {
                                     if (isset($content[0]->message->new_version)) {
                                         $addon->new_version = $content[0]->message->new_version;
                                     }
                                 }
                             }
                             $addons[] = $addon;
                         }
                     }
                 }
             }
         }
     }
     $data['addons'] = $addons;
     $data['title'] = lang('breadcrumb_installed', true);
     $data['breadcrumb'] = lang('breadcrumb_installed', true);
     $data['sub_title'] = lang('breadcrumb_manager', true);
     $this->view('installed', $data);
 }