static function insert($type, $ref_id, $user_id = 0, $annotation = false) { global $db, $globals; if ($globals['behind_load_balancer'] && $globals['form_user_ip']) { // If the page stored the "real IP" in a form $ip = $globals['form_user_ip']; $ip_int = inet_ptod($globals['form_user_ip']); } else { $ip = $globals['user_ip']; $ip_int = $globals['user_ip_int']; } $sub = SitesMgr::my_parent(); // Get this subsite's parent id (or itself if it's a parent) $res = $db->query("insert into logs (log_sub, log_date, log_type, log_ref_id, log_user_id, log_ip_int, log_ip) values ({$sub}, now(), '{$type}', {$ref_id}, {$user_id}, {$ip_int}, '{$ip}')"); if ($res && $annotation) { $a = new Annotation('log-' . $db->insert_id); $a->text = $annotation; $a->store(time() + 86400 * 30); // Valid for one month } return $res; }
$last_timestamp = $time_f; if (!empty($_REQUEST['items']) && intval($_REQUEST['items']) > 0) { $max_items = intval($_REQUEST['items']); } if ($max_items < 1 || $max_items > 100) { $max_items = 100; // Avoid abuse } if (empty($_REQUEST['novote']) || empty($_REQUEST['noproblem'])) { get_votes($dbtime); } // Get the logs if ($current_user->admin) { $site_filter = ''; } else { $site_filter = 'and log_sub = ' . SitesMgr::my_parent(); } $logs = $db->get_results("select UNIX_TIMESTAMP(log_date) as time, log_type, log_ref_id, log_user_id from logs where log_type != 'login_failed' and log_date > {$dbtime} {$site_filter} order by log_date desc limit {$max_items}"); if ($logs) { foreach ($logs as $log) { if ($current_user->user_id > 0) { if (!empty($_REQUEST['friends']) && $log->log_user_id != $current_user->user_id) { // Check the user is a friend if (User::friend_exists($current_user->user_id, $log->log_user_id) <= 0) { continue; } } elseif (!empty($_REQUEST['admin']) && $current_user->admin) { $user_level = $db->get_var("select user_level from users where user_id={$log->log_user_id}"); if ($user_level != 'admin' && $user_level != 'god') { continue; }
<?php // The source code packaged with this file is Free Software, Copyright (C) 2005 by // Ricardo Galli <gallir at uib dot es>. // It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise. // You can get copies of the licenses here: // http://www.affero.org/oagpl.html // AFFERO GENERAL PUBLIC LICENSE is also included in the file called "COPYING". include 'config.php'; include mnminclude . 'html1.php'; $globals['ads'] = false; promote_style(); do_header(_('promote') . ' | ' . _('menéame')); echo '<div id="singlewrap">' . "\n"; $site_id = SitesMgr::my_parent(); $annotation = new Annotation("promote-{$site_id}"); $annotation->text = $output; if ($annotation->read()) { echo $annotation->text; } echo '</div>' . "\n"; do_footer_menu(); do_footer(); function promote_style() { global $globals; $globals['extra_head'] = ' <style type="text/css"> p { font-family: Bitstream Vera Sans, Arial, Helvetica, sans-serif; font-size: 90%;
static function duplicates($url) { global $db; $trimmed = $db->escape(preg_replace('/\\/$/', '', $url)); $list = "'{$trimmed}', '{$trimmed}/'"; if (preg_match('/^http.{0,1}:\\/\\/www\\./', $trimmed)) { $link_alternative = preg_replace('/^(http.{0,1}):\\/\\/www\\./', '$1://', $trimmed); } else { $link_alternative = preg_replace('/^(http.{0,1}):\\/\\//', '$1://www.', $trimmed); } $list .= ", '{$link_alternative}', '{$link_alternative}/'"; /* Alternative to http and https */ if (preg_match('/^http:/', $url)) { $list2 = preg_replace('/http:\\/\\//', 'https://', $list); } else { $list2 = preg_replace('/https:\\/\\//', 'http://', $list); } $list .= ", {$list2}"; $site_id = SitesMgr::my_id(); $filter_by_site_sql = "(sub_statuses.id = {$site_id} "; $site_parent = SitesMgr::my_parent(); if ($site_parent > 0 && $site_parent != $site_id) { $filter_by_site_sql .= " OR sub_statuses.id = {$site_parent} "; } $site_children = SitesMgr::get_children($site_id); // array if (is_array($site_children) && count($site_children) > 0) { $filter_by_site_sql .= " OR sub_statuses.id in (" . implode(',', $site_children) . ")"; } $filter_by_site_sql .= ")"; // If it was abuse o autodiscarded allow other to send it again $found = $db->get_var("SELECT link_id FROM links, sub_statuses WHERE link_url in ({$list}) AND link_status not in ('abuse') AND link_votes > 0 AND sub_statuses.link = link_id AND {$filter_by_site_sql} ORDER by link_id asc limit 1"); return $found; }