case 'google': if (isset($_GET['lt']) && $_GET['lt'] == 1) { $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(''); header('Location:./?m=profile&t=sync&n=' . $nct); exit; } require_once 'lib/google.php'; $is_sync = 0; $s_dby = sprintf('select id, s_id, s_t, s_r, s_n, edate, is_show from %s where aid=%s and name=%s limit 1', $dbprefix . 'm_sync', $r_dbu['id'], SQLString($nct, 'text')); $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 googlePHP($config['google_key'], $config['google_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['edate'] = time() + $result['expires_in']; } $u_db = sprintf('update %s set s_t=%s, edate=%s, mdate=%s where id=%s', $dbprefix . 'm_sync', SQLString($r_dby['s_t'], 'text'), SQLString($r_dby['edate'], 'int'), time(), $r_dby['id']); $result = mysql_query($u_db) or die(''); } $gg_o = new googlePHP($config['google_key'], $config['google_se'], $r_dby['s_t']); $gg_a = $gg_o->me(); if (isset($gg_a['id']) && $gg_a['id'] != '') { $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($gg_a['id'], 'text')); $result = mysql_query($d_db) or die(''); $me_url = $gg_a['link']; if ($r_dby['s_n'] != $me_url || $r_dby['s_id'] != $gg_a['id']) {