Skip to content

Commit

Permalink
Add Head Code
Browse files Browse the repository at this point in the history
Add Logo change on configuration
  • Loading branch information
daniel authored and daniel committed May 9, 2017
1 parent 8e9318c commit f740ad8
Show file tree
Hide file tree
Showing 12 changed files with 384 additions and 93 deletions.
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@

<p>Restart apache2 after </p>

<p><pre><code>/etc/init.d/apache2 restart</code></pre></p>
<p><pre><code>sudo /etc/init.d/apache2 restart</code></pre></p>

<p>or </p>

<p><pre><code>service apache2 restart</code></pre></p>
<p><pre><code>sudo service apache2 restart</code></pre></p>

</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion install/checkConfiguration.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$installationVersion = "2.4";
$installationVersion = "2.5";

header('Content-Type: application/json');

Expand Down
66 changes: 65 additions & 1 deletion objects/configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class Configuration {
private $exiftool;
private $exiftoolPath;

private $head;
private $logo;
private $logo_small;

function __construct($video_resolution="") {
$this->load();
Expand Down Expand Up @@ -99,7 +102,10 @@ function save() {
. "ffprobeDuration = '{$global['mysqli']->real_escape_string($this->getFfprobeDuration())}',"
. "youtubedl = '{$global['mysqli']->real_escape_string($this->getYoutubedl())}',"
. "youtubedlPath = '{$global['mysqli']->real_escape_string($this->youtubeDlPath)}',"
. "ffmpegPath = '{$global['mysqli']->real_escape_string($this->ffmpegPath)}'"
. "ffmpegPath = '{$global['mysqli']->real_escape_string($this->ffmpegPath)}',"
. "head = '{$global['mysqli']->real_escape_string($this->getHead())}',"
. "logo = '{$global['mysqli']->real_escape_string($this->getLogo())}',"
. "logo_small = '{$global['mysqli']->real_escape_string($this->getLogo_small())}'"
. "WHERE id = 1";

$insert_row = $global['mysqli']->query($sql);
Expand Down Expand Up @@ -376,6 +382,64 @@ function setFfmpegWebmPortrait($ffmpegWebmPortrait) {
$this->ffmpegWebmPortrait = $ffmpegWebmPortrait;
}

function getHead() {
if(empty($this->head)){
return "
<script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></script>
<script>
// YouPHPTube Analytics
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-96597943-1', 'auto');
ga('send', 'pageview');
// YouPHPTube Adsense
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: \"ca-pub-5750060815915776\",
enable_page_level_ads: true
});
</script>
";

}
return $this->head;
}

function getLogo() {
if(empty($this->logo)){
return "view/img/logo138x30.png";
}
return $this->logo;
}

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;
}



Expand Down
67 changes: 63 additions & 4 deletions objects/configurationUpdate.json.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<?php

