织梦dede整合discuz后会员注册后不用激活实现方法(5)

   //note 同步登出 API 接口
   header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
   include_once DEDEINC.'/memberlogin.class.php';
   $cfg_ml = new MemberLogin();
   $cfg_ml->ExitCookie();
}

function updatepw($get, $post)
{
   if(!API_UPDATEPW)
   {
    return API_RETURN_FORBIDDEN;
   }
   $username = $get['username'];
   $password = $get['password'];
  
   //note 修改密码 API 接口
   $newpw = md5($password);
   $this->db->ExecuteNoneQuery("UPDATE `dede_member` SET `pwd`='$newpw' WHERE `userid`='$username'");
   return API_RETURN_SUCCEED;
}

function updatebadwords($get, $post)
{
   if(!API_UPDATEBADWORDS)
   {
    return API_RETURN_FORBIDDEN;
   }

   $row = $this->db->GetOne("SELECT `value` FROM `dede_sysconfig` WHERE `varname`='cfg_replacestr'");
  
   $badwords = isset($row['value']) ? explode(",", $row['value']) : array();
  
   if(is_array($post))
   {
    foreach($post as $k => $v)
    {
     if(in_array($v['find'],$badwords)) continue;
     $badwords[] = $v['find'];
    }
   }

   $badwords_comma = !empty($badwords) ? implode(",", $badwords) : '';
  

   $this->db->ExecuteNoneQuery("UPDATE `dede_sysconfig` SET `value`='$badwords_comma' WHERE `varname`='cfg_replacestr'");
  
   $cachefile = DEDEDATA.'/config.cache.inc.php';
  
   if(!is_writeable($cachefile))
   {
    return API_RETURN_FORBIDDEN;
   }

   $fp = fopen($cachefile, 'w');
   $this->db->SetQuery("SELECT `varname`,`type`,`value`,`groupid` From `dede_sysconfig` order by aid asc ");
   $this->db->Execute();
   $s = '<?php'."\r\n";
   while($row = $this->db->GetArray())
   {
    $s .= '$'.$row['varname'].' = '.($row['type']=='number' ? $row['value'] : "'".str_replace("'",'',$row['value'])."'").";\r\n";
   }
   $s .= '?>';
   fwrite($fp, $s);
   fclose($fp);
   return API_RETURN_SUCCEED;
}

function updatehosts($get, $post)
{
   if(!API_UPDATEHOSTS)
   {
    return API_RETURN_FORBIDDEN;
   }
   //note 理新HOST缓存 API 接口
   $cachefile = UC_CLIENT_ROOT.'/data/cache/hosts.php';
   $fp = fopen($cachefile, 'w');
   $s = "<?php\r\n";
   $s .= '$_CACHE[\'hosts\'] = '.var_export($post, TRUE).";\r\n";
   fwrite($fp, $s);
   fclose($fp);
   return API_RETURN_SUCCEED;
}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/c8d5d8fa55c6b5c32a897c09ccd717cf.html