Exemple #1
0
 public function edit_pc_tag()
 {
     if (empty($this->tpl_edit)) {
         showmessage(L('tpl_edit'));
     }
     $dir = isset($_GET['dir']) && trim($_GET['dir']) ? str_replace(array('..\\', '../', './', '.\\'), '', urldecode(trim($_GET['dir']))) : showmessage(L('illegal_operation'));
     $file = isset($_GET['file']) && trim($_GET['file']) ? urldecode(trim($_GET['file'])) : showmessage(L('illegal_operation'));
     $op = isset($_GET['op']) && trim($_GET['op']) ? trim($_GET['op']) : showmessage(L('illegal_operation'));
     $tag_md5 = isset($_GET['tag_md5']) && trim($_GET['tag_md5']) ? trim($_GET['tag_md5']) : showmessage(L('illegal_operation'));
     $show_header = $show_scroll = $show_validator = true;
     pc_base::load_app_func('global');
     pc_base::load_sys_class('form', '', 0);
     $filepath = $this->filepath . $dir . DIRECTORY_SEPARATOR . $file;
     switch ($op) {
         case 'xml':
         case 'json':
             if ($_POST['dosubmit']) {
                 $url = isset($_POST['url']) && trim($_POST['url']) ? trim($_POST['url']) : showmessage(L('data_address') . L('empty'));
                 $cache = isset($_POST['cache']) && trim($_POST['cache']) ? trim($_POST['cache']) : 0;
                 $return = isset($_POST['return']) && trim($_POST['return']) ? trim($_POST['return']) : '';
                 if (!preg_match('/http:\\/\\//i', $url)) {
                     showmessage(L('data_address_reg_sg'), HTTP_REFERER);
                 }
                 $tag_md5_list = tag_md5($filepath);
                 $pc_tag = creat_pc_tag($op, array('url' => $url, 'cache' => $cache, 'return' => $return));
                 if (in_array($tag_md5, $tag_md5_list[0])) {
                     $old_pc_tag = $tag_md5_list[1][$tag_md5];
                 }
                 if (replace_pc_tag($filepath, $old_pc_tag, $pc_tag, $this->style, $dir)) {
                     showmessage('<script style="text/javascript">if(!window.top.right){parent.location.reload();}art.dialog({id:"edit"}).close();</script>', '', '', 'edit');
                 } else {
                     showmessage(L('failure_the_document_may_not_to_write'));
                 }
             }
             include $this->admin_tpl('pc_tag_tools_json_xml');
             break;
         case 'get':
             if ($_POST['dosubmit']) {
                 $sql = isset($_POST['sql']) && trim($_POST['sql']) ? trim($_POST['sql']) : showmessage('SQL' . L('empty'));
                 $dbsource = isset($_POST['dbsource']) && trim($_POST['dbsource']) ? trim($_POST['dbsource']) : '';
                 $cache = isset($_POST['cache']) && intval($_POST['cache']) ? intval($_POST['cache']) : 0;
                 $return = isset($_POST['return']) && trim($_POST['return']) ? trim($_POST['return']) : '';
                 $tag_md5_list = tag_md5($filepath);
                 $pc_tag = creat_pc_tag($op, array('sql' => $sql, 'dbsource' => $dbsource, 'cache' => $cache, 'return' => $return));
                 if (in_array($tag_md5, $tag_md5_list[0])) {
                     $old_pc_tag = $tag_md5_list[1][$tag_md5];
                 }
                 if (replace_pc_tag($filepath, $old_pc_tag, $pc_tag, $this->style, $dir)) {
                     showmessage('<script style="text/javascript">if(!window.top.right){parent.location.reload();}art.dialog({id:"edit"}).close();</script>', '', '', 'edit');
                 } else {
                     showmessage(L('failure_the_document_may_not_to_write'));
                 }
             }
             $dbsource_db = pc_base::load_model('dbsource_model');
             $r = $dbsource_db->select('', 'name');
             $dbsource_list = array('' => L('please_select'));
             foreach ($r as $v) {
                 $dbsource_list[$v['name']] = $v['name'];
             }
             include $this->admin_tpl('pc_tag_tools_get');
             break;
         default:
             if (!file_exists(PC_PATH . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $op . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . $op . '_tag.class.php')) {
                 showmessage(L('the_module_will_not_support_the_operation'));
             }
             $op_tag = pc_base::load_app_class($op . "_tag", $op);
             if (!method_exists($op_tag, 'pc_tag')) {
                 showmessage(L('the_module_will_not_support_the_operation'));
             }
             $html = $op_tag->pc_tag();
             if ($_POST['dosubmit']) {
                 $action = isset($_POST['action']) && trim($_POST['action']) ? trim($_POST['action']) : 0;
                 $data = array('action' => $action);
                 if (isset($html[$action]) && is_array($html[$action])) {
                     foreach ($html[$action] as $key => $val) {
                         $val['validator']['reg_msg'] = $val['validator']['reg_msg'] ? $val['validator']['reg_msg'] : $val['name'] . L('inputerror');
                         if ($val['htmltype'] != 'checkbox') {
                             ${$key} = isset($_POST[$key]) && trim($_POST[$key]) ? trim($_POST[$key]) : '';
                         } else {
                             ${$key} = isset($_POST[$key]) && $_POST[$key] ? implode(',', $_POST[$key]) : '';
                         }
                         if (isset($val['ajax']['id']) && !empty($val['ajax']['id'])) {
                             $data[$val['ajax']['id']] = isset($_POST[$val['ajax']['id']]) && trim($_POST[$val['ajax']['id']]) ? trim($_POST[$val['ajax']['id']]) : '';
                         }
                         if (!empty($val['validator'])) {
                             if (isset($val['validator']['min']) && strlen(${$key}) < $val['validator']['min']) {
                                 showmessage($val['name'] . L('should') . L('is_greater_than') . $val['validator']['min'] . L('lambda'));
                             }
                             if (isset($val['validator']['max']) && strlen(${$key}) > $val['validator']['max']) {
                                 showmessage($val['name'] . L('should') . L('less_than') . $val['validator']['max'] . L('lambda'));
                             }
                             if (!preg_match('/' . $val['validator']['reg'] . '/' . $val['validator']['reg_param'], ${$key})) {
                                 showmessage($val['name'] . $val['validator']['reg_msg']);
                             }
                         }
                         $data[$key] = ${$key};
                     }
                 }
                 $page = isset($_POST['page']) && trim($_POST['page']) ? trim($_POST['page']) : '';
                 $num = isset($_POST['num']) && intval($_POST['num']) ? intval($_POST['num']) : 0;
                 $return = isset($_POST['return']) && trim($_POST['return']) ? trim($_POST['return']) : '';
                 $cache = isset($_POST['cache']) && intval($_POST['cache']) ? intval($_POST['cache']) : 0;
                 $data['page'] = $page;
                 $data['num'] = $num;
                 $data['return'] = $return;
                 $data['cache'] = $cache;
                 $tag_md5_list = tag_md5($filepath);
                 $pc_tag = creat_pc_tag($op, $data);
                 if (in_array($tag_md5, $tag_md5_list[0])) {
                     $old_pc_tag = $tag_md5_list[1][$tag_md5];
                 }
                 if (!file_exists($filepath)) {
                     showmessage($filepath . L('file_does_not_exists'));
                 }
                 if (replace_pc_tag($filepath, $old_pc_tag, $pc_tag, $this->style, $dir)) {
                     showmessage(L('operation_success') . '<script style="text/javascript">top.art.dialog({id:"edit"}).close();</script>', '', '', 'edit');
                 } else {
                     showmessage(L('failure_the_document_may_not_to_write'));
                 }
             }
             include $this->admin_tpl('pc_tag_modules');
             break;
     }
 }
