本文整理汇总了PHP中Link::duplicates方法的典型用法代码示例。如果您正苦于以下问题:PHP Link::duplicates方法的具体用法?PHP Link::duplicates怎么用?PHP Link::duplicates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Link
的用法示例。
在下文中一共展示了Link::duplicates方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: promote_from_subs
function promote_from_subs($destination, $hours, $min_karma, $min_votes)
{
global $db;
echo "Promote to main: {$destination}\n";
$res = $db->get_results("select sub_statuses.*, link_url, link_karma, link_votes from sub_statuses, subs, links where date > date_sub(now(), interval {$hours} hour) and status = 'published' and link_karma >= {$min_karma} and sub_statuses.id = origen and subs.id = sub_statuses.id and subs.created_from = {$destination} and not subs.private and not subs.nsfw and sub_statuses.id not in (select src from subs_copy where dst={$destination}) and {$destination} not in (select id from sub_statuses as t where t.link=sub_statuses.link) and link_id = sub_statuses.link and link_votes >= {$min_votes}");
foreach ($res as $status) {
// If there are more of the same sub in queue or published, multiply minimums
$promoted = $db->get_var("select count(*) from sub_statuses where id = {$destination} and origen = {$status->id} and date > date_sub(now(), interval {$hours} hour)");
echo "PROMOTED {$status->id} -> {$destination}: {$promoted}\n";
if ($promoted > 0 && $status->link_karma < min(4, $promoted * 0.5 + 1) * $min_karma && $status->link_votes < min(4, $promoted * 0.5 + 1) * $min_votes) {
echo "Already in main {$promoted}, doesn't have minimums, {$status->link_url}\n";
continue;
}
$properties = SitesMgr::get_extended_properties($status->id);
if (!empty($properties['no_link']) && empty($status->link_url)) {
echo "NO LINK, {$status->id}\n";
// continue;
}
if (!empty($status->link_url) && Link::duplicates($status->link_url, $destination)) {
echo "Duplicated in destination, {$status->link_url}\n";
continue;
}
$status->id = $destination;
$status->status = 'queued';
echo "--->\n";
if (!DEBUG) {
SitesMgr::store($status);
}
}
}
示例2: do_submit1
function do_submit1()
{
global $db, $dblang, $current_user, $globals;
do_navbar(_('enviar noticia ') . '»' . _(' paso 2: detalles'));
echo '<div id="genericform-contents">' . "\n";
if ($globals['min_karma_for_links'] > 0 && $current_user->user_karma < $globals['min_karma_for_links']) {
echo '<p class="error"><strong>' . _('no tienes el mínimo de karma para enviar una nueva historia') . '</strong></p> ';
echo '<br style="clear: both;" />' . "\n";
echo '</div>' . "\n";
return;
}
// avoid spams, an extra security check
$from = time() - 7200;
$same_user = $db->get_var("select count(*) from links where link_date > from_unixtime({$from}) and link_author={$current_user->user_id}");
$same_ip = $db->get_var("select count(*) from links, votes where link_date > from_unixtime({$from}) and vote_type='links' and vote_link_id = link_id and vote_user_id = link_author and vote_ip_int = " . $globals['user_ip_int']);
echo "<!-- Same user: {$same_user} -->\n";
echo "<!-- Same IP: {$same_ip} -->\n";
if ($same_user > 4 || $same_ip > 4) {
echo '<p class="error"><strong>' . _('debes esperar, ya se enviaron varias con el mismo usuario o dirección IP') . '</strong></p>';
echo '<br style="clear: both;" />' . "\n";
echo '</div>' . "\n";
return;
}
$url = clean_input_url($_POST['url']);
$linkres = new Link();
$edit = false;
if ($found = $linkres->duplicates($url)) {
echo '<p class="error"><strong>' . _('noticia repetida!') . '</strong></p> ';
echo '<p class="error-text">' . _('lo sentimos') . '</p>';
echo '<p class="error-text"><a href="' . $globals['base_url'] . '?search=' . htmlspecialchars($found) . '">' . _('haz clic aquí para votar o comentar la noticia que enviaron antes') . '</a>';
echo '<br style="clear: both;" /><br style="clear: both;" />' . "\n";
echo '<form id="genericform">';
echo '<input class="genericsubmit" type=button onclick="window.history.go(-1)" value="' . _('« retroceder') . '" />';
echo '</form>' . "\n";
echo '</div>' . "\n";
return;
}
if (!$linkres->get($url)) {
echo '<p class="error"><strong>' . _('URL inválido') . ':</strong> ' . htmlspecialchars($url) . '</p>';
echo '<p>' . _('URL inválido, incompleto o no permitido') . '</p>';
// If the domain is banned, decrease user's karma
if ($linkres->banned) {
$db->query("update users set user_karma = user_karma - 0.1 where user_id = {$current_user->user_id}");
}
print_empty_submit_form();
echo '</div>' . "\n";
return;
}
$trackback = $linkres->trackback;
$linkres->randkey = intval($_POST['randkey']);
if (!$linkres->valid) {
echo '<p class="error"><strong>' . _('error leyendo el url') . ':</strong> ' . htmlspecialchars($url) . '</p>';
// Dont allow new users with low karma to post wrong URLs
if ($current_user->user_karma < 7 && $current_user->user_level == 'normal') {
echo '<p>' . _('URL inválido, incompleto o no permitido') . '</p>';
print_empty_submit_form();
return;
}
echo '<p>' . _('no es válido, está fuera de línea, o tiene mecanismos antibots, <strong>continúa</strong>, pero asegúrate que sea correcto') . '</p>';
}
// check that the user also votes, not only sends links
if ($current_user->user_karma < 7) {
$from = time() - 3600 * 24;
$user_votes = $db->get_var("select count(*) from votes where vote_type='links' and vote_date > from_unixtime({$from}) and vote_user_id={$current_user->user_id}");
$user_links = 1 + $db->get_var("select count(*) from links where link_author={$current_user->user_id} and link_date > from_unixtime({$from}) and link_status != 'discard'");
$total_links = $db->get_var("select count(*) from links where link_date > from_unixtime({$from}) and link_status = 'queued'");
$min_votes = min(4, intval($total_links / 20)) * $user_links;
if ($user_votes < $min_votes) {
$needed = $min_votes - $user_votes;
echo '<p class="error"><strong>' . _('no tienes el mínimo de votos necesarios para enviar una nueva historia') . '</strong></p> ';
echo '<p class="error-text">' . _('necesitas votar como mínimo a') . " {$needed} " . _('noticias') . ', ';
echo '<a href="' . $globals['base_url'] . 'shakeit.php" target="_blank">' . _('haz clic aquí para ir a votar') . '</a></p>';
echo '<br style="clear: both;" />' . "\n";
echo '</div>' . "\n";
return;
}
}
$linkres->status = 'discard';
$linkres->author = $current_user->user_id;
/***** Currently commented out until we find if it makes sense here
// First delete last drafts, just in case to avoid triggering the anti spam measure
$from = time() - 1800;
$db->query("delete from links where link_date > from_unixtime($from) and link_author=$current_user->user_id and link_status='discard' and link_votes = 0");
*****/
$linkres->create_blog_entry();
// avoid auto-promotion (autobombo)
$hours = 2;
$from = time() - 3600 * $hours;
$same_blog = $db->get_var("select count(*) from links where link_date > from_unixtime({$from}) and link_author={$current_user->user_id} and link_blog={$linkres->blog} and link_votes > 0");
if ($same_blog > 0 && $current_user->user_karma < 12) {
echo '<p class="error"><strong>' . _('ya has enviado un enlace al mismo sitio hace poco tiempo') . '</strong></p> ';
echo '<p class="error-text">' . _('debes esperar') . " {$hours} " . _(' horas entre cada envío al mismo sitio. Es para evitar "spams" y "autobombo"') . ', ';
echo '<a href="' . $globals['base_url'] . 'faq-' . $dblang . '.php">' . _('lee el FAQ') . '</a></p>';
echo '<br style="clear: both;" />' . "\n";
echo '</div>' . "\n";
return;
}
// Now stores new draft
$linkres->store();
echo '<h2>' . _('envío de una nueva noticia: paso 2 de 3') . '</h2>' . "\n";
//.........这里部分代码省略.........
示例3: do_submit1
function do_submit1() {
global $db, $dblang, $current_user;
do_navbar(_('enviar noticia ') . '»'. _(' paso 2: detalles'));
echo '<div id="genericform-contents">'."\n";
// avoid spams, an extra security check
$from = time() - 3600;
$same_user = $db->get_var("select count(*) from links where link_date > from_unixtime($from) and link_author=$current_user->user_id");
if ($same_user > 4) {
echo '<p class="error"><strong>'._('debes esperar'). '</strong></p>';
echo '<br style="clear: both;" />' . "\n";
echo '</div>'. "\n";
return;
}
$url = trim(preg_replace('/ /', '+', $_POST['url']));
$linkres=new Link;
$edit = false;
$linkres->get($url);
$trackback=$linkres->trackback;
$linkres->randkey = intval($_POST['randkey']);
if(!$linkres->valid) {
echo '<p class="error"><strong>'._('url no válido').':</strong> ('.$url.')</p>';
echo '<p>'._('prueba con otra dirección').'</p>';
print_empty_submit_form();
return;
}
// avoid auto-promotion (autobombo)
$hours = 4;
$from = time() - 3600*$hours;
$same_blog = $db->get_var("select count(*) from links where link_date > from_unixtime($from) and link_author=$current_user->user_id and link_blog=$linkres->blog and link_votes > 0");
if ($same_blog > 0 && $current_user->user_karma < 12) {
echo '<p class="error"><strong>'._('ya has enviado un enlace al mismo sitio hace poco tiempo').'</strong></p> ';
echo '<p class="error-text">'._('debes esperar'). " $hours " . _(' horas entre cada envío al mismo sitio. Es para evitar "spams" y "autobombo"') . ', ';
echo '<a href="faq-'.$dblang.'.php">'._('lee el FAQ').'</a></p>';
echo '<br style="clear: both;" />' . "\n";
echo '</div>'. "\n";
return;
}
// check that the user also votes, not only sends links
if ($current_user->user_karma < 10) {
$from = time() - 3600*24;
$user_votes = $db->get_var("select count(*) from votes where vote_type='links' and vote_date > from_unixtime($from) and vote_user_id=$current_user->user_id");
$user_links = 1 + $db->get_var("select count(*) from links where link_author=$current_user->user_id and link_date > from_unixtime($from) and link_status != 'discard'");
$total_links = $db->get_var("select count(*) from links where link_date > from_unixtime($from) and link_status = 'queued'");
$min_votes = intval($total_links/20) * $user_links;
if ($user_votes < $min_votes) {
$needed = $min_votes - $user_votes;
echo '<p class="error"><strong>'._('no tienes el mínimo de votos necesarios para enviar una nueva historia').'</strong></p> ';
echo '<p class="error-text">'._('necesitas votar como mínimo a'). " $needed " . _('noticias') . ', ';
echo '<a href="shakeit.php" target="_blank">'._('haz clic aquí para ir a votar').'</a></p>';
echo '<br style="clear: both;" />' . "\n";
echo '</div>'. "\n";
return;
}
}
if($linkres->duplicates($url) > 0) {
echo '<p class="error"><strong>'._('noticia repetida!').'</strong></p> ';
echo '<p class="error-text">'._('lo sentimos').'</p>';
echo '<p class="error-text"><a href="index.php?search='.htmlentities($url).'">'._('haz clic aquí para votar o comentar la noticia que enviaron antes').'</a>';
echo '<br style="clear: both;" /><br style="clear: both;" />' . "\n";
echo '<form id="genericform">';
echo '<input class="genericsubmit" type=button onclick="window.history.go(-1)" value="'._('« retroceder').'" />';
echo '</form>'. "\n";
echo '</div>'. "\n";
return;
}
$linkres->status='discard';
$linkres->author=$current_user->user_id;
/***** Currently commented out until we find if it makes sense here
// First delete last drafts, just in case to avoid triggering the anti spam measure
$from = time() - 1800;
$db->query("delete from links where link_date > from_unixtime($from) and link_author=$current_user->user_id and link_status='discard' and link_votes = 0");
*****/
// Now stores new draft
$linkres->store();
echo '<h2>'._('envío de una nueva noticia: paso 2 de 3').'</h2>'."\n";
echo '<div id="genericform">'."\n";
echo '<form action="/submit.php" method="post" id="thisform">'."\n";
echo '<input type="hidden" name="url" id="url" value="'.$url.'" />'."\n";
echo '<input type="hidden" name="phase" value="2" />'."\n";
echo '<input type="hidden" name="randkey" value="'.intval($_POST['randkey']).'" />'."\n";
echo '<input type="hidden" name="id" value="'.$linkres->id.'" />'."\n";
echo '<fieldset><legend><span class="sign">'._('info de la noticia').'</span></legend>'."\n";
echo '<p class="genericformtxt"><label for="url_title" accesskey="1">'._('título de la página').': </label> '."\n";
echo $linkres->url_title;
if($linkres->type() === 'blog') {
echo '<br /> ('._('parece ser un blog').')</p>'."\n";
//.........这里部分代码省略.........
示例4: report_dupe
function report_dupe($url) {
global $globals;
$link = new Link;
if(($found = $link->duplicates($url))) {
$dupe = new Link;
$dupe->id = $found;
$dupe->read();
echo '<p class="error"><strong>'._('noticia repetida').'</strong></p> ';
echo '<p class="error-text">'._('disculpas').'</p>';
$dupe->print_summary();
echo '<br style="clear: both;" /><br/>' . "\n";
echo '<form class="genericform" action="">';
echo '<input class="button" type="button" onclick="window.history.go(-1)" value="« '._('retroceder').'" />';
echo '</form>'. "\n";
echo '</div>'. "\n";
return true;
}
return false;
}
示例5: do_the_import_stuff
//.........这里部分代码省略.........
// strip all except letters and spaces and commas
$linkres->tags = preg_replace('/[^a-z A-Z,]+/i', '', $temp1);
}
//----------------------------------------------------------------------
if (checklevel('god')) {
$Story_Content_Tags_To_Allow = Story_Content_Tags_To_Allow_God;
} elseif (checklevel('admin')) {
$Story_Content_Tags_To_Allow = Story_Content_Tags_To_Allow_Admin;
} else {
$Story_Content_Tags_To_Allow = Story_Content_Tags_To_Allow_Normal;
}
$linkres->title_url = makeUrlFriendly($linkres->title);
$linkres->url = get_val($item, $MyArray['link_url']);
$linkres->url_title = $linkres->title;
$linkres->content = get_val($item, $MyArray['content']);
$linkres->content = strip_tags($linkres->content, $Story_Content_Tags_To_Allow);
$linkres->content = str_replace("\n", "<br />", $linkres->content);
$linkres->link_field1 = get_val($item, $MyArray['link_field1']);
$linkres->link_field2 = get_val($item, $MyArray['link_field2']);
$linkres->link_field3 = get_val($item, $MyArray['link_field3']);
$linkres->link_field4 = get_val($item, $MyArray['link_field4']);
$linkres->link_field5 = get_val($item, $MyArray['link_field5']);
$linkres->link_field6 = get_val($item, $MyArray['link_field6']);
$linkres->link_field7 = get_val($item, $MyArray['link_field7']);
$linkres->link_field8 = get_val($item, $MyArray['link_field8']);
$linkres->link_field9 = get_val($item, $MyArray['link_field9']);
$linkres->link_field10 = get_val($item, $MyArray['link_field10']);
$linkres->link_field11 = get_val($item, $MyArray['link_field11']);
$linkres->link_field12 = get_val($item, $MyArray['link_field12']);
$linkres->link_field13 = get_val($item, $MyArray['link_field13']);
$linkres->link_field14 = get_val($item, $MyArray['link_field14']);
$linkres->link_field15 = get_val($item, $MyArray['link_field15']);
$linkres->category = $feed->feed_category;
//MJE: MOD
$linkres->link_summary = utf8_substr(strip_tags($linkres->content), 0, StorySummary_ContentTruncate - 1);
//---------
if ($thecount >= $feed->feed_item_limit && $skipthis == 0) {
echo "Reached import limit, skipping<HR>";
$skipthis = 1;
}
if ($feed->feed_title_dupe == 0 && $skipthis == 0) {
// 0 means don't allow, 1 means allow
if ($linkres->duplicates_title($linkres->title) > 0) {
//echo "Title Match, skipping: " . $linkres->title . "<HR>";
echo '<span style="color:#fc0000;">Title Match, skipping</span> <hr>';
$skipthis = 1;
}
}
if ($feed->feed_url_dupe == 0 && $linkres->url != "" && $skipthis == 0) {
// 0 means don't allow, 1 means allow
if ($linkres->duplicates($linkres->url) > 0) {
//echo "URL Match, skipping: " . $linkres->title . "<HR>";
echo '<span style="color:#fc0000;">URL Match, skipping</span> <hr>';
$skipthis = 1;
}
}
if ($skipthis == 0) {
echo "Importing <hr>";
$added_one = true;
$linkres->store();
totals_adjust_count($linkres->status, 1);
tags_insert_string($linkres->id, $dblang, $linkres->tags);
require_once mnminclude . 'votes.php';
if ($feed->feed_random_vote_enable == 1) {
$feed->feed_votes = rand($feed->feed_random_vote_min, $feed->feed_random_vote_max);
}
$votes = 0;
for ($i = 1; $i <= $feed->feed_votes; $i++) {
$value = 1;
$vote = new Vote();
$vote->type = 'links';
$vote->user = 0;
$vote->link = $linkres->id;
$vote->ip = '0.0.0.' . $i;
$vote->value = $value;
$vote->insert();
$vote = "";
$votes += $value;
// $vote = new Vote;
// $vote->type='links';
// $vote->link=$linkres->id;
}
$linkres->votes = $votes;
$linkres->store_basic();
$linkres->check_should_publish();
$thecount = $thecount + 1;
}
}
$sql = "UPDATE `" . table_feeds . "` SET `feed_last_check` = FROM_UNIXTIME(" . (time() - 300) . ") WHERE `feed_id` = {$feed->feed_id};";
//echo $sql;
$db->query($sql);
} else {
echo "Feed not fully setup, skipping <hr>";
}
if ($added_one) {
return true;
} else {
return false;
}
}
示例6: Vote
$linkres->category = $feed->feed_category;
$linkres->link_summary = utf8_substr($linkres->content, 0, StorySummary_ContentTruncate - 1);
if ($thecount >= $feed->feed_item_limit && $skipthis == 0) {
echo "Reached import limit, skipping<HR>";
$skipthis = 1;
}
if ($feed->feed_title_dupe == 0 && $skipthis == 0) {
// 0 means don't allow, 1 means allow
if ($linkres->duplicates_title($linkres->title) > 0) {
echo "Title Match, skipping: " . $linkres->title . "<HR>";
$skipthis = 1;
}
}
if ($feed->feed_url_dupe == 0 && $linkres->url != "" && $skipthis == 0) {
// 0 means don't allow, 1 means allow
if ($linkres->duplicates($linkres->url) > 0) {
echo "URL Match, skipping: " . $linkres->title . "<HR>";
$skipthis = 1;
}
}
if ($skipthis == 0) {
echo "Importing <hr>";
$linkres->store();
tags_insert_string($linkres->id, $dblang, $linkres->tags);
require_once mnminclude . 'votes.php';
for ($i = 1; $i <= $feed->feed_votes; $i++) {
$value = 10;
$vote = new Vote();
$vote->type = 'links';
$vote->user = 0;
$vote->link = $linkres->id;
示例7: report_duplicated
function report_duplicated($url)
{
global $globals;
if ($found = Link::duplicates($url)) {
$link = new Link();
$link->id = $found;
$link->read();
Haanga::Load('link/duplicated.html', compact('link'));
return true;
}
return false;
}
示例8: do_submit1
function do_submit1()
{
global $main_smarty, $db, $dblang, $current_user, $the_template;
$url = htmlspecialchars(strip_tags(trim($_POST['url'])));
$url = html_entity_decode($url);
// thanks czytom
$linkres = new Link();
$linkres->randkey = strip_tags($_POST['randkey']);
if (Submit_Show_URL_Input == false) {
$url = "http://";
$linkres->randkey = rand(10000, 10000000);
}
$Submit_Show_URL_Input = Submit_Show_URL_Input;
if ($url == "http://" || $url == "") {
$Submit_Show_URL_Input = false;
}
$main_smarty->assign('randkey', $linkres->randkey);
$main_smarty->assign('submit_url', $url);
$main_smarty->assign('Submit_Show_URL_Input', $Submit_Show_URL_Input);
$main_smarty->assign('Submit_Require_A_URL', Submit_Require_A_URL);
$edit = false;
$linkres->get($url);
$trackback = $linkres->trackback;
if ($url == "http://" || $url == "") {
if (Submit_Require_A_URL == false) {
$linkres->valid = true;
} else {
$linkres->valid = false;
}
}
if (!$linkres->valid) {
$main_smarty->assign('submit_error', 'invalidurl');
$main_smarty->assign('tpl_center', $the_template . '/submit_errors');
define('pagename', 'submit');
$main_smarty->assign('pagename', pagename);
$main_smarty->display($the_template . '/pligg.tpl');
return;
}
if (Submit_Require_A_URL == true || $url != "http://" && $url != "") {
if ($linkres->duplicates($url) > 0) {
$main_smarty->assign('submit_search', getmyurl("search", htmlentities($url)));
$main_smarty->assign('submit_error', 'dupeurl');
$main_smarty->assign('tpl_center', $the_template . '/submit_errors');
define('pagename', 'submit');
$main_smarty->assign('pagename', pagename);
$main_smarty->display($the_template . '/pligg.tpl');
return;
}
}
check_actions('submit_validating_url', array("url" => $url));
$linkres->status = 'discard';
$linkres->author = $current_user->user_id;
$linkres->store();
$main_smarty->assign('StorySummary_ContentTruncate', StorySummary_ContentTruncate);
$main_smarty->assign('SubmitSummary_Allow_Edit', SubmitSummary_Allow_Edit);
$main_smarty->assign('enable_tags', Enable_Tags);
$main_smarty->assign('submit_url_title', $linkres->url_title);
$main_smarty->assign('submit_id', $linkres->id);
$main_smarty->assign('submit_type', $linkres->type());
if (isset($link_title)) {
$main_smarty->assign('submit_title', $link_title);
}
if (isset($link_content)) {
$main_smarty->assign('submit_content', $link_content);
}
$main_smarty->assign('submit_trackback', $trackback);
$main_smarty->assign('submit_link_field1', $linkres->link_field1);
$main_smarty->assign('submit_link_field2', $linkres->link_field2);
$main_smarty->assign('submit_link_field3', $linkres->link_field3);
$main_smarty->assign('submit_link_field4', $linkres->link_field4);
$main_smarty->assign('submit_link_field5', $linkres->link_field5);
$main_smarty->assign('submit_link_field6', $linkres->link_field6);
$main_smarty->assign('submit_link_field7', $linkres->link_field7);
$main_smarty->assign('submit_link_field8', $linkres->link_field8);
$main_smarty->assign('submit_link_field9', $linkres->link_field9);
$main_smarty->assign('submit_link_field10', $linkres->link_field10);
$main_smarty->assign('submit_link_field11', $linkres->link_field11);
$main_smarty->assign('submit_link_field12', $linkres->link_field12);
$main_smarty->assign('submit_link_field13', $linkres->link_field13);
$main_smarty->assign('submit_link_field14', $linkres->link_field14);
$main_smarty->assign('submit_link_field15', $linkres->link_field15);
$catsql = mysql_query("SELECT category_id, category_name FROM " . table_categories . " WHERE category_lang='{$dblang}' ORDER BY category_name ASC");
$categories = array();
while ($rows = mysql_fetch_array($catsql, MYSQL_ASSOC)) {
array_push($categories, $rows);
}
$main_smarty->assign('categories', $categories);
include_once mnminclude . 'dbtree.php';
$array = tree_to_array(0, table_categories, FALSE);
$main_smarty->assign('lastspacer', 0);
$main_smarty->assign('cat_array', $array);
//spellchecker
$main_smarty->assign('Spell_Checker', Spell_Checker);
$main_smarty->assign('tpl_extra_fields', $the_template . '/submit_extra_fields');
$main_smarty->assign('tpl_center', $the_template . '/submit_step_2');
define('pagename', 'submit');
$main_smarty->assign('pagename', pagename);
$main_smarty->display($the_template . '/pligg.tpl');
}