Exemplo n.º 1
0
 public function message_post_do()
 {
     if ($users_inst = cmsController::getInstance()->getModule("users")) {
         if (!$users_inst->is_auth()) {
             if (!regedit::getInstance()->getVal("//modules/forum/allow_guest")) {
                 return "%forum_not_allowed_post%";
             }
         }
     }
     $title = getRequest('title');
     $body = getRequest('body');
     $title = htmlspecialchars($title);
     $body = htmlspecialchars($body);
     $nickname = htmlspecialchars(getRequest('nickname'));
     $email = htmlspecialchars(getRequest('email'));
     $ip = getServer('REMOTE_ADDR');
     $publish_time = new umiDate(time());
     $parent_id = (int) getRequest('param0');
     $parent_element = umiHierarchy::getInstance()->getElement($parent_id, true);
     if (!strlen(trim($title)) && $parent_element instanceof umiHierarchyElement) {
         $title = "Re: " . $parent_element->getName();
     }
     // check captcha
     $referer_url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/';
     if (isset($_REQUEST['captcha'])) {
         $_SESSION['user_captcha'] = md5((int) getRequest('captcha'));
     }
     if (!umiCaptcha::checkCaptcha() || !$parent_element) {
         $this->errorNewMessage('%errors_wrong_captcha%', false);
         $this->errorPanic();
     }
     if (!strlen(trim($body))) {
         $this->errorNewMessage('%error_message_empty%', false);
         $this->errorPanic();
     }
     $lang_id = cmsController::getInstance()->getCurrentLang()->getId();
     $domain_id = cmsController::getInstance()->getCurrentDomain()->getId();
     $tpl_id = $parent_element->getTplId();
     $hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("forum", "message")->getId();
     $object_type_id = umiObjectTypesCollection::getInstance()->getBaseType("forum", "message");
     $is_supervisor = false;
     if ($users_inst = cmsController::getInstance()->getModule("users")) {
         if ($users_inst->is_auth()) {
             $user_id = $users_inst->user_id;
             $author_id = $users_inst->createAuthorUser($user_id);
             $is_supervisor = $users_inst->isSv($user_id);
         } else {
             $author_id = $users_inst->createAuthorGuest($nickname, $email, $ip);
         }
         $author = umiObjectsCollection::getInstance()->getObject($author_id);
         $author->commit();
     }
     $element_id = umiHierarchy::getInstance()->addElement($parent_id, $hierarchy_type_id, $title, $title, $object_type_id, $domain_id, $lang_id, $tpl_id);
     permissionsCollection::getInstance()->setDefaultPermissions($element_id);
     $element = umiHierarchy::getInstance()->getElement($element_id, true);
     $element->setIsVisible(false);
     $bNeedModerate = !$is_supervisor && regedit::getInstance()->getVal("//modules/forum/need_moder");
     if (!$bNeedModerate) {
         $bNeedModerate = !antiSpamHelper::checkContent($body . $title . $nickname . $email);
     }
     $element->setIsActive(!$bNeedModerate);
     $element->setAltName($title);
     $element->getObject()->setName($title);
     $element->setValue("meta_descriptions", "");
     $element->setValue("meta_keywords", "");
     $element->setValue("h1", $title);
     $element->setValue("title", $title);
     $element->setValue("is_expanded", false);
     $element->setValue("show_submenu", false);
     $element->setValue("message", $body);
     $element->setValue("author_id", $author_id);
     $element->setValue("publish_time", $publish_time);
     if ($headers = umiFile::upload("pics", "headers", "./images/cms/headers/")) {
         $element->setValue("header_pic", $headers);
     }
     $object_id = $element->getObject()->getId();
     $data_module = cmsController::getInstance()->getModule('data');
     $data_module->saveEditedObject($object_id, true);
     $element->commit();
     if (!defined("DISABLE_SEARCH_REINDEX")) {
         define("DISABLE_SEARCH_REINDEX", 1);
     }
     if ($parent_id) {
         $parentElement = umiHierarchy::getInstance()->getElement($element->getRel());
         if ($parentElement instanceof umiHierarchyElement) {
             $parentElement->setValue("last_message", $element_id);
             $parentElement->setValue("last_post_time", time());
             $parentElement->commit();
         }
         $parentElement = umiHierarchy::getInstance()->getElement($parentElement->getRel());
         if ($parentElement instanceof umiHierarchyElement) {
             $parentElement->setValue("last_message", $element_id);
             $parentElement->commit();
         }
     }
     if (!$bNeedModerate) {
         $this->recalcCounts($element);
     }
     $oEventPoint = new umiEventPoint("forum_message_post_do");
     $oEventPoint->setMode("after");
     $oEventPoint->setParam("topic_id", $parent_id);
     $oEventPoint->setParam("message_id", $element_id);
     $this->setEventPoint($oEventPoint);
     $path = $bNeedModerate ? $referer_url : $this->getMessageLink($element_id);
     $this->redirect($path);
 }
