## main vars
$Summoner = new Summoner();
-# database object
-$DB = false;
# the template data as an array
$TemplateData = array();
# translation
}
}
- # decide if we want to make a local full page scrrenshot
+ # decide if we want to make a local full page screenshot
if(isset($data['pagescreenshot'])) {
$pagescreenshot = ABSOLUTE_PATH . '/' . LOCAL_STORAGE . '/pagescreenshot-' . $this->_data['hash'].'.jpg';
if ($data['pagescreenshot'] === true) {
if (!file_exists($pagescreenshot) || $_imageUrlChanged === true) {
require_once 'lib/snapshot.class.php';
$snap = new Snapshot();
- $do = $snap->wholePageSnpashot($this->_data['link'], $pagescreenshot);
+ $do = $snap->wholePageSnapshot($this->_data['link'], $pagescreenshot);
if(!empty($do)) {
error_log('ERROR Failed to create snapshot: '.var_export($data,true));
}
/**
* @var string
*/
- private $_googlePageSpeed = 'https://www.googleapis.com/pagespeedonline/v2/runPagespeed?url=';
+ private string $_googlePageSpeed = 'https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=';
/**
* @var string
*/
- private $_wkhtmltoimageOptions = '--load-error-handling ignore --quality 80 --quiet --width 1900';
+ private string $_wkhtmltoimageOptions = '--load-error-handling ignore --quality 80 --quiet --width 1900';
/**
* Snapshot constructor
*/
- public function __constructor() {}
+ public function __constructor(): void {}
/**
* call given url with google PageSpeed API
public function doSnapshot(string $url, string $filename): bool {
$ret = false;
+ // new path in jason
+ // lighthouseResult audits full-page-screenshot details screenshot data (base64 encoded)
+
if(!empty($url) && is_writable(dirname($filename))) {
$theCall = Summoner::curlCall($this->_googlePageSpeed.urlencode($url).'&screenshot=true');
if(!empty($theCall)) {
* @param string $filename
* @return boolean
*/
- public function wholePageSnpashot(string $url, string $filename): bool {
+ public function wholePageSnapshot(string $url, string $filename): bool {
$ret = false;
require_once 'lib/shellcommand.class.php';
* execute a curl call to the given $url
*
* @param string $url The request url
- * @param bool $port
+ * @param int $port
* @return string
*/
- static function curlCall(string $url, $port=false): string {
+ static function curlCall(string $url, int $port=0): string {
$ret = '';
$ch = curl_init();
*
* @param string $url
* @param string $whereToStore
- * @param bool $port
+ * @param int $port
* @return bool
*/
- static function downloadFile(string $url, string $whereToStore, $port=false): bool {
+ static function downloadFile(string $url, string $whereToStore, int $port=0): bool {
$fh = fopen($whereToStore, 'w+');
$ret = false;
* @param string $key
* @return mixed
*/
- static function ifset(array $array, string $key) {
+ static function ifset(array $array, string $key): mixed {
return $array[$key] ?? false;
}
* @param string $urlString
* @return string
*/
- static function addSchemeToURL($urlString): string {
+ static function addSchemeToURL(string $urlString): string {
$ret = $urlString;
if(empty(parse_url($ret, PHP_URL_SCHEME))) {
* @param string $unit
* @return string
*/
- static function humanFileSize(int $size, $unit=""): string {
+ static function humanFileSize(int $size, string $unit=""): string {
$ret = number_format($size)." bytes";
if((!$unit && $size >= 1<<30) || $unit == "GB") {
* @param int $fTime If not false remove files older then this value in sec.
* @return boolean
*/
- static function recursive_remove_directory(string $directory, $empty=false, $fTime=0): bool {
+ static function recursive_remove_directory(string $directory, bool $empty=false, int $fTime=0): bool {
if(substr($directory,-1) == '/') {
$directory = substr($directory,0,-1);
}
recursive_remove_directory($path);
}
else {
- if($fTime !== false && is_int($fTime)) {
+ if(!empty($fTime) && is_int($fTime)) {
$ft = filemtime($path);
$offset = time()-$fTime;
if($ft <= $offset) {
* modify will remove: only key with no value
*
* @param array $array
- * @param bool $modify
+ * @param array $modify
* @return string
*/
- static function createFromParameterLinkQuery(array $array, $modify=false): string {
+ static function createFromParameterLinkQuery(array $array, array $modify=array()): string {
$ret = '';
if(!empty($modify)) {
* Insipid
* Personal web-bookmark-system
*
- * Copyright 2016-2021 Johannes Keßler
+ * Copyright 2016-2022 Johannes Keßler
*
* Development starting from 2011: Johannes Keßler
* https://www.bananas-playground.net/projekt/insipid/
* Insipid
* Personal web-bookmark-system
*
- * Copyright 2016-2021 Johannes Keßler
+ * Copyright 2016-2022 Johannes Keßler
*
* Development starting from 2011: Johannes Keßler
* https://www.bananas-playground.net/projekt/insipid/
/**
* @var string The lang code
*/
- private $_defaultLangToUse = 'eng';
+ private string $_defaultLangToUse = 'eng';
/**
* @var array The loaded lang information from the file
*/
- private $_langData = array();
+ private array $_langData = array();
/**
* Translation constructor.
# can/should be extended in the future.
Summoner::simpleAuth();
-$_id = false;
+$_id = '';
if(isset($_GET['id']) && !empty($_GET['id'])) {
$_id = trim($_GET['id']);
- $_id = Summoner::validate($_id,'nospace') ? $_id : false;
+ $_id = Summoner::validate($_id,'nospace') ? $_id : '';
}
$_isAwm = false;
$Management->setShowAwm($_isAwm);
}
-$_requestMode = false;
+$_requestMode = '';
if(isset($_GET['m']) && !empty($_GET['m'])) {
$_requestMode = trim($_GET['m']);
- $_requestMode = Summoner::validate($_requestMode,'nospace') ? $_requestMode : false;
+ $_requestMode = Summoner::validate($_requestMode,'nospace') ? $_requestMode : '';
}
$linkData = $Management->loadLink($_id);
$honeypotCheck = false;
$formData = array();
-$_requestMode = false;
+$_requestMode = '';
if(isset($_GET['m']) && !empty($_GET['m'])) {
$_requestMode = trim($_GET['m']);
$_requestMode = Summoner::validate($_requestMode,'nospace') ? $_requestMode : "all";
*
*/
-$_id = false;
+$_id = '';
if(isset($_GET['id']) && !empty($_GET['id'])) {
$_id = trim($_GET['id']);
- $_id = Summoner::validate($_id,'nospace') ? $_id : false;
+ $_id = Summoner::validate($_id,'nospace') ? $_id : '';
}
$linkData = $Management->loadLink($_id);
*/
$currentGetParameters['p'] = 'overview';
-$_requestMode = false;
+$_requestMode = '';
if(isset($_GET['m']) && !empty($_GET['m'])) {
$_requestMode = trim($_GET['m']);
- $_requestMode = Summoner::validate($_requestMode,'nospace') ? $_requestMode : false;
+ $_requestMode = Summoner::validate($_requestMode,'nospace') ? $_requestMode : '';
}
-$_id = false;
+$_id = '';
if(isset($_GET['id']) && !empty($_GET['id'])) {
$_id = trim($_GET['id']);
- $_id = Summoner::validate($_id,'digit') ? $_id : false;
+ $_id = Summoner::validate($_id,'digit') ? $_id : '';
}
$_curPage = 1;
$_curPage = Summoner::validate($_curPage,'digit') ? $_curPage : 1;
}
-$_sort = false;
+$_sort = '';
if(isset($_GET['s']) && !empty($_GET['s'])) {
$_sort = trim($_GET['s']);
- $_sort = Summoner::validate($_sort,'nospace') ? $_sort : false;
+ $_sort = Summoner::validate($_sort,'nospace') ? $_sort : '';
}
-$_sortDirection = false;
+$_sortDirection = '';
if(isset($_GET['sd']) && !empty($_GET['sd'])) {
$_sortDirection = trim($_GET['sd']);
- $_sortDirection = Summoner::validate($_sortDirection,'nospace') ? $_sortDirection : false;
+ $_sortDirection = Summoner::validate($_sortDirection,'nospace') ? $_sortDirection : '';
}
$linkCollection = array();
}
if(isset($_POST['statsDeleteLocalStorage'])) {
-
if($Management->clearLocalStorage() === true) {
$TemplateData['refresh'] = 'index.php?p=stats';
}