Esempio n. 1
0
 $q_dby = mysql_query($s_dby) or die('');
 $r_dby = mysql_fetch_assoc($q_dby);
 if (mysql_num_rows($q_dby) > 0) {
     if ($r_dby['edate'] < time() && $r_dby['edate'] > 0 && $r_dby['s_r'] != '') {
         $o = new baiduPHP($config['baidu_key'], $config['baidu_se']);
         $result = $o->access_token_refresh($r_dby['s_r']);
         if (isset($result['access_token']) && $result['access_token'] != '') {
             $r_dby['s_t'] = $result['access_token'];
             $r_dby['s_r'] = $result['refresh_token'];
             $r_dby['edate'] = time() + $result['expires_in'];
         }
         $u_db = sprintf('update %s set s_t=%s, s_r=%s, edate=%s, mdate=%s where id=%s', $dbprefix . 'm_sync', SQLString($r_dby['s_t'], 'text'), SQLString($r_dby['s_r'], 'text'), SQLString($r_dby['edate'], 'int'), time(), $r_dby['id']);
         $result = mysql_query($u_db) or die('');
     }
     $bo = new baiduPHP($config['baidu_key'], $config['baidu_se'], $r_dby['s_t']);
     $ba = $bo->me();
     if (!isset($ba['error_code']) && isset($ba['uid']) && $ba['uid'] != '') {
         $is_sync = 1;
         $d_db = sprintf('delete from %s where aid<>%s and name=%s and s_id=%s', $dbprefix . 'm_sync', $r_dbu['id'], SQLString($nct, 'text'), SQLString($ba['uid'], 'text'));
         $result = mysql_query($d_db) or die('');
         if ($r_dby['s_id'] != $ba['uid']) {
             $u_db = sprintf('update %s set s_id=%s where id=%s', $dbprefix . 'm_sync', SQLString($ba['uid'], 'text'), $r_dby['id']);
             $result = mysql_query($u_db) or die('');
         }
         $content .= '当前已绑定百度账号<table width="200"><tr><td align="center"><img src="http://himg.bdimg.com/sys/portraitn/item/' . $ba['portrait'] . '.jpg" alt=""/><br/>' . $ba['uname'] . '(<a href="?m=profile&amp;t=sync&amp;n=' . $nct . '&amp;lt=1">取消绑定</a>)</td></tr></table>';
     } else {
         $d_db = sprintf('delete from %s where aid=%s and name=%s', $dbprefix . 'm_sync', $r_dbu['id'], SQLString($nct, 'text'));
         $result = mysql_query($d_db) or die('');
     }
 }
 mysql_free_result($q_dby);