Exemplo n.º 2
0
	public function post_question() {

		$iPosted= getRequest('posted');
		if(is_null($tickets = getSession('tickets'))) {
			$tickets = $_SESSION['tickets'] = Array();
		}

		if ($iPosted) {
			$sPosted = getArrayKey($tickets, $iPosted);
			return $sPosted;
		}

		$referer_url = getServer('HTTP_REFERER');
		$this->errorRegisterFailPage($referer_url);

		$parent_element_id = (int) getRequest('param0');
		// input
		$email = htmlspecialchars(getRequest('email'));
		$nick = htmlspecialchars(getRequest('nick'));
		$title = htmlspecialchars(getRequest('title'));
		$question = htmlspecialchars(getRequest('question'));
		$ip = $_SERVER['REMOTE_ADDR'];

		if(!strlen($title)) {
			$this->errorNewMessage("%error_faq_required_title%");
			$this->errorPanic();
		}

		if(!strlen($question)) {
			$this->errorNewMessage("%error_faq_required_question%");
			$this->errorPanic();
		}

		if(!strlen($email)) {
			$users = cmsController::getInstance()->getModule("users");
			if($users instanceof def_module) {
				$user_id = $users->user_id;
				if($user = umiObjectsCollection::getInstance()->getObject($user_id)) {
					$email = $user->getValue('e-mail');
				}
			}
		}

		$referer_url = (string) $_SERVER['HTTP_REFERER'];
		$posttime = time();
		$ip = $_SERVER['REMOTE_ADDR'];

		if (isset($_REQUEST['captcha'])) {
			$_SESSION['user_captcha'] = md5((int) getRequest('captcha'));
		}

		if (!umiCaptcha::checkCaptcha()) {
			$this->errorNewMessage("%errors_wrong_captcha%");
			$this->errorPanic();
		}

		// before add event point
		$oEventPoint = new umiEventPoint("faq_post_question");
		$oEventPoint->setMode("before");
		$oEventPoint->setParam("parent_element_id", $parent_element_id);
		$oEventPoint->setParam("test_captcha", umiCaptcha::checkCaptcha());

		$this->setEventPoint($oEventPoint);

		// check captcha
		if (!umiCaptcha::checkCaptcha() || !$parent_element_id) {
			$this->redirect($referer_url);
		}

		$is_active = 0;

		if($oUsers = cmsController::getInstance()->getModule("users")) {
			if($oUsers->is_auth()) {
				$user_id = cmsController::getInstance()->getModule('users')->user_id;
				$iAuthorId = $oUsers->createAuthorUser($user_id);
				$is_active = $oUsers->isSv($user_id);
			} else {
				$iAuthorId = $oUsers->createAuthorGuest($nick, $email, $ip);
			}
		}

		$object_type_id = umiObjectTypesCollection::getInstance()->getBaseType("faq", "question");
		$hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("faq", "question")->getId();

		$parentElement = umiHierarchy::getInstance()->getElement($parent_element_id);
		$tpl_id		= $parentElement->getTplId();
		$domain_id	= $parentElement->getDomainId();
		$lang_id	= $parentElement->getLangId();

		$element_id = umiHierarchy::getInstance()->addElement($parent_element_id, $hierarchy_type_id, $title, $title, $object_type_id, $domain_id, $lang_id, $tpl_id);

		permissionsCollection::getInstance()->setDefaultPermissions($element_id);

		$element = umiHierarchy::getInstance()->getElement($element_id);

		$element->setIsActive(false);
		$element->setIsVisible(false);

		$element->setValue("question", $question);
		$element->setValue("publish_time", $posttime);

		$element->getObject()->setName($title);
		$element->setValue("h1", $title);

		$element->setValue("author_id", $iAuthorId);
		$element->commit();

		// send mails

		$from = regedit::getInstance()->getVal("//settings/fio_from");
		$from_email = regedit::getInstance()->getVal("//settings/email_from");
		$admin_email = regedit::getInstance()->getVal("//settings/admin_email");

		list(
			$confirm_mail_subj_user, $confirm_mail_user, $confirm_mail_subj_admin, $confirm_mail_admin
		) = def_module::loadTemplatesForMail("faq/default",
			"confirm_mail_subj_user", "confirm_mail_user", "confirm_mail_subj_admin", "confirm_mail_admin"
		);

		// for admin
		$mail_arr = Array();
		$mail_arr['domain'] = $domain = $_SERVER['HTTP_HOST'];
		$mail_arr['question'] = $question;
		$mail_arr['question_link'] = "http://" . $domain . $this->pre_lang. "/admin/faq/edit/" . $element_id . "/";
		$mail_adm_subj = def_module::parseTemplateForMail($confirm_mail_subj_admin, $mail_arr);
		$mail_adm_content = def_module::parseTemplateForMail($confirm_mail_admin, $mail_arr);

		$confirmAdminMail = new umiMail();
		$confirmAdminMail->addRecipient($admin_email);
		$confirmAdminMail->setFrom($email, $nick);
		$confirmAdminMail->setSubject($mail_adm_subj);
		$confirmAdminMail->setContent($mail_adm_content);
		$confirmAdminMail->commit();
		$confirmAdminMail->send();

		// for user
		$user_mail = Array();
		$user_mail['domain'] = $domain = $_SERVER['HTTP_HOST'];
		$user_mail['question'] = $question;
		$user_mail['ticket'] = $element_id;
		$mail_usr_subj = def_module::parseTemplateForMail($confirm_mail_subj_user, $user_mail);
		$mail_usr_content = def_module::parseTemplateForMail($confirm_mail_user, $user_mail);

		$confirmMail = new umiMail();
		$confirmMail->addRecipient($email);
		$confirmMail->setFrom($from_email, $from);
		$confirmMail->setSubject($mail_usr_subj);
		$confirmMail->setContent($mail_usr_content);
		$confirmMail->commit();
		$confirmMail->send();

		// after add event point
		$oEventPoint = new umiEventPoint("faq_post_question");
		$oEventPoint->setMode("after");
		$oEventPoint->setParam("element_id", $element_id);
		$this->setEventPoint($oEventPoint);

		$_SESSION['tickets'][$element_id] = $mail_usr_content;
		$this->redirect($this->pre_lang . '/faq/post_question/?posted=' . $element_id);
	}
 public function send_ajax()
 {
     // Check captcha to know we should do anything
     if (isset($_REQUEST['captcha'])) {
         $_SESSION['user_captcha'] = md5((int) $_REQUEST['captcha']);
     }
     if (!umiCaptcha::checkCaptcha()) {
         return $this->errorNewMessageCustom("%errors_wrong_captcha%", array('captcha'));
     }
     //-------------------------------------------------------------------
     // Get necessary data
     $oTypes = umiObjectTypesCollection::getInstance();
     $iBaseTypeId = $oTypes->getBaseType("webforms", "form");
     $iFormTypeId = getRequest('system_form_id');
     $sSenderIP = getServer('REMOTE_ADDR');
     $iTime = new umiDate(time());
     $aAddresses = getRequest('system_email_to');
     if (!is_array($aAddresses)) {
         $aAddresses = array($aAddresses);
     }
     $aRecipients = array();
     foreach ($aAddresses as $address) {
         if ($address) {
             $sEmailTo = $this->guessAddressValue($address);
             $sAddress = $this->guessAddressName($address);
             $aRecipients[] = array('email' => $sEmailTo, 'name' => $sAddress);
         }
     }
     if (!$oTypes->isExists($iFormTypeId) || $oTypes->getParentClassId($iFormTypeId) != $iBaseTypeId) {
         return $this->errorNewMessageCustom("%wrong_form_type%");
     }
     //
     if (($ef = $this->checkRequiredFieldsCustom($iFormTypeId)) !== true) {
         return $this->errorNewMessageCustom(getLabel('error-required_list') . $this->assembleErrorFields($ef), $this->assembleErrorFieldsArray($ef));
     }
     //-------------------------------------------------------------------
     // Saving message and preparing it for sending
     $_REQUEST['data']['new']['sender_ip'] = $sSenderIP;
     // Hack for saving files-only-forms
     $oObjectsCollection = umiObjectsCollection::getInstance();
     $iObjectId = $oObjectsCollection->addObject($sAddress, $iFormTypeId);
     $oObjectsCollection->getObject($iObjectId)->setOwnerId(permissionsCollection::getInstance()->getUserId());
     cmsController::getInstance()->getModule('data')->saveEditedObject($iObjectId, true);
     $oObject = $oObjectsCollection->getObject($iObjectId);
     $oObject->setValue('destination_address', $sEmailTo);
     $oObject->setValue('sender_ip', $sSenderIP);
     $oObject->setValue('sending_time', $iTime);
     $aMessage = $this->formatMessage($iObjectId, true);
     //--------------------------------------------------------------------
     // Make an e-mail
     $oMail = new umiMail();
     //--------------------------------------------------------------------
     // Determine file fields
     $aFTypes = array('file', 'img_file', 'swf_file');
     $aFields = $oTypes->getType($oObject->getTypeId())->getAllFields();
     foreach ($aFields as $oField) {
         $oType = $oField->getFieldType();
         if (in_array($oType->getDataType(), $aFTypes)) {
             $oFile = $oObject->getValue($oField->getName());
             if ($oFile instanceof umiFile) {
                 $oMail->attachFile($oFile);
             }
             /*else {
             			return $this->errorNewMessageCustom("%errors_wrong_file_type%");
             		}*/
         }
     }
     $recpCount = 0;
     foreach ($aRecipients as $recipient) {
         foreach (explode(',', $recipient['email']) as $sAddress) {
             if (strlen(trim($sAddress))) {
                 $oMail->addRecipient(trim($sAddress), $recipient['name']);
                 $recpCount++;
             }
         }
     }
     if (!$recpCount) {
         return $this->errorNewMessageCustom(getLabel('error-no_recipients'));
     }
     $oMail->setFrom($aMessage['from_email_template'], $aMessage['from_template']);
     $oMail->setSubject($aMessage['subject_template']);
     $oMail->setContent($aMessage['master_template']);
     $oMail->commit();
     $oMail->send();
     //--------------------------------------------------------------------
     // Send autoreply if should
     if (strlen($aMessage['autoreply_template'])) {
         $oMailReply = new umiMail();
         $oMailReply->addRecipient($aMessage['from_email_template'], $aMessage['from_template']);
         $oMailReply->setFrom($aMessage['autoreply_from_email_template'], $aMessage['autoreply_from_template']);
         $oMailReply->setSubject($aMessage['autoreply_subject_template']);
         $oMailReply->setContent($aMessage['autoreply_template']);
         $oMailReply->commit();
         $oMailReply->send();
     }
     //--------------------------------------------------------------------
     // Process events
     $oEventPoint = new umiEventPoint("webforms_post");
     $oEventPoint->setMode("after");
     $oEventPoint->setParam("email", $aMessage['from_email_template']);
     $oEventPoint->setParam("message_id", $iObjectId);
     $oEventPoint->setParam("form_id", $iFormTypeId);
     $oEventPoint->setParam("fio", $aMessage['from_template']);
     $this->setEventPoint($oEventPoint);
     //--------------------------------------------------------------------
     return array('plain:result' => json_encode(array('success' => $this->posted($iFormTypeId))));
 }
