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

function updateapps($get, $post)
{
   if(!API_UPDATEAPPS)
   {
    return API_RETURN_FORBIDDEN;
   }
   $UC_API = $post['UC_API'];

   //note 写 app 缓存文件
   $cachefile = UC_CLIENT_ROOT.'/data/cache/apps.php';
   $fp = fopen($cachefile, 'w');
   $s = "<?php\r\n";
   $s .= '$_CACHE[\'apps\'] = '.var_export($post, TRUE).";\r\n";
   fwrite($fp, $s);
   fclose($fp);

   return API_RETURN_SUCCEED;
}

function updateclient($get, $post)
{
   if(!API_UPDATECLIENT)
   {
    return API_RETURN_FORBIDDEN;
   }
   $cachefile = UC_CLIENT_ROOT.'/data/cache/settings.php';
   $fp = fopen($cachefile, 'w');
   $s = '<?php'."\r\n";
   $s .= '$_CACHE[\'settings\'] = '.var_export($post, TRUE).";\r\n";
   fwrite($fp, $s);
   fclose($fp);
  
   return API_RETURN_SUCCEED;
}

function updatecredit($get, $post)
{
   if(!API_UPDATECREDIT)
   {
    return API_RETURN_FORBIDDEN;
   }
   /*
   note 更新积分
   discuz 默认8个积分表达,而DedeCMS只有一个积分字段,scores.注意money不能做积分来用.
   extcredits1 extcredits2 extcredits3 extcredits4 extcredits5 extcredits6 extcredits7 extcredits8
   */
    
   $credit = intval($get['credit']);
   $fileds = $credit > 1 ? 'money' : 'scores';
   $amount = $get['amount'];
   $uid = $get['uid'];
   include UC_CLIENT_ROOT.'/client.php';
   $data = uc_get_user($uid,1);
   $username = $data[1];
  
   $result = $this->db->GetOne("SELECT mid FROM `dede_member` WHERE userid='$username'");
   if(is_array($result))
   {
    $this->db->ExecuteNoneQuery("UPDATE `dede_member` SET `$fileds`=`$fileds`+'$amount' WHERE mid='$result[mid]'");
   }
  
   return API_RETURN_SUCCEED;
}

function getcredit($get, $post)
{
   if(!API_GETCREDIT)
   {
    return API_RETURN_FORBIDDEN;
   }
  
   include UC_CLIENT_ROOT.'/client.php';
   $data = uc_get_user($uid,1);
   $username = $data[1];
   $credit = intval($get['credit']);
   $fileds = $credit > 1 ? 'money' : 'scores';
   $result = $this->db->GetOne("SELECT `$fileds` AS credit FROM `dede_member` WHERE userid='$username'");
  
   echo is_array($result) ? $result['credit'] : 0;  
}

function getcreditsettings($get, $post)
{
   if(!API_GETCREDITSETTINGS)
   {
    return API_RETURN_FORBIDDEN;
   }
  
   //这里支持DedeCMS积分,金币设置
   $credits[1] = array(strip_tags('积分'), '分');
   $credits[2] = array(strip_tags('金币'), '枚');
   return $this->_serialize($credits);
}

function updatecreditsettings($get, $post)
{
   if(!API_UPDATECREDITSETTINGS)
   {
    return API_RETURN_FORBIDDEN;
   }
   $credit = $get['credit'];
   $outextcredits = array();
   if($credit && is_array($credit)) {
    foreach($credit as $appid => $credititems) {
     foreach($credititems as $value) {
      if($value['appiddesc']!=UC_APPID) continue;
      $outextcredits[$appid][] = array(
       'appiddesc' => $value['appiddesc'],
       'creditdesc' => $value['creditdesc'],
       'creditsrc' => $value['creditsrc'],
       'title' => $value['title'],
       'unit' => $value['unit'],
       'ratiosrc' => $value['ratiosrc'],
       'ratiodesc' => $value['ratiodesc'],
       'ratio' => $value['ratio']
      );
     }
    }
   }
   $_CACHE = "<?php !defined('UC_API') && exit(\"403 Forbidden!\");\n".'$_CACHE[\'credit\'] = unserialize("'.addslashes(serialize($outextcredits)).'");'."\r\n".'?>';
   $fp = @fopen(DEDEDATA.'/credits.inc.php', 'w');
   @fwrite($fp, $_CACHE);
   @fclose($fp);
   return API_RETURN_SUCCEED;
}
}


function _authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {
$ckey_length = 4;

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

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