public function tuisong($id, $fmimg) { if (mc_is_admin() || mc_is_bianji()) { if (is_numeric($id) && $fmimg) { mc_add_meta($id, 'tuisong', mc_save_img_base64($fmimg)); } $this->success('推送成功!', mc_get_url($id)); } else { $this->error('请不要放弃治疗'); } }
function mc_str_replace_base64($content) { preg_match_all("/\\<img.*?src\\=\"(.*?)\"[^>]*>/i", $content, $match); foreach ($match[1] as $img) { $content = str_replace($img, mc_save_img_base64($img), $content); } return $content; }
public function set() { if (mc_user_id()) { if (mc_is_admin()) { if ($_POST['site_name'] && $_POST['site_url'] && $_POST['page_size']) { mc_update_option('site_name', I('param.site_name')); mc_update_option('site_url', I('param.site_url')); mc_update_option('site_color', I('param.site_color')); mc_update_option('theme', $_POST['theme']); mc_update_option('pro_name', $_POST['pro_name']); mc_update_option('group_name', $_POST['group_name']); mc_update_option('article_name', $_POST['article_name']); mc_update_option('logo', mc_save_img_base64($_POST['logo'])); mc_update_option('stmp_from', I('param.stmp_from')); mc_update_option('stmp_name', I('param.stmp_name')); mc_update_option('stmp_host', I('param.stmp_host')); mc_update_option('stmp_port', I('param.stmp_port')); mc_update_option('stmp_username', I('param.stmp_username')); mc_update_option('stmp_password', I('param.stmp_password')); mc_update_option('fmimg', mc_save_img_base64($_POST['fmimg'])); mc_update_option('homehdimg1', mc_save_img_base64($_POST['homehdimg1'])); mc_update_option('homehdimg2', mc_save_img_base64($_POST['homehdimg2'])); mc_update_option('homehdimg3', mc_save_img_base64($_POST['homehdimg3'])); mc_update_option('homehdlnk1', I('param.homehdlnk1')); mc_update_option('homehdlnk2', I('param.homehdlnk2')); mc_update_option('homehdlnk3', I('param.homehdlnk3')); mc_update_option('homehdtitle1', I('param.homehdtitle1')); mc_update_option('homehdtitle2', I('param.homehdtitle2')); mc_update_option('homehdtitle3', I('param.homehdtitle3')); mc_update_option('homehdtext1', I('param.homehdtext1')); mc_update_option('homehdtext2', I('param.homehdtext2')); mc_update_option('homehdtext3', I('param.homehdtext3')); mc_update_option('homehdbtn1', I('param.homehdbtn1')); mc_update_option('homehdbtn2', I('param.homehdbtn2')); mc_update_option('homehdbtn3', I('param.homehdbtn3')); mc_update_option('page_size', I('param.page_size')); mc_update_option('shehe_comment', I('param.shehe_comment')); mc_update_option('upyun', I('param.upyun')); mc_update_option('upyun_url', I('param.upyun_url')); mc_update_option('upyun_bucket', I('param.upyun_bucket')); mc_update_option('upyun_user', I('param.upyun_user')); mc_update_option('upyun_pwd', I('param.upyun_pwd')); mc_update_option('loginqq', I('param.loginqq')); mc_update_option('loginqq_appid', I('param.loginqq_appid')); mc_update_option('loginqq_appkey', I('param.loginqq_appkey')); $loginqq = '<?php die("forbidden"); ?> {"appid":"' . I('param.loginqq_appid') . '","appkey":"' . I('param.loginqq_appkey') . '","callback":"' . I('param.site_url') . '/connect-qq","scope":"get_user_info","errorReport":true,"storageType":"file","host":"localhost","user":"******","password":"******","database":"test"}'; $fileName = THINK_PATH . '../connect-qq/API/comm/inc.php'; if (!is_writeable($fileName)) { @chmod($fileName, 0777); } file_put_contents($fileName, $loginqq); mc_update_option('loginweibo', I('param.loginweibo')); mc_update_option('loginweibo_appid', I('param.loginweibo_appid')); mc_update_option('loginweibo_appkey', I('param.loginweibo_appkey')); $loginweibo = "<?php header('Content-Type: text/html; charset=UTF-8'); define( 'WB_AKEY' , '" . I('param.loginweibo_appid') . "' ); define( 'WB_SKEY' , '" . I('param.loginweibo_appkey') . "' ); define( 'WB_CALLBACK_URL' , '" . I('param.site_url') . "/connect-weibo' );"; $fileName2 = THINK_PATH . '../connect-weibo/config.php'; if (!is_writeable($fileName2)) { @chmod($fileName2, 0777); } file_put_contents($fileName2, $loginweibo); $this->success('更新成功'); } else { $this->theme('admin')->display('Control/set'); } } else { $this->error('您没有权限访问此页面!'); } } else { $this->success('请先登陆', U('User/login/index')); } }
public function edit($id = false) { if (!is_numeric($id)) { $id = mc_user_id(); } if (is_numeric($id)) { if (mc_user_id() == $id) { if (mc_remove_html($_POST['title'], 'all')) { $title = M('page')->where("title='" . mc_magic_in(mc_remove_html($_POST['title'], 'all')) . "' AND type ='user'")->getField('id'); if (is_numeric($title) && $title != $id) { $this->error('昵称已存在!'); } else { mc_update_page(mc_user_id(), mc_magic_in(mc_remove_html($_POST['title'], 'all')), 'title'); } if ($_POST['content']) { mc_update_page(mc_user_id(), mc_magic_in(mc_remove_html($_POST['content'], 'all')), 'content'); } if ($_POST['user_avatar']) { if (mc_get_meta(mc_user_id(), 'user_avatar', true, 'user')) { mc_update_meta(mc_user_id(), 'user_avatar', mc_magic_in(mc_save_img_base64($_POST['user_avatar'], 1, 120, 120)), 'user'); } else { mc_add_meta(mc_user_id(), 'user_avatar', mc_magic_in(mc_save_img_base64($_POST['user_avatar'], 1, 120, 120)), 'user'); } } if ($_POST['fmimg']) { mc_delete_meta($id, 'fmimg', 'basic'); mc_add_meta($id, 'fmimg', mc_magic_in(mc_save_img_base64($_POST['fmimg']))); } mc_delete_meta($id, 'buyer_name', 'user'); if ($_POST['buyer_name']) { mc_add_meta($id, 'buyer_name', mc_magic_in($_POST['buyer_name']), 'user'); } mc_delete_meta($id, 'buyer_province', 'user'); if ($_POST['buyer_province']) { mc_add_meta($id, 'buyer_province', mc_magic_in($_POST['buyer_province']), 'user'); } mc_delete_meta($id, 'buyer_city', 'user'); if ($_POST['buyer_city']) { mc_add_meta($id, 'buyer_city', mc_magic_in($_POST['buyer_city']), 'user'); } mc_delete_meta($id, 'buyer_address', 'user'); if ($_POST['buyer_address']) { mc_add_meta($id, 'buyer_address', mc_magic_in($_POST['buyer_address']), 'user'); } mc_delete_meta($id, 'buyer_phone', 'user'); if ($_POST['buyer_phone']) { mc_add_meta($id, 'buyer_phone', mc_magic_in($_POST['buyer_phone']), 'user'); } $user_email_now = mc_get_meta(mc_user_id(), 'user_email', true, 'user'); if ($_POST['user_email'] != $user_email_now) { $user_email = M('meta')->where("meta_key='user_email' AND type ='user'")->getField('meta_value', true); if (in_array(strip_tags($_POST['user_email']), $user_email)) { $this->error('邮箱已存在!'); } else { mc_update_meta(mc_user_id(), 'user_email', mc_magic_in($_POST['user_email']), 'user'); } } elseif ($_POST['user_email'] == '') { $this->error('邮箱必须填写!'); } else { mc_update_meta(mc_user_id(), 'user_email', mc_magic_in($_POST['user_email']), 'user'); } if (I('param.pass')) { if (I('param.pass2') == I('param.pass')) { mc_update_meta(mc_user_id(), 'user_pass', md5(I('param.pass') . mc_option('site_key')), 'user'); $this->success('修改密码成功,请使用新密码登陆', U('User/login/index')); } else { $this->error('两次密码必须填写一致!'); } } else { $this->success('更新资料成功', U('User/index/edit?id=' . $id)); } } else { $this->theme(mc_option('theme'))->display('User/edit'); } } else { $this->error('禁止访问!'); } } else { $this->error('参数错误!', U('User/login/index')); } }