Exemplo n.º 4
0
<?php

session_start();
ob_start();
require CURRENT_WORKING_DIR . "/libs/root-src/standalone.php";
ob_end_clean();
$code = getSession('umi_captcha_plain');
$drawer = umiCaptcha::getDrawer();
if (!$code || isset($_REQUEST['reset'])) {
    $code = $drawer->getRandomCode();
}
$_SESSION['umi_captcha'] = md5($code);
$_SESSION['umi_captcha_plain'] = $code;
setcookie("umi_captcha", md5($code));
$drawer->draw($code);
Exemplo n.º 5
0
		public function registrate_do($template = "default") {
			if ($this->is_auth()) {
				$this->redirect($this->pre_lang . "/");
			}
			if (!($template = getRequest('template'))) {
				$template = 'default';
			}
			$objectTypes = umiObjectTypesCollection::getInstance();
			$regedit = regedit::getInstance();

			$refererUrl = getServer('HTTP_REFERER');
			$without_act = (bool) $regedit->getVal("//modules/users/without_act");

			$objectTypeId	= $objectTypes->getBaseType("users",	"user");
			if ($customObjectTypeId = getRequest('type-id')) {
				$childClasses = $objectTypes->getChildClasses($objectTypeId);
				if (in_array($customObjectTypeId, $childClasses)) {
					$objectTypeId = $customObjectTypeId;
				}
			}

			$objectType = $objectTypes->getType($objectTypeId);

			$this->errorSetErrorPage($refererUrl);

			$login = $this->validateLogin(getRequest('login'), false, true);
			$password = $this->validatePassword(getRequest('password'), getRequest('password_confirm'), getRequest('login'), true);
			$email = $this->validateEmail(getRequest('email'), false, !$without_act);

			//Captcha validation
			if (isset($_REQUEST['captcha'])) {
				$_SESSION['user_captcha'] = md5((int) getRequest('captcha'));
			}

			if (!umiCaptcha::checkCaptcha()) {
				$this->errorAddErrors('errors_wrong_captcha');
			}

			$this->errorThrow('public');

			$oEventPoint = new umiEventPoint("users_registrate");
			$oEventPoint->setMode("before");
			$oEventPoint->setParam("login",	$login);
			$oEventPoint->addRef("password", $password);
			$oEventPoint->addRef("email", $email);
			$this->setEventPoint($oEventPoint);

			//Creating user...
			$objectId = umiObjectsCollection::getInstance()->addObject($login, $objectTypeId);
			$activationCode = md5($login . time());

			$object = umiObjectsCollection::getInstance()->getObject($objectId);

			$object->setValue("login", $login);
			$object->setValue("password", md5($password));
			$object->setValue("e-mail", $email);

			$object->setValue("is_activated", $without_act);
			$object->setValue("activate_code", $activationCode);
			$object->setValue("referer", urldecode(getSession("http_referer")));
			$object->setValue("target", urldecode(getSession("http_target")));
			$object->setValue("register_date", umiDate::getCurrentTimeStamp());
			$object->setValue("referer", getSession("http_referer"));
			$object->setValue("target", getSession("http_target"));
			$object->setValue("register_date", umiDate::getCurrentTimeStamp());

			if ($without_act) {
				$_SESSION['cms_login'] = $login;
				$_SESSION['cms_pass'] = md5($password);
				$_SESSION['user_id'] = $objectId;

				session_commit();
			}

			$group_id = regedit::getInstance()->getVal("//modules/users/def_group");
			$object->setValue("groups", Array($group_id));

			cmsController::getInstance()->getModule('data');
			$data_module = cmsController::getInstance()->getModule('data');
			$data_module->saveEditedObject($objectId, true);

			$object->commit();

			if ($eshop_module = cmsController::getInstance()->getModule('eshop')) {
				$eshop_module->discountCardSave($objectId);
			}

			//Forming mail...
			list(
				$template_mail, $template_mail_subject, $template_mail_noactivation, $template_mail_subject_noactivation
			) = def_module::loadTemplatesForMail("users/register/".$template,
				"mail_registrated", "mail_registrated_subject", "mail_registrated_noactivation", "mail_registrated_subject_noactivation"
			);

			if ($without_act && $template_mail_noactivation && $template_mail_subject_noactivation) {
				$template_mail = $template_mail_noactivation;
				$template_mail_subject = $template_mail_subject_noactivation;
			}

			$mailData = array(
				'user_id' => $objectId,
				'domain' => $domain = $_SERVER['HTTP_HOST'],
				'activate_link' => "http://" . $domain . $this->pre_lang . "/users/activate/" . $activationCode . "/",
				'login' => $login,
				'password' => $password,
				'lname' => $object->getValue("lname"),
				'fname' => $object->getValue("fname"),
				'father_name' => $object->getValue("father_name"),
			);

			$mailContent = def_module::parseTemplateForMail($template_mail, $mailData, false, $objectId);
			$mailSubject = def_module::parseTemplateForMail($template_mail_subject, $mailData, false, $objectId);

			$fio = $object->getValue("lname") . " " . $object->getValue("fname") . " " . $object->getValue("father_name");

			$email_from = regedit::getInstance()->getVal("//settings/email_from");
			$fio_from = regedit::getInstance()->getVal("//settings/fio_from");


			$registrationMail = new umiMail();
			$registrationMail->addRecipient($email, $fio);
			$registrationMail->setFrom($email_from, $fio_from);
			$registrationMail->setSubject($mailSubject);
			$registrationMail->setContent($mailContent);
			$registrationMail->commit();
			$registrationMail->send();

			$oEventPoint = new umiEventPoint("users_registrate");
			$oEventPoint->setMode("after");
			$oEventPoint->setParam("user_id", $objectId);
			$oEventPoint->setParam("login", $login);
			$this->setEventPoint($oEventPoint);

			if ($without_act) {
				$this->redirect($this->pre_lang . "/users/registrate_done/?result=without_activation");
			} else {
				$this->redirect($this->pre_lang . "/users/registrate_done/");
			}
		}
