/** * @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&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&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')); } }