⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pp_dederemote_interface.php

📁 强大的PHP内容管理系统尽量不要让站长把时间都花费在为您修正说明上。压缩包解压
💻 PHP
字号:
<?
/*--------------------------------------
本文件用于第三方系统反向整合DedeCms在相关程序调用的接口

调用本文件的接口函数前必须不能输出任何字符,本API不需要导入被整合系统的数据

使用本接口的系统必须支持 file_get_contents 函数
--------------------------------------*/

//这里请填写DedeCms系统的cookie加密码(通行证密钥)

$cfg_cookie_encode = "";

//Cookie主域名(用 "abc.com" 形式,不要加主机名,本地域名留空)

$domain = "";

//DedeCms通行证接口网址
//如果程序装在根目录,一般为 http://localhost/member/passport/pp_dederemote_new.php
//如果你不想让人知道dedecms这个接口(pp_dederemote.php)的真实网址,你也可以把它改其它名称

$DedeAPI_Url = "http://localhost/member/passport/pp_dederemote_new.php"; 


//登录成功后跳转的网址     (空按第三方系统默认)

$cfg_loginJumpUrl = "http://localhost/member/index.php";

//注册成功后跳转的网址     (空按第三方系统默认)

$cfg_regJumpUrl = "http://localhost/member/index.php";

//更改资料成功后跳转的网址 (空按第三方系统默认)

$cfg_editJump = "";      

//退出后跳转到的网址       (空按第三方系统默认)

$cfg_exitJump = "";


//----------------------------------
//第三方系统与Dedecms系统同步注册、登录、更改密码、退出接口函数
//SynchDedeCms($userid,$action,$exptime='36000')
//参数说明
/*-------------------------
$userid          用户登录的用户名,必须
$action          动作,必须,选项为:reg edit login exit test(测试用户ID是否存在)
$exptime='36000' cookie保存时间,单位为秒
返回值:
返回字串前三位为OK!表示操作成功
返回其它则是错误提示
--------------------------*/
function SynchDedeCms($userid,$action,$exptime='36000')
{
	 global $cfg_cookie_encode,$domain,$DedeAPI_Url;
	 if($domain!='') $cpath = '';
	 else $cpath = '/';
	 
	 $keys = Array('userid','action','exptime');
   $querystr = '';
   foreach($keys as $v){
   	  if(!empty($$v)) $querystr .= $v.'='.urlencode($$v).'&';
   }
   $signstr = substr(md5($userid.$cfg_cookie_encode),0,24);
   $querystr .= "signstr=$signstr";
   $DedeAPI_Url = $DedeAPI_Url."?rmdata=".base64_encode($querystr); 
   
   if(function_exists("file_get_contents")){
       $rcdata = file_get_contents($DedeAPI_Url) or die("远程通信错误!");
   }else{
   	   require_once(dirname(__FILE__)."/pub_httpdown.php");
   	   $dhd = new DedeHttpDown();
       $dhd->OpenUrl($DedeAPI_Url);
       $rcdata = $dhd->GetHtml();
       $dhd->Close();
   }
   
   if(substr($rcdata,0,3)=='OK!'){
   	  $okdata = ereg_replace("^OK!","",$rcdata);
   	  if($okdata!=""){
   	  	$headerStr = trim($okdata);
   	  	PutCookie("DedeUserID",$headerStr,$kptime,$cpath,$domain);
   	  	PutCookie("DedeUserIDckMd5",substr(md5($cfg_cookie_encode.$headerStr),0,16),$kptime,$cpath,$domain);
   	  }
   	  return 'OK';
   }else{
      return $rcdata;
   }
}

//按默认参数设置一个Cookie
function PutCookie($key,$value,$kptime,$pa='/',$dm=''){
	 global $cfg_cookie_encode;
	 setcookie($key,$value,time()+$kptime,$pa,$dm);
	 setcookie($key.'ckMd5',substr(md5($cfg_cookie_encode.$value),0,16),time()+$kptime,$pa,$dm);
}
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -