function mw_post_form($edit = 0) { global $xoopsConfig, $xoopsUser, $xoopsSecurity; if (!$xoopsUser) { redirect_header(MWFunctions::get_url(), 1, __('You are not allowed to do this action!', 'mywords')); die; } // Check if user is a editor $author = new MWEditor(); if (!$author->from_user($xoopsUser->uid()) && !$xoopsUser->isAdmin()) { redirect_header(MWFunctions::get_url(), 1, __('You are not allowed to do this action!', 'mywords')); die; } RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.min.js'); RMTemplate::get()->add_script(RMCURL . '/include/js/jquery-ui.min.js'); if ($edit) { $id = rmc_server_var($_GET, 'id', 0); if ($id <= 0) { redirect_header(MWFunctions::get_url(), __('Please, specify a valid post ID', 'mywords'), 1); die; } $post = new MWPost($id); if ($post->isNew()) { redirect_header(MWFunctions::get_url(), __('Specified post does not exists!', 'mywords'), 1); die; } // Check if user is the admin or a editor of this this post if ($author->id() != $post->getVar('author') && !$xoopsUser->isAdmin()) { redirect_header($post->permalink(), 1, __('You are not allowed to do this action!', 'mywords')); die; } } // Read privileges $perms = @$author->getVar('privileges'); $perms = is_array($perms) ? $perms : array(); $allowed_tracks = in_array("tracks", $perms) || $xoopsUser->isAdmin() ? true : false; $allowed_tags = in_array("tags", $perms) || $xoopsUser->isAdmin() ? true : false; $allowed_cats = in_array("cats", $perms) || $xoopsUser->isAdmin() ? true : false; $allowed_comms = in_array("comms", $perms) || $xoopsUser->isAdmin() ? true : false; $xoopsOption['module_subpage'] = 'submit'; include 'header.php'; $form = new RMForm('', '', ''); $editor = new RMFormEditor('', 'content', '99%', '300px', $edit ? $post->getVar('content') : ''); $meta_names = MWFunctions::get()->get_metas(); RMTemplate::get()->add_xoops_style('submit.css', 'mywords'); RMTemplate::get()->add_script(XOOPS_URL . '/modules/mywords/include/js/scripts.php?file=posts.js&front=1'); include RMTemplate::get()->get_template('mywords_submit_form.php', 'module', 'mywords'); include 'footer.php'; }
/** * Provides a widget to specify the default image for posts */ function mw_widget_image() { global $xoopsSecurity, $xoopsModuleConfig, $xoopsUser, $rm_config; $id = rmc_server_var($_REQUEST, 'id', 0); $type = rmc_server_var($_REQUEST, 'type', ''); $op = rmc_server_var($_REQUEST, 'op', ''); $edit = $op == 'edit' ? 1 : 0; $widget = array(); $widget['title'] = __('Default Image', 'mywords'); $util = new RMUtilities(); if ($edit) { //Verificamos que el software sea válido if ($id <= 0) { $params = ''; } $post = new MWPost($id); if ($post->isNew()) { $params = ''; } else { $params = $post->getVar('image'); } } else { $params = ''; } $widget['content'] = '<form name="frmDefimage" id="frm-defimage" method="post">'; $widget['content'] .= $util->image_manager('image', $params); $widget['content'] .= '</form>'; return $widget; }
/** * Función para realizar búsquedas */ function mywords_search($qa, $andor, $limit, $offset, $userid) { global $xoopsUser; $db = XoopsDatabaseFactory::getDatabaseConnection(); include_once XOOPS_ROOT_PATH . '/modules/mywords/class/mwpost.class.php'; $util =& RMUtilities::get(); $mc =& $util->module_config('mywords'); $sql = "SELECT * FROM " . $db->prefix("mw_posts"); $adds = ''; if (is_array($qa) && ($count = count($qa))) { $adds = ''; for ($i = 0; $i < $count; $i++) { $adds .= $adds == '' ? "(title LIKE '%{$qa[$i]}%' OR content LIKE '%{$qa[$i]}%')" : " {$andor} (title LIKE '%{$qa[$i]}%' OR content LIKE '%{$qa[$i]}%')"; } } $sql .= $adds != '' ? " WHERE " . $adds : ''; if ($userid > 0) { $sql .= ($adds != '' ? " AND " : " WHERE ") . "author='{$userid}'"; } $sql .= " ORDER BY pubdate DESC"; $i = 0; $result = $db->query($sql, $limit, $offset); $ret = array(); while ($row = $db->fetchArray($result)) { $post = new MWPost(); $post->assignVars($row); $ret[$i]['image'] = "images/post.png"; $ret[$i]['link'] = $post->permalink(); $ret[$i]['title'] = $post->getVar('title'); $ret[$i]['time'] = $post->getVar('pubdate'); $ret[$i]['uid'] = $post->getVar('author'); $ret[$i]['desc'] = substr(strip_tags($post->content()), 0, 150); $i++; } return $ret; }
public function get_item($params, $com) { static $posts; $params = urldecode($params); parse_str($params); if (!isset($post) || $post <= 0) { return __('Not found', 'mywords'); } if (isset($posts[$post])) { return $posts[$post]->getVar('title'); } include_once XOOPS_ROOT_PATH . '/modules/mywords/class/mwpost.class.php'; include_once XOOPS_ROOT_PATH . '/modules/mywords/class/mwfunctions.php'; $item = new MWPost($post); if ($item->isNew()) { return __('Not found', 'mywords'); } $posts[$post] = $item; return $item->getVar('title'); }
/** * 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; }
header('Content-Type: text/xml'); require '../../mainfile.php'; load_mod_locale('mywords'); global $xoopsLogger; $xoopsLogger->renderingEnabled = false; error_reporting(0); $xoopsLogger->activated = false; $id = rmc_server_var($_REQUEST, 'trackback', 0); if ($id <= 0) { die; } $post = new MWPost($id); if ($post->isNew()) { die; } $editor = new MWEditor($post->getVar('author')); if ($editor->isNew()) { $user = new XoopsUser($post->getVar('author')); } $track = new MWTrackback($xoopsConfig['sitename'], $editor->getVar('name')); $id = $track->post_id; // 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'));
$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'))); } } $xoopsTpl->assign('shownav', $xoopsModuleConfig['shownav']); if ($xoopsUser && ($xoopsUser->isAdmin() || $editor->getVar('uid') == $xoopsUser->uid())) { $edit = '<a href="' . XOOPS_URL . '/modules/mywords/admin/posts.php?op=edit&id=' . $post->id() . '">' . __('Edit Post', 'mywords') . '</a>'; $xoopsTpl->assign('edit_link', $edit); unset($edit); }
$post = new MWPost($id); if ($post->isNew()) { redirect_header(MWFunctions::get_url(), __('Specified post does not exists!', 'mywords'), 1); die; } // Check if user is the admin or a editor of this this post if ($author->id() != $post->getVar('author') && !$xoopsUser->isAdmin()) { redirect_header($post->permalink(), 1, __('You are not allowed to do this action!', 'mywords')); die; } } else { $post = new MWPost(); } // Read privileges $perms = @$author->getVar('privileges'); $perms = is_array($perms) ? $perms : array(); $allowed_tracks = in_array("tracks", $perms) || $xoopsUser->isAdmin() ? true : false; $allowed_tags = in_array("tags", $perms) || $xoopsUser->isAdmin() ? true : false; $allowed_cats = in_array("cats", $perms) || $xoopsUser->isAdmin() ? true : false; $allowed_comms = in_array("comms", $perms) || $xoopsUser->isAdmin() ? true : false; $xoopsOption['module_subpage'] = 'submit'; include 'header.php'; $form = new RMForm('', '', ''); $editor = new RMFormEditor('', 'content', '100%', '300px', $edit ? $post->getVar('content', $rmc_config['editor_type'] == 'tiny' ? 's' : 'e') : ''); $editor->setExtra('required'); $meta_names = MWFunctions::get()->get_metas(); RMTemplate::get()->add_style('submit.css', 'mywords'); RMTemplate::get()->add_script('scripts.php?file=posts.js', 'mywords', array('directory' => 'include')); RMTemplate::get()->add_script('jquery.validate.min.js', 'rmcommon', array('footer' => 1)); include RMTemplate::get()->get_template('mywords-submit-form.php', 'module', 'mywords'); include 'footer.php';
$post->setVar('format', $format); // SEO $post->setVar('description', $description); $post->setVar('keywords', $keywords); $post->setVar('customtitle', $seotitle); if ($edit) { $post->setVar('modified', time()); } if ($post->isNew()) { $post->setVar('created', time()); } if ($status != 'draft') { if ($schedule <= time() && !$edit) { $post->setVar('pubdate', time()); } elseif ($schedule <= time() && $edit) { $post->setVar('pubdate', $post->getVar('pubdate') == 0 ? time() : $post->getVar('pubdate')); } else { $post->setVar('pubdate', 0); } } if (MWFunctions::post_exists($post)) { return_error(__('There is already another post with same title for same date', 'mywords'), $xoopsSecurity->createToken()); die; } // Add categories $post->add_categories($categories, true); // Add tags $post->add_tags($tags); $post->clear_metas(); foreach ($meta as $data) { $post->add_meta($data['key'], $data['value']);
* This file execute the pings for a given post */ require '../../mainfile.php'; global $xoopsLogger; $xoopsLogger->renderingEnabled = false; error_reporting(0); $xoopsLogger->activated = false; $id = rmc_server_var($_GET, 'post', 0); if ($id <= 0) { die; } $post = new MWPost($id); if ($post->isNew()) { die; } $editor = new MWEditor($post->getVar('author')); if ($editor->isNew()) { $user = new XoopsUser($post->getVar('author')); } $tracks = $post->getVar('toping'); if (empty($tracks)) { die; } $pinged = $post->getVar('pinged'); $toping = $post->getVar('toping'); $tp = array(); $tback = new MWTrackback($xoopsModuleConfig['blogname'], $editor->isNew() ? $user->getVar('uname') : $editor->getVar('name')); foreach ($tracks as $t) { if (!empty($pinged) && in_array($t, $pinged)) { continue; }
// Blogging System // Author: Eduardo Cortés <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- if (!defined('XOOPS_ROOT_PATH')) { header('location: ./'); die; } // Authors cache $editors = array(); while ($row = $db->fetchArray($result)) { $post = new MWPost(); $post->assignVars($row); # Generamos los vínculos $day = date('d', $post->getVar('pubdate')); $month = date('m', $post->getVar('pubdate')); $year = date('Y', $post->getVar('pubdate')); $link = $post->permalink(); # Generamos el vínculo para el autor if ($post->getVar('author') > 0) { if (!isset($editors[$post->getVar('author')])) { $editors[$post->getVar('author')] = new MWEditor($post->getVar('author'), 'user'); } if ($editors[$post->getVar('author')]->isNew()) { if ($xoopsUser && $xoopsUser->uid() == $post->author) { $user = $xoopsUser; } else { $user = new RMUser($post->author); } $editors[$post->getVar('author')]->uid = $user->uid();
// Blogging System // Author: Eduardo Cortés <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- if (!defined('XOOPS_ROOT_PATH')) { header('location: ./'); die; } // Authors cache $authors = array(); while ($row = $db->fetchArray($result)) { $post = new MWPost(); $post->assignVars($row); # Generamos los vínculos $day = date('d', $post->getVar('pubdate')); $month = date('m', $post->getVar('pubdate')); $year = date('Y', $post->getVar('pubdate')); $link = $post->permalink(); # Generamos el vínculo para el autor if ($post->getVar('author') > 0) { if (!isset($authors[$post->getVar('author')])) { $authors[$post->getVar('author')] = new MWEditor($post->getVar('author')); } $author = $authors[$post->getVar('author')]; $alink = $author->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($author) ? $author->getVar('name') : __('Anonymous', 'mywords')) . "</a>");