HEX
Server: Apache/2.4.6 (CentOS) mpm-itk/2.4.7-04 mod_fcgid/2.3.9 PHP/5.4.16
System: Linux dvm.vladweb.ru 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: region-gk.ru (1016)
PHP: 7.3.33
Disabled: NONE
Upload Files
File: //home/temp/yarusvl.ru/exchanger/functions.php
<?php
/**
 * Created by el.
 * @autor: el
 * @pakage: el
 * @version: 0.1 13.08.18 15:52
 * Date: 13.08.18
 */
 
function validationXML($xmlFile, $err='') {
	$xml = file_get_contents($xmlFile);
	if($xml === false) {
		$subject = 'XML файл ' . $err . ' не найден';
		$content = 'XML файл ' . $err . ' не найден.
					<br/>Адрес файла: <b>' . $xmlFile . '</b><br/>
					<br/>
					При многократном повторении данной ошибки, обратитесь к поставщику '  . '
					за разъяснением причин отсутствия данного файла.';
		sendErrorAdmin($subject, $content);
		return false;
	}

	try {
		$xml = new SimpleXMLElement($xml);
	} catch(Exception $e) {
		$subject = 'Ошибка разбора XML файла ' . $err;
		$content = 'При разборе XML файла ' . $err . ' произошла ошибка.
					<br/>Адрес файла: <b>' . $xmlFile . ' </b><br/>
					<br/>
					При многократном повторении данной ошибки, обратитесь к поставщику ' ;
		sendErrorAdmin($subject, $content);
		return false;
	}
	return $xml;
}



function sendErrorAdmin($subj,$content){
    return true;
}


function getBrand($name,$update = false){
    global $mgc;
    $brand1['url'] = $mgc->brands->translit_alpha($name);
    $brand1['meta_title'] = $name;
    $brand1['meta_keywords'] = $name;
    $brand1['meta_description'] = $name;
    $brand1['visible'] = 1;
    $brand1['name'] = $name;
    
    $id = $mgc->brands->get_brand((string)$brand1['url']);
    $id = $id->id;
    
    if(!$id)$id = $mgc->brands->add_brand($brand1);
    else if($update)$mgc->brands->update_brand($id,$brand1);

    return $id;
}

function check_http_status($url)
  {
  $user_agent = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_VERBOSE, false);
  curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_SSLVERSION, 3);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  $page = curl_exec($ch);

  $err = curl_error($ch);
  if (!empty($err))
    return $err;
 
  $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  curl_close($ch);
  return $httpcode;
  }