Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Транслітерація назв картинок


 Share

Recommended Posts

Підкажіть, шукаю варіант як зробити  - для Ocstore

МОЖЛиво є готові модулі!

 

1. щоб назви картинок у великому обємі  (прописані  кирилицею )  перегенерувати на  латиницю 

 

2. Якщо загружаю  картинку де назва на кирилиці - щоб їх автоматично перегерувало на латиницю (на сервері)

 

Edited by Sokolov39
Link to comment
Share on other sites


  • Sokolov39 changed the title to Транслітерація назв картинок

э невеликий скріпт
котрий
SELECT image from product
file get_content CURL
translit
file_put_content
UPDATE product

 

 

			$sql ="SELECT product_id, image FROM " . DB_PREFIX . "product";
			$result = $this->db->query($sql);
			foreach ($result->rows as $p) {
				$curl = curl_init('Адрес Сайта/image/' . rawurlencode($p['image']));
				curl_setopt($curl, CURLOPT_HEADER, 0);
				curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
				curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
				curl_setopt($curl, CURLOPT_FORBID_REUSE, 1);
				curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);
	
				$response = curl_exec($curl);
				$file_name = strtolower($this->translit(str_replace('data/', '',$p['image'])));
	
				$directories = explode('/', dirname($file_name));
				$path = '';
				foreach ($directories as $directory) {
					$path = $path . '/' . $directory;
	
					if (!is_dir(DIR_IMAGE . 'catalog/' .  $path)) {
						@mkdir(DIR_IMAGE .  'catalog/' . $path, 0777);
					}
				}			
				file_put_contents(DIR_IMAGE . 'catalog/' . $file_name, $response);
				var_dump($file_name, $p['product_id']);
			$this->db->query("UPDATE " . DB_PREFIX . "product 
			SET `image` = '" . $this->db->escape('catalog/' . $file_name) . "'
			WHERE `product_id` = " . (int)$p['product_id']);

код не далек от совершенства, но 10гиг фото пробежал
 

  • +1 1
Link to comment
Share on other sites

В 06.12.2023 в 21:08, chukcha сказав:

э невеликий скріпт
котрий
SELECT image from product
file get_content CURL
translit
file_put_content
UPDATE product

 

 

			$sql ="SELECT product_id, image FROM " . DB_PREFIX . "product";
			$result = $this->db->query($sql);
			foreach ($result->rows as $p) {
				$curl = curl_init('Адрес Сайта/image/' . rawurlencode($p['image']));
				curl_setopt($curl, CURLOPT_HEADER, 0);
				curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
				curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
				curl_setopt($curl, CURLOPT_FORBID_REUSE, 1);
				curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);
	
				$response = curl_exec($curl);
				$file_name = strtolower($this->translit(str_replace('data/', '',$p['image'])));
	
				$directories = explode('/', dirname($file_name));
				$path = '';
				foreach ($directories as $directory) {
					$path = $path . '/' . $directory;
	
					if (!is_dir(DIR_IMAGE . 'catalog/' .  $path)) {
						@mkdir(DIR_IMAGE .  'catalog/' . $path, 0777);
					}
				}			
				file_put_contents(DIR_IMAGE . 'catalog/' . $file_name, $response);
				var_dump($file_name, $p['product_id']);
			$this->db->query("UPDATE " . DB_PREFIX . "product 
			SET `image` = '" . $this->db->escape('catalog/' . $file_name) . "'
			WHERE `product_id` = " . (int)$p['product_id']);

код не далек от совершенства, но 10гиг фото пробежал
 

$curl = curl_init('Адрес Сайта/image/' . rawurlencode($p['image']));

 

$file_name = strtolower($this->translit(str_replace('data/', '',$p['image'])));

Невистарчає методу $this->translit)

 

Ну і в curl_init свій адрес сайту потрібно вписати)

 

  • +1 1
Link to comment
Share on other sites

Старый древний относительно рабочий скрипт

 

