%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
| Server IP : 14.207.165.8 / Your IP : 216.73.216.26 Web Server : Apache/2.4.18 (Ubuntu) System : Linux 246 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : root ( 0) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,pcntl_exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/thread-self/root/var/www/html/old/modules/mod_powrcountdowntimer/ |
Upload File : |
<?php
/**
* Joomla! POWr Countdown Timer
*
* @version 2.0
* @author POWr.io
* @package POWr Countdown Timer
* @subpackage POWr
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
if(!class_exists('PowrHelper')){
class PowrHelper{
public $powr_token;
function __construct() {
$this->get_powr_token(); //Get powr token
$this->add_powr_js(); //Add powr.js
}
//Generate a powr token
public function generate_powr_token(){
$alphabet = 'abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789';
$pass = array(); //remember to declare $pass as an array
$alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
for ($i = 0; $i < 10; $i++) { //Add 10 random characters
$n = rand(0, $alphaLength);
$pass[] = $alphabet[$n];
}
$pass_string = implode($pass) . time(); //Add the current time to avoid duplicate keys
return $pass_string; //turn the array into a string
}
//Get powr token (or create it if it doesn't exist)
public function get_powr_token(){
$db = JFactory::getDBO(); //Initialize JFactory;
//Make sure table exists:
$query = "CREATE TABLE IF NOT EXISTS `#__powr` ( `data_type` VARCHAR(50) NOT NULL, `value` VARCHAR(50) NOT NULL, PRIMARY KEY (`data_type`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$db->setQuery($query);
$result = $db->query();
//Get powr_token:
$query = "SELECT value FROM #__powr WHERE data_type = 'powr_token'";
$db->setQuery($query);
$result = $db->loadAssoc();
$powr_token = $result['value'];
//If powr token is null, set it;
if($powr_token == NULL){
$powr_token = $this->generate_powr_token();
$query = "INSERT INTO #__powr (data_type, value) VALUES ('powr_token','$powr_token')";
$db->setQuery($query);
$db->query();
}
//Set powr token:
$this->powr_token = $powr_token;
//echo "POWR TOKEN IS $this->powr_token";
}
public function add_powr_js(){
global $POWR_JS_ADDED; //Global flag that powr js has been added
if($POWR_JS_ADDED){
return;
}
$js_url = JURI::base()."modules/mod_powrcountdowntimer/powr_joomla.js";
$js = "(function(d){
var js, id = 'powr-js', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = '$js_url';
js.setAttribute('powr-token','$this->powr_token');
js.setAttribute('external-type','joomla');
ref.parentNode.insertBefore(js, ref);
}(document));";
$document = JFactory::getDocument();
$document->addScriptDeclaration($js); //Add js to doc
$POWR_JS_ADDED=true;
}
}
}
//Create Helper
new PowrHelper();
echo "<div class='powr-countdown-timer' label='joomla_$module->id'></div>";
?>