case 'live': 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/live.php'; $is_sync = 0; $s_dby = sprintf('select id, s_id, s_t, s_r, 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 livePHP($config['live_key'], $config['live_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(''); } $ms_o = new livePHP($config['live_key'], $config['live_se'], $r_dby['s_t']); $ms_a = $ms_o->me(); if (isset($ms_a['id']) && $ms_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($ms_a['id'], 'text')); $result = mysql_query($d_db) or die(''); if ($r_dby['s_id'] != $ms_a['id']) {