Скрытый текст
<?php
class ControllerCommonCyrlat extends Controller {
public function index(){

print "<br><br>!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Product !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!<br><br><br>";

	$numnum = 0;		
	$query = $this->db->query("select image, product_id from " . DB_PREFIX . "product");
		
	$results_a = $query->rows;
			
	foreach ($results_a as $result_at) {
				
		if ($result_at['image'] && file_exists(DIR_IMAGE . $result_at['image'])) {
		

			$unic_flag = true;
			$old_image = $result_at['image'];
				
			if (preg_match('#[^A-Za-z0-9_\-/\.]#', $old_image)) 
			{
			$numnum = $numnum +1;
			print "<br>- ".$numnum." -<br>";
			
						$image_new = $this->translitIt($old_image);
						$image_new = preg_replace('#[^A-Za-z0-9_\-/\.]#', '', $image_new);
						
						$info = pathinfo($image_new);
						$extension = $info['extension'];
						$name_body = substr($image_new, 0, strrpos($image_new, '.'));
						$new_image = $name_body . '.' . $extension;
						$directories = explode('/', dirname(str_replace('../', '', $new_image)));
						array_shift($directories);
						
						$path = 'data';
						foreach ($directories as $directory) {
							$path = $path . '/' . $directory;
							
							if (!file_exists(DIR_IMAGE . $path)) {
								@mkdir(DIR_IMAGE . $path, 0777);
							}		
						}
						
						
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x91'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x92'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x93'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x94'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x95'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x96'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x97'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x98'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x99'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {print "<br>__________!!!!!! mnogo copiy takogo faila ".$old_image." --- ". $new_image . " __pid=(".$result['product_id'].")<br>";}
						
						if ($unic_flag && rename(DIR_IMAGE . $old_image, DIR_IMAGE . $new_image)) {
							print $old_image." = p = ".$new_image . " __pid=(".$result_at['product_id'].")<br>";
							$unic_flag = false;
						}
						else {print "<br>__________!!! ERRORcopyFile ".$old_image." === ". $new_image. " __pid=(".$result['product_id'].")<br>";}
			
			
			
			
// ищем в Продуктах

				$query = $this->db->query("select product_id, image from " . DB_PREFIX . "product where image='".$old_image."'");
		
				$results = $query->rows;

				foreach ($results as $result) {
				
					if ($result['image'] && ($result['image'] = $old_image)) {
						print "p(". $result['product_id'] .")<br>";
						$this->db->query("UPDATE " . DB_PREFIX . "product SET image='".$this->db->escape($new_image)."' where product_id ='".(int)$result['product_id']."'");
					}
				}
	
// теперь это же ищем в Продукт_Картинках
		
				$query = $this->db->query("select product_image_id, image from " . DB_PREFIX . "product_image where image='".$old_image."'");
		
				$results = $query->rows;
			
				foreach ($results as $result) {
				
					if ($result['image'] && ($result['image'] = $old_image)) {
						print "i(". $result['product_image_id'] .")<br>";
						$this->db->query("UPDATE " . DB_PREFIX . "product_image SET image='".$this->db->escape($new_image)."' where product_image_id ='".(int)$result['product_image_id']."'");
					}
				}
			
			}
		
		}
		else
			if (!file_exists(DIR_IMAGE . $result_at['image'])) {
			print "<br>__________file NOT found______". $result_at['image'] . " __pid=(".$result_at['product_id'].")<br>";
			}
	}
			
print "<br><br><br>!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Product_Image !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!<br><br><br>";

	// перебор Прод_картинок
			
	$query = $this->db->query("select image, product_image_id from " . DB_PREFIX . "product_image");
		
	$results_a = $query->rows;
			
	foreach ($results_a as $result_at) {
				
		if ($result_at['image'] && file_exists(DIR_IMAGE . $result_at['image'])) {

			$unic_flag = true;
			$old_image = $result_at['image'];
				
			if (preg_match('#[^A-Za-z0-9_\-/\.]#', $old_image)) 
			{
			$numnum = $numnum +1;
			print "<br>- ".$numnum." -<br>";
						$image_new = $this->translitIt($old_image);
						$image_new = preg_replace('#[^A-Za-z0-9_\-/\.]#', '', $image_new);
						
						$info = pathinfo($image_new);
						$extension = $info['extension'];
						$name_body = substr($image_new, 0, strrpos($image_new, '.'));
						$new_image = $name_body . '.' . $extension;
						$directories = explode('/', dirname(str_replace('../', '', $new_image)));
						array_shift($directories);
						
						$path = 'data';
						foreach ($directories as $directory) {
							$path = $path . '/' . $directory;
							
							if (!file_exists(DIR_IMAGE . $path)) {
								@mkdir(DIR_IMAGE . $path, 0777);
							}		
						}
						
						
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x91'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x92'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x93'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x94'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x95'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x96'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x97'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x98'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x99'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {print "<br>__________!!!!!! mnogo copiy takogo faila ".$old_image." --- ". $new_image . " __piid=(".$result['product_image_id'].")<br>";}
						
						if ($unic_flag && rename(DIR_IMAGE . $old_image, DIR_IMAGE . $new_image)) {
							print $old_image." = i = ".$new_image . " __piid=(".$result_at['product_image_id'].")<br>";
							$unic_flag = false;
						}
						else {print "<br>__________!!! ERRORcopyFile ".$old_image." === ". $new_image. " __piid=(".$result['product_image_id'].")<br>";}
			
			
			
			
// ищем в Продукт_image

				$query = $this->db->query("select product_image_id, image from " . DB_PREFIX . "product_image where image='".$old_image."'");
		
				$results = $query->rows;

				foreach ($results as $result) {
				
					if ($result['image'] && ($result['image'] = $old_image)) {
						print "i(". $result['product_image_id'] .")<br>";
						$this->db->query("UPDATE " . DB_PREFIX . "product_image SET image='".$this->db->escape($new_image)."' where product_image_id ='".(int)$result['product_image_id']."'");
					}
				}
	
// теперь это же ищем в Продуктах
		
				$query = $this->db->query("select product_id, image from " . DB_PREFIX . "product where image='".$old_image."'");
		
				$results = $query->rows;
			
				foreach ($results as $result) {
				
					if ($result['image'] && ($result['image'] = $old_image)) {
						print "p(". $result['product_id'] .")<br>";
						$this->db->query("UPDATE " . DB_PREFIX . "product SET image='".$this->db->escape($new_image)."' where product_id ='".(int)$result['product_id']."'");
					}
				}
			
			}
		
		}
		else
			if (!file_exists(DIR_IMAGE . $result_at['image'])) {
			print "<br>__________file NOT found______". $result_at['image'] . " __piid=(".$result_at['product_image_id'].")<br>";
			}
	}

	
}

