getMessage() . "\n"); } if (Configure::read('debug')) { Configure::write('Cache._cake_model_.duration', '+2 minutes'); Configure::write('Cache._cake_core_.duration', '+2 minutes'); // disable router cache during development Configure::write('Cache._cake_routes_.duration', '+2 seconds'); } date_default_timezone_set('Europe/Moscow'); mb_internal_encoding(Configure::read('App.encoding')); ini_set('intl.default_locale', Configure::read('App.defaultLocale')); $isCli = PHP_SAPI === 'cli'; if ($isCli) { (new ConsoleErrorHandler(Configure::read('Error')))->register(); } else { (new ErrorHandler(Configure::read('Error')))->register(); } if ($isCli) { require __DIR__ . '/bootstrap_cli.php'; } if (!Configure::read('App.fullBaseUrl')) { $s = null; if (env('HTTPS')) { $s = 's'; } $httpHost = env('HTTP_HOST'); if (isset($httpHost)) { Configure::write('App.fullBaseUrl', 'http' . $s . '://' . $httpHost); } unset($httpHost, $s); } Cache::setConfig(Configure::consume('Cache')); ConnectionManager::setConfig(Configure::consume('Datasources')); //Email::setConfigTransport(Configure::consume('EmailTransport')); //Email::setConfig(Configure::consume('Email')); Log::setConfig(Configure::consume('Log')); Security::setSalt(Configure::consume('Security.salt')); ServerRequest::addDetector('mobile', function ($request) { $detector = new \Detection\MobileDetect(); return $detector->isMobile(); }); ServerRequest::addDetector('tablet', function ($request) { $detector = new \Detection\MobileDetect(); return $detector->isTablet(); }); Type::build('time') ->useImmutable(); Type::build('date') ->useImmutable(); Type::build('datetime') ->useImmutable(); Type::build('timestamp') ->useImmutable(); require_once(ROOT . DS . 'vendor' . DS . 'dbf' . DS . 'DBF.class.php'); require_once(ROOT . DS . 'vendor' . DS . 'sms' . DS . 'sms.ru.php'); require_once(ROOT . DS . 'vendor' . DS . 'browser_detection' . DS . 'BrowserDetection.php'); //require_once(ROOT . DS . 'vendor' . DS . 'mpdf' . DS . 'mpdf.php'); function cmpDetailsByBothSides($a, $b) { if (max($a->width, $a->height) != max($b->width, $b->height)) { return (max($a->width, $a->height) > max($b->width, $b->height)) ? -1 : 1; } else { if (min($a->width, $a->height) != min($b->width, $b->height)) { return (min($a->width, $a->height) > min($b->width, $b->height)) ? -1 : 1; } else { if ($a->height != $b->height) { return ($a->height > $b->height ) ? -1 : 1; } else { if ($a->width == $b->width ) { return 0; } return ($a->width > $b->width ) ? -1 : 1; } } } } function cmpDetailsByBothSidesReversed($a, $b) { if (max($a->width, $a->height) != max($b->width, $b->height)) { return (max($a->width, $a->height) > max($b->width, $b->height)) ? 1 : -1; } else { if (min($a->width, $a->height) != min($b->width, $b->height)) { return (min($a->width, $a->height) > min($b->width, $b->height)) ? 1 : -1; } else { if ($a->height != $b->height) { return ($a->height > $b->height ) ? 1 : -1; } else { if ($a->width == $b->width ) { return 0; } return ($a->width > $b->width ) ? 1 : -1; } } } } function cmpDetailsByWidth($a, $b) { if ($a->width != $b->width) { return ($a->width > $b->width ) ? -1 : 1; } else { return 0; } } function cmpDetailsByWidthReversed($a, $b) { if ($a->width != $b->width) { return ($a->width > $b->width ) ? 1 : -1; } else { return 0; } } function cmpDetailsByHeight($a, $b) { if ($a->height != $b->height) { return ($a->height > $b->height ) ? -1 : 1; } else { return 0; } } function cmpDetailsByHeightReversed($a, $b) { if ($a->height != $b->height) { return ($a->height > $b->height ) ? 1 : -1; } else { return 0; } } function cmpDetailsByBothSidesForToTop($a, $b) { if ($a->height != $b->height) { return ($a->height > $b->height ) ? -1 : 1; } else { if ($a->width != $b->width) { return ($a->width > $b->width ) ? -1 : 1; } else { return 0; } } } if (!function_exists('mb_ucfirst') && function_exists('mb_substr')) { function mb_ucfirst($string) { $string = mb_strtoupper(mb_substr($string, 0, 1)) . mb_substr($string, 1); return $string; } } function toFixed2($num) { return str_replace(".00", "", number_format(ceil($num * 10000) / 10000, 2, ".", "")); } function toFixed2Price($num) { return number_format(str_replace(" ", "", $num), 2, ".", " "); } function cleanupPhone($phone) { return str_replace(["+", "-", " ", "(", ")"], "", $phone); } function formatPhone($phone) { return "+7 (" . substr($phone, 1, 3) . ") " . substr($phone, 4, 3) . "-" . substr($phone, 7, 2) . "-" . substr($phone, 9, 2); } function cleanupEmail($email) { return str_replace([" "], "", $email); } function br2nl($str) { return preg_replace('/\/ui', "\r\n", $str); } function cleanupDetailLabel($label) { return preg_replace("/_{2,}/", "_", preg_replace("/[^\w\d\\*]/ui", "_" , $label)); } function cleanupDetailLabel2($label) { return preg_replace("/_{2,}/", "_", preg_replace("/[^\w\d\\*\-]/ui", "_" , $label)); } function counterPluralForm($number, $before, $after, $echoResults = false ) { $cases = array(2,0,1,1,1,2); $result = $before[($number % 100 > 4 && $number % 100 < 20) ? 2 : $cases[min($number % 10, 5)]] . ' ' . $number . ' ' . $after[($number % 100 > 4 && $number % 100 < 20) ? 2 : $cases[min($number % 10, 5)]]; if ($echoResults) { echo $result; } else { return $result; } }