diff --git a/objects/configuration.php b/objects/configuration.php index d29c88c2b..1635d6715 100644 --- a/objects/configuration.php +++ b/objects/configuration.php @@ -1,430 +1,441 @@ load(); if (!empty($video_resolution)) { $this->video_resolution = $video_resolution; } } function load() { global $global; $sql = "SELECT * FROM configurations WHERE id = 1 LIMIT 1"; //echo $sql;exit; // add true because I was not getting the SMTP configuration on function setSiteSendMessage(&$mail) $res = sqlDAL::readSql($sql, "", array(), true); $result = sqlDAL::fetchAssoc($res); sqlDAL::close($res); if ($res && !empty($result)) { $config = $result; //var_dump($config);exit; foreach ($config as $key => $value) { $this->$key = $value; } } else { return false; } } function save() { global $global; if (!User::isAdmin()) { header('Content-Type: application/json'); die('{"error":"' . __("Permission denied") . '"}'); } $this->users_id = User::getId(); $sql = "UPDATE configurations SET " . "video_resolution = '{$this->video_resolution}'," . "webSiteTitle = '{$this->webSiteTitle}'," . "language = '{$this->language}'," . "contactEmail = '{$this->contactEmail}'," . "users_id = '{$this->users_id}', " . "authCanUploadVideos = '{$this->authCanUploadVideos}'," . "authCanViewChart = '{$this->authCanViewChart}'," . "authCanComment = '{$this->authCanComment}'," . "encoderURL = '{$global['mysqli']->real_escape_string($this->_getEncoderURL())}'," . "head = '{$global['mysqli']->real_escape_string($this->getHead())}'," . "adsense = '{$global['mysqli']->real_escape_string($this->getAdsense())}'," . "mode = '{$this->getMode()}'," . "logo = '{$global['mysqli']->real_escape_string($this->getLogo())}'," . "logo_small = '{$global['mysqli']->real_escape_string($this->getLogo_small())}'," . "disable_analytics = '{$this->getDisable_analytics()}'," . "disable_youtubeupload = '{$this->getDisable_youtubeupload()}'," . "allow_download = '{$this->getAllow_download()}'," . "session_timeout = '{$this->getSession_timeout()}'," . "autoplay = '{$this->getAutoplay()}'," . "theme = '{$global['mysqli']->real_escape_string($this->getTheme())}'," . "smtp = '{$this->getSmtp()}'," . "smtpAuth = '{$this->getSmtpAuth()}'," . "smtpSecure = '{$global['mysqli']->real_escape_string($this->getSmtpSecure())}'," . "smtpHost = '{$global['mysqli']->real_escape_string($this->getSmtpHost())}'," . "smtpUsername = '{$global['mysqli']->real_escape_string($this->getSmtpUsername())}'," . "smtpPort = '{$global['mysqli']->real_escape_string($this->getSmtpPort())}'," . "smtpPassword = '{$global['mysqli']->real_escape_string($this->getSmtpPassword())}'" . " WHERE id = 1"; return sqlDAL::writeSql($sql); } function getVideo_resolution() { return $this->video_resolution; } function getUsers_id() { return $this->users_id; } function getVersion() { if (empty($this->version)) { return " 0.1"; } return $this->version; } function getWebSiteTitle() { return $this->webSiteTitle; } function getLanguage() { if ($this->language == "en") { return "us"; } return $this->language; } function getContactEmail() { return $this->contactEmail; } function setVideo_resolution($video_resolution) { $this->video_resolution = $video_resolution; } function setWebSiteTitle($webSiteTitle) { $this->webSiteTitle = $webSiteTitle; } function setLanguage($language) { $this->language = $language; } function setContactEmail($contactEmail) { $this->contactEmail = $contactEmail; } function currentVersionLowerThen($version) { return version_compare($version, $this->getVersion()) > 0; } function currentVersionGreaterThen($version) { return version_compare($version, $this->getVersion()) < 0; } function currentVersionEqual($version) { return version_compare($version, $this->getVersion()) == 0; } function getAuthCanUploadVideos() { return $this->authCanUploadVideos; } function getAuthCanViewChart() { return $this->authCanViewChart; } function getAuthCanComment() { return $this->authCanComment; } function setAuthCanUploadVideos($authCanUploadVideos) { $this->authCanUploadVideos = $authCanUploadVideos; } function setAuthCanViewChart($authCanViewChart) { $this->authCanViewChart = $authCanViewChart; } function setAuthCanComment($authCanComment) { $this->authCanComment = $authCanComment; } function getHead() { return $this->head; } function getLogo($timestamp=false) { global $global; if (empty($this->logo)) { return "view/img/logo.png"; } $get = ""; $file = str_replace("?", "", $global['systemRootPath'].$this->logo); if($timestamp && file_exists($file)){ $get .= "?".filemtime($file); } return $this->logo.$get; } + function getFavicon() { + global $global; + $file = $global['systemRootPath']."videos/favicon.png"; + $url = "{$global['webSiteRootURL']}videos/favicon.png"; + if (!file_exists($file)) { + $file = $global['systemRootPath']."view/img/favicon.png"; + $url = "{$global['webSiteRootURL']}view/img/favicon.png"; + } + return $url."?". filectime($file); + } + function setHead($head) { $this->head = $head; } function setLogo($logo) { $this->logo = $logo; } function getLogo_small() { if (empty($this->logo_small)) { return "view/img/logo32.png"; } return $this->logo_small; } function setLogo_small($logo_small) { $this->logo_small = $logo_small; } function getAdsense() { return $this->adsense; } function setAdsense($adsense) { $this->adsense = $adsense; } function getMode() { if (empty($this->mode)) { return 'Youtube'; } return $this->mode; } function setMode($mode) { $this->mode = $mode; } // version 2.7 function getDisable_analytics() { return $this->disable_analytics; } function getDisable_youtubeupload() { return $this->disable_youtubeupload; } function getAllow_download() { return $this->allow_download; } function getSession_timeout() { return $this->session_timeout; } function setDisable_analytics($disable_analytics) { $this->disable_analytics = ($disable_analytics == 'true' || $disable_analytics == '1') ? 1 : 0; } function setDisable_youtubeupload($disable_youtubeupload) { $this->disable_youtubeupload = ($disable_youtubeupload == 'true' || $disable_youtubeupload == '1') ? 1 : 0; } function setAllow_download($allow_download) { $this->allow_download = ($allow_download == 'true' || $allow_download == '1') ? 1 : 0; } function setSession_timeout($session_timeout) { $this->session_timeout = $session_timeout; } function getAutoplay() { return intval($this->autoplay); } function setAutoplay($autoplay) { $this->autoplay = ($autoplay == 'true' || $autoplay == '1') ? 1 : 0; } // end version 2.7 static function rewriteConfigFile() { global $global, $mysqlHost, $mysqlUser, $mysqlPass, $mysqlDatabase; if(empty($global['salt'])){ $global['salt'] = uniqid(); } $content = "theme)) { return "default"; } return $this->theme; } function setTheme($theme) { $this->theme = $theme; } function getSmtp() { return intval($this->smtp); } function getSmtpAuth() { return intval($this->smtpAuth); } function getSmtpSecure() { return $this->smtpSecure; } function getSmtpHost() { return $this->smtpHost; } function getSmtpUsername() { return $this->smtpUsername; } function getSmtpPassword() { return $this->smtpPassword; } function setSmtp($smtp) { $this->smtp = ($smtp == 'true' || $smtp == '1') ? 1 : 0; } function setSmtpAuth($smtpAuth) { $this->smtpAuth = ($smtpAuth == 'true' || $smtpAuth == '1') ? 1 : 0; } function setSmtpSecure($smtpSecure) { $this->smtpSecure = $smtpSecure; } function setSmtpHost($smtpHost) { $this->smtpHost = $smtpHost; } function setSmtpUsername($smtpUsername) { $this->smtpUsername = $smtpUsername; } function setSmtpPassword($smtpPassword) { $this->smtpPassword = $smtpPassword; } function getSmtpPort() { return intval($this->smtpPort); } function setSmtpPort($smtpPort) { $this->smtpPort = intval($smtpPort); } function _getEncoderURL() { return $this->encoderURL; } function getEncoderURL() { global $advancedCustom; if(!empty($advancedCustom->useEncoderNetworkRecomendation) && !empty($advancedCustom->encoderNetwork)){ if (substr($advancedCustom->encoderNetwork, -1) !== '/') { $advancedCustom->encoderNetwork .= "/"; } $bestEncoder = json_decode(url_get_contents($advancedCustom->encoderNetwork."view/getBestEncoder.php")); if(!empty($bestEncoder->siteURL)){ $this->encoderURL = $bestEncoder->siteURL; } } if (empty($this->encoderURL)) { return "https://encoder.youphptube.com/"; } if (substr($this->encoderURL, -1) !== '/') { $this->encoderURL .= "/"; } return $this->encoderURL; } function setEncoderURL($encoderURL) { $this->encoderURL = $encoderURL; } } diff --git a/objects/configurationUpdate.json.php b/objects/configurationUpdate.json.php index bcd4b77dd..01f02be29 100644 --- a/objects/configurationUpdate.json.php +++ b/objects/configurationUpdate.json.php @@ -1,80 +1,99 @@ setContactEmail($_POST['contactEmail']); $config->setLanguage($_POST['language']); $config->setWebSiteTitle($_POST['webSiteTitle']); $config->setAuthCanComment($_POST['authCanComment']); $config->setAuthCanUploadVideos($_POST['authCanUploadVideos']); $config->setAuthCanViewChart($_POST['authCanViewChart']); if (empty($global['disableAdvancedConfigurations'])) { $config->setDisable_analytics($_POST['disable_analytics']); $config->setDisable_youtubeupload($_POST['disable_youtubeupload']); $config->setAllow_download($_POST['allow_download']); $config->setSession_timeout($_POST['session_timeout']); $config->setEncoderURL($_POST['encoder_url']); $config->setSmtp($_POST['smtp']); $config->setSmtpAuth($_POST['smtpAuth']); $config->setSmtpSecure($_POST['smtpSecure']); $config->setSmtpHost($_POST['smtpHost']); $config->setSmtpUsername($_POST['smtpUsername']); $config->setSmtpPassword($_POST['smtpPassword']); $config->setSmtpPort($_POST['smtpPort']); } $config->setHead($_POST['head']); $config->setAdsense($_POST['adsense']); $config->setMode('Youtube'); $config->setAutoplay($_POST['autoplay']); $config->setTheme($_POST['theme']); $imagePath = "videos/userPhoto/"; //Check write Access to Directory if (!file_exists($global['systemRootPath'] . $imagePath)) { mkdir($global['systemRootPath'] . $imagePath, 0755, true); } if (!is_writable($global['systemRootPath'] . $imagePath)) { $response = Array( "status" => 'error', "message" => 'No write Access' ); print json_encode($response); return; } $response = array(); if (!empty($_POST['logoImgBase64'])) { $fileData = base64DataToImage($_POST['logoImgBase64']); $fileName = 'logo.png'; $photoURL = $imagePath . $fileName; $bytes = file_put_contents($global['systemRootPath'] . $photoURL, $fileData); if ($bytes > 10) { $response = array( "status" => 'success', "url" => $global['systemRootPath'] . $photoURL ); $config->setLogo($photoURL); } else { $response = array( "status" => 'error', "msg" => 'We could not save logo', "url" => $global['systemRootPath'] . $photoURL ); } } +if (!empty($_POST['faviconBase64'])) { + $imagePath = "videos/"; + $fileData = base64DataToImage($_POST['faviconBase64']); + $fileName = 'favicon.png'; + $photoURL = $imagePath . $fileName; + $bytes = file_put_contents($global['systemRootPath'] . $photoURL, $fileData); + if ($bytes > 10) { + $response2 = array( + "status" => 'success', + "url" => $global['systemRootPath'] . $photoURL + ); + } else { + $response2 = array( + "status" => 'error', + "msg" => 'We could not save favicon', + "url" => $global['systemRootPath'] . $photoURL + ); + } +} -echo '{"status":"' . $config->save() . '", "respnseLogo": ' . json_encode($response) . '}'; +echo '{"status":"' . $config->save() . '", "respnseLogo": ' . json_encode($response) . ', "respnseFavicon": ' . json_encode($response2) . '}'; diff --git a/view/configurations_body.php b/view/configurations_body.php index f64473dd3..b55169586 100644 --- a/view/configurations_body.php +++ b/view/configurations_body.php @@ -1,752 +1,808 @@