	private function translitIt($str) 
	{
		$tr = array(
			"А"=>"A","Б"=>"B","В"=>"V","Г"=>"G",
			"Д"=>"D","Е"=>"E","Ж"=>"J","З"=>"Z","И"=>"I",
			"Й"=>"Y","К"=>"K","Л"=>"L","М"=>"M","Н"=>"N",
			"О"=>"O","П"=>"P","Р"=>"R","С"=>"S","Т"=>"T",
			"У"=>"U","Ф"=>"F","Х"=>"H","Ц"=>"TS","Ч"=>"CH",
			"Ш"=>"SH","Щ"=>"SCH","Ъ"=>"","Ы"=>"YI","Ь"=>"",
			"Э"=>"E","Ю"=>"YU","Я"=>"YA","а"=>"a","б"=>"b",
			"в"=>"v","г"=>"g","д"=>"d","е"=>"e","ж"=>"j",
			"з"=>"z","и"=>"i","й"=>"y","к"=>"k","л"=>"l",
			"м"=>"m","н"=>"n","о"=>"o","п"=>"p","р"=>"r",
			"с"=>"s","т"=>"t","у"=>"u","ф"=>"f","х"=>"h",
			"ц"=>"ts","ч"=>"ch","ш"=>"sh","щ"=>"sch","ъ"=>"",
			"ы"=>"yi","ь"=>"","э"=>"e","ю"=>"yu","я"=>"ya", 
			" "=> "_","+"=>"_plus_","!"=>"_i_","%20"=>"_","Ё"=>"IO",
			"ё"=>"io",
			"$"=>"_",
			","=>"_",
			"&"=>"_",
			"!"=>"_",
			"("=>"_",
			")"=>"_",
			";"=>"_",
			
		);
		return strtr($str,$tr);
	}
}	
?>

 

 

  • +1 2
Link to comment
Share on other sites

06.12.2023 в 22:24, spectre сказал:

Старый древний относительно рабочий скрипт

 

  Показать содержимое
