Beispiel #1
0
 static function factory()
 {
     $config = Config::getInstance()->DB;
     $class = 'DengLuTong\\lib\\Db\\Db' . $config['type'];
     if (class_exists($class)) {
         $db = new $class($config);
         return $db;
     } else {
         throw new Exception($class . ' not exists');
     }
 }
Beispiel #2
0
 /**
  * 显示登录条
  * @param string $url	登录地址
  * @param string $vendor	服务商
  * @param string $theme	模板
  */
 static function getBar($theme = 'theme', $url = '', $vendor = '', $name = '')
 {
     empty($theme) ? $theme = 'theme' : '';
     $str = static::${$theme};
     $vendor == '' ? $vendor = static::$site : '';
     $name == '' ? $name = static::$name : '';
     if (empty($url)) {
         $url = Config::getInstance()->LoginUrl;
     }
     $logo = self::getLogo($vendor);
     return str_replace(array('{url}', '{vendor}', '{logo}', '{name}'), array($url, $vendor, $logo, $name), $str);
 }
Beispiel #3
0
 /**
  * 获取设置
  */
 static function getConfig()
 {
     self::$config = Config::getInstance();
 }
Beispiel #4
0
 function __construct()
 {
     $this->dbconfig = Config::getInstance()->DB;
     $this->initDB();
 }
Beispiel #5
0
<?php

use DengLuTong\lib\Config;
use DengLuTong\Vendor_Msn;
use DengLuTong\Vendor_Sohu;
use DengLuTong\Vendor_TaoBao;
use DengLuTong\Vendor_KaiXin;
use DengLuTong\Vendor_RenRen;
use DengLuTong\Vendor_NetEase;
use DengLuTong\Vendor_Gmail;
use DengLuTong\Vendor_DouBan;
use DengLuTong\Vendor_QQ;
use DengLuTong\Vendor_Sina;
use DengLuTong\Vendor_TianYa;
$config = Config::getInstance();
$config->DB = array('type' => 'Mysql', 'dbhost' => 'localhost', 'dbname' => 'test', 'dbuser' => 'root', 'dbpass' => 'root', 'tablename' => 'denglutong_user', 'charset' => 'utf8');
$config->KEYID = array(Vendor_Sina::$site => '', Vendor_QQ::$site => '', Vendor_DouBan::$site => '', Vendor_NetEase::$site => '', Vendor_RenRen::$site => '', Vendor_KaiXin::$site => '', Vendor_TaoBao::$site => '', Vendor_Sohu::$site => '', Vendor_Msn::$site => '', Vendor_TianYa::$site => '', Vendor_Gmail::$site => TRUE);
$config->SECID = array(Vendor_Sina::$site => '', Vendor_QQ::$site => '', Vendor_DouBan::$site => '', Vendor_NetEase::$site => '', Vendor_RenRen::$site => '', Vendor_KaiXin::$site => '', Vendor_TaoBao::$site => '', Vendor_Sohu::$site => '', Vendor_Msn::$site => '', Vendor_TianYa::$site => '', Vendor_Gmail::$site => TRUE);
$config->LOGO = array(Vendor_Sina::$site => 'http://open.sinaimg.cn/wikipic/button/24.png', Vendor_QQ::$site => 'http://qzonestyle.gtimg.cn/qzone/vas/opensns/res/img/Connect_logo_3.png', Vendor_DouBan::$site => 'http://img3.douban.com/pics/doubanicon-24-full.png', Vendor_Gmail::$site => 'DengLuTong/tpl/logo_gmail_small.gif', Vendor_NetEase::$site => 'http://img1.cache.netease.com/cnews/img/wblogostandard/logo3.png', Vendor_RenRen::$site => 'http://wiki.dev.renren.com/mediawiki/images/2/2b/%E8%93%9D%E8%89%B2_112X23.png', Vendor_KaiXin::$site => 'http://img1.kaixin001.com.cn/i3/platform/login_1.png', Vendor_TaoBao::$site => 'http://img01.taobaocdn.com/tps/i1/T1T2RZXf8nXXXXXXXX-140-35.png', Vendor_Sohu::$site => 'http://s1.cr.itc.cn/img/i2/t/130.png', Vendor_Msn::$site => 'http://col.stb.s-msn.com/i/B7/EB75D45B8948F72EE451223E95A96.gif', Vendor_TianYa::$site => 'http://open.tianya.cn/static/wiki/tylogin16.png');
//客户端文件(如:DLTClient.php)位置,如http://localhost/DLTClient.php
$baseurl = 'http://' . $_SERVER['SERVER_NAME'] . str_replace(basename($_SERVER['PHP_SELF']), 'DLTClient.php', $_SERVER['PHP_SELF']);
$config->BaseUrl = $baseurl;
$config->LoginUrl = $baseurl . '?dltact=login&vendor=';
//登录条链接地址
$config->CallBack = $baseurl . '?dltact=callback&vendor=';
//回调地址
$config->Local = 'Local';
//默认本地用户处理类
$config->themefile = 'showBars';
//showMiniBars  样式文件
$config->theme = 'theme';
Beispiel #6
0
<?php

