コード例 #1
0
ファイル: postcards.php プロジェクト: laiello/bitcero-modules
/**
* @desc Visualiza todas las postales existentes
**/
function showPostCards()
{
    global $xoopsModule, $tpl, $xoopsModuleConfig, $xoopsSecurity;
    $mc =& $xoopsModuleConfig;
    $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
    $limit = isset($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 15;
    $limit = $limit <= 0 ? 15 : $limit;
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    //Barra de Navegación
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_postcards');
    list($num) = $db->fetchRow($db->query($sql));
    list($num) = $db->fetchRow($db->query($sql));
    $start = $num <= 0 ? 0 : ($page - 1) * $limit;
    $tpages = ceil($num / $limit);
    $nav = new RMPageNav($num, $limit, $page, 5);
    $nav->target_url("postcards.php?page={PAGE_NUM}&limit={$limit}");
    //Fin de barra de navegación
    $sql = "SELECT * FROM " . $db->prefix('gs_postcards');
    $sql .= " LIMIT {$start},{$limit}";
    $result = $db->query($sql);
    $posts = array();
    $tf = new RMTimeFormatter(0, __('%M% %d%, %Y% - %h%:%i%:%s%', 'galleries'));
    while ($rows = $db->fetchArray($result)) {
        $post = new GSPostcard();
        $post->assignVars($rows);
        $link = GSFunctions::get_url() . ($mc['urlmode'] ? 'postcard/view/id/' . $post->code() . '/' : '?postcard=view&amp;id=' . $post->code());
        $posts[] = array('id' => $post->id(), 'title' => $post->title(), 'date' => $tf->format($post->date()), 'toname' => $post->toName(), 'name' => $post->email(), 'view' => $post->viewed(), 'link' => $link);
    }
    GSFunctions::toolbar();
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; " . __('E-cards', 'galleries'));
    xoops_cp_header();
    RMTemplate::get()->add_local_script('gsscripts.php?file=sets&form=frm-postcards&', 'galleries');
    RMTemplate::get()->add_head("<script type='text/javascript'>\nvar delete_warning='" . __('Do you really wish to delete selected e-cards?', 'galleries') . "';\n</script>");
    include RMTemplate::get()->get_template('admin/gs_postcards.php', 'module', 'galleries');
    xoops_cp_footer();
}
コード例 #2
0
ファイル: postcard.php プロジェクト: laiello/bitcero-modules
/**
* @desc Envia la postal
*/
function sendPostcard()
{
    global $tpl, $xoopsModule, $xoopsModuleConfig, $rmc_config, $mc, $xoopsUser, $xoopsConfig, $util;
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
    }
    if (!$xoopsUser) {
        redirect_header(XOOPS_URL . '/user.php#register', 1, _MS_GS_ERRUSR);
        die;
    }
    $img = new GSImage($img);
    if ($img->isNew()) {
        redirect_header(XOOPS_URL . '/modules/galleries/', 1, _MS_GS_ERRIMG);
        die;
    }
    // Recaptcha check
    if (!RMEvents::get()->run_event('rmcommon.captcha.check', true)) {
        redirect_header(GSFunctions::get_url() . ($xoopsModuleConfig['urlmode'] ? 'postcard/new/img/' . $img->id() . '/' : '?postcard=new&amp;img=' . $img->id()), 1, __('Please check the security words and write it correctly!', 'contact'));
        die;
    }
    $post = new GSPostcard();
    $post->setTitle($title);
    $post->setMessage($msg);
    $post->setDate(time());
    $post->setToName($tname);
    $post->setToEmail($tmail);
    $post->setImage($img->id());
    $post->setName($fname);
    $post->setEmail($fmail);
    $post->setUid($uid);
    $post->setIp($_SERVER['REMOTE_ADDR']);
    $post->setViewed(0);
    //Generamos el código de la postal
    $post->setCode(RMUtilities::randomString(10, 1, false, 1, 1));
    if (!$post->save()) {
        redirect_header(base64_decode($return), 2, __('Unable to send e-card. Please try again!', 'galleries'));
        die;
    }
    $xoopsMailer =& getMailer();
    $xoopsMailer->useMail();
    $ectpl = is_file(XOOPS_ROOT_PATH . '/modules/galleries/lang/' . 'postcard-' . $rmc_config['language'] . '.tpl') ? $rmc_config['language'] . '.tpl' : 'postcard-en_US.tpl';
    $xoopsMailer->setTemplate($ectpl);
    $xoopsMailer->assign('SITENAME', $xoopsConfig['sitename']);
    $xoopsMailer->assign('SITEURL', XOOPS_URL . "/");
    $xoopsMailer->assign('FNAME', $fname);
    $xoopsMailer->assign('FMAIL', $fmail);
    $xoopsMailer->assign('TNAME', $tname);
    $xoopsMailer->assign('MODULE_LINK', GSfunctions::get_url());
    $xoopsMailer->assign('POSTAL_LINK', GSfunctions::get_url() . ($mc['urlmode'] ? 'postcard/view/id/' . $post->code() . '/' : '?postcard=view&amp;id=' . $post->code()));
    $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . "/modules/galleries/lang/");
    $xoopsMailer->setFromEmail($fmail);
    $xoopsMailer->setFromName($fname);
    $xoopsMailer->setToEmails($tmail);
    $xoopsMailer->setSubject(sprintf(_MS_GS_SUBJECT, $tname));
    if (!$xoopsMailer->send(true)) {
        redirect_header(base64_decode($return), 2, $xoopsMailer->getErrors());
    } else {
        redirect_header($user->userURL() . 'img/' . $img->id() . '/', 1, __('E-card sent successfully!', 'galleries'));
    }
}