<?php
class ControllerCommonCyrlat extends Controller {
public function index(){

print "<br><br>!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Product !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!<br><br><br>";

	$numnum = 0;		
	$query = $this->db->query("select image, product_id from " . DB_PREFIX . "product");
		
	$results_a = $query->rows;
			
	foreach ($results_a as $result_at) {
				
		if ($result_at['image'] && file_exists(DIR_IMAGE . $result_at['image'])) {
		

			$unic_flag = true;
			$old_image = $result_at['image'];
				
			if (preg_match('#[^A-Za-z0-9_\-/\.]#', $old_image)) 
			{
			$numnum = $numnum +1;
			print "<br>- ".$numnum." -<br>";
			
						$image_new = $this->translitIt($old_image);
						$image_new = preg_replace('#[^A-Za-z0-9_\-/\.]#', '', $image_new);
						
						$info = pathinfo($image_new);
						$extension = $info['extension'];
						$name_body = substr($image_new, 0, strrpos($image_new, '.'));
						$new_image = $name_body . '.' . $extension;
						$directories = explode('/', dirname(str_replace('../', '', $new_image)));
						array_shift($directories);
						
						$path = 'data';
						foreach ($directories as $directory) {
							$path = $path . '/' . $directory;
							
							if (!file_exists(DIR_IMAGE . $path)) {
								@mkdir(DIR_IMAGE . $path, 0777);
							}		
						}
						
						
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x91'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x92'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x93'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x94'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x95'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x96'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x97'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x98'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x99'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {print "<br>__________!!!!!! mnogo copiy takogo faila ".$old_image." --- ". $new_image . " __pid=(".$result['product_id'].")<br>";}
						
						if ($unic_flag && rename(DIR_IMAGE . $old_image, DIR_IMAGE . $new_image)) {
							print $old_image." = p = ".$new_image . " __pid=(".$result_at['product_id'].")<br>";
							$unic_flag = false;
						}
						else {print "<br>__________!!! ERRORcopyFile ".$old_image." === ". $new_image. " __pid=(".$result['product_id'].")<br>";}
			
			
			
			
// ищем в Продуктах

				$query = $this->db->query("select product_id, image from " . DB_PREFIX . "product where image='".$old_image."'");
		
				$results = $query->rows;

				foreach ($results as $result) {
				
					if ($result['image'] && ($result['image'] = $old_image)) {
						print "p(". $result['product_id'] .")<br>";
						$this->db->query("UPDATE " . DB_PREFIX . "product SET image='".$this->db->escape($new_image)."' where product_id ='".(int)$result['product_id']."'");
					}
				}
	
// теперь это же ищем в Продукт_Картинках
		
				$query = $this->db->query("select product_image_id, image from " . DB_PREFIX . "product_image where image='".$old_image."'");
		
				$results = $query->rows;
			
				foreach ($results as $result) {
				
					if ($result['image'] && ($result['image'] = $old_image)) {
						print "i(". $result['product_image_id'] .")<br>";
						$this->db->query("UPDATE " . DB_PREFIX . "product_image SET image='".$this->db->escape($new_image)."' where product_image_id ='".(int)$result['product_image_id']."'");
					}
				}
			
			}
		
		}
		else
			if (!file_exists(DIR_IMAGE . $result_at['image'])) {
			print "<br>__________file NOT found______". $result_at['image'] . " __pid=(".$result_at['product_id'].")<br>";
			}
	}
			
print "<br><br><br>!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Product_Image !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!<br><br><br>";

	// перебор Прод_картинок
			
	$query = $this->db->query("select image, product_image_id from " . DB_PREFIX . "product_image");
		
	$results_a = $query->rows;
			
	foreach ($results_a as $result_at) {
				
		if ($result_at['image'] && file_exists(DIR_IMAGE . $result_at['image'])) {

			$unic_flag = true;
			$old_image = $result_at['image'];
				
			if (preg_match('#[^A-Za-z0-9_\-/\.]#', $old_image)) 
			{
			$numnum = $numnum +1;
			print "<br>- ".$numnum." -<br>";
						$image_new = $this->translitIt($old_image);
						$image_new = preg_replace('#[^A-Za-z0-9_\-/\.]#', '', $image_new);
						
						$info = pathinfo($image_new);
						$extension = $info['extension'];
						$name_body = substr($image_new, 0, strrpos($image_new, '.'));
						$new_image = $name_body . '.' . $extension;
						$directories = explode('/', dirname(str_replace('../', '', $new_image)));
						array_shift($directories);
						
						$path = 'data';
						foreach ($directories as $directory) {
							$path = $path . '/' . $directory;
							
							if (!file_exists(DIR_IMAGE . $path)) {
								@mkdir(DIR_IMAGE . $path, 0777);
							}		
						}
						
						
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x91'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x92'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x93'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x94'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x95'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x96'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x97'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x98'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {$new_image = $name_body . '_x99'. '.' . $extension; print "* ";}
						if ($unic_flag && file_exists(DIR_IMAGE . $new_image)) {print "<br>__________!!!!!! mnogo copiy takogo faila ".$old_image." --- ". $new_image . " __piid=(".$result['product_image_id'].")<br>";}
						
						if ($unic_flag && rename(DIR_IMAGE . $old_image, DIR_IMAGE . $new_image)) {
							print $old_image." = i = ".$new_image . " __piid=(".$result_at['product_image_id'].")<br>";
							$unic_flag = false;
						}
						else {print "<br>__________!!! ERRORcopyFile ".$old_image." === ". $new_image. " __piid=(".$result['product_image_id'].")<br>";}
			
			
			
			
// ищем в Продукт_image

				$query = $this->db->query("select product_image_id, image from " . DB_PREFIX . "product_image where image='".$old_image."'");
		
				$results = $query->rows;

				foreach ($results as $result) {
				
					if ($result['image'] && ($result['image'] = $old_image)) {
						print "i(". $result['product_image_id'] .")<br>";
						$this->db->query("UPDATE " . DB_PREFIX . "product_image SET image='".$this->db->escape($new_image)."' where product_image_id ='".(int)$result['product_image_id']."'");
					}
				}
	
// теперь это же ищем в Продуктах
		
				$query = $this->db->query("select product_id, image from " . DB_PREFIX . "product where image='".$old_image."'");
		
				$results = $query->rows;
			
				foreach ($results as $result) {
				
					if ($result['image'] && ($result['image'] = $old_image)) {
						print "p(". $result['product_id'] .")<br>";
						$this->db->query("UPDATE " . DB_PREFIX . "product SET image='".$this->db->escape($new_image)."' where product_id ='".(int)$result['product_id']."'");
					}
				}
			
			}
		
		}
		else
			if (!file_exists(DIR_IMAGE . $result_at['image'])) {
			print "<br>__________file NOT found______". $result_at['image'] . " __piid=(".$result_at['product_image_id'].")<br>";
			}
	}

	
}

