Last active
January 17, 2024 13:30
-
-
Save PechenkiUA/3597210ac4b5fe9f0651d2f373558f72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<modification> | |
<name>Coder_ocm_error_top</name> | |
<code>default</code> | |
<version>1.0</version> | |
<author>CoderUa</author> | |
<link>https://google.com</link> | |
<file path="admin/view/template/common/header.twig"> | |
<operation> | |
<search> | |
<![CDATA[<ul class="nav navbar-nav navbar-right">]]> | |
</search> | |
<add position="after"> | |
<![CDATA[ | |
<li class="dropdown"> | |
<a onclick="ocmodError()" class="dropdown-toggle" data-toggle="dropdown"> | |
<i class="fa fa-bug fa-lg"></i> | |
</a> | |
<div onclick="event.stopPropagation()" id='error_ocmod' class="dropdown-menu dropdown-menu-right clear-dropdown"> | |
<span class="btn" onclick="ocmodError()"> <i class="fa fa-refresh fa-lg"></i> </span> | |
<div id='error_ocmod_text'> | |
<pre style="max-height: 500px;"></pre> | |
</div> | |
</div> | |
</li> | |
]]> | |
</add> | |
</operation> | |
<operation> | |
<search><![CDATA[</head>]]></search> | |
<add position="before"><![CDATA[ | |
<script> | |
async function ocmodError(){ | |
event.preventDefault(); | |
const _resElem = document.querySelector('#error_ocmod_text'); | |
_resElem.innerHTML = ` | |
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="margin: auto; display: block; shape-rendering: auto;" width="200px" height="200px" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid"> | |
<circle cx="50" cy="50" r="32" stroke-width="8" stroke="#1d3f72" stroke-dasharray="50.26548245743669 50.26548245743669" fill="none" stroke-linecap="round"> | |
<animateTransform attributeName="transform" type="rotate" repeatCount="indefinite" dur="1s" keyTimes="0;1" values="0 50 50;360 50 50"></animateTransform> | |
</circle> | |
</svg> | |
`; | |
const url = `/admin/index.php?route=marketplace/modification/error_log&user_token=${getURLVar('user_token')}&`; | |
const response = await fetch(url); | |
const data = await response.json(); | |
_resElem.innerHTML = `<pre style="max-height: 500px;">${data.log}</pre>`; | |
event.stopPropagation(); | |
} | |
</script> | |
]]></add> | |
</operation> | |
</file> | |
<file path="admin/controller/marketplace/modification.php"> | |
<operation> | |
<search trim="true"><![CDATA[ | |
private $error = array(); | |
]]></search> | |
<add position="before"><![CDATA[ | |
public function error_log(){ | |
$data = []; | |
// Log | |
$file = DIR_LOGS . 'ocmod_error_q.log'; | |
if (file_exists($file)) { | |
$data['log'] = htmlentities(file_get_contents($file, FILE_USE_INCLUDE_PATH, null)); | |
if(empty(trim($data['log']))){ | |
$data['log'] = 'ocmod_error_q.log - empty'; | |
} | |
} else { | |
$data['log'] = 'ocmod_error_q.log - not found'; | |
} | |
$this->response->addHeader('Content-Type: application/json'); | |
$this->response->setOutput(json_encode($data)); | |
} | |
]]></add> | |
</operation> | |
<operation> | |
<search trim="true"><![CDATA[ | |
$this->load->model('setting/setting'); | |
]]></search> | |
<add position="after"><![CDATA[ | |
$handle = fopen(DIR_LOGS . 'ocmod_error_q.log', 'w+'); | |
fclose($handle); | |
]]></add> | |
</operation> | |
<operation> | |
<search trim="true"><![CDATA[ | |
$log[] = 'MOD: ' . $dom->getElementsByTagName('name')->item(0)->textContent; | |
]]></search> | |
<add position="after"><![CDATA[ | |
$error_logs_mod = 'MOD: ' . $dom->getElementsByTagName('name')->item(0)->textContent; | |
]]></add> | |
</operation> | |
<operation> | |
<search trim="true"><![CDATA[ | |
$files = glob($path, GLOB_BRACE); | |
]]></search> | |
<add position="after"><![CDATA[ | |
if (!$files) { | |
if ($file_error != 'skip') { | |
$error_logs[] = PHP_EOL; | |
$error_logs[] = '----------------------------------------------------------------'; | |
$error_logs[] = $error_logs_mod; | |
$error_logs[] = 'MISSING FILE!'; | |
$error_logs[] = $path; | |
} | |
} | |
]]></add> | |
</operation> | |
<operation> | |
<search trim="true"><![CDATA[ | |
if (!$status) { | |
]]></search> | |
<add position="after"><![CDATA[ | |
if ($error != 'skip') { | |
$error_logs[] = PHP_EOL; | |
$error_logs[] = $error_logs_mod; | |
$error_logs[] = 'NOT FOUND!'; | |
$error_logs[] = 'CODE: ' . $search; | |
$error_logs[] = 'FILE: ' . $key; | |
} | |
]]></add> | |
</operation> | |
<operation> | |
<search trim="true"><![CDATA[ | |
$ocmod->write(implode("\n", $log)); | |
]]></search> | |
<add position="after"><![CDATA[ | |
//error log | |
if ($error_logs) { | |
$ocmod = new Log('ocmod_error_q.log'); | |
$ocmod->write(implode("\n", $error_logs)); | |
} | |
]]></add> | |
</operation> | |
</file> | |
</modification> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment