ini_set('default_socket_timeout', 2); $db->connect_timeout = 2; if (!empty($_REQUEST['rows'])) { $rows = min(2000, intval($_REQUEST['rows'])); } else { $rows = 100; } // Compatibility with the old "search" query string if ($_REQUEST['search']) { $_REQUEST['q'] = $_REQUEST['search']; } // Sub if ($_REQUEST['sub']) { $sub_id = SitesMgr::get_id(mb_substr($_REQUEST['sub'], 20)); if ($sub_id) { SitesMgr::__init($sub_id); } else { die; } } else { $site_id = SitesMgr::my_id(); } $site_info = SitesMgr::get_info(); if ($site_info->sub && $site_info->owner > 0) { $site_info->name = $site_info->name; } if (!empty($_REQUEST['id']) && intval($_REQUEST['id']) > 0) { // // Comments // $id = intval($_REQUEST['id']);
#! /usr/bin/env php <?php // Check which hostname server we run for, for example: mnm, emnm, etc. $site_name = $argv[2]; include dirname(__FILE__) . '/../www/config.php'; include mnminclude . 'external_post.php'; $my_id = SitesMgr::get_id($site_name); if (!$my_id > 0) { syslog(LOG_INFO, "Meneame, " . basename(__FILE__) . " site not found {$site_name}"); echo "No site id found\n"; die; } SitesMgr::__init($my_id); syslog(LOG_INFO, "Meneame, running " . basename(__FILE__) . " for {$site_name}"); $info = SitesMgr::get_info(); $properties = SitesMgr::get_extended_properties(); if (intval($argv[1]) > 0) { $hours = intval($argv[1]); } else { $hours = 1; } $key = "post_best_comment_{$my_id}"; $previous = Annotation::get_text($key); if ($previous) { $extra = "AND comment_id not in ({$previous})"; } $now = intval(time() / 60) * 60; $coef = 0.8; $min_karma = $globals['comment_highlight_karma'] * 2; $min_value = $globals['comment_highlight_karma']; $min_length = 400;
echo "STARTING delete non validated users\n"; // Delete not validated users $db->query("delete from users where user_date < date_sub(now(), interval 12 hour) and user_date > date_sub(now(), interval 24 hour) and user_validated_date is null"); echo "STARTING delete old bad links\n"; // Delete old bad links $minutes = intval($globals['draft_time'] / 60); $ids = $db->get_col("select link_id from links where link_status='discard' and link_date > date_sub(now(), interval 24 hour) and link_date < date_sub(now(), interval {$minutes} minute) and link_votes = 0 order by link_id asc"); if ($ids) { $ids_str = implode(',', $ids); echo "Deleting {$ids_str}\n"; $db->query("delete from links where link_id in ({$ids_str})"); } $sites = SitesMgr::get_active_sites(); foreach ($sites as $site) { echo "START SITE: {$site}\n"; SitesMgr::__init($site); $site_info = SitesMgr::get_info($site_id); if ($site_info->owner == 0) { // Only depublish in main subs depublish($site); } if ($site_info->sub) { // Only discard in the subs discard($site); } } punish_comments(); // END function discard($site_id) { global $db, $globals, $max_date, $min_date;
function publish($site, $link) { global $globals, $db; $site_info = SitesMgr::get_info($site); if (DEBUG) { return; } // Calculate votes average // it's used to calculate and check future averages $votes_avg = (double) $db->get_var("select SQL_NO_CACHE avg(vote_value) from votes, users where vote_type='links' AND vote_link_id={$link->id} and vote_user_id > 0 and vote_value > 0 and vote_user_id = user_id and user_level !='disabled'"); if ($votes_avg < $globals['users_karma_avg']) { $link->votes_avg = max($votes_avg, $globals['users_karma_avg'] * 0.97); } else { $link->votes_avg = $votes_avg; } $link->status = 'published'; $link->date = $link->published_date = time(); $db->transaction(); $db->query("update links set link_status='published', link_date=now(), link_votes_avg={$link->votes_avg} where link_id={$link->id}"); SitesMgr::deploy($link); $db->commit(); // Increase user's karma $user = new User($link->author); if ($site_info->sub) { $karma_bonus = $globals['instant_karma_per_published'] / 10; // currently these published don't receive extra karma $log = false; } else { $karma_bonus = $globals['instant_karma_per_published']; $log = _('noticia publicada'); } if ($user->read) { $user->add_karma($karma_bonus, $log); } // Add the publish event/log Log::insert('link_publish', $link->id, $link->author); $link->annotation .= _('publicación') . "<br/>"; $link->save_annotation('link-karma'); // read twitter and facebok configuration from subs' extended info if (!$site_info->sub || $site_info->visible) { // Only post if it's not a sub or it's visible (dmnm in mnm, f.e.) syslog(LOG_INFO, "Meneame, calling: " . dirname(__FILE__) . "/post_link.php {$site_info->name} {$link->id}"); passthru(dirname(__FILE__) . "/post_link.php {$site_info->name} {$link->id} published"); } // Publish the links of the source subs if ($site_info->meta && ($senders = SitesMgr::get_senders($site))) { if (in_array($link->sub_id, $senders) && $link->sub_status_origen == 'queued') { syslog(LOG_INFO, "Meneame, publishing for sender {$link->sub_name} ({$link->sub_id})"); // "Simulate" the other site, needed for deploy SitesMgr::__init($link->sub_id); publish($link->sub_id, $link); SitesMgr::__init($site); // Back to the original site } } return; }