/** * Elimina un artículo de la base de datos */ function deletePost() { global $xoopsSecurity; $posts = rmc_server_var($_POST, 'posts', array()); if (empty($posts)) { redirectMsg('posts.php', __('Select one post at least!', 'mywords'), 1); die; } if (!$xoopsSecurity->check()) { redirectMsg('posts.php', __('Session token expired!', 'mywords'), 1); die; } $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix("mod_mywords_posts") . " WHERE id_post IN (" . implode(",", $posts) . ")"; $result = $db->query($sql); while ($row = $db->fetchArray($result)) { $post = new MWPost(); $post->assignVars($row); if (!$post->delete()) { showMessage(sprintf(__('Errors ocurred while deleting "%s"', 'mw_categories'), $post->getVar('title')), 1); } RMFunctions::delete_comments('mywords', urlencode('post=' . $post->id())); } redirectMsg('posts.php', __('Database updated!', 'mw_categories'), 0); }
/** * Check if given post already exists * @param object MWPost object * @return bool */ public function post_exists(MWPost &$post) { if ($post->getVar('title', 'n') == '') { return false; } // the pubdate if ($post->getVar('pubdate') <= 0) { $day = date('j', $post->getVar('schedule')); $month = date('n', $post->getVar('schedule')); $year = $day = date('Y', $post->getVar('schedule')); $bdate = mktime(0, 0, 0, $month, $day, $year); $tdate = mktime(23, 59, 59, $month, $day, $year); } else { $day = date('j', $post->getVar('pubdate')); $month = date('n', $post->getVar('pubdate')); $year = date('Y', $post->getVar('pubdate')); $bdate = mktime(0, 0, 0, $month, $day, $year); $tdate = $bdate + 86400; } $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT COUNT(*) FROM " . $db->prefix("mw_posts") . " WHERE (pubdate>={$bdate} AND pubdate<={$tdate}) AND \n \t\t(title='" . $post->getVar('title', 'n') . "' OR shortname='" . $post->getVar('shortname', 'n') . "')"; if (!$post->isNew()) { $sql .= " AND id_post<>" . $post->id(); } list($num) = $db->fetchRow($db->query($sql)); if ($num > 0) { return true; } return false; }
// The id of the item being trackbacked $url = $track->url; // The URL from which we got the trackback $title = $track->title; // Subject/title send by trackback $excerpt = $track->excerpt; // Short text send by trackback $blog_name = rmc_server_var($_POST, 'blog_name', ''); if ($url == '' || $title == '' || $excerpt == '') { echo $track->recieve(false, __('Sorry, your trackback seems to be invalid!', 'mywords')); die; } $params = array('blogurl' => MWFunctions::get_url(), 'name' => 'Trackback', 'email' => '', 'url' => $url, 'text' => $excerpt, 'permalink' => $post->permalink()); $ret = RMEvents::get()->run_event('rmcommon.check.post.spam', $params); if (!$ret) { echo $track->recieve(false, __('Sorry, your trackback seems to be SPAM', 'mywords')); } else { $to = new MWTrackbackObject(); $to->setVar('date', time()); $to->setVar('title', $title); $to->setVar('blog_name', $blog_name); $to->setVar('excerpt', $excerpt); $to->setVar('url', $url); $to->setVar('post', $post->id()); if ($to->save()) { echo $track->recieve(true); } else { echo $track->recieve(false, __('We are unable to store your trackback. Please try again later!', 'mywords')); } } die;
$path = explode("/", $request); $srh = array_search('page', $path); if (isset($path[$srh]) && $path[$srh] == 'page') { if (!isset($path[$srh])) { $page = 1; } else { $page = $path[$srh + 1]; } } else { $page = 1; } } $post->add_read(); // Navegación entre artículos if ($xoopsModuleConfig['shownav']) { $sql = "SELECT * FROM " . $db->prefix("mw_posts") . " WHERE id_post<" . $post->id() . " AND status='publish' ORDER BY id_post DESC LIMIT 0, 1"; $result = $db->query($sql); $pn = new MWPost(); // Anterior if ($db->getRowsNum($result) > 0) { $pn->assignVars($db->fetchArray($result)); $xoopsTpl->assign('prev_post', array('link' => $pn->permalink(), 'title' => $pn->getVar('title'))); } // Siguiente $sql = "SELECT * FROM " . $db->prefix("mw_posts") . " WHERE id_post>" . $post->id() . " AND status='publish' ORDER BY id_post ASC LIMIT 0, 1"; $result = $db->query($sql); if ($db->getRowsNum($result) > 0) { $pn->assignVars($db->fetchArray($result)); $xoopsTpl->assign('next_post', array('link' => $pn->permalink(), 'title' => $pn->getVar('title'))); } }
$editors[$post->getVar('author')]->uid = $user->uid(); $editors[$post->getVar('author')]->name = $user->getVar('name'); $editors[$post->getVar('author')]->shortname = $user->getVar('uname'); $editors[$post->getVar('author')]->privileges = array('tags', 'tracks', 'comms'); $editors[$post->getVar('author')]->save(); } $editor = $editors[$post->getVar('author')]; $alink = $editor->permalink(); } else { $alink = ''; } # Información de Publicación $published = sprintf(__('%s by %s', 'mywords'), MWFunctions::format_time($post->getVar('pubdate'), 'string'), '<a href="' . $alink . '">' . (isset($editor) ? $editor->name : __('Anonymous', 'mywords')) . "</a>"); # Texto de continuar leyendo if ($post->getVar('visibility') == 'password') { $text = isset($_SESSION['password-' . $post->id()]) && $_SESSION['password-' . $post->id()] == $post->getVar('password') ? $post->content(true) : MWFunctions::show_password($post); } else { $text = $post->content(true); } // Redes Sociales if ($xoopsModuleConfig['showbookmarks']) { $bms = array(); foreach ($socials as $bm) { $bms[] = array('icon' => $bm->getVar('icon'), 'alt' => $bm->getVar('alt'), 'link' => str_replace(array('{URL}', '{TITLE}', '{DESC}'), array($post->permalink(), $post->getVar('title'), TextCleaner::getInstance()->truncate($text, 50)), $bm->getVar('url'))); } } $xoopsTpl->append('posts', array('id' => $post->id(), 'title' => $post->getVar('title'), 'format' => $post->getVar('format'), 'text' => $text, 'description' => $post->getVar('description'), 'keywords' => $post->getVar('keywords'), 'cats' => $post->get_categos('data'), 'link' => $link, 'published' => $published, 'comments' => $post->getVar('comments'), 'lang_comments' => sprintf(__('%u Comments', 'mywords'), $post->getVar('comments')), 'continue' => $post->hasmore_text(), 'lang_continue' => $post->hasmore_text() ? sprintf(__('Read more about "%s"', 'mywords'), $post->getVar('title')) : '', 'bookmarks' => $bms, 'time' => $post->getVar('pubdate'), 'author' => array('name' => $editor->name != '' ? $editor->name : $editor->shortname, 'id' => $editor->id(), 'link' => $editor->permalink(), 'bio' => $editor->getVar('bio'), 'email' => $editor->data('email'), 'avatar' => RMEvents::get()->run_event('rmcommon.get.avatar', $editor->data('email'))), 'alink' => $alink, 'edit' => $xoopsUser && ($xoopsUser->isAdmin() || $editor->getVar('uid') == $xoopsUser->uid()), 'tags' => $post->tags(false), 'meta' => $post->get_meta('', false), 'image' => $post->image(), 'video' => $post->video, 'player' => $post->format == 'video' ? $post->video_player() : '')); } $xoopsTpl->assign('lang_editpost', __('Edit Post', 'mywords')); $xoopsTpl->assign('lang_postedin', __('Posted in:', 'mywords')); $xoopsTpl->assign('lang_taggedas', __('Tagged as:', 'mywords'));
$path = explode("/", $request); $srh = array_search('page', $path); if (isset($path[$srh]) && $path[$srh] == 'page') { if (!isset($path[$srh])) { $page = 1; } else { $page = $path[$srh + 1]; } } else { $page = 1; } } $post->add_read(); // Navegación entre artículos if ($xoopsModuleConfig['shownav']) { $sql = "SELECT * FROM " . $db->prefix("mod_mywords_posts") . " WHERE id_post<" . $post->id() . " AND status='publish' ORDER BY id_post DESC LIMIT 0, 1"; $result = $db->query($sql); $pn = new MWPost(); // Anterior if ($db->getRowsNum($result) > 0) { $pn->assignVars($db->fetchArray($result)); $xoopsTpl->assign('prev_post', array('link' => $pn->permalink(), 'title' => $pn->getVar('title'))); } // Siguiente $sql = "SELECT * FROM " . $db->prefix("mod_mywords_posts") . " WHERE id_post>" . $post->id() . " AND status='publish' ORDER BY id_post ASC LIMIT 0, 1"; $result = $db->query($sql); if ($db->getRowsNum($result) > 0) { $pn->assignVars($db->fetchArray($result)); $xoopsTpl->assign('next_post', array('link' => $pn->permalink(), 'title' => $pn->getVar('title'))); } }