function last_visit() { global $db; $sql = "SELECT `pv_datetime` FROM `" . table_pageviews . "` where `pv_type` = 'story' and `pv_page_id` = {$this->page_id} and `pv_user_id` = {$this->user_id} order by `pv_datetime` DESC Limit 1"; //echo $sql; $lastvisit = $db->get_var($sql); $lastvisit = unixtimestamp($lastvisit); return $lastvisit; }
function read() { // read the comment from the database global $db, $current_user; $this->username = false; $id = $this->id; if ($link = $db->get_row("SELECT * FROM " . table_comments . " WHERE comment_id = {$id}")) { $this->author = $link->comment_user_id; $this->randkey = $link->comment_randkey; $this->link = $link->comment_link_id; $this->karma = $link->comment_karma; $this->parent = $link->comment_parent; $this->content = $link->comment_content; $this->randkey = $link->comment_randkey; $this->votes = $link->comment_votes; $date = $link->comment_date; $this->date = unixtimestamp($date); $this->read = true; return true; } $this->read = false; return false; }
function read($usecache = TRUE) { // read the comment from the database global $db, $current_user, $cached_comments; $this->username = false; $id = $this->id; if (!is_numeric($id)) { return false; } if (isset($cached_comments[$id]) && $usecache == TRUE) { $link = $cached_comments[$id]; } else { $link = $db->get_row("SELECT * FROM " . table_comments . " WHERE comment_id = {$id}"); $cached_comments[$id] = $link; } if ($link) { $this->author = $link->comment_user_id; $this->randkey = $link->comment_randkey; $this->link = $link->comment_link_id; $this->karma = $link->comment_karma; $this->parent = $link->comment_parent; $this->content = $link->comment_content; $this->status = $link->comment_status; $this->randkey = $link->comment_randkey; $this->votes = $link->comment_votes; $date = $link->comment_date; $this->date = unixtimestamp($date); $this->read = true; return true; } $this->read = false; return false; }
$queued = $db->get_var('SELECT count(*) from ' . table_links . ' where link_status = "queued";'); $main_smarty->assign('queued', $queued); $main_smarty->assign('total', $queued + $published); $votes = $db->get_var('SELECT count(*) from ' . table_votes . ' where vote_type="links";'); $main_smarty->assign('votes', $votes); $comments = $db->get_var('SELECT count(*) from ' . table_comments . ';'); $main_smarty->assign('comments', $comments); $sql = mysql_query("SELECT link_id,link_date FROM " . table_links . " ORDER BY link_date DESC LIMIT 1"); while ($rows = mysql_fetch_array($sql)) { $link_date = txt_time_diff(unixtimestamp($rows['link_date'])); $main_smarty->assign('link_date', $link_date . ' ' . $main_smarty->get_config_vars('PLIGG_Visual_Comment_Ago')); $main_smarty->assign('link_id', $rows['link_id']); } $sql = mysql_query("SELECT link_id,comment_id,comment_link_id,comment_date FROM " . table_comments . "," . table_links . " WHERE comment_link_id = link_id ORDER BY comment_date DESC LIMIT 1"); while ($rows = mysql_fetch_array($sql)) { $comment_date = txt_time_diff(unixtimestamp($rows['comment_date'])); $main_smarty->assign('comment_date', $comment_date . ' ' . $main_smarty->get_config_vars('PLIGG_Visual_Comment_Ago')); $main_smarty->assign('link_id', $rows['link_id']); $main_smarty->assign('comment_id', $rows['comment_id']); } $sql = "SELECT user_login FROM " . table_users . " ORDER BY user_id DESC LIMIT 1"; $last_user = $db->get_var($sql); $main_smarty->assign('last_user', $last_user); // read the mysql database to get the pligg version $sql = "SELECT data FROM " . table_misc_data . " WHERE name = 'pligg_version'"; $pligg_version = $db->get_var($sql); $main_smarty->assign('version_number', $pligg_version); // pagename define('pagename', 'admin_index'); $main_smarty->assign('pagename', pagename); // show the template
<div class="show_post_author_date"> <?php //echo " " . $h->lang["bookmarking_post_posted_by"] . " "; ?> <li class="fa fa-user"></li> <?php if ($h->post->authorname) { echo "<a href='" . $h->url(array('user' => $h->post->authorname)) . "'>" . $h->post->authorname . "</a>"; } else { echo $h->lang['main_anonymous']; } ?> <li class="fa fa-clock-o"></li> <?php echo time_difference(unixtimestamp($h->post->date), $h->lang) . " " . $h->lang["bookmarking_post_ago"]; ?> <?php //echo time_ago($h->post->date); ?> <?php $h->pluginHook('show_post_author_date'); ?> </div> <?php if ($h->vars['use_content']) { ?>
<div class="comment_header_left"> <?php // Show avatars if enabled (requires an avatars plugin) if ($h->comment->avatars == 'checked') { if ($h->isActive('avatar')) { $h->setAvatar($h->comment->author, $h->comment->avatarSize); echo $h->wrapAvatar(); } } ?> <div class="comment_author"> <?php $username = $h->getUserNameFromId($h->comment->author); echo $h->lang['comments_written_by'] . " "; echo "<a href='" . $h->url(array('user' => $username)) . "'>" . $username . "</a>, "; echo time_difference(unixtimestamp($h->comment->date), $h->lang) . " "; echo $h->lang['comments_time_ago'] . "."; if ($display) { echo "<a href='#' class='comment_show_hide'>" . $h->lang['comments_show_hide'] . "</a>"; } ?> </div> </div> <?php // Show votes if enabled (requires a comment voting plugin) if ($h->comment->voting == 'checked') { $h->pluginHook('show_comments_votes'); } ?> </div>
/** * Picks the right SQL and gets the last_update time in seconds * * @param string $table DB table name * @return int $last_update */ public function smartCacheSQL($h, $table = '') { /* Get the last time the table was updated */ switch ($table) { case 'categories': $sql = "SELECT category_updatedts FROM " . DB_PREFIX . "categories ORDER BY category_updatedts DESC LIMIT 1"; break; case 'tags': $sql = "SELECT tags_updatedts FROM " . DB_PREFIX . "tags ORDER BY tags_updatedts DESC LIMIT 1"; break; case 'posts': $sql = "SELECT post_updatedts FROM " . DB_PREFIX . "posts ORDER BY post_updatedts DESC LIMIT 1"; break; case 'postvotes': $sql = "SELECT vote_updatedts FROM " . DB_PREFIX . "postvotes ORDER BY vote_updatedts DESC LIMIT 1"; break; case 'comments': $sql = "SELECT comment_updatedts FROM " . DB_PREFIX . "comments ORDER BY comment_updatedts DESC LIMIT 1"; break; case 'commentvotes': $sql = "SELECT cvote_updatedts FROM " . DB_PREFIX . "commentvotes ORDER BY cvote_updatedts DESC LIMIT 1"; break; case 'users': $sql = "SELECT user_updatedts FROM " . DB_PREFIX . "users ORDER BY user_updatedts DESC LIMIT 1"; break; case 'useractivity': $sql = "SELECT useract_updatedts FROM " . DB_PREFIX . "useractivity ORDER BY useract_updatedts DESC LIMIT 1"; break; case 'usermeta': $sql = "SELECT usermeta_updatedts FROM " . DB_PREFIX . "usermeta ORDER BY usermeta_updatedts DESC LIMIT 1"; break; case 'miscdata': $sql = "SELECT miscdata_updatedts FROM " . DB_PREFIX . "miscdata ORDER BY miscdata_updatedts DESC LIMIT 1"; break; case 'blocked': $sql = "SELECT blocked_updatedts FROM " . DB_PREFIX . "blocked ORDER BY blocked_updatedts DESC LIMIT 1"; break; case 'friends': $sql = "SELECT friends_updatedts FROM " . DB_PREFIX . "friends ORDER BY friends_updatedts DESC LIMIT 1"; break; default: $h->vars['smart_cache_sql'] = ''; $h->pluginHook('smart_cache_sql'); // allow plugins to add additional table checks here $sql = $h->vars['smart_cache_sql']; if (!$sql) { return false; } } // run DB query: $last_update = unixtimestamp($h->db->get_var($sql)); return $last_update; }
$WhosOnline->UpdateGuestLastActive(); } } if (in_array($Context->SelfUrl, array("account.php", "categories.php", "comments.php", "index.php", "post.php", "search.php", "settings.php")) && $Context->Session->UserID > 0 && !$Context->Session->User->Preference("HideWhosOnline")) { $ListName = $Context->GetDefinition("Who's Online"); $Panel->AddList($ListName); $online_list = $WhosOnline->GetWhosOnline(); $guest_count = $WhosOnline->GetGuestCount(); $phantom_count = 0; if ($online_list) { foreach ($online_list as $name) { if ($name["Phantom"]) { $phantom_count++; } if (!$name["Phantom"] || !isset($name["Phantom"]) || $Context->Session->User->Permission("PERMISSION_WHOS_PHANTOM")) { $TimePast = TimeDiff($Context, unixtimestamp($name["DateLastActive"])); $Panel->AddListItem($ListName, $Context->GetDefinition($name["Name"]), "account.php?u=" . $name["UserID"], NULL, "title=\"{$TimePast}\""); } } if ($phantom_count > 0) { $phantom_string = "{$phantom_count} phantom user"; if ($phantom_count > 1) { $phantom_string .= "s"; } $Panel->AddListItem($ListName, '', '', $phantom_string); } if ($guest_count > 0) { $guest_string = "{$guest_count} guest"; if ($guest_count > 1) { $guest_string .= "s"; }
function read() { global $db, $current_user; $id = $this->id; if ($this->id > 0) { $where = "user_id = {$id}"; } else { if (!empty($this->username)) { $where = "user_login='******'"; } } if (!empty($where) && ($user = $db->get_row("SELECT * FROM " . table_users . " WHERE {$where}"))) { $this->id = $user->user_id; $this->username = $user->user_login; $this->level = $user->user_level; $date = $user->user_date; $this->date = unixtimestamp($date); $date = $user->user_modification; $this->modification = unixtimestamp($date); $this->pass = $user->user_pass; $this->email = $user->user_email; $this->names = $user->user_names; $this->lang = $user->user_lang; $this->karma = $user->user_karma; $this->public_email = $user->public_email; $this->location = $user->user_location; $this->occupation = $user->user_occupation; $this->url = $user->user_url; $this->aim = $user->user_aim; $this->msn = $user->user_msn; $this->yahoo = $user->user_yahoo; $this->gtalk = $user->user_gtalk; $this->skype = $user->user_skype; $this->irc = $user->user_irc; $this->avatar_source = $user->user_avatar_source; $this->read = true; //$this->extra_field = (array)$user; (does this work in php4 ?!?) $this->extra_field = object_2_array($user); return true; } $this->read = false; return false; }
function read($data = "long") { // $data = long -- return all user data // $data = short -- return just basic info global $db, $current_user, $cached_users; if ($this->id > 0) { $where = "user_id = {$this->id}"; } else { if (!empty($this->username)) { $where = "user_login='******'"; // if we only know the users login, check the cache to see if it's // already in there and set $this->id so the code below can find it in the cache. foreach ($cached_users as $user) { if ($user->user_login == $this->username) { $this->id = $user->user_id; } } } } if (!empty($where)) { // this is a simple cache type system // when we lookup a user from the DB, store the results in memory // in case we need to lookup that user information again // good for sites where the content is submitted by the same group of people if (isset($cached_users[$this->id])) { $user = $cached_users[$this->id]; } else { if (!($user = $db->get_row("SELECT * FROM " . table_users . " WHERE {$where}"))) { return false; } if ($this->id > 0) { //only cache when the id is provided. $cached_users[$this->id] = $user; } } $this->id = $user->user_id; $this->username = $user->user_login; $this->level = $user->user_level; $this->email = $user->user_email; $this->avatar_source = $user->user_avatar_source; // if short, then stop here if ($data == 'short') { return true; } $this->names = $user->user_names; $date = $user->user_date; $this->date = unixtimestamp($date); $date = $user->user_modification; $this->modification = unixtimestamp($date); $this->pass = $user->user_pass; $this->karma = $user->user_karma; $this->public_email = $user->public_email; $this->location = $user->user_location; $this->occupation = $user->user_occupation; $this->url = $user->user_url; $this->aim = $user->user_aim; $this->msn = $user->user_msn; $this->yahoo = $user->user_yahoo; $this->gtalk = $user->user_gtalk; $this->skype = $user->user_skype; $this->irc = $user->user_irc; $this->read = true; $this->extra_field = object_2_array($user, 0, 0); return true; } $this->read = false; return false; }
echo $h->post->title; ?> <?php } ?> <?php $h->pluginHook('sb_base_show_post_title'); ?> </div> <div class="show_post_author_date"> <?php echo " " . $h->lang["sb_base_post_posted_by"] . " <a href='" . $h->url(array('user' => $user->name)) . "'>" . $user->name . "</a>"; ?> <?php echo time_difference(unixtimestamp($h->post->date), $h->lang) . " " . $h->lang["sb_base_post_ago"]; ?> <?php $h->pluginHook('sb_base_show_post_author_date'); ?> <?php if ($h->pageName != 'submit3' && ($h->currentUser->getPermission('can_edit_posts') == 'yes' || $h->currentUser->getPermission('can_edit_posts') == 'own' && $h->currentUser->id == $user->id)) { echo "<a class='show_post_edit' href='" . BASEURL . "index.php?page=edit_post&post_id=" . $h->post->id . "'>" . $h->lang["sb_base_post_edit"] . "</a>"; } ?> </div> <?php if ($h->vars['use_content']) { ?>
/** * Picks the right SQL and gets the last_update time in seconds * * @param string $table DB table name * @return int $last_update */ private function smartCacheSQL($h, $table = '') { //print "table = " . $table; /* Get the last time the table was updated */ switch ($table) { case 'plugins': $sql = "SELECT MAX(plugin_updatedts) FROM " . DB_PREFIX . $table; break; case 'pluginhooks': $sql = "SELECT MAX(plugin_updatedts) FROM " . DB_PREFIX . $table; break; case 'tags': $sql = "SELECT MAX(tags_updatedts) FROM " . DB_PREFIX . $table; break; case 'posts': $sql = "SELECT MAX(post_updatedts) FROM " . DB_PREFIX . $table; break; case 'postvotes': $sql = "SELECT MAX(vote_updatedts) FROM " . DB_PREFIX . $table; break; case 'comments': $sql = "SELECT MAX(comment_updatedts) FROM " . DB_PREFIX . $table; break; case 'commentvotes': $sql = "SELECT MAX(cvote_updatedts) FROM " . DB_PREFIX . $table; break; case 'users': $sql = "SELECT MAX(user_updatedts) FROM " . DB_PREFIX . $table; break; case 'useractivity': $sql = "SELECT MAX(useract_updatedts) FROM " . DB_PREFIX . $table; break; case 'usermeta': $sql = "SELECT MAX(usermeta_updatedts) FROM " . DB_PREFIX . $table; break; case 'miscdata': $sql = "SELECT MAX(miscdata_updatedts) FROM " . DB_PREFIX . $table; break; case 'blocked': $sql = "SELECT MAX(blocked_updatedts) FROM " . DB_PREFIX . $table; break; case 'friends': $sql = "SELECT MAX(friends_updatedts) FROM " . DB_PREFIX . $table; break; case 'settings': $sql = "SELECT MAX(settings_updatedts) FROM " . DB_PREFIX . $table; break; case 'messaging': $sql = "SELECT MAX(message_updatedts) FROM " . DB_PREFIX . $table; break; default: $h->vars['smart_cache_sql'] = ''; $h->pluginHook('smart_cache_sql'); // allow plugins to add additional table checks here $sql = $h->vars['smart_cache_sql']; if (!$sql) { return false; } } // run DB query: $last_update = unixtimestamp($h->db->get_var($sql)); return $last_update; }
function read_basic() { global $db, $current_user; $this->username = false; $this->fullread = false; $id = $this->id; if ($link = $db->get_row("SELECT link_author, link_blog, link_status, link_randkey, link_category, link_date, link_votes, link_karma, link_published_date FROM " . table_links . " WHERE link_id = {$id}")) { $this->author = $link->link_author; $this->blog = $link->link_blog; $this->votes = $link->link_votes; $this->karma = $link->link_karma; $this->status = $link->link_status; $this->randkey = $link->link_randkey; $this->category = $link->link_category; $date = $link->link_date; $this->date = unixtimestamp($date); $date = $link->link_published_date; $this->published_date = unixtimestamp($date); $this->read = true; return true; } $this->read = false; return false; }