	private function translitIt($str) 
	{
		$tr = array(
			"А"=>"A","Б"=>"B","В"=>"V","Г"=>"G",
			"Д"=>"D","Е"=>"E","Ж"=>"J","З"=>"Z","И"=>"I",
			"Й"=>"Y","К"=>"K","Л"=>"L","М"=>"M","Н"=>"N",
			"О"=>"O","П"=>"P","Р"=>"R","С"=>"S","Т"=>"T",
			"У"=>"U","Ф"=>"F","Х"=>"H","Ц"=>"TS","Ч"=>"CH",
			"Ш"=>"SH","Щ"=>"SCH","Ъ"=>"","Ы"=>"YI","Ь"=>"",
			"Э"=>"E","Ю"=>"YU","Я"=>"YA","а"=>"a","б"=>"b",
			"в"=>"v","г"=>"g","д"=>"d","е"=>"e","ж"=>"j",
			"з"=>"z","и"=>"i","й"=>"y","к"=>"k","л"=>"l",
			"м"=>"m","н"=>"n","о"=>"o","п"=>"p","р"=>"r",
			"с"=>"s","т"=>"t","у"=>"u","ф"=>"f","х"=>"h",
			"ц"=>"ts","ч"=>"ch","ш"=>"sh","щ"=>"sch","ъ"=>"",
			"ы"=>"yi","ь"=>"","э"=>"e","ю"=>"yu","я"=>"ya", 
			" "=> "_","+"=>"_plus_","!"=>"_i_","%20"=>"_","Ё"=>"IO",
			"ё"=>"io",
			"$"=>"_",
			","=>"_",
			"&"=>"_",
			"!"=>"_",
			"("=>"_",
			")"=>"_",
			";"=>"_",
			
		);
		return strtr($str,$tr);
	}
}	
?>

 

 

 

07.12.2023 в 11:44, Sokolov39 сказал:

А готового модуля нема, щоб мав такий функціонал

Або можливо у пакетном редакторі він є якомусь ? 

 

Link to comment
Share on other sites

В 07.12.2023 в 11:44, Sokolov39 сказав:

А готового модуля нема, щоб мав такий функціонал

Або можливо у пакетном редакторі він є якомусь ? 

@spectre вам надав.

 

  1. Створюєте новий файл cyrlat.php в admin/controller/common
  2. Вставляєте весь код в файл
  3. В Правах груп користувачів надаєте доступ до common/cyrlat
  4. Запускаєте скрипт через браузер - https://ваш_сайт/admin/index.php?route=common/cyrlat

 

 

 

  • +1 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.