Exemplo n.º 6
0
    public function post()
    {
        if (defined('CURRENT_VERSION_LINE') && CURRENT_VERSION_LINE == 'demo') {
            $url = getRequest('ref_onsuccess');
            if (!$url) {
                $url = $this->pre_lang . "/webforms/posted/";
            }
            $this->redirect($url);
        }
        global $_FILES;
        $iOldErrorReportingLevel = error_reporting(~E_ALL & ~E_STRICT);
        $res = "";
        $email_to = getRequest('email_to');
        $message = getRequest('message');
        $data = getRequest('data');
        $domain = getRequest('domain');
        $subject = cmsController::getInstance()->getCurrentDomain()->getHost();
        $referer_url = $_SERVER['HTTP_REFERER'];
        $this->errorRegisterFailPage($referer_url);
        // check captcha
        if (isset($_REQUEST['captcha'])) {
            $_SESSION['user_captcha'] = md5((int) $_REQUEST['captcha']);
        }
        if (!umiCaptcha::checkCaptcha()) {
            $this->errorNewMessage("%errors_wrong_captcha%");
            $this->errorPanic();
        }
        $sRecipientName = "administrator";
        if (is_numeric($email_to)) {
            $to = $this->guessAddressValue($email_to);
            if (intval($to) != $email_to) {
                $sRecipientName = $this->guessAddressName($email_to);
            } else {
                $oTCollection = umiObjectTypesCollection::getInstance();
                $iTypeId = $oTCollection->getBaseType('webforms', 'address');
                $oType = $oTCollection->getType($iTypeId);
                $iFieldId = $oType->getFieldId('insert_id');
                $oSelection = new umiSelection();
                $oSelection->addObjectType($iTypeId);
                $oSelection->addPropertyFilterEqual($iFieldId, $email_to);
                $aIDs = umiSelectionsParser::runSelection($oSelection);
                if (count($aIDs)) {
                    $oObject = umiObjectsCollection::getInstance()->getObject($aIDs[0]);
                    $to = $oObject->getValue('address_list');
                    $sRecipientName = $oObject->getValue('address_description');
                } else {
                    if (!defined("DB_DRIVER") || DB_DRIVER != "xml") {
                        $sql = "SELECT email, descr FROM cms_webforms WHERE id={$email_to}";
                        $result = l_mysql_query($sql);
                        list($to, $sRecipientName) = mysql_fetch_row($result);
                    } else {
                        $this->redirect($this->pre_lang . "/webforms/posted/?template=error_no_recipient");
                    }
                }
            }
        } else {
            $this->checkAddressExistence($email_to);
            $to = $email_to;
        }
        if (!$data['email_from'] && isset($data['email'])) {
            $data['email_from'] = $data['email'];
        }
        $someMail = new umiMail();
        $arrMails = explode(",", $to);
        $arrMails = array_map("trim", $arrMails);
        foreach ($arrMails as $sEmail) {
            $someMail->addRecipient($sEmail, $sRecipientName);
        }
        $from = $data['fname'] . " " . $data['lname'];
        $someMail->setFrom($data['email_from'], $from);
        $mess = "";
        if (is_array($data)) {
            if (isset($data['subject'])) {
                $subject = $data['subject'];
            }
            if (isset($data['fio'])) {
                $from = $data['fio'];
            }
            if ($data['fname'] || $data['lname'] || $data['mname']) {
                $from = $data['lname'] . " " . $data['fname'] . " " . $data['mname'];
            }
            if ($data['fio_frm']) {
                $from = $data['fio_frm'];
            }
            if ($email_from = $data['email_from']) {
                $email_from = $data['email_from'];
            }
            $mess = <<<END

<table border="0" width="100%">

END;
            if (is_array($_FILES['data']['name'])) {
                $data = array_merge($data, $_FILES['data']['name']);
            }
            $uploadDir = CURRENT_WORKING_DIR . "/sys-temp/uploads";
            if (!is_dir($uploadDir)) {
                mkdir($uploadDir);
            }
            $max_size = getBytesFromString(mainConfiguration::getInstance()->get('system', 'quota-files-and-images'));
            if ($max_size != 0) {
                $summary_size = getBusyDiskSize(array('/images', '/files', '/sys-temp/uploads'));
            }
            foreach ($data as $field => $cont) {
                if ($filename = $_FILES['data']['name'][$field]) {
                    if ($max_size == 0 || $summary_size + $_FILES['data']['size'][$field] <= $max_size) {
                        $file = umiFile::upload('data', $field, $uploadDir);
                        if (!$file) {
                            $this->errorNewMessage("%errors_wrong_file_type%");
                            $this->errorPanic();
                        }
                        $someMail->attachFile($file);
                        $summary_size += $_FILES['data']['size'][$field];
                    } else {
                        $cont = def_module::parseTPLMacroses("%not_enough_space_for_load_file%");
                    }
                }
                if (!is_array($cont)) {
                    $cont = str_replace("%", "&#37;", $cont);
                }
                if (!$cont) {
                    $cont = "&mdash;";
                }
                if (is_array($cont)) {
                    foreach ($cont as $i => $v) {
                        $cont[$i] = str_replace("%", "&#37;", $v);
                    }
                    $cont = implode(", ", $cont);
                }
                $label = $_REQUEST['labels'][$field] ? $_REQUEST['labels'][$field] : "%" . $field . "%";
                $mess .= <<<END

\t<tr>
\t\t<td width="30%">
\t\t\t{$label}:
\t\t</td>

\t\t<td>
\t\t\t{$cont}
\t\t</td>
\t</tr>

END;
            }
            $mess .= <<<END

</table>
<hr />

END;
        }
        if ($from) {
            $user_fio_from = $from;
        }
        $message = str_replace("%", "&#37;", $message);
        $mess .= nl2br($message);
        if (!$from) {
            $from = regedit::getInstance()->getVal("//settings/fio_from");
        }
        if (!$from_email) {
            $from_email = regedit::getInstance()->getVal("//settings/email_from");
        }
        $from = $from . "<" . $from_email . ">";
        $someMail->setSubject($subject);
        $someMail->setContent($mess);
        $someMail->commit();
        $someMail->send();
        if ($template = (string) $_REQUEST['template']) {
            //Sending auto-reply
            list($template_mail, $template_mail_subject) = def_module::loadTemplatesForMail("webforms/" . $template, "webforms_reply_mail", "webforms_reply_mail_subject");
            $template_mail = def_module::parseTemplateForMail($template_mail, $arr);
            $template_mail_subject = def_module::parseTemplateForMail($template_mail, $arr);
            $check_param = false;
            if (!is_array($template_mail)) {
                if ((bool) strlen($template_mail)) {
                    $check_param = true;
                }
            }
            if ($check_param) {
                $email_from = regedit::getInstance()->getVal("//settings/email_from");
                $fio_from = regedit::getInstance()->getVal("//settings/fio_from");
                $replyMail = new umiMail();
                $replyMail->addRecipient($data['email_from'], $from);
                $replyMail->setFrom($email_from, $fio_from);
                $replyMail->setSubject($template_mail_subject);
                $replyMail->setContent($template_mail);
                $replyMail->commit();
                $replyMail->send();
            }
        }
        $oEventPoint = new umiEventPoint("webforms_post");
        $oEventPoint->setMode("after");
        $oEventPoint->setParam("email", $data['email_from']);
        $oEventPoint->setParam("fio", $user_fio_from);
        $this->setEventPoint($oEventPoint);
        $url = getRequest('ref_onsuccess');
        if (!$url) {
            $url = $this->pre_lang . "/webforms/posted/";
        }
        if ($template) {
            $url .= (strpos($url, '?') === false ? '?' : '&') . "template=" . $template;
        }
        error_reporting($iOldErrorReportingLevel);
        $this->redirect($url);
    }
Exemplo n.º 7
0
 public function captcha($v66f6181bcb4cff4cd38fbc804a036db6 = 'default')
 {
     $v8b1dc169bf460ee884fceef66c6607d6 = cmsController::getInstance();
     $v753527be46567ad90a4203cf4b40d70e = $v8b1dc169bf460ee884fceef66c6607d6->getCurrentLang()->getPrefix();
     $vd811accaee37e3fdcd3d39e7b0e4936d = $v8b1dc169bf460ee884fceef66c6607d6->getCurrentLang()->getIsDefault();
     if (!$v66f6181bcb4cff4cd38fbc804a036db6) {
         if ($vd811accaee37e3fdcd3d39e7b0e4936d) {
             $v66f6181bcb4cff4cd38fbc804a036db6 = "default";
         } else {
             $v66f6181bcb4cff4cd38fbc804a036db6 = "default." . $v753527be46567ad90a4203cf4b40d70e;
             $v8c7dd922ad47494fc02c388e12c00eac = "tpls/captcha/" . $v66f6181bcb4cff4cd38fbc804a036db6 . ".tpl";
             if (!file_exists($v8c7dd922ad47494fc02c388e12c00eac)) {
                 $v66f6181bcb4cff4cd38fbc804a036db6 = "default";
             }
         }
     }
     $v2245023265ae4cf87d02c8b6ba991139 = mainConfiguration::getInstance();
     if (!$v2245023265ae4cf87d02c8b6ba991139->get('anti-spam', 'captcha.enabled')) {
         return '';
     }
     return umiCaptcha::generateCaptcha($v66f6181bcb4cff4cd38fbc804a036db6);
 }
