public function remove_from_disk() { $deleted = true; $season_ids = $this->get_seasons(); foreach ($season_ids as $id) { $season = new TVShow_Season($id); $deleted = $season->remove_from_disk(); if (!$deleted) { debug_event('tvshow', 'Error when deleting the season `' . $id . '`.', 1); break; } } if ($deleted) { $sql = "DELETE FROM `tvshow` WHERE `id` = ?"; $deleted = Dba::write($sql, array($this->id)); if ($deleted) { Art::gc('tvshow', $this->id); Userflag::gc('tvshow', $this->id); Rating::gc('tvshow', $this->id); Shoutbox::gc('tvshow', $this->id); Useractivity::gc('tvshow', $this->id); } } return $deleted; }
$sh = $this->CAT_FILE_WEB . ' | grep -i "usermac" | awk \'{if(index($0,"usermac=")) $1=substr($0,index($0,"usermac=")+8,17);a=index($0,$12);print $1,substr($0,a)}\' | awk \'{a[$1]=$0}END{for(i in a)print a[i]}\' | grep -i -v "window" | grep -io "android\\|mac" | awk \'BEGIN{FS=OFS="/"}{count[tolower($1)]++}END{for(name in count)print name,count[name]}\' '; exec($sh, $SysUse); foreach ($SysUse as $v) { list($tep['name'], $tep['num']) = explode('/', $v); $tep += array('date' => $this->today, 'stationid' => $this->STATIONID, 'hour' => $this->hour, 'type' => 'sys'); $this->Insert($tep, 'rha_mobile_ranklist'); } } } error_reporting(E_ALL ^ E_NOTICE); //接收stationid $stationid = $argv[1]; if (!$stationid) { exit; } $obj = new Useractivity($stationid); $station = $obj->STATION[0]; $check = $obj->CheckDo(); $filelogs = array(); if (!in_array($station['id'], $check)) { // $obj->deldir($obj->LOG_BASE_PATH.$station['logfile']); $obj->setPath($station['logfile'], $station['logname'], $station['is_moreweb']); $obj->setIpFilter($station['logip'], $station['ifconf'], $station['ap'], $station['xuip'], $station['is_alone']); $obj->Log($station['is_moreweb']); $obj->setStationId($station['id']); /*$obj->ClickRedPacket(); $obj->ActivityPage(); $obj->DownAppInfo(); $obj->SendMessage(); $obj->UserQuestion(); $obj->Lottery();
$browse->store(); ?> </div> <div id="followers" class="tab_content"> <?php $follower_ids = $client->get_followers(); $browse = new Browse(); $browse->set_type('user'); $browse->set_simple_browse(false); $browse->show_objects($follower_ids); $browse->store(); ?> </div> <div id="timeline" class="tab_content"> <?php if (Preference::get_by_user($client->id, 'allow_personal_info_recent')) { $activities = Useractivity::get_activities($client->id); Useractivity::build_cache($activities); foreach ($activities as $aid) { $activity = new Useractivity($aid); $activity->show(); } } ?> </div> <?php } ?> </div> </div>
/** * toggle_follow * @param integer $user_id * @return boolean */ public function toggle_follow($user_id) { if (!$user_id || $user_id === $this->id) { return false; } $params = array($this->id, $user_id); if ($this->is_following($user_id)) { $sql = "DELETE FROM `user_follower` WHERE `user` = ? AND `follow_user` = ?"; } else { $sql = "INSERT INTO `user_follower` (`user`, `follow_user`, `follow_date`) VALUES (?, ?, ?)"; $params[] = time(); Useractivity::post_activity($this->id, 'follow', 'user', $user_id); } return Dba::write($sql, $params); }
/** * gc * * This is a wrapper function for all of the different cleaning * functions, it runs them in an order that resembles correctness. */ public static function gc() { debug_event('catalog', 'Database cleanup started', 5); Song::gc(); Album::gc(); Artist::gc(); Video::gc(); Art::gc(); Stats::gc(); Rating::gc(); Userflag::gc(); Useractivity::gc(); Playlist::gc(); Tmp_Playlist::gc(); Shoutbox::gc(); Tag::gc(); // TODO: use InnoDB with foreign keys and on delete cascade to get rid of garbage collection \Lib\Metadata\Repository\Metadata::gc(); \Lib\Metadata\Repository\MetadataField::gc(); debug_event('catalog', 'Database cleanup ended', 5); }
$sh = $this->CAT_FILE_WEB . ' | grep -i "usermac" | awk \'{if(index($0,"usermac=")) $1=substr($0,index($0,"usermac=")+8,17);a=index($0,$12);print $1,substr($0,a)}\' | awk \'{a[$1]=$0}END{for(i in a)print a[i]}\' | grep -i -v "window" | grep -io "android\\|mac" | awk \'BEGIN{FS=OFS="/"}{count[tolower($1)]++}END{for(name in count)print name,count[name]}\' '; exec($sh, $SysUse); foreach ($SysUse as $v) { list($tep['name'], $tep['num']) = explode('/', $v); $tep += array('date' => $this->today, 'stationid' => $this->STATIONID, 'hour' => $this->hour, 'type' => 'sys'); $this->Insert($tep, 'rha_mobile_ranklist'); } } } error_reporting(E_ALL ^ E_NOTICE); //接收stationid $stationid = $argv[1]; if (!$stationid) { exit; } $obj = new Useractivity($stationid); $station = $obj->STATION[0]; $check = $obj->CheckDo(); $filelogs = array(); if (!in_array($station['id'], $check)) { $obj->deldir($obj->LOG_BASE_PATH . $station['logfile']); $obj->setPath($station['logfile'], $station['logname'], $station['is_moreweb']); $obj->setIpFilter($station['logip'], $station['ifconf'], $station['ap'], $station['xuip'], $station['is_alone']); $obj->Log($station['is_moreweb']); $obj->setStationId($station['id']); $obj->Sindex_uv(); $obj->alertwindow(); $obj->ClickRedPacket(); $obj->ActivityPage(); $obj->DownAppInfo(); $obj->SendMessage();
/** * display_home * This display the module in home page */ public function display_home() { if (AmpConfig::get('sociable')) { $user_id = $GLOBALS['user']->id; if ($user_id) { $activities = Useractivity::get_friends_activities($user_id, $this->maxitems); if (count($activities) > 0) { UI::show_box_top(T_('Friends Timeline')); Useractivity::build_cache($activities); foreach ($activities as $aid) { $activity = new Useractivity($aid); $activity->show(); } UI::show_box_bottom(); } } } }
/** * insert * This inserts a new record for the specified object * with the specified information, amazing! */ public static function insert($type, $oid, $user, $agent = '', $location, $count_type = 'stream') { if (!self::is_already_inserted($type, $oid, $user)) { $type = self::validate_type($type); $latitude = null; $longitude = null; $geoname = null; if (isset($location['latitude'])) { $latitude = $location['latitude']; } if (isset($location['longitude'])) { $longitude = $location['longitude']; } if (isset($location['name'])) { $geoname = $location['name']; } $sql = "INSERT INTO `object_count` (`object_type`,`object_id`,`count_type`,`date`,`user`,`agent`, `geo_latitude`, `geo_longitude`, `geo_name`) " . " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; $db_results = Dba::write($sql, array($type, $oid, $count_type, time(), $user, $agent, $latitude, $longitude, $geoname)); if (Core::is_media($type)) { Useractivity::post_activity($user, 'play', $type, $oid); } if (!$db_results) { debug_event('statistics', 'Unabled to insert statistics:' . $sql, '3'); } } else { debug_event('statistics', 'Statistics insertion ignored due to graceful delay.', '3'); } }
public function remove_from_disk() { $deleted = true; $video_ids = $this->get_episodes(); foreach ($video_ids as $id) { $video = Video::create_from_id($id); $deleted = $video->remove_from_disk(); if (!$deleted) { debug_event('tvshow_season', 'Error when deleting the video `' . $id . '`.', 1); break; } } if ($deleted) { $sql = "DELETE FROM `tvshow_season` WHERE `id` = ?"; $deleted = Dba::write($sql, array($this->id)); if ($deleted) { Art::gc('tvshow_season', $this->id); Userflag::gc('tvshow_season', $this->id); Rating::gc('tvshow_season', $this->id); Shoutbox::gc('tvshow_season', $this->id); Useractivity::gc('tvshow_season', $this->id); } } return $deleted; }
public function remove() { $sql = "DELETE FROM `label` WHERE `id` = ?"; $deleted = Dba::write($sql, array($this->id)); if ($deleted) { Art::gc('label', $this->id); Userflag::gc('label', $this->id); Rating::gc('label', $this->id); Shoutbox::gc('label', $this->id); Useractivity::gc('label', $this->id); } return $deleted; }
public function remove_from_disk() { $deleted = true; $song_ids = $this->get_songs(); foreach ($song_ids as $id) { $song = new Song($id); $deleted = $song->remove_from_disk(); if (!$deleted) { debug_event('album', 'Error when deleting the song `' . $id . '`.', 1); break; } } if ($deleted) { $sql = "DELETE FROM `album` WHERE `id` = ?"; $deleted = Dba::write($sql, array($this->id)); if ($deleted) { Art::gc('album', $this->id); Userflag::gc('album', $this->id); Rating::gc('album', $this->id); Shoutbox::gc('album', $this->id); Useractivity::gc('album', $this->id); } } return $deleted; }
/** * timeline * This get current user friends timeline * @param array $input */ public static function friends_timeline($input) { if (AmpConfig::get('sociable')) { $limit = intval($input['limit']); $since = intval($input['since']); if ($GLOBALS['user']->id > 0) { $activities = Useractivity::get_friends_activities($GLOBALS['user']->id, $limit, $since); ob_end_clean(); echo XML_Data::timeline($activities); } } else { debug_event('api', 'Sociable feature is not enabled.', 3); } }
/** * set_flag * This function sets the user flag for the current object. * If no userid is passed in, we use the currently logged in user. */ public function set_flag($flagged, $user_id = null) { if ($user_id === null) { $user_id = $GLOBALS['user']->id; } $user_id = intval($user_id); debug_event('Userflag', "Setting userflag for {$this->type} {$this->id} to {$flagged}", 5); if (!$flagged) { $sql = "DELETE FROM `user_flag` WHERE " . "`object_id` = ? AND " . "`object_type` = ? AND " . "`user` = ?"; $params = array($this->id, $this->type, $user_id); } else { $sql = "REPLACE INTO `user_flag` " . "(`object_id`, `object_type`, `user`, `date`) " . "VALUES (?, ?, ?, ?)"; $params = array($this->id, $this->type, $user_id, time()); Useractivity::post_activity($user_id, 'userflag', $this->type, $this->id); } Dba::write($sql, $params); parent::add_to_cache('userflag_' . $this->type . '_user' . $user_id, $this->id, $flagged); // Forward flag to last.fm and Libre.fm (song only) if ($this->type == 'song') { $user = new User($user_id); $song = new Song($this->id); if ($song) { $song->format(); foreach (Plugin::get_plugins('save_mediaplay') as $plugin_name) { try { $plugin = new Plugin($plugin_name); if ($plugin->load($user)) { $plugin->_plugin->set_flag($song, $flagged); } } catch (Exception $e) { debug_event('user.class.php', 'Stats plugin error: ' . $e->getMessage(), '1'); } } } } return true; }
/** * Remove the video from disk. */ public function remove_from_disk() { if (file_exists($this->file)) { $deleted = unlink($this->file); } else { $deleted = true; } if ($deleted === true) { $sql = "DELETE FROM `video` WHERE `id` = ?"; $deleted = Dba::write($sql, array($this->id)); if ($deleted) { Art::gc('video', $this->id); Userflag::gc('video', $this->id); Rating::gc('video', $this->id); Shoutbox::gc('video', $this->id); Useractivity::gc('video', $this->id); } } else { debug_event('video', 'Cannot delete ' . $this->file . 'file. Please check permissions.', 1); } return $deleted; }
/** * create * This takes a key'd array of data as input and inserts a new shoutbox entry, it returns the auto_inc id */ public static function create(array $data) { if (!Core::is_library_item($data['object_type'])) { return false; } $sticky = isset($data['sticky']) ? 1 : 0; $user = intval($data['user'] ?: $GLOBALS['user']->id); $date = intval($data['date'] ?: time()); $comment = strip_tags($data['comment']); $sql = "INSERT INTO `user_shout` (`user`,`date`,`text`,`sticky`,`object_id`,`object_type`, `data`) " . "VALUES (? , ?, ?, ?, ?, ?, ?)"; Dba::write($sql, array($user, $date, $comment, $sticky, $data['object_id'], $data['object_type'], $data['data'])); Useractivity::post_activity($user, 'shout', $data['object_type'], $data['object_id']); $insert_id = Dba::insert_id(); // Never send email in case of user impersonation if (!isset($data['user']) && $insert_id) { $libitem = new $data['object_type']($data['object_id']); $item_owner_id = $libitem->get_user_owner(); if ($item_owner_id) { if (Preference::get_by_user($item_owner_id, 'notify_email')) { $item_owner = new User($item_owner_id); if (!empty($item_owner->email)) { $libitem->format(); $mailer = new Mailer(); $mailer->set_default_sender(); $mailer->recipient = $item_owner->email; $mailer->recipient_name = $item_owner->fullname; $mailer->subject = T_('New shout on your content'); $mailer->message = sprintf(T_("You just received a new shout from %s on your content `%s`.\n\n\n ----------------------\n %s\n ----------------------\n\n %s\n "), $GLOBALS['user']->fullname, $libitem->get_fullname(), $comment, AmpConfig::get('web_path') . "/shout.php?action=show_add_shout&type=" . $data['object_type'] . "&id=" . $data['object_id'] . "#shout" . $insert_id); $mailer->send(); } } } } return $insert_id; }