new class Ssettings to get videopath from db
add test - failing remove useless videopath and tvpath from app.js
This commit is contained in:
22
api/SSettings.php
Normal file
22
api/SSettings.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
class SSettings
|
||||
{
|
||||
private $database;
|
||||
|
||||
/**
|
||||
* SSettings constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->database = Database::getInstance();
|
||||
}
|
||||
|
||||
public function getVideoPath() {
|
||||
$query = "SELECT video_path from settings";
|
||||
|
||||
$result = $this->database->getConnection()->query($query);
|
||||
|
||||
$r = mysqli_fetch_assoc($result);
|
||||
return $r['video_path'];
|
||||
}
|
||||
}
|
@ -1,9 +1,15 @@
|
||||
<?php
|
||||
require 'Database.php';
|
||||
require 'SSettings.php';
|
||||
|
||||
// establish initial db connection
|
||||
$conn = Database::getInstance()->getConnection();
|
||||
$settings = new SSettings();
|
||||
|
||||
// load video path from settings
|
||||
$videopath = $settings->getVideoPath();
|
||||
|
||||
|
||||
//$_POST['action'] = "getRandomMovies";$_POST['number'] =6;
|
||||
if (isset($_POST['action'])) {
|
||||
$action = $_POST['action'];
|
||||
switch ($action) {
|
||||
@ -84,7 +90,9 @@ if (isset($_POST['action'])) {
|
||||
|
||||
$arr["movie_id"] = $row["movie_id"];
|
||||
$arr["movie_name"] = $row["movie_name"];
|
||||
$arr["movie_url"] = str_replace("?","%3F",$row["movie_url"]);
|
||||
// todo drop video url from db -- maybe one with and one without extension
|
||||
// extension hardcoded here!!!
|
||||
$arr["movie_url"] = str_replace("?", "%3F", $videopath . $row["movie_name"] . ".mp4");
|
||||
$arr["likes"] = $row["likes"];
|
||||
$arr["quality"] = $row["quality"];
|
||||
$arr["length"] = $row["length"];
|
||||
|
Reference in New Issue
Block a user