403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/abricos.chatgpt/load/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/abricos.chatgpt/load/lib.php
<?php
Class CAbricosChatgptLib
{
	static function getProfile($id)
	{
		if ($id > 0) {
			global $DB;
			$strSql = "SELECT * FROM `abricos_chatgpt_profile` where `id`=" . $id . ";";
			$res = $DB->Query($strSql, false, __LINE__);
			$row = $res->Fetch();
			return ($row);
		}
	}
	static function CurlInstalled()
	{
		if (in_array('curl', get_loaded_extensions())) {
			return true;
		} else {
			return false;
		}
	}
	static function prepareVars($SETUP_VARS)
	{
		if (!CModule::IncludeModule("abricos.chatgpt")) die;
		$vars = array();
		parse_str($SETUP_VARS, $vars);
		return $vars;
	}

	static function get_text($templ, $text)
	{
		$templ = str_replace('#NAME#', $text, $templ);
		return $templ;
	}
	static function GetProp($prodId, $iblockId, $propId,$nidName=false)
	{
		$propVal = false;
		$db_props = CIBlockElement::GetProperty($iblockId, $prodId, Array("sort" => "asc"), Array("ID" => $propId));
		if ($ob = $db_props->GetNext()) {
			if ($ob['PROPERTY_TYPE'] == 'N') {
				$propVal = $ob['~VALUE'];
				$isArray = is_array($propVal);
				if (($isArray && !empty($arProperty['~VALUE']))
					|| (!$isArray && $arProperty['~VALUE'] != '')) {
					$value = call_user_func_array(
						$arUserTypeFormat[$PROPERTY],
						array(
							$iblockProperty,
							array("VALUE" => $arProperty["~VALUE"]),
							array('MODE' => 'SIMPLE_TEXT')
						)
					);
				}
			} elseif ($ob['PROPERTY_TYPE'] == 'L') $propVal = $ob['VALUE_ENUM'];
			elseif ($ob['PROPERTY_TYPE'] == 'S' and $ob['USER_TYPE'] == 'HTML') $propVal = $ob["~VALUE"]["TEXT"];
			elseif ($ob['PROPERTY_TYPE'] == 'S' and $ob['USER_TYPE'] == 'directory') {
				$propVal = '';
				$XML_ID = $ob["VALUE"];
				$a = $ob['USER_TYPE_SETTINGS'];
				$tableName = $a['TABLE_NAME'];
				$hlblock = \Bitrix\Highloadblock\HighloadBlockTable::getList(
					array(
						"filter" => array(
							'TABLE_NAME' => $tableName
						)
					)
				)->fetch();
				if (isset($hlblock['ID'])) {
					$entity = \Bitrix\Highloadblock\HighloadBlockTable::compileEntity($hlblock);
					$entity_data_class = $entity->getDataClass();
					$res = $entity_data_class::getList(array('filter' => array('UF_XML_ID' => $XML_ID,)));
					if ($item = $res->fetch()) $propVal = $item['UF_NAME'];
				}
			} elseif ($ob['PROPERTY_TYPE'] == 'E') {
				$propId = $ob['VALUE'];
				$element = CIBlockElement::GetList([], ['=ID' => $propId], false, false, ['ID', 'NAME'])->Fetch();
				$propVal = $element['NAME'];
			} 
			elseif($ob['PROPERTY_TYPE'] == 'F')
			$propVal = false;
			else $propVal = $ob['VALUE'];
		}
	if($nidName and $propVal)
		return ($ob['NAME'].'-'.$propVal);
	else
		return $propVal;
	}
	static function getSQL()
	{
		global $DB;
		$strSql = "SELECT count(*) as CNT FROM `abricos_chatgpt_export` WHERE `in_iblock`>0;";
		$res = $DB->Query($strSql, false, __LINE__);
		$row = $res->Fetch();
		return $row['CNT'];
	}
	
	static function GetKeyApi($keyString,$keyArr=0)
	{
		$keyString=trim($keyString);
		$array = explode(PHP_EOL, $keyString);		
		if(!is_integer($keyArr) and $keyArr==='rand')
			$key=$array[array_rand($array)];			  
		else  
			$key=$array[$keyArr];
		if($key=='')
			$key=$array[0];
		return $key;
	}
	static function addRowQuestion($arProp, $nameIn, $sel = '')
	{
		$res = "<select name='" . $nameIn . "'>\n";
		$res .= '<option value="name" '.($sel == 'name' ? 'selected' : '').'>'. GetMessage('CHATGPT_NAME') . "</option>\n";
		$res .= '<option value="url" '.($sel == 'url' ? 'selected' : '').'>'. GetMessage('CHATGPT_URL') . "</option>\n";
		$res .= '<option value="descr" '.($sel == 'descr' ? 'selected' : '').'>'. GetMessage('CHATGPT_QDESCR') . "</option>\n";
		$res .= '<option value="prew" '.($sel == 'prew' ? 'selected' : '').'>'. GetMessage('CHATGPT_QPREW') . "</option>\n";
		$res .= '<option value>' . GetMessage('CHATGPT_PROP_PROP') . "</option>\n";
		foreach ($arProp as $key => $val) {
			$res .= '<option value="' . $key . '"' . ($sel == $key ? 'selected' : '') . '>';
			$res .= $val['NAME'] . ' [' . $key . ']';
			$res .= "</option>\n";
		}
		$res .= "</select>\n";
		return $res;
	}
	
	static function addRowAnswer($arProp, $nameIn, $sel = '')
	{
		$res = "<select name='" . $nameIn . "'>\n";
		$res .= '<option value="descr" '. ($sel == 'descr' ? 'selected' : '') .'>' . GetMessage('CHATGPT_DESCR') . "</option>\n";
		$res .= '<option value="prew" '. ($sel == 'prew' ? 'selected' : '') .'>' . GetMessage('CHATGPT_PREW') . "</option>\n";
		$res .= '<option value="seo_title" '. ($sel == 'seo_title' ? 'selected' : '') .'>' . GetMessage('CHATGPT_SEO_TITLE') . "</option>\n";
		$res .= '<option value="seo_key" '. ($sel == 'seo_key' ? 'selected' : '') .'>' . GetMessage('CHATGPT_SEO_KEY') . "</option>\n";
		$res .= '<option value="seo_descr" '. ($sel == 'seo_descr' ? 'selected' : '') .'>' . GetMessage('CHATGPT_SEO_DESCR') . "</option>\n";
		$res .= '<option value>' . GetMessage('CHATGPT_PROP') . "</option>\n";
		foreach ($arProp as $key => $val) {
			$res .= '<option value="' . $key . '"' . ($sel == $key ? 'selected' : '') . '>';
			$res .= $val['NAME'] . ' [' . $key . ']';
			$res .= "</option>\n";
		}
		$res .= "</select>\n";
		return $res;
	}

	static function addRowProp($arProp, $nameIn, $sel = array())
	{
		if(!$sel) $sel = array();
		$res = "<select multiple name='" . $nameIn . "[]'>\n";
		foreach ($arProp as $key => $val) {
			$res .= '<option value="' . $key . '"' . (is_array($sel) and in_array($key,$sel) ? 'selected' : '') . '>';
			$res .= $val['NAME'] . ' [' . $key . ']';
			$res .= "</option>\n";
		}
		$res .= "</select>\n";
		return $res;
	}

	
	static function getSectionName($sectionId) {
    $section = CIBlockSection::GetByID($sectionId)->GetNext();
    return $section["NAME"];
}

	static function addRowQuestionCat($sectionId) 
	{
    $section = CIBlockSection::GetByID($sectionId)->GetNext();
    return $section["NAME"];
	}
	static function getName($id)
	{
		$app = new CBitrixComponent();
		$element = new CIBlockElement;
		$select = array("IBLOCK_ID");
		$filter = array("ID" => $id);
		$result = $element->GetList(array(), $filter, false, false, $select);
		if ($row = $result->Fetch()) 
			$iblockId = $row["IBLOCK_ID"];
		$res = CIBlockElement::GetByID($id);
		$arButtons = CIBlock::GetPanelButtons(
			 $iblockId,
			 $id,
			 0,
			 array("SECTION_BUTTONS"=>false, "SESSID"=>false)
		 );
        $elem["EDIT_LINK"] = $arButtons["edit"]["edit_element"]["ACTION_URL"];
		if ($ar_res = $res->GetNext()) 
			return '<a href="' . $elem["EDIT_LINK"] . '&bxpublic=N" target="blank">' . $ar_res['NAME'] . '</a>';
		else{
			$section = CIBlockSection::GetByID($id)->Fetch();
			if ($section) {
				return $section["NAME"];
			} else {
				return "";
			}
		}
	}

	static function updateExportTable($id_element, $question, $answer, $profile_id, $in_iblock)
	{
		global $DB;
		$data = date("d.m.y H-i");
		$id_element = intval($id_element);
		$strSql1 = "SELECT * FROM `abricos_chatgpt_export` WHERE `id_element`=" . $id_element . " and `id_profile`=" . $profile_id . ";";
		$res1 = $DB->Query($strSql1, true, __LINE__);
		if (intval($res1->SelectedRowsCount()) > 0) {
			$strSql = "UPDATE `abricos_chatgpt_export` SET  `question`='" . $DB->ForSql($question) . "', `answer`='" . $DB->ForSql($answer) . "', `in_iblock`='" . $in_iblock . "' WHERE `id_element`=" . $id_element . " and `id_profile`=" . $profile_id . ";";
		} else {
			$strSql = "INSERT INTO `abricos_chatgpt_export` (`id_element`,`question`,`answer`,`in_iblock`,`id_profile`) VALUES (" . $id_element . ",'" . $DB->ForSql($question) . "','" . $DB->ForSql($answer) . "','" . $in_iblock . "','" . $profile_id . "'); ";
		}
		$res = $DB->Query($strSql, false, __LINE__);
	}
	static function AddLog($log)
	{
		$fp = fopen($_SERVER['DOCUMENT_ROOT'] . "/reportChatgpt.txt", "a");
		$logs = fwrite($fp, $log . "\n");
		fclose($fp);
	}

	static function encodingUTF(string $text)
	{
		global $APPLICATION;
		if (LANG_CHARSET !== 'UTF-8') $text = $APPLICATION->ConvertCharset($text, LANG_CHARSET, 'UTF-8');
		return $text;
	}
	static function decodingUTF(string $text)
	{
		global $APPLICATION;
		if (LANG_CHARSET !== 'UTF-8') $text = $APPLICATION->ConvertCharset($text, 'UTF-8', LANG_CHARSET);
		return $text;
	}
	static function updateInblock($id_element, $profile_id, $inblock)
	{
		global $DB;
		$strSql = "UPDATE `abricos_chatgpt_export` SET `in_iblock`=" . $inblock . " WHERE `id_element`=" . $id_element . " and `id_profile`=" . $profile_id . ";";
		$res = $DB->Query($strSql, false, __LINE__);
	}

}
?>

Youez - 2016 - github.com/yon3zu
LinuXploit