Hello,
After I loose all my works/files couple days ago, I am trying to fix them with old backups.
Below I call a php file with shell script and it injects processed data into related database in mysql .
Current process gives below output: http://127.0.0.1/vod-www/Top Gun 1986.mkv
But I wish to have get: http://127.0.0.1/vod-www/TopGun.mkv
I am starting to explain... A bit big file, I am sorry...
I have run.sh, imdb.class.php, inject.php and list_of_movies.txt file
./run.sh
run.sh
Code:
while read -r line;do
php 44.php $line
sleep 2
done<list_of_movies.txt
list_of_movies.txt
Code:
TopGun.mkv
44.php
Code:
<?php
include_once 'imdb.class.php';
//mysql config.
$servername = "127.0.0.1";
$username = "root";
$password = "my_password";
$dbname = "stalker_db";
$dbport = "3306";
//open mysql connection.
$conn = new mysqli($servername, $username, $password, $dbname, $dbport);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//read video database to array.
$sql = mysqli_query($conn, "select * from video ORDER BY name ASC");
while ($row = mysqli_fetch_assoc($sql)) {
$video[] = $row;
}
#################################################################
# $aTests = [
# '$argv',
# ];
#################################################################
//grab info from imdb.
$i = 1 ;
#foreach ($aTests as $sMovie) { #--------!!!
foreach($argv as $sMovie) {
$i++;
$IMDB = new IMDB($sMovie);
if ($IMDB->isReady) {
$title = $IMDB->getTitle($bForceLocal = true);
$description = mysqli_real_escape_string($conn, $IMDB->getDescription());
$plot = mysqli_real_escape_string($conn, $IMDB->getPlot($iLimit = 0));
..
..
..#to make it shorter, had to delete other lines###
if (!isset($last_id)) {
$adddate = date('y-m-d H:i:s');
$sql = "INSERT INTO video (name, o_name, cost, time, protocol, category_id, cat_genre_id_1, accessed, status, description, director, country, year, actors, added, rating_kinopoisk, rating_mpaa)
VALUES ('$title $year', '$title $year', '0', '$runtime', '', '2030', '459', '1', '1', '$description', '$director', '$country', '$year', '$cast', '$adddate', '$rating', '$mpaa')";
if ($conn->query($sql) !== TRUE) {
echo '<p style="text-align: center;">Error: ' . $sql . '<br>' . $conn->error . '</p>';
} else {
$last_id = $conn->insert_id;
}
//get next id for screenshots table.
$sql = mysqli_query($conn, "SHOW TABLE STATUS LIKE 'screenshots'");
$next_screenshot = mysqli_fetch_assoc($sql)['Auto_increment'];
//now we will add poster to movie.
$screenshot_file = $next_screenshot . '.jpeg';
if (!copy("/root/$poster", "/var/www/stalker_portal/screenshots/136/$screenshot_file")) {
echo "failed to copy $screenshot_file...\n";
}
$sql = "INSERT INTO screenshots (name, type, media_id)
VALUES ('$screenshot_file', 'image/jpeg', '$last_id')";
if ($conn->query($sql) !== TRUE) {
echo '<p style="text-align: center;">Error: ' . $sql . '<br>' . $conn->error . '</p>';
}
//add file under movie directory.
$url = 'http://127.0.0.1/vod-www/'.$title.'.'.$year.'.mkv';
..
..
#then insert into sql commands follow....
$result = mysqli_query($conn, "SELECT * FROM video_series_files WHERE url='$url'");
The problem is related to this field:
Code:
//add file under movie directory.
$url = 'http://127.0.0.1/vod-www/'.$title.'.'.$year.'.mkv';
The data injected into mysql table is: http://127.0.0.1/vod-www/Top Gun 1986.mkv
But I wish to have get: http://127.0.0.1/vod-www/TopGun.mkv
I replaced: $url = 'http://127.0.0.1/vod-www/'.$title.'.'.$year.'.mkv';
by $url = 'http://127.0.0.1/vod-www/'$xargv'.';
but did not work. Also tried different variations but no luck.
I have checked my previous posts and I do not remember how I solved it earlier.
Thank you
Boris
Solved now:
I assumed that I should create a variable for filename but have just seen that a variable for that purpose was already created earlier in code.. $url = 'http://127.0.0.1/vod-www/'.$sMovie.'.mkv';
Solved the problem
Linux System having all Perl, Python, PHP (and Ruby) installed
From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file
eg
eg
a Shell script run in a case statement call to run a php file, also Perl or/and Python file???
Like
#!/usr/bin/bash
....
....
case $INPUT_STRING... (1 Reply)
I am running the xampp on WINDOWS, and my php script is connecting to a unix script on a different server (ssh2_connect("11.31.138.56", 22). I am running the unix script and inside this script I am calling the .sql file . The SQL is connecting to oracle db on the unix server.
But the sqlplus... (2 Replies)
hi everyone
i wrote a system call and compiled the kernel succesfully...
my system call is in a file in the kernel folder named my_syscall1.c (kernel/my_syscall1.c)
the header file for this system call i added it in the folder include like this include/my_syscall1/my_syscall1.h
my problem is... (2 Replies)
Hello,
I have a problem with package and name space.
require "/Mehran/DSGateEngineLib/general.pl";
use strict;
sub System_Status_Main_Service_Status_Intrusion_Prevention
{
my %idpstatus;
my @result;
&General_ReadHash("/var/dsg/idp/settings",\%idpstatus);
#print... (4 Replies)
Hi.
I write a shell script for import data to oracle using sql loader.
I set permission 755 or 777 for that script. I can run that script in the consol okay.
When I call it from PHP using system command. I got return value 126 this value when don't have permission right ?
I check step... (2 Replies)
Hi,
Ho do I differentiate system call from library call?
for example if I am using chmod , how do I find out if it is a system call or library call?
Thanks
Muru (2 Replies)