Файловый менеджер - Редактировать - /home/lmsyaran/public_html/plugins/content/zaya_linkshortener_in_content/b.php
Назад
<?php /*----------------------------------------------------------------------------------| www.vdm.io |----/ Lmskaran /-------------------------------------------------------------------------------------------------------/ @version 1.0.78 @build 19th May, 2022 @created 22nd July, 2020 @package Moojla @subpackage zaya_linkshortener_in_content.php @author Lmskaran <http://Lmskaran.com> @copyright Copyright (C) 2015. All Rights Reserved @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) .-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( \____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) /------------------------------------------------------------------------------------------------------*/ // No direct access to this file defined('_JEXEC') or die('Restricted access'); /***[JCBGUI.class_extends.head.1.$$$$]***/ use Joomla\CMS\Application\CMSApplication; use Joomla\CMS\Plugin\CMSPlugin; /***[/JCBGUI$$$$]***/ /***[JCBGUI.class_extends.comment.1.$$$$]***/ /** * Content - Zaya_linkshortener_in_content plugin. * * @package Zaya_linkshortener_in_content * @since 1.1.1 *//***[/JCBGUI$$$$]***/ class PlgContentZaya_linkshortener_in_content extends JPlugin { public function browser($user_agent) { if (strpos($user_agent, 'Opera') || strpos($user_agent, 'OPR/')) return 'Opera'; elseif (strpos($user_agent, 'Edge')) return 'Edge'; elseif (strpos($user_agent, 'Chrome')) return 'Chrome'; elseif (strpos($user_agent, 'Safari')) return 'Safari'; elseif (strpos($user_agent, 'Firefox')) return 'Firefox'; elseif (strpos($user_agent, 'MSIE') || strpos($user_agent, 'Trident/7')) return 'Internet Explorer'; return false; } public function onContentAfterTitle($context, $table, $item) { if ($context != 'com_content.article') return false; //prevent generete the short link from robots crawl if (!$this->browser($_SERVER['HTTP_USER_AGENT'])) return false; $app = JFactory::getApplication(); $view = 'content'; $id = $table->id; $domain = $this->get_domain(); $source_link= (string)juri::getinstance(); $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('id, link') ->from($db->quoteName('#__zaya_content', 'r')) ->where($db->quoteName('r.link_id') . '=' . $id) ->where($db->quoteName('r.type') . '=' . $db->quote($view)) ->where($db->quoteName('r.domain') . '=' . $db->quote($domain)) ->where($db->quoteName('r.source_link').'='. $db->quote($source_link)); $db->setQuery($query); $result = $db->loadObject(); if (0) { $short_link = $result->link; } else { $current_url = $source_link; $url_encode = urlencode($current_url); $api_key = 'rrrFjYXyffiavdpwHcpKxdBSbbvetxYf9p3z0hg19wNPjZUI425hp1EM71G2'; $url = 'https://zaya.io/api/v1/links'; $post_fields= "url=".$url_encode; $header= [ "Content-Type: application/x-www-form-urlencoded", "Authorization: Bearer ".$api_key ]; $curl_handle = curl_init(); curl_setopt($curl_handle, CURLOPT_URL, $url); curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $header); curl_setopt($curl_handle, CURLOPT_POST, true); curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $post_fields); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true); $curl_data = json_decode(curl_exec($curl_handle)); curl_close($curl_handle); $filename = __DIR__ . '/log.txt'; file_put_contents($filename, print_r($curl_data, true) . "\n", FILE_APPEND); if ($curl_data->status == 200) { $short_link = $curl_data->data->short_url; $query = $db->getQuery(true); $columns = array('link_id', 'source_link', 'link', 'type', 'domain'); $values = array($id, $db->quote($source_link), $db->quote($short_link), $db->quote($view), $db->quote($domain)); $query ->insert($db->quoteName('#__zaya_content')) ->columns($db->quoteName($columns)) ->values(implode(',', $values)); $db->setQuery($query); $app = JFactory::getApplication(); $db->execute(); } else { echo 'response from rizy: ' . $curl_data->status; return 0; } } ?> <script> function copyElementText() { var ShortLinkButton = document.querySelector('#short_link_copy'); var text = document.getElementById('this-a-link').innerText; var elem = document.createElement("textarea"); document.body.appendChild(elem); elem.value = text; elem.select(); document.execCommand("copy"); document.body.removeChild(elem); ShortLinkButton.classList.add("Copied"); } </script> <short_link> <div> <span>لینک کوتاه دوره</span> <div id="short_link_copy" onclick="copyElementText()"> <button> <span class="copy_link">کپی کنید</span> <span class="copied_link">کپی شد !</span> </button> <div id="this-a-link"> <?php echo $short_link; ?> <svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewBox="0 0 64.000000 64.000000" preserveAspectRatio="xMidYMid meet"> <metadata> Created by potrace 1.10, written by Peter Selinger 2001-2011 </metadata> <g transform="translate(0.000000,64.000000) scale(0.100000,-0.100000)" fill="#a5afbb" stroke="none"> <path d="M409 567 c-32 -18 -98 -87 -99 -104 0 -24 23 -13 71 32 57 53 96 59 134 20 46 -45 36 -78 -53 -167 -84 -84 -113 -95 -160 -62 -24 16 -42 12 -42 -11 0 -33 103 -59 140 -35 42 26 170 165 175 191 21 96 -83 181 -166 136z"/> <path d="M240 400 c-42 -26 -170 -165 -175 -191 -10 -43 2 -83 33 -111 59 -56 119 -49 186 20 77 79 55 102 -25 27 -57 -53 -96 -59 -134 -20 -46 45 -36 78 53 167 84 84 113 95 160 62 24 -16 42 -12 42 11 0 33 -103 59 -140 35z"/> </g> </svg> </div> <!-- <span class="before-copy">کپی کنید</span> <span class="lms-copied">کپی شد</span> --> </div> </div> </short_link> <script> var removeClassShortLink = document.querySelector('#short_link_copy'); removeClassShortLink.addEventListener('mouseleave', remove_class) function remove_class() { // alert('mahdi'); removeClassShortLink.classList.remove("Copied"); } </script> <style> #this-a-link { display: inline-block; } #short_link_copy { background: white; border: 1px solid #e6e6e6; padding: 3px 3px 3px 8px; text-align: left; display: flex; justify-content: space-between; align-items: center; border-radius: 5px; margin: 10px 0; box-shadow: 2px 0px 5px #e5e5e5; color: #a5afbb; font-weight: 100; font-size: 0.9rem; } .before-copy { position: absolute; top: 0; right: 0; width: 100%; display: flex; justify-content: center; align-items: center; height: 100%; opacity: 0; transition: 0.6s; color: white; border-radius: 50px; } .lms-copied { position: absolute; top: 0; right: 0; width: 100%; display: flex; justify-content: center; align-items: center; height: 100%; opacity: 0; transition: 0.6s; z-index: -1; color: white; border-radius: 50px; } #short_link_copy button { border: unset; border-radius: 5px; padding: 8px 20px; color: white; font-size: 0.8rem; background: #4d90fd; position: relative; overflow: hidden; transition:0.3s; opacity: 0.8; } #short_link_copy button:hover{ opacity: 1; } span.copied_link { position: absolute; left: 50%; transform: translateX(-50%); top: -30px; transition: 0.2s; } span.copy_link { position: relative; top: 0; transition: 0.2s; } div#short_link_copy.Copied button { background:#27c452; } div#short_link_copy.Copied .copy_link { top: 30px; } div#short_link_copy.Copied .copied_link{ top: 8px; } #short_link_copy::selection { color: red; background: yellow; } </style> <?php } public function get_domain() { $domain = juri::root(); $domain = preg_replace('/http:\/\/|https:\/\/|http:\/\/www\.|https:\/\/www\.|www\.|\//', '', $domain); return $domain; } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Генерация страницы: 0.01 |
proxy
|
phpinfo
|
Настройка