Узнать размер папок в директории и сортировка по размеру
1 |
du -h --max-depth=1 | sort -n -r |
или
1 |
du -sh * | sort -h -r |
сортировка du sort
1 |
du -h --max-depth=1 | sort -n -r |
или
1 |
du -sh * | sort -h -r |
сортировка du sort
Кастомизация комментариев UMI в _-custom.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
public function formReCaptcha(){ require_once $_SERVER["DOCUMENT_ROOT"]."/customForm/recapcha.php"; $secret = "secret)))"; $response = null; $reCaptcha = new ReCaptcha($secret); if ($_REQUEST["g-recaptcha-response"]) { $response = $reCaptcha->verifyResponse( $_SERVER["REMOTE_ADDR"], $_REQUEST["g-recaptcha-response"] ); } return $response->success; } public function postCommentNew($parent_element_id = false) { $bNeedFinalPanic = false; $parent_element_id = (int) $parent_element_id; if(!isset($parent_element_id) || !$parent_element_id) { $parent_element_id = (int) getRequest('param0'); } $title = trim(getRequest('title')); $content = trim(getRequest('comment')); $nick = htmlspecialchars(getRequest('author_nick')); $email = htmlspecialchars(getRequest('author_email')); $referer_url = getServer('HTTP_REFERER'); $posttime = time(); $ip = getServer('REMOTE_ADDR'); if(!$referer_url) { $referer_url = umiHierarchy::getInstance()->getPathById($parent_element_id); } $this->errorRegisterFailPage($referer_url); if (!(strlen($title) || strlen($content))) { $this->errorNewMessage('%comments_empty%', false); $this->errorPanic(); } if (getRequest('param0') == 539){ $formReCaptcha = $this->formReCaptcha(); if (!$formReCaptcha){ $this->errorNewMessage("%errors_wrong_captcha%"); $this->errorPanic(); } } $user_id = permissionsCollection::getInstance()->getUserId(); if(!$nick) { $nick = getRequest('nick'); } if(!$email) { $email = getRequest('email'); } if($nick) { $nick = htmlspecialchars($nick); } if($email) { $email = htmlspecialchars($email); } $is_sv = false; if($users_inst = cmsController::getInstance()->getModule("users")) { if($users_inst->is_auth()) { $author_id = $users_inst->createAuthorUser($user_id); $is_sv = permissionsCollection::getInstance()->isSv($user_id); } else { if(!(regedit::getInstance()->getVal("//modules/comments/allow_guest"))) { $this->errorNewMessage('%comments_not_allowed_post%', true); } $author_id = $users_inst->createAuthorGuest($nick, $email, $ip); } } $is_active = ($this->moderated && !$is_sv) ? 0 : 1; if($is_active) { $is_active = antiSpamHelper::checkContent($content.$title.$nick.$email) ? 1 : 0; } if (!$is_active) { $this->errorNewMessage('%comments_posted_moderating%', false); $bNeedFinalPanic = true; } $object_type_id = umiObjectTypesCollection::getInstance()->getTypeIdByHierarchyTypeName("comments", "comment"); $hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("comments", "comment")->getId(); $parentElement = umiHierarchy::getInstance()->getElement($parent_element_id); $tpl_id = $parentElement->getTplId(); $domain_id = $parentElement->getDomainId(); $lang_id = $parentElement->getLangId(); if (!strlen(trim($title)) && ($parentElement instanceof umiHierarchyElement)) { $title = "Re: ".$parentElement->getName(); } $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, true); $element->setIsActive($is_active); $element->setIsVisible(false); $element->setValue("message", $content); $element->setValue("publish_time", $posttime); $element->getObject()->setName($title); $element->setValue("h1", $title); $element->setValue("author_id", $author_id); $object_id = $element->getObject()->getId(); $data_module = cmsController::getInstance()->getModule('data'); $data_module->saveEditedObject($object_id, true); // moderate $element->commit(); $parentElement->commit(); $oEventPoint = new umiEventPoint("comments_message_post_do"); $oEventPoint->setMode("after"); $oEventPoint->setParam("topic_id", $parent_element_id); $oEventPoint->setParam("message_id", $element_id); $this->setEventPoint($oEventPoint); // redirect with or without error messages if ($bNeedFinalPanic) { $this->errorPanic(); } else { // validate url $referer_url = preg_replace("/_err=\d+/is", '', $referer_url); while (strpos($referer_url, '&&') !== false || strpos($referer_url, '??') !== false || strpos($referer_url, '?&') !== false) { $referer_url = str_replace('&&', '&', $referer_url); $referer_url = str_replace('??', '?', $referer_url); $referer_url = str_replace('?&', '?', $referer_url); } if (strlen($referer_url) && (substr($referer_url, -1) === '?' || substr($referer_url, -1) === '&')) $referer_url = substr($referer_url, 0, strlen($referer_url)-1); $this->redirect($referer_url); } } |
Проверка формы на фронте
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
$('form#review-form').submit(function(event){ var errors = false; var comment = $(this).find('textarea[name="comment"]').val(); var spam = ['href', 'http']; var spamLetter = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; var errorsLetter = 0; spam.forEach(function(item, i){ if (comment.indexOf(item) >= 0){ errors = true; } }); if (errors){ alert('Ваше сообщение содержит ссылку!\nВы спамер!'); } commentSpace = comment.replace(" ",""); if (!errors){ for (var i = 0; i < commentSpace.length; i++){ if (spamLetter.indexOf(comment[i]) >= 0){ errorsLetter++; } } } if (errorsLetter > 0){ if ((commentSpace.length / errorsLetter) <= 2){ errors = true; alert('Ваше сообщение на половину состоит из английских букв!\nВы спамер!'); } else if (commentSpace.length / errorsLetter == 1){ alert('Ваше сообщение состоит полностью из английских букв!\nВы спамер!'); } } if ($(this).find('textarea#g-recaptcha-response').length == 1 && $(this).find('textarea#g-recaptcha-response').val().length == 0){ errors = true; grecaptcha.reset(); alert('Вы забыли капчу!'); } if (errors){ event.preventDefault(); } }); |
Не забываем про permissions
1 2 3 |
<?php $permissions = Array('insert' => Array('postCommentNew')); ?> |
Полезности: Документация UMI recapcha.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
require_once $_SERVER["DOCUMENT_ROOT"]."/customForm/recapcha.php"; $secret = "secretGoogle))"; $response = null; $reCaptcha = new ReCaptcha($secret); if ($_REQUEST["g-recaptcha-response"]) { $response = $reCaptcha->verifyResponse( $_SERVER["REMOTE_ADDR"], $_REQUEST["g-recaptcha-response"] ); } |
Проверяем
1 2 3 4 5 |
if (!$response->success){ echo "fail"; } else { echo "success"; } |
Проверить форму на фронте
1 2 3 4 |
if ($(this).find('textarea#g-recaptcha-response').length == 1 && $(this).find('textarea#g-recaptcha-response').val().length == 0){ errors = true; alert('Вы забыли капчу!'); } |
скачать recapcha.php
Создадим файл с содержимым в lagouts/feedback.xsl
1 2 3 4 5 |
<xsl:stylesheet extension-element-prefixes="math" version="1.0" xmlns:math="http://exslt.org/math" xmlns:php="http://php.net/xsl" xmlns:umi="http://www.umi-cms.ru/TR/umi" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="result" mode="feedback"> test </xsl:template> </xsl:stylesheet> |
Подключаем шаблон
1 |
<xsl:include href="layouts/feedback.xsl"/> |
Для вывода используем в нужном месте
1 |
<xsl:apply-templates select="/" mode="feedback" /> |
Полезности https://msdn.microsoft.com/ru-ru/library/ms256125(v=vs.120).aspx
Получаем email адрес администратора сайта bitrix
1 2 |
require($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/main/include/prolog_before.php'); echo COption::GetOptionString("main", "email_from"); |
Добавить preloader/прелоудер
1 2 3 4 5 6 7 8 9 10 11 |
.preloader { display: block; position: absolute; top: 0px; left: 0; width: 100%; height: 100%; z-index: 10000000; background: #988989ab url(/assets/template/img/tail-spin.svg) center center no-repeat; background-size: 42px; } |
Родителю дать
1 |
position: relative; |
У нас есть форма
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<div class="services_form_right"> <form class="services_form" id="paving_and_laying"> <input type="text" name="name" placeholder="Имя"> <input type="email" name="email" placeholder="E-mail"> <input type="tel" name="phone" placeholder="Телефон"> <textarea name="message" placeholder="Комментарий к заказу"></textarea> <div class="box_agree"> <input type="checkbox" name="agree" id="agree" class="checkbox"> <label for="agree" class="check">Даю согласие на обработку персональных данных</label> </div> <div class="services_btn"> <button type="submit" class="btn">Расчитать заказ</button> </div> </form> </div> |
js’ка
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
$("form#paving_and_laying").on('submit', function(event){ event.preventDefault(); form = $(this); $.ajax({ type: "POST", url: "/make.php", data: $(this).serializeArray(), success: function(msg) { json = $.parseJSON(msg); form.find('.requiredInputError').removeClass('requiredInputError'); if (json.result) { form.parent('.services_form_right').addClass('success').html(json.msg); form.remove(); } else { if (json.errors) { json.errors.forEach(function(item) { if (item == 'agree') { form.children('div').children('label').addClass('requiredInputError'); } else if (item == 'message') { form.children('textarea[name="message"]').addClass('requiredInputError'); } else { form.children('input[name="' + item + '"]').addClass('requiredInputError'); } }); } else { alert(json.msg); } } } }); }); |
Файл make.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
<?php $name = $_REQUEST['name']; $email = $_REQUEST['email']; $phone = $_REQUEST['phone']; $message = $_REQUEST['message']; $agree = isset($_REQUEST['agree']); $errors = false; $requiredFields = ['name', 'email', 'phone', 'agree', 'message']; $errorFields = []; // проверяем обязательные поля foreach($requiredFields as $field){ if (!$_REQUEST[$field]){ array_push($errorFields, $field); $errors = true; } } if (!$errors) : $subjectuser = "Сообщение"; $headersuser = "From: Сообщение\r\n"; $headersuser .= "Reply-To: ". strip_tags($name) . "\r\n"; $headersuser .= "MIME-Version: 1.0\r\n"; $headersuser .= "Content-Type: text/html;charset=utf-8 \r\n"; $my_message = "<h1>ТЕМА</h1><br/>"; $my_message .= "Имя: {$name}<br/>"; if ($phone){ $my_message .= "Телефон: {$phone}<br />"; } if ($email){ $my_message .= "E-mail: {$email}<br />"; } if ($message){ $my_message .= "Комментарий: <br>" . $message . "<hr/>"; } $my_message .= "Время заказа: " . date('H:i:s d.m.Y'); require_once($_SERVER['DOCUMENT_ROOT'] . '/include/libs/PHPMailer/class.phpmailer.php'); //Подключаем PHPMailer $mail = new PHPMailer(true); //New instance, with exceptions enabled $mail->CharSet = "UTF-8"; $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "smtp.yandex.ru"; // SMTP server $mail->SMTPDebug = 0; // enables SMTP debug information (for testing) $mail->SMTPAuth = true; // enable SMTP authentication $mail->Port = 465; // set the SMTP port for the GMAIL server $mail->SMTPSecure = 'ssl'; // Secure SMTP $mail->Username = 'from@matveevs,ru'; // SMTP account username $mail->Password = "fromPassword"; // SMTP account password $mail->SetFrom('from@matveevs,ru', 'site.ru'); $mail->AddReplyTo('from@matveevs,ru','site.ru'); $mail->Subject = "Сообщение с сайта site.ru"; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($my_message); $address = 'to@matveevs.ru'; $mail->AddAddress($address, "User"); $mail->CharSet="UTF-8"; $mail->IsHTML(true); // send as HTML if(!$mail->Send()) : $res = Array( "result" => false, "msg" => "Ошибка отправления" ); else: $res = Array( "result" => true, "msg" => "Спасибо! Ваша заявка отправлена" ); require $_SERVER["DOCUMENT_ROOT"] . '/addToBitrix.php'; endif; else: $res = Array( "result" => false, "msg" => "Ошибка: заполните все поля формы", "errors" => $errorFields ); endif; echo json_encode($res, JSON_UNESCAPED_UNICODE); |
addToBitrix.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<?php require $_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/main/include/prolog_before.php'; CModule::IncludeModule("catalog"); $el = new CIBlockElement; $PROP = array( "NAME" => $name, "PHONE" => $phone, "EMAIL" => $email, "MESSAGE" => $message ); $arFields = array( "IBLOCK_ID" => 10, "IBLOCK_SECTION_ID" => false, "NAME" => $name, "PROPERTY_VALUES" => $PROP, "ACTIVE" => "Y", ); $el->Add($arFields); |
1 2 3 4 5 6 7 8 9 |
RewriteCond %{HTTPS} off # First rewrite to HTTPS: # Don't put www. here. If it is already there it will be included, if not # the subsequent rule will catch it. RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Now, rewrite any request to the wrong domain to use www. # [NC] is a case-insensitive match RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] |
1 2 3 4 5 6 7 8 |
<? $APPLICATION->IncludeComponent("bitrix:main.include","",Array( "AREA_FILE_SHOW" => "file", "PATH" => SITE_TEMPLATE_PATH."/include/header.php", "EDIT_TEMPLATE" => "standard.php" ) ); ?> |
Документация
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
<?$APPLICATION->IncludeComponent( "bitrix:news.list", "slider-main", array( "ACTIVE_DATE_FORMAT" => "d.m.Y", "ADD_SECTIONS_CHAIN" => "Y", "AJAX_MODE" => "N", "AJAX_OPTION_ADDITIONAL" => "", "AJAX_OPTION_HISTORY" => "N", "AJAX_OPTION_JUMP" => "N", "AJAX_OPTION_STYLE" => "Y", "CACHE_FILTER" => "N", "CACHE_GROUPS" => "Y", "CACHE_TIME" => "36000000", "CACHE_TYPE" => "A", "CHECK_DATES" => "Y", "DETAIL_URL" => "", "DISPLAY_BOTTOM_PAGER" => "Y", "DISPLAY_DATE" => "Y", "DISPLAY_NAME" => "Y", "DISPLAY_PICTURE" => "Y", "DISPLAY_PREVIEW_TEXT" => "Y", "DISPLAY_TOP_PAGER" => "N", "FIELD_CODE" => array( 0 => "DETAIL_TEXT", 1 => "", ), "FILTER_NAME" => "", "HIDE_LINK_WHEN_NO_DETAIL" => "N", "IBLOCK_ID" => "4", "IBLOCK_TYPE" => "banner", "INCLUDE_IBLOCK_INTO_CHAIN" => "Y", "INCLUDE_SUBSECTIONS" => "Y", "MESSAGE_404" => "", "NEWS_COUNT" => "5", "PAGER_BASE_LINK_ENABLE" => "N", "PAGER_DESC_NUMBERING" => "N", "PAGER_DESC_NUMBERING_CACHE_TIME" => "36000", "PAGER_SHOW_ALL" => "N", "PAGER_SHOW_ALWAYS" => "N", "PAGER_TEMPLATE" => ".default", "PAGER_TITLE" => "Новости", "PARENT_SECTION" => "", "PARENT_SECTION_CODE" => "", "PREVIEW_TRUNCATE_LEN" => "", "PROPERTY_CODE" => array( 0 => "LINK", 1 => "ICON", 2 => "", ), "SET_BROWSER_TITLE" => "N", "SET_LAST_MODIFIED" => "N", "SET_META_DESCRIPTION" => "N", "SET_META_KEYWORDS" => "N", "SET_STATUS_404" => "N", "SET_TITLE" => "N", "SHOW_404" => "N", "SORT_BY1" => "SORT", "SORT_BY2" => "ACTIVE_FROM", "SORT_ORDER1" => "ASC", "SORT_ORDER2" => "DESC", "STRICT_SECTION_CHECK" => "N" ), false );?> |
Документация