function link_errors($linkres) { global $main_smarty, $the_template, $cached_categories; $error = false; if (Submit_Require_A_URL && ($linkres->url == "http://" || $linkres->url == "")) { $main_smarty->assign('submit_error', 'invalidurl'); $error = true; } // if story title or description is too short $story = preg_replace('/[\\s]+/', ' ', strip_tags($linkres->content)); if (utf8_strlen($linkres->title) < minTitleLength || utf8_strlen($story) < minStoryLength) { $main_smarty->assign('submit_error', 'incomplete'); $error = true; } if (utf8_strlen($linkres->title) > maxTitleLength) { $main_smarty->assign('submit_error', 'long_title'); $error = true; } if (utf8_strlen($linkres->content) > maxStoryLength) { $main_smarty->assign('submit_error', 'long_content'); $error = true; } if (utf8_strlen($linkres->tags) > maxTagsLength) { $main_smarty->assign('submit_error', 'long_tags'); $error = true; } if (utf8_strlen($linkres->summary) > maxSummaryLength) { $main_smarty->assign('submit_error', 'long_summary'); $error = true; } // if URL is submitted in story title if (preg_match('/.*http:\\//', $linkres->title)) { $main_smarty->assign('submit_error', 'urlintitle'); $error = true; } // if no category is selected if (!$linkres->category > 0) { $main_smarty->assign('submit_error', 'nocategory'); $error = true; } foreach ($cached_categories as $cat) { if ($cat->category__auto_id == $linkres->category && !allowToAuthorCat($cat)) { // category does not allow authors of this level $main_smarty->assign('submit_error', 'nocategory'); $error = true; } } if ($error) { $main_smarty->assign('tpl_center', $the_template . '/submit_errors_center'); $main_smarty->assign('link_id', $_GET['id']); // pagename define('pagename', 'editlink'); $main_smarty->assign('pagename', pagename); // show the template $main_smarty->display($the_template . '/pligg.tpl'); } return $error; }
function link_errors($linkres) { global $main_smarty, $the_template, $cached_categories; $error = false; if (sanitize($_POST['randkey'], 3) !== $linkres->randkey) { // random key error $main_smarty->assign('submit_error', 'badkey'); $error = true; } if ($linkres->status != 'discard' && $linkres->status != 'draft') { // if link has already been submitted $main_smarty->assign('submit_error', 'hashistory'); $main_smarty->assign('submit_error_history', $linkres->status); $error = true; } $story = preg_replace('/[\\s]+/', ' ', strip_tags($linkres->content)); if (utf8_strlen($linkres->title) < minTitleLength || utf8_strlen($story) < minStoryLength) { $main_smarty->assign('submit_error', 'incomplete'); $error = true; } if (utf8_strlen($linkres->title) > maxTitleLength) { $main_smarty->assign('submit_error', 'long_title'); $error = true; } if (utf8_strlen($linkres->content) > maxStoryLength) { $main_smarty->assign('submit_error', 'long_content'); $error = true; } if (utf8_strlen($linkres->tags) > maxTagsLength) { $main_smarty->assign('submit_error', 'long_tags'); $error = true; } if (utf8_strlen($linkres->summary) > maxSummaryLength) { $main_smarty->assign('submit_error', 'long_summary'); $error = true; } if (preg_match('/.*http:\\//', $linkres->title)) { // if URL is found in link title $main_smarty->assign('submit_error', 'urlintitle'); $error = true; } if (!$linkres->category > 0) { // if no category is selected $main_smarty->assign('submit_error', 'nocategory'); $error = true; } foreach ($cached_categories as $cat) { if ($cat->category__auto_id == $linkres->category && !allowToAuthorCat($cat)) { // category does not allow authors of this level $main_smarty->assign('submit_error', 'nocategory'); $error = true; } } if ($error == true) { $main_smarty->assign('link_id', $linkres->id); $main_smarty->assign('tpl_center', $the_template . '/submit_errors'); $main_smarty->display($the_template . '/pligg.tpl'); die; } return $error; }
function link_errors($linkres) { global $main_smarty, $the_template, $cached_categories; $error = false; if (sanitize($_POST['randkey'], 3) !== $linkres->randkey) { // random key error $main_smarty->assign('submit_error', 'badkey'); $error = true; } if ($linkres->status != 'discard') { // if link has already been submitted $main_smarty->assign('submit_error', 'hashistory'); $main_smarty->assign('submit_error_history', $linkres->status); $error = true; } if (strlen($linkres->title) < minTitleLength || strlen($linkres->content) < minStoryLength) { // if link title or descrition is too short $main_smarty->assign('submit_error', 'incomplete'); $error = true; } if (preg_match('/.*http:\\//', $linkres->title)) { // if URL is found in link title $main_smarty->assign('submit_error', 'urlintitle'); $error = true; } if (!$linkres->category > 0) { // if no category is selected $main_smarty->assign('submit_error', 'nocategory'); $error = true; } foreach ($cached_categories as $cat) { if ($cat->category__auto_id == $linkres->category && !allowToAuthorCat($cat)) { // category does not allow authors of this level $main_smarty->assign('submit_error', 'nocategory'); $error = true; } } if ($error == true) { $main_smarty->assign('tpl_center', $the_template . '/submit_errors'); $main_smarty->display($the_template . '/pligg.tpl'); die; } return $error; }