Skip to content

Instantly share code, notes, and snippets.

View seriiserii825's full-sized avatar

Burduja Sergiu seriiserii825

  • Bludelego
  • Moldova. Chishinau
View GitHub Profile
@seriiserii825
seriiserii825 / form-ajax
Last active June 12, 2017 21:23
form-ajax
$(".forms").submit(function() {
$.ajax({
type: "POST",
url: "mail.php",
data: $(this).serialize()
}).done(function() {
alert("Спасибо за заявку! Скоро мы с вами свяжемся.");
setTimeout(function(){
$(".form").trigger("reset");
});
$recepient = "agragregra@ya.ru";
$sitename = "Название сайта";
$name = trim($_POST["name"]);
$phone = trim($_POST["phone"]);
$text = trim($_POST["text"]);
$message = "Имя: $name \nТелефон: $phone \nТекст: $text";
$pagetitle = "Новая заявка с сайта \"$sitename\"";
mail($recepient, $pagetitle, $message, "Content-type: text/plain; charset=\"utf-8\"\n From: $recepient");
/*img svg
===============================*/
if(!Modernizr.svg){
$('img[src*="svg"]').attr('src', function(){
return $(this).attr().replace('svg', 'png');
});
}
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Слой_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 2457.6 100" preserveAspectRatio="none" style="enable-background:new 0 0 2457.6 100;" xml:space="preserve">
<style type="text/css">
.st0{fill:#394B5F;}
</style>
<polyline class="st0" points="1228.8,0 2457.6,100 0,100 "/>
</svg>
$('.card').each(function(index){
var ths = $(this);
setInterval(function(){
ths.removeClass('active');
}, 100*index);
});
function isNumeric(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
@seriiserii825
seriiserii825 / index.php
Created July 21, 2017 23:11
Function str_all_pos
function str_all_pos($haystack, $needle) {
$pos = 0;
$result = [];
while (false !== ($pos = strpos($haystack, $needle, $pos))) {
$result[] = $pos;
$pos = $pos + strlen($needle);
}
return $result;
}
function autoload($className){
//переводим в нижний регистр; заменяем обратные слеши.
$path = str_replace('\\', '/', $className).'.php';
if(is_readable($path)){
require_once ($path);//подключаем файл
}else throw new \DbException('Класс не найден: '.$path);
}
//регистрируем функцию
spl_autoload_register('autoload');
class Singleton
{
protected static $instance;
protected function __construct()
{
}
public static function instance()
$option = [
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
\PDO::ATTR_EMULATE_PREPARES => false
];
try{
$this->dbh = new \PDO('mysql:host=127.0.0.1;dbname=stepantev', 'root', 'root', $option);
$this->dbh->exec('set charset UTF8');
}