Exemplo n.º 8
0
 /**
  * @desc Выводит форму для добавления комментария и выполняет все действия по сохранению
  * @param int $postId Идентификатор публикации или комментария
  * @param string $template имя файла шаблона
  * @return string|array
  */
 public function commentAdd($postId = false, $template = 'default')
 {
     $bNeedFinalPanic = false;
     if (!($oUsersModule = cmsController::getInstance()->getModule("users"))) {
         throw new publicException("Can't find users module");
     }
     if (!($oUsersModule->is_auth() || regedit::getInstance()->getVal("//modules/blogs20/allow_guest_comments"))) {
         return;
     }
     if ($postId === false) {
         $iTmp = getRequest('param0');
         if ($iTmp) {
             $postId = $iTmp;
         } else {
             $postId = cmsController::getInstance()->getCurrentElementId();
         }
     }
     $postId = (int) $postId;
     $oHierarchy = umiHierarchy::getInstance();
     $oHTypesCollection = umiHierarchyTypesCollection::getInstance();
     if (!($oPost = $oHierarchy->getElement($postId))) {
         throw new publicException(getLabel('error-page-does-not-exist', null, $postId));
     }
     if ($oPost->getTypeId() != $oHTypesCollection->getTypeByName("blogs20", "post")->getId() && $oPost->getTypeId() != $oHTypesCollection->getTypeByName("blogs20", "comment")->getId()) {
         throw new publicException("The id(#{$postId}) given is not an id of the blog's post");
     }
     $sTitle = ($tmp = getRequest('title')) ? $tmp : 'Re: ' . $oPost->getName();
     $sContent = htmlspecialchars(trim(getRequest('content')));
     if ($postId !== false && strlen($sContent) > 0) {
         if (!umiCaptcha::checkCaptcha()) {
             $this->errorNewMessage("%errors_wrong_captcha%");
             $this->errorPanic();
         }
         $hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("blogs20", "comment")->getId();
         $iCommentId = $oHierarchy->addElement($postId, $hierarchy_type_id, $sTitle, $sTitle);
         permissionsCollection::getInstance()->setDefaultPermissions($iCommentId);
         if ($oUsersModule->is_auth()) {
             $userId = $oUsersModule->user_id;
             $authorId = $oUsersModule->createAuthorUser($userId);
             $oActivity = antiSpamHelper::checkContent($sContent . $sTitle);
         } else {
             $nick = getRequest('nick');
             $email = getRequest('email');
             $ip = getServer('REMOTE_ADDR');
             $authorId = $oUsersModule->createAuthorGuest($nick, $email, $ip);
             $oActivity = antiSpamHelper::checkContent($sContent . $sTitle . $nick . $email);
         }
         $oComment = $oHierarchy->getElement($iCommentId, true);
         $is_active = $this->moderate ? 0 : 1;
         if ($is_active) {
             $is_active = $oActivity;
         }
         if (!$is_active) {
             $this->errorNewMessage('%comments_posted_moderating%', false);
             $bNeedFinalPanic = true;
         }
         $oComment->setIsActive($is_active);
         $oComment->setValue('title', $sTitle);
         $oComment->setValue('content', $sContent);
         $oComment->setValue('author_id', $authorId);
         $oComment->setValue('publish_time', new umiDate());
         $oComment->commit();
         // Raise Event
         $oEventPoint = new umiEventPoint("blogs20CommentAdded");
         $oEventPoint->setMode("after");
         $oEventPoint->setParam("id", $iCommentId);
         $oEventPoint->setParam('template', $template);
         $this->setEventPoint($oEventPoint);
         // Redirecting
         if ($bNeedFinalPanic) {
             $this->errorPanic();
         } else {
             $sRefererUri = getServer('HTTP_REFERER');
             if (strlen($sRefererUri)) {
                 $this->redirect($sRefererUri . '#comment_' . $iCommentId);
             }
             return null;
         }
     } else {
         if (!strlen($sContent) && !is_null(getRequest('content'))) {
             $this->errorNewMessage("%errors_missed_field_value%");
             $this->errorPanic();
         }
     }
     $sTplName = $oUsersModule->is_auth() ? 'comment_add_form' : 'comment_add_form_guest';
     list($sFormTemplate) = self::loadTemplates('blogs20/' . $template, $sTplName);
     return self::parseTemplate($sFormTemplate, array('parent_id' => $postId));
 }