public function show($segments) { extract($_POST); if (!isset($username)) { $username = $segments[1]; } $entry = DB::query('select id,username,title,location,bio,avatar from users where username = \'' . $username . '\'', 1); $entry['activity'] = DB::query('select count(*) as activity from feed where user_id = \'' . $entry['id'] . '\'', 2, 'activity'); if (!is_file(PATH_UPLOAD . 'profile/' . $entry['avatar'])) { $entry['avatar'] = 'default.png'; } $feed = array(); $feedraw = DB::query('select * from feed where user_id = ' . $entry['id'] . ' and privacy_id = 1 order by id desc limit 20', 0); foreach ($feedraw as $i => $row) { $feed[$i] = $row; $feed[$i]['status'] = Feed::parse_status($row['status']); $feed[$i]['files'] = Feed::get_files($row['id'], 'th'); if (isset($row['created_ts'])) { $feed[$i]['timespan'] = timespan($row['created_ts']); } } $follow_btn = ""; if ($entry['id'] != $_SESSION['user_id']) { $following = DB::query('select id from follows where user_id = ' . $_SESSION['user_id'] . ' and user2_id = ' . $entry['id'], 1); if ($following) { $follow_btn = '<button class="btn btn-success follow" data-id="' . $entry['id'] . '"><i class="ion-checkmark-round"></i> ' . _l('Following') . ' </button>'; } else { $follow_btn = '<button class="btn btn-info follow" data-id="' . $entry['id'] . '"><i class="ion-ios-bolt"></i> ' . _l('Follow') . ' </button>'; } } return array('view' => "account", 'follow_btn' => $follow_btn, 'entry' => $entry, 'feed' => $feed); }
static function get_files($id, $type = 'th') { $data = DB::query('select filename from files where feed_id = ' . $id, 4, 'filename'); $files = array(); foreach ($data as $value) { if (file_exists(PATH_UPLOAD . 'feed/' . $type . '-' . $value)) { $files[] = $value; } } return $files; }
public function add() { $email = $_REQUEST['email']; $exists = DB::query("select * from suscribers where email = '" . $email . "'", 1); $json = "already_suscribed"; if (!$exists) { DB::write("insert into suscribers set email = '" . $email . "'"); $json = "success"; } return array('result' => $json); }
public function add_cam_code() { $webcams = DB::query('select * from webcams', 0); foreach ($webcams as $cam) { if ($cam['code'] == '') { $code = substr(md5(uniqid(mt_rand(), true)), 0, 12); DB::write('update webcams set code = \'' . $code . '\' where id = ' . $cam['id']); } } return []; }
public function login() { extract($_REQUEST); $data = DB::query("select * from users \n\t\t\twhere email = '" . $email . "' and pass = '******' \n\t\t\tor username = '******' and pass = '******'", 1); DB::write('update users set lastlogin_ts = ' . time() . ' where id = ' . $data['id']); $json = 0; if ($data) { $json = 1; AuthController::add_session($data); } return array('result' => $json); }
public function register_preview() { extract($_REQUEST); $exists = DB::query("select * from users where email = '" . $email . "'", 1); $json = "email_not_evailable"; $id = 0; if (!$exists) { $id = DB::write("insert into suscribers set \n\t\t\t\t\ttitle = '" . $title . "',\n\t\t\t\t\temail = '" . $email . "',\n\t\t\t\t\tusername = '******'"); $json = "email_evailable"; } return array('result' => $json, 'id' => $id); }
public function user_username() { extract($_REQUEST); $exists = DB::query("select * from users where username = '******'", 1); $ion = "alert-circled"; $status = "danger"; $message = 'username_not_available'; if (!$exists) { $ion = "checkmark-round"; $status = "success"; $message = 'username_available'; } return array('ion' => $ion, 'status' => $status, 'message' => $message); }
public function detect() { global $lang; $data = array('lang' => $lang, 'sess' => array('privacy_icons' => DB::query('select * from privacy', 0))); if (isset($_SESSION['user_id'])) { $data['sess']['user_id'] = $_SESSION['user_id']; $data['sess']['privacy_id'] = $_SESSION['privacy_id']; $data['sess']['style_id'] = DB::query('select style_id from users where id = ' . $_SESSION['user_id'], 2, 'style_id'); $data['sess']['privacy_icon'] = DB::query('select icon from privacy where id = ' . $_SESSION['privacy_id'], 2, 'icon'); $data['sess']['username'] = $_SESSION['username']; $data['sess']['title'] = $_SESSION['title']; $data['sess']['first_name'] = $_SESSION['title']; } return $data; }
public function show($segments) { $entry = array(); $data = DB::query('select webcams.title, webcams.caption, webcams.code, webcams.location, users.username, users.title as user_title from webcams join users on users.id = webcams.user_id where webcams.code = \'' . $segments[1] . '\'', 1); if ($data) { $files = File::dir_content(PATH_WEBCAM . $data['username'], '', 'lastsnap.jpg'); $dotssize = 16; $dotssize = count($files); $select = array(); if (count($files)) { sort($files); foreach ($files as $i => $file) { $tmp = stat(PATH_WEBCAM . $data['username'] . '/' . $file); if (isset($segments[2]) && isset($segments[3])) { if ($tmp[9] >= $segments[2] && $tmp[9] <= $segments[3]) { //$select[] = array($tmp[9],date('Y m d H:i:s',$tmp[9]),timespan($tmp[9])); } else { unset($files[$i]); } } else { if ($i == count($files) - 1) { $segments[3] = $tmp[9]; } } $select[] = array($tmp[9], date('Y m d H:i:s', $tmp[9]), timespan($tmp[9])); } if ($segments[4] == null) { $segments[4] = 1000; } if ($segments[5] == null) { $segments[5] = 500; } $stat = stat(PATH_WEBCAM . $data['username'] . '/' . $files[count($files) - 1]); $entry = $data; $entry['count'] = count($files); $entry['timespan'] = timespan($stat[9]); //$entry['files'] = array_slice($files,count($files)-$dotssize,count($files)); $entry['files'] = $files; } } return array('view' => 'webcams/show', 'select' => $select, 'segments' => $segments, 'entry' => $entry); }
public function add() { extract($_REQUEST); $now = time(); $lastid = DB::update('feed', $id, '*'); /* preg_match_all('/(#\w+)/', $status, $matches); foreach ($matches[0] as $hashtag) echo $hashtag . ' '; */ preg_match_all("/(@\\w+)/", $status, $matches); foreach ($matches[0] as $mentiontag) { $user_id = DB::query('select id from users where username = \'' . str_replace('@', '', $mentiontag) . '\'', '2', 'id'); if ($user_id) { DB::write('insert into mentions set user_id = ' . $_SESSION['user_id'] . ', user2_id = ' . $user_id . ', feed_id = ' . $lastid . ', created_ts = ' . $now); } } $entry = feedController::status($lastid); return array('entry' => $entry); }
public function index() { $count = DB::query('select count(*) from users', 2, 'count(*)'); return array('count' => $count); }
public function index() { $entry = DB::query('select * from users where id = ' . $_SESSION['user_id'], 1); return array('entry' => $entry); }
public function connect() { $j = 0; $feed = array(); $online = array(); $feed_ids = array(); extract($_POST); $connect_user = $segments[1]; if (strlen($connect_user)) { $connect_id = DB::query('select id from users where username = \'' . $connect_user . '\'', 2, 'id'); } if (!$connect_id) { return false; } $user_id = $_SESSION['user_id']; if (!isset($limit_ts)) { $limit_ts = time() - 3600 * 24 * 30; // when read first time, update for online timestamp DB::write('update users set updated_ts = ' . time() . ' where id = ' . $user_id); } IController::keep_online(); $follows = DB::query('select user2_id from follows where user_id = ' . $user_id, 4, 'user2_id'); $follows[] = $user_id; $feedraw = DB::query('select feed.*, users.username, users.title as user, users.avatar from mentions left join feed on feed.id = mentions.feed_id left join users on users.id = feed.user_id where mentions.user_id in(' . implode(',', array($user_id, $connect_id)) . ') group by mentions.feed_id order by feed.created_ts desc limit 20', 0); $onlineraw = DB::query('select users.username, users.title, users.lastlogin_ts, users.last_ts from follows inner join users on users.id = follows.user2_id where follows.user_id = ' . $_SESSION['user_id'] . ' group by follows.user2_id', 0); if (count($follows)) { $feed_ids = DB::query('select feed.id from feed left join users on users.id = feed.user_id where feed.user_id in(' . implode(',', $follows) . ') order by feed.created_ts desc limit 20', 4, 'id'); } foreach ($feedraw as $i => $row) { // mark as read $feed[$j] = $row; if (!is_file(PATH_UPLOAD . 'profile/' . $row['avatar'])) { $feed[$j]['avatar'] = 'default.png'; } $feed[$j]['status'] = Feed::parse_status($row['status']); $feed[$j]['files'] = Feed::get_files($row['id'], 'th'); if (isset($row['created_ts'])) { $feed[$j]['timespan'] = timespan($row['created_ts']); } $j++; } foreach ($onlineraw as $i => $row) { $status = "offline"; if ($row['last_ts'] > time() - 20) { // n + 2 $status = "online"; } $online[$i]['unread'] = 0; $online[$i] = $row; $online[$i]['timespan'] = timespan($row['lastlogin_ts']); $online[$i]['unread'] = DB::query('select count(*) as total from feed where id in(' . implode(',', $feed_ids) . ') and read_ts = 0', 2, 'total'); $online[$i]['total'] = DB::query('select count(*) as total from mentions where user2_id = ' . $user_id, 2, 'total'); $online[$i]['status'] = $status; $online[$i]['show_as'] = 'mention'; if ($feed_ids) { $online[$i]['unread'] = DB::query('select count(*) as total from feed where id in (' . implode(',', $feed_ids) . ') and read_ts = 0', 2, 'total'); } } DB::write('update feed set read_ts = ' . time() . ' where id in (' . implode(',', $feed_ids) . ')'); return array('feed' => $feed, 'online' => $online); }
$view = isset($segments[1]) && strlen($segments[1]) ? $segments[1] : 'index'; $cfile = PATH_CTRL . $cname . '.php'; $mfile = PATH_MDL . $mname . '.php'; $method = count($segments) > 1 ? implode('_', array_slice($segments, 1)) : ($umethod != '' ? $umethod : 'index'); $params = array_slice($segments, 2); if (is_file($mfile)) { include $mfile; } if (is_file($cfile)) { header('Content-Type: application/json', true); // log user activity if (isset($_SESSION['user_id'])) { if (isset($_SESSION['style_id'])) { unset($_SESSION['style_id']); } $_SESSION['style_id'] = DB::query('select style_id from users where id = ' . $_SESSION['user_id'], 2, 'style_id'); /* $data = array( 'activity_path' => '/' . implode('/',$segments), 'last_ts' => time() ); DB::update('users',$_SESSION['user_id'],'last_ts activity_path',$data); */ } include $cfile; $obj = "App\\Controllers\\" . $cname; $c = new $obj(); $method = strstr($method, "%20", true); debug('*** ' . date('H:i:s')); debug(json_encode($segments));