header('Content-Type: application/json');
if(empty($global['systemRootPath'])){
if (empty($global['systemRootPath'])) {
$global['systemRootPath'] = "../";
}
require_once $global['systemRootPath'] . 'objects/user.php';
if (!User::isAdmin()) {
die('{"error":"'.__("Permission denied").'"}');
die('{"error":"' . __("Permission denied") . '"}');
}

require_once $global['systemRootPath'].'videos/configuration.php';
require_once $global['systemRootPath'] . 'videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/configuration.php';
require_once $global['systemRootPath'] . 'objects/functions.php';
$config = new Configuration();
$config->setContactEmail($_POST['contactEmail']);
$config->setLanguage($_POST['language']);
Expand All @@ -32,4 +34,61 @@
$config->setYoutubedl($_POST['youtubeDl']);
$config->setYoutubeDlPath($_POST['youtubeDlPath']);
$config->setFfmpegPath($_POST['ffmpegPath']);
echo '{"status":"'.$config->save().'"}';
$config->setHead($_POST['head']);


$imagePath = "videos/userPhoto/";

//Check write Access to Directory
if (!file_exists($global['systemRootPath'] . $imagePath)) {
mkdir($global['systemRootPath'] . $imagePath, 0777, true);
}

if (!is_writable($global['systemRootPath'] . $imagePath)) {
$response = Array(
"status" => 'error',
"message" => 'No write Access'
);
print json_encode($response);
return;
}
$response = $responseSmall = 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) {
$response = array(
"status" => 'success',
"url" => $global['systemRootPath'] . $photoURL
);
} else {
$response = array(
"status" => 'error',
"msg" => 'We could not save logo',
"url" => $global['systemRootPath'] . $photoURL
);
}
$config->setLogo($photoURL);
}
if (!empty($_POST['logoSmallImgBase64'])) {
$fileData = base64DataToImage($_POST['logoSmallImgBase64']);
$fileName = 'logoSmall.png';
$photoURL = $imagePath . $fileName;
$bytes = file_put_contents($global['systemRootPath'] . $photoURL, $fileData);
if ($bytes) {
$responseSmall = array(
"status" => 'success',
"url" => $global['systemRootPath'] . $photoURL
);
} else {
$responseSmall = array(
"status" => 'error',
"msg" => 'We could not save small logo',
"url" => $global['systemRootPath'] . $photoURL
);
}
$config->setLogo_small($photoURL);
}
echo '{"status":"' . $config->save() . '", "respnseLogo": ' . json_encode($response) . ', "respnseLogoSmall": ' . json_encode($responseSmall) . '}';
7 changes: 7 additions & 0 deletions objects/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,11 @@ function check_memory_limit() {

function check_mysqlnd() {
return function_exists('mysqli_fetch_all');
}

function base64DataToImage($imgBase64){
$img = $imgBase64;
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
return base64_decode($img);
}
6 changes: 2 additions & 4 deletions objects/userSavePhoto.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
}
require_once $global['systemRootPath'] . 'videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/user.php';
require_once $global['systemRootPath'] . 'objects/functions.php';
$obj = new stdClass();
if (!User::isLogged()) {
$obj->error = __("You must be logged");
Expand All @@ -27,10 +28,7 @@
return;
}

$img = $_POST['imgBase64'];
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$fileData = base64_decode($img);
$fileData = base64DataToImage($_POST['imgBase64']);
$fileName = 'photo'. User::getId().'.png';
$photoURL = $imagePath.$fileName;
$bytes = file_put_contents($global['systemRootPath'].$photoURL, $fileData);
Expand Down
30 changes: 30 additions & 0 deletions update/updateDb.v2.5.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-- MySQL Workbench Synchronization
-- Generated: 2017-05-09 14:05
-- Model: New Model
-- Version: 1.0
-- Project: Name of the project
-- Author: Daniel

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';

ALTER TABLE `configurations`
CHANGE COLUMN `ffprobeDuration` `ffprobeDuration` VARCHAR(400) NULL DEFAULT NULL ,
CHANGE COLUMN `ffmpegImage` `ffmpegImage` VARCHAR(400) NULL DEFAULT NULL ,
CHANGE COLUMN `ffmpegMp4` `ffmpegMp4` VARCHAR(400) NULL DEFAULT NULL ,
CHANGE COLUMN `ffmpegWebm` `ffmpegWebm` VARCHAR(400) NULL DEFAULT NULL ,
CHANGE COLUMN `ffmpegMp3` `ffmpegMp3` VARCHAR(400) NULL DEFAULT NULL ,
CHANGE COLUMN `ffmpegOgg` `ffmpegOgg` VARCHAR(400) NULL DEFAULT NULL ,
CHANGE COLUMN `youtubeDl` `youtubeDl` VARCHAR(400) NULL DEFAULT NULL ,
ADD COLUMN `head` TEXT NULL DEFAULT NULL AFTER `exiftoolPath`,
ADD COLUMN `logo` VARCHAR(255) NULL DEFAULT NULL AFTER `head`,
ADD COLUMN `logo_small` VARCHAR(255) NULL DEFAULT NULL AFTER `logo`;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;


UPDATE configurations SET version = '2.5', modified = now() WHERE id = 1;
Loading

0 comments on commit f740ad8

Please sign in to comment.