use DengLuTong\Exception;
use DengLuTong\lib\Config;
use DengLuTong\DengLuTong;
require_once 'DengLuTong/DengLuTong.php';
//require_once 'DengLuTong/DLTConfig.php';
$act = empty($_GET['dltact']) ? 'showBars' : $_GET['dltact'];
$vendor = empty($_GET['vendor']) ? '' : 'Vendor_' . $_GET['vendor'];
$dlt = DengLuTong::getInstance($vendor);
if (!method_exists($dlt, $act)) {
    throw new Exception('Method not exists.');
}
$return = $dlt->{$act}($vendor);
switch ($act) {
    case 'callback':
        echo '<script>window.opener.location.href="' . Config::getInstance()->BaseUrl . '?dltact=bind";window.close();</script>';
        die;
    case 'unbind':
        $url = empty($_GET['url']) ? './' : $_GET['url'];
        header('Location: ' . $url);
        die;
}
Beispiel #7
0
require_once 'DengLuTong/DengLuTong.php';
use DengLuTong\DengLuTong;
use DengLuTong\lib\Config;
if (empty($_SESSION['user'])) {
    header('Location: login.php');
    die;
}
DengLuTong::clearSession();
$user = $_SESSION['user'];
echo 'Hi, ' . $user['name'] . ' Welcome.';
$dlt = DengLuTong::getInstance('', 'Local');
$binded = $dlt->getBinded($user['id']);
echo '<div>';
foreach ($binded as $bind) {
    echo '<p>' . $bind['name'] . ':' . ($bind['dlt_user'] ? $bind['dlt_user'] . ' <a href="DLTClient.php?dltact=unbind&vendor=' . $bind['site'] . '">解除绑定</a>' : '<a href="javascript:DLTWinOpen(\'' . Config::getInstance()->LoginUrl . $bind['site'] . '\')">绑定</a>') . '</p>';
}
echo '</div>';
?>
<a href='logout.php'>logout</a>
<script>
function DLTWinOpen(url,id,iWidth,iHeight)
{
	var iTop = (screen.height-30-iHeight)/2; //获得窗口的垂直位置;
	var iLeft = (screen.width-10-iWidth)/2; //获得窗口的水平位置;
	//DLTWin=window.open(url,id,'height='+iHeight+',innerHeight='+iHeight+',width='+iWidth+',innerWidth='+iWidth+',top='+iTop+',left='+iLeft+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
	//chrome不支持showModalDialog弹出模态窗口
	DLTWin=window.showModalDialog(url,null,"dialogWidth="+iWidth+"px;dialogHeight="+iHeight+"px;dialogTop="+iTop+"px;dialogLeft="+iLeft+"px");
	
}
function $(id)