Exemplo n.º 1
0
 public function edit($id)
 {
     if (is_numeric($id)) {
         if (mc_is_admin() || mc_is_bianji() || mc_author_id($id) == mc_user_id()) {
             $this->page = M('page')->where("id='{$id}'")->order('id desc')->select();
             if (mc_get_page_field($id, 'type') == 'pro') {
                 $this->theme('admin')->display('Publish/edit_pro');
             } elseif (mc_get_page_field($id, 'type') == 'publish' || mc_get_page_field($id, 'type') == 'pending') {
                 $this->theme(mc_option('theme'))->display('Publish/edit');
             } elseif (mc_get_page_field($id, 'type') == 'group') {
                 $this->theme('admin')->display('Publish/edit_group');
             } elseif (mc_get_page_field($id, 'type') == 'article') {
                 $this->theme('admin')->display('Publish/edit_article');
             } elseif (mc_get_page_field($id, 'type') == 'topic') {
                 $this->theme('admin')->display('Publish/edit_topic');
             } elseif (mc_get_page_field($id, 'type') == 'zhongchou') {
                 $this->theme(mc_option('theme'))->display('Publish/edit_zhongchou');
             } else {
                 $this->error('哥们,你放弃治疗了吗?', U('home/index/index'));
             }
         } else {
             $this->error('哥们,你放弃治疗了吗?', U('home/index/index'));
         }
     } else {
         $this->error('哥们,你放弃治疗了吗?', U('home/index/index'));
     }
 }
 public function edit()
 {
     if (mc_is_admin() || mc_is_bianji() || mc_author_id($_POST['id']) == mc_user_id()) {
         if (mc_remove_html($_POST['title'], 'all') && $_POST['content'] && is_numeric($_POST['id'])) {
             if (mc_get_page_field($_POST['id'], 'type') == 'pro') {
                 if ($_POST['term']) {
                     mc_update_meta($_POST['id'], 'term', mc_magic_in($_POST['term']));
                 } else {
                     $this->error('请设置分类!');
                 }
                 if ($_POST['price'] > 0) {
                     mc_update_meta($_POST['id'], 'price', mc_magic_in($_POST['price']));
                 } else {
                     $this->error('请填写价格!');
                 }
                 if ($_POST['canshu'] > 0) {
                     mc_delete_meta($_POST['id'], 'kucun');
                     mc_update_meta($_POST['id'], 'parameter', serialize($_POST['parameter']));
                 } else {
                     mc_delete_meta($_POST['id'], 'parameter');
                     if (is_numeric($_POST['kucun'])) {
                         mc_update_meta($_POST['id'], 'kucun', $_POST['kucun']);
                     } else {
                         mc_update_meta($_POST['id'], 'kucun', 0);
                     }
                 }
                 if (is_numeric($_POST['xiaoliang'])) {
                     mc_update_meta($_POST['id'], 'xiaoliang', $_POST['xiaoliang']);
                 }
                 if ($_POST['fmimg']) {
                     mc_delete_meta($_POST['id'], 'fmimg');
                     foreach ($_POST['fmimg'] as $val) {
                         mc_add_meta($_POST['id'], 'fmimg', mc_save_img_base64($val, 1));
                     }
                 } else {
                     $this->error('请设置商品图片!');
                 }
                 mc_update_meta($_POST['id'], 'tb_name', $_POST['tb_name']);
                 mc_update_meta($_POST['id'], 'tb_url', $_POST['tb_url']);
                 mc_update_meta($_POST['id'], 'keywords', $_POST['keywords']);
                 mc_update_meta($_POST['id'], 'description', $_POST['description']);
             }
             if (mc_get_page_field($_POST['id'], 'type') == 'group') {
                 mc_update_meta($_POST['id'], 'fmimg', mc_magic_in(mc_save_img_base64($_POST['fmimg'])));
             }
             if (mc_get_page_field($_POST['id'], 'type') == 'publish') {
                 mc_update_meta($_POST['id'], 'group', mc_magic_in($_POST['group']));
                 if (mc_get_meta($_POST['id'], 'number') && mc_get_page_field($_POST['group'], 'type') == 'pro') {
                     mc_update_meta($_POST['id'], 'buyer_phone', mc_magic_in($_POST['buyer_phone']));
                     mc_update_meta($_POST['id'], 'buyer_address', mc_magic_in($_POST['buyer_address']));
                     mc_update_meta($_POST['id'], 'buyer_city', mc_magic_in($_POST['buyer_city']));
                     mc_update_meta($_POST['id'], 'buyer_province', mc_magic_in($_POST['buyer_province']));
                     mc_update_meta($_POST['id'], 'buyer_name', mc_magic_in($_POST['buyer_name']));
                 }
             }
             if (mc_get_page_field($_POST['id'], 'type') == 'article') {
                 mc_update_meta($_POST['id'], 'fmimg', mc_magic_in(mc_save_img_base64($_POST['fmimg'])));
                 if (I('param.tags')) {
                     mc_delete_meta($_POST['id'], 'tag');
                     $tags = explode(' ', I('param.tags'));
                     foreach ($tags as $tag) {
                         if ($tag) {
                             mc_add_meta($_POST['id'], 'tag', $tag);
                         }
                     }
                 }
                 if ($_POST['term']) {
                     mc_update_meta($_POST['id'], 'term', mc_magic_in($_POST['term']));
                 } else {
                     $this->error('请设置分类!');
                 }
             }
             $page['title'] = mc_magic_in(mc_remove_html($_POST['title'], 'all'));
             $page['content'] = mc_magic_in(mc_remove_html(mc_str_replace_base64($_POST['content'])));
             M('page')->where("id='" . $_POST['id'] . "'")->save($page);
             if (mc_get_page_field($_POST['id'], 'type') == 'pro') {
                 $this->success('编辑成功', U('control/index/pro_index'));
             } elseif (mc_get_page_field($_POST['id'], 'type') == 'publish' || mc_get_page_field($_POST['id'], 'type') == 'pending') {
                 $this->success('编辑成功', U('post/index/single?id=' . $_POST['id']));
             } elseif (mc_get_page_field($_POST['id'], 'type') == 'group') {
                 $this->success('编辑成功', U('post/group/index?id=' . $_POST['id']));
             } elseif (mc_get_page_field($_POST['id'], 'type') == 'article') {
                 $this->success('编辑成功', U('control/index/article_index'));
             } elseif (mc_get_page_field($_POST['id'], 'type') == 'topic') {
                 $page['content'] = mc_magic_in(mc_str_replace_base64($_POST['content']));
                 M('page')->where("id='" . $_POST['id'] . "'")->save($page);
                 $this->success('编辑成功', U('control/index/topic_index'));
             } else {
                 $this->error('未知的Page类型', U('home/index/index'));
             }
         } else {
             $this->error('请完整填写信息!');
         }
     } else {
         $this->error('哥们,你放弃治疗了吗?', U('home/index/index'));
     }
 }
Exemplo n.º 3
0
<?php

mc_template_part('header');
?>
	<?php 
foreach ($page as $val) {
    ?>
	<?php 
    $author = mc_author_id($val['id']);
    $group_id = mc_get_meta($val['id'], 'group');
    ?>
	<header id="group-head" class="hidden-xs">
		<div class="container">
			<div class="row">
				<div class="col-sm-8">
					<h1>
						<a id="logo" class="pull-left img-div" href="<?php 
    echo mc_get_url(mc_get_meta($val['id'], 'group'));
    ?>
"><img src="<?php 
    echo mc_fmimg(mc_get_meta($val['id'], 'group'));
    ?>
"></a>
						<a href="<?php 
    echo U('post/group/single?id=' . mc_get_meta($val['id'], 'group'));
    ?>
" class="pull-left title"><?php 
    echo mc_get_page_field(mc_get_meta($val['id'], 'group'), 'title');
    ?>
</a>
					</h1>
 public function edit()
 {
     if (mc_is_admin() || mc_is_bianji() || mc_author_id($_POST['id']) == mc_user_id()) {
         if ($_POST['title'] && $_POST['content'] && is_numeric($_POST['id'])) {
             if (mc_get_page_field($_POST['id'], 'type') == 'pro') {
                 if ($_POST['term']) {
                     mc_update_meta($_POST['id'], 'term', mc_magic_in($_POST['term']));
                 } else {
                     $this->error('请设置分类!');
                 }
                 if (is_numeric($_POST['price'])) {
                     mc_update_meta($_POST['id'], 'price', mc_magic_in($_POST['price']));
                 } else {
                     $this->error('请填写价格!');
                 }
                 if (is_numeric($_POST['kucun'])) {
                     mc_update_meta($_POST['id'], 'kucun', mc_magic_in($_POST['kucun']));
                 }
                 if (is_numeric($_POST['xiaoliang'])) {
                     mc_update_meta($_POST['id'], 'xiaoliang', mc_magic_in($_POST['xiaoliang']));
                 }
                 M('meta')->where("page_id='" . $_POST['id'] . "' AND type = 'parameter'")->delete();
                 M('meta')->where("page_id='" . $_POST['id'] . "' AND type = 'price'")->delete();
                 if ($_POST['pro-parameter']) {
                     $parameter = $_POST['pro-parameter'];
                     foreach ($parameter as $key => $val) {
                         $val = array_reverse($val);
                         foreach ($val as $vals) {
                             if ($vals['name'] != '') {
                                 mc_add_meta($_POST['id'], $key, $vals['name'], 'parameter');
                                 if ($vals['price'] > 0) {
                                     mc_add_meta($_POST['id'], $vals['name'], $vals['price'], 'price');
                                 } else {
                                     mc_add_meta($_POST['id'], $vals['name'], 0, 'price');
                                 }
                             }
                         }
                     }
                 }
                 if ($_POST['fmimg']) {
                     mc_delete_meta($_POST['id'], 'fmimg');
                     foreach ($_POST['fmimg'] as $val) {
                         mc_add_meta($_POST['id'], 'fmimg', $val);
                     }
                 } else {
                     $this->error('请设置商品图片!');
                 }
                 if ($_POST['keywords']) {
                     mc_update_meta($_POST['id'], 'keywords', $_POST['keywords']);
                 }
                 if ($_POST['description']) {
                     mc_update_meta($_POST['id'], 'description', $_POST['description']);
                 }
             }
             if (mc_get_page_field($_POST['id'], 'type') == 'group') {
                 mc_update_meta($_POST['id'], 'fmimg', mc_magic_in($_POST['fmimg']));
             }
             if (mc_get_page_field($_POST['id'], 'type') == 'publish') {
                 mc_update_meta($_POST['id'], 'group', mc_magic_in($_POST['group']));
             }
             if (mc_get_page_field($_POST['id'], 'type') == 'article') {
                 mc_update_meta($_POST['id'], 'fmimg', mc_magic_in($_POST['fmimg']));
                 if (I('param.tags')) {
                     mc_delete_meta($_POST['id'], 'tag');
                     $tags = explode(' ', I('param.tags'));
                     foreach ($tags as $tag) {
                         if ($tag) {
                             mc_add_meta($_POST['id'], 'tag', $tag);
                         }
                     }
                 }
                 if ($_POST['term']) {
                     mc_update_meta($_POST['id'], 'term', mc_magic_in($_POST['term']));
                 } else {
                     $this->error('请设置分类!');
                 }
             }
             $page['title'] = mc_magic_in($_POST['title']);
             $page['content'] = mc_magic_in($_POST['content']);
             M('page')->where("id='" . $_POST['id'] . "'")->save($page);
             if (mc_get_page_field($_POST['id'], 'type') == 'pro') {
                 $this->success('编辑成功', U('pro/index/single?id=' . $_POST['id']));
             } elseif (mc_get_page_field($_POST['id'], 'type') == 'publish' || mc_get_page_field($_POST['id'], 'type') == 'pending') {
                 $this->success('编辑成功', U('post/index/single?id=' . $_POST['id']));
             } elseif (mc_get_page_field($_POST['id'], 'type') == 'group') {
                 $this->success('编辑成功', U('post/group/index?id=' . $_POST['id']));
             } elseif (mc_get_page_field($_POST['id'], 'type') == 'article') {
                 $this->success('编辑成功', U('article/index/single?id=' . $_POST['id']));
             } else {
                 $this->error('未知的Page类型', U('home/index/index'));
             }
         } else {
             $this->error('请完整填写信息!');
         }
     } else {
         $this->error('哥们,你放弃治疗了吗?', U('home/index/index'));
     }
 }