' -background white -gravity center -extent 800x600 " . $dst); } /* ---------------------------------------------------------------------- 17.03.2023 Получаем получаем последню цену ---------------------------------------------------------------------- */ static function GetLostPrice($tovar_id) { return \DB::getValue("SELECT `cena` FROM `tovar_price_history` WHERE `tovar_id`=? AND `status`=1 ORDER BY `t` DESC LIMIT 1", $tovar_id); } /* ---------------------------------------------------------------------- 06.07.2023 Поиск текста по строке ---------------------------------------------------------------------- */ static function findtxt($txt, $find) { $r = (stripos($txt, $find) === false) ? 0 : 1; /* $pos1 = stripos($txt, $find); if ($pos1 === false) return 0; else return 1;*/ return $r; } /* ---------------------------------------------------------------------- 08.07.2023 Уникализирует массив, документация: https://snipp.ru/php/array-unique-multi ---------------------------------------------------------------------- */ static function array_unique_key($array, $key) { $tmp = $key_array = array(); $i = 0; foreach ($array as $val) { if (!in_array($val[$key], $key_array)) { $key_array[$i] = $val[$key]; $tmp[$i] = $val; } $i++; } return $tmp; } /* ---------------------------------------------------------------------- 26.08.2023 Загружаем фотки в таблицу img ---------------------------------------------------------------------- */ static function upload_img($content_type, $content_id, $clear = 0) { @mkdir('img/' . $_SERVER['SERVER_NAME'] . '/' . $content_type, 0700); @mkdir('img/' . $_SERVER['SERVER_NAME'] . '/' . $content_type . '/' . $content_id, 0700); if ($_FILES['file']['tmp_name']) { if (preg_match('/[.](jpg)|(jpeg)|(JPG)|(JPEG)$/', $_FILES['file']['name'])) { $img_name = self::genpassword(30); $source = $_FILES['file']['tmp_name']; $target_original = 'img/' . $_SERVER['SERVER_NAME'] . '/' . $content_type . '/' . $content_id . '/' . $img_name . '.jpg'; copy($source, $target_original); \DB::add("INSERT INTO `img` (`filename`, `content_type`, `content_id`) VALUES (?, ?, ?)", array($img_name, $content_type, $content_id)); if ($clear == 1) { //удаляем мусор $hlam = \DB::getAll("SELECT * FROM `img` WHERE `content_type`=? AND `content_id`=? AND `filename`<>?", array($content_type, $content_id, $img_name)); for ($i = 0; $i < count($hlam); $i++) unlink('img/' . $_SERVER['SERVER_NAME'] . '/' . $content_type .'/' . $content_id . '/' . $hlam[$i]['filename'] . '.jpg'); \DB::set("DELETE FROM `img` WHERE `content_type`=? AND `content_id`=? AND `filename`<>?", array($content_type, $content_id, $img_name)); } $res['img'] = $img_name; echo \json::to_j($res); } } } } ?>