Exemple #2
0
 /**
  * 编辑YUN标签
  */
 public function edit_yun_tag()
 {
     if (empty($this->tpl_edit)) {
         showmessage(L('tpl_edit'));
     }
     $dir = isset($_GET['dir']) && trim($_GET['dir']) ? str_replace(array('..\\', '../', './', '.\\'), '', urldecode(trim($_GET['dir']))) : showmessage(L('illegal_operation'));
     $file = isset($_GET['file']) && trim($_GET['file']) ? urldecode(trim($_GET['file'])) : showmessage(L('illegal_operation'));
     $op = isset($_GET['op']) && trim($_GET['op']) ? trim($_GET['op']) : showmessage(L('illegal_operation'));
     $tag_md5 = isset($_GET['tag_md5']) && trim($_GET['tag_md5']) ? trim($_GET['tag_md5']) : showmessage(L('illegal_operation'));
     $show_header = $show_scroll = $show_validator = true;
     Loader::helper('template:global');
     $filepath = $this->filepath . $dir . DIRECTORY_SEPARATOR . $file;
     switch ($op) {
         case 'xml':
         case 'json':
             if ($_POST['dosubmit']) {
                 $url = isset($_POST['url']) && trim($_POST['url']) ? trim($_POST['url']) : showmessage(L('data_address') . L('empty'));
                 $cache = isset($_POST['cache']) && trim($_POST['cache']) ? trim($_POST['cache']) : 0;
                 $return = isset($_POST['return']) && trim($_POST['return']) ? trim($_POST['return']) : '';
                 if (!preg_match('/http:\\/\\//i', $url)) {
                     showmessage(L('data_address_reg_sg'), HTTP_REFERER);
                 }
                 $tag_md5_list = tag_md5($filepath);
                 $yun_tag = creat_yun_tag($op, array('url' => $url, 'cache' => $cache, 'return' => $return));
                 if (in_array($tag_md5, $tag_md5_list[0])) {
                     $old_yun_tag = $tag_md5_list[1][$tag_md5];
                 }
                 if (replace_yun_tag($filepath, $old_yun_tag, $yun_tag, $this->style, $dir)) {
                     showmessage(L('operation_success'), '', '', 'edit', 'if(!window.top.right){parent.location.reload();}');
                 } else {
                     showmessage(L('failure_the_document_may_not_to_write'));
                 }
             }
             include $this->view('yun_tag_tools_json_xml');
             break;
         case 'get':
             if ($_POST['dosubmit']) {
                 $sql = isset($_POST['sql']) && trim($_POST['sql']) ? trim($_POST['sql']) : showmessage('SQL' . L('empty'));
                 $dbsource = isset($_POST['dbsource']) && trim($_POST['dbsource']) ? trim($_POST['dbsource']) : '';
                 $cache = isset($_POST['cache']) && intval($_POST['cache']) ? intval($_POST['cache']) : 0;
                 $return = isset($_POST['return']) && trim($_POST['return']) ? trim($_POST['return']) : '';
                 $tag_md5_list = tag_md5($filepath);
                 $yun_tag = creat_yun_tag($op, array('sql' => $sql, 'dbsource' => $dbsource, 'cache' => $cache, 'return' => $return));
                 if (in_array($tag_md5, $tag_md5_list[0])) {
                     $old_yun_tag = $tag_md5_list[1][$tag_md5];
                 }
                 if (replace_yun_tag($filepath, $old_yun_tag, $yun_tag, $this->style, $dir)) {
                     showmessage(L('operation_success'), '', '', 'edit', 'if(!window.top.right){parent.location.reload();}');
                 } else {
                     showmessage(L('failure_the_document_may_not_to_write'));
                 }
             }
             $dbsource_db = Loader::model('dbsource_model');
             $r = $dbsource_db->select('', 'name');
             $dbsource_list = array('' => L('please_select'));
             foreach ($r as $v) {
                 $dbsource_list[$v['name']] = $v['name'];
             }
             include $this->view('yun_tag_tools_get');
             break;
         default:
             if (!file_exists(APPS_PATH . $op . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . $op . '_tag.php')) {
                 showmessage(L('the_application_will_not_support_the_operation'));
             }
             $op_tag = Loader::lib($op . ':' . $op . "_tag");
             if (!method_exists($op_tag, 'yun_tag')) {
                 showmessage(L('the_application_will_not_support_the_operation'));
             }
             $html = $op_tag->yun_tag();
             if (isset($_POST['dosubmit'])) {
                 $do = isset($_POST['do']) && trim($_POST['do']) ? trim($_POST['do']) : 0;
                 $data = array('do' => $do);
                 if (isset($html[$do]) && is_array($html[$do])) {
                     foreach ($html[$do] as $key => $val) {
                         $val['validator']['reg_msg'] = isset($val['validator']['reg_msg']) ? $val['validator']['reg_msg'] : $val['name'] . L('inputerror');
                         if ($val['htmltype'] != 'checkbox') {
                             ${$key} = isset($_POST[$key]) && trim($_POST[$key]) ? trim($_POST[$key]) : '';
                         } else {
                             ${$key} = isset($_POST[$key]) && $_POST[$key] ? implode(',', $_POST[$key]) : '';
                         }
                         if (isset($val['ajax']['id']) && !empty($val['ajax']['id'])) {
                             $data[$val['ajax']['id']] = isset($_POST[$val['ajax']['id']]) && trim($_POST[$val['ajax']['id']]) ? trim($_POST[$val['ajax']['id']]) : '';
                         }
                         if (!empty($val['validator'])) {
                             if (isset($val['validator']['min']) && strlen(${$key}) < $val['validator']['min']) {
                                 showmessage($val['name'] . L('should') . L('is_greater_than') . $val['validator']['min'] . L('lambda'));
                             }
                             if (isset($val['validator']['max']) && strlen(${$key}) > $val['validator']['max']) {
                                 showmessage($val['name'] . L('should') . L('less_than') . $val['validator']['max'] . L('lambda'));
                             }
                             if (!preg_match('/' . $val['validator']['reg'] . '/' . $val['validator']['reg_param'], ${$key})) {
                                 showmessage($val['name'] . $val['validator']['reg_msg']);
                             }
                         }
                         $data[$key] = ${$key};
                     }
                 }
                 $page = isset($_POST['page']) && trim($_POST['page']) ? trim($_POST['page']) : '';
                 $num = isset($_POST['num']) && intval($_POST['num']) ? intval($_POST['num']) : 0;
                 $return = isset($_POST['return']) && trim($_POST['return']) ? trim($_POST['return']) : '';
                 $cache = isset($_POST['cache']) && intval($_POST['cache']) ? intval($_POST['cache']) : 0;
                 $data['page'] = $page;
                 $data['num'] = $num;
                 $data['return'] = $return;
                 $data['cache'] = $cache;
                 $tag_md5_list = tag_md5($filepath);
                 $yun_tag = creat_yun_tag($op, $data);
                 if (in_array($tag_md5, $tag_md5_list[0])) {
                     $old_yun_tag = $tag_md5_list[1][$tag_md5];
                 }
                 if (replace_yun_tag($filepath, $old_yun_tag, $yun_tag, $this->style, $dir)) {
                     showmessage(L('operation_success'), '', '', 'edit', "window.top.art.dialog.tips('" . L('operation_success') . "', 2);if(!window.top.right){parent.location.reload();}");
                 } else {
                     showmessage(L('failure_the_document_may_not_to_write'));
                 }
             }
             include $this->view('yun_tag_application');
             break;
     }
 }