PHP from command line - php

I am trying to use some of the scripts on this site
http://www.tubekit.org/tools.php
As you can see under the Usage section it gives you some arguments to put into the command line
php extractYTVideoURLs.php yturls.txt mylist.txt
I have downloaded the extract php file and made the 2 text files yet I only get this answer in the command line.
c:\php>php C:/Users/extractYTVideoURLs.php yturls.txt my
list.txt
Warning: fopen(yturls.txt): failed to open stream: No such file or directory in
C:\Users\extractYTVideoURLs.php on line 21
Warning: fgets() expects parameter 1 to be resource, boolean given in C:\Users\extractYTVideoURLs.php on line 24
Warning: fclose() expects parameter 1 to be resource, boolean given in C:\Users\
extractYTVideoURLs.php on line 52

The error seems pretty clear. On line 21 of C:\Users\extractYTVideoURLs.php the code calls fopen() on a file called yturls.txt which it can't find. Where is this file? Does it exist at all?
It's generally best practice to reference a file with a fully-qualified path name. Note that you're currently in the directory c:\php so if that file isn't in the current working directory then just referencing it by name isn't going to find it. You'll need to reference the file by where it's located. Potentially something like this:
php C:/Users/extractYTVideoURLs.php C:/Path/to/yturls.txt C:/Path/to/mylist.txt

Related

Errors on Opencart website developed n local PC after being uploaded to live server

I have developed an OC store on my local PC using XAMPP. I've uploaded the store to the server, and it's displaying well, BUT there are some irregularities. To cite an example, admin panel isn't functioning properly - I can sign in, but nothing is displayed then. I am almost sure the problem is in the urls, but as I have messed with the site once and had to reupload it, I more than welcome help from others. There are two sections of error messages - one in the header and one in the footer.
Errors in the header:
Warning: fopen(/home/davofvpt/public_html/storage/logs/openbay.log): failed to open stream: No such file or directory in /home/davofvpt/public_html/system/library/log.php on line 22
Warning: fopen(/home/davofvpt/public_html/storage/logs/openbay.log): failed
to open stream: No such file or directory in
/home/davofvpt/public_html/system/library/log.php on line 22
Warning: fclose() expects parameter 1 to be resource, boolean given in
/home/davofvpt/public_html/system/library/log.php on line 39
Warning: Cannot modify header information - headers already sent by (output
started at /home/davofvpt/public_html/system/framework.php:42) in
/home/davofvpt/public_html/catalog/controller/startup/session.php on line
25Warning: Cannot modify header information - headers already sent by
(output started at /home/davofvpt/public_html/system/framework.php:42) in
/home/davofvpt/public_html/catalog/controller/startup/startup.php on line
99Warning: Cannot modify header information - headers already sent by
(output started at /home/davofvpt/public_html/system/framework.php:42) in
/home/davofvpt/public_html/catalog/controller/startup/startup.php on line
157Warning: fopen(/home/davofvpt/public_html/storage/logs/openbay.log):
failed to open stream: No such file or directory in
/home/davofvpt/public_html/system/library/log.php on line 22
Warning: fclose() expects parameter 1 to be resource, boolean given in
/home/davofvpt/public_html/system/library/log.php on line 39
Warning: fopen(/home/davofvpt/public_html/storage/logs/error.log): failed to
open stream: No such file or directory in
/home/davofvpt/public_html/system/library/log.php on line 22
Errors in the footer:
Warning: fclose() expects parameter 1 to be resource, boolean given in
/home/davofvpt/public_html/system/library/log.php on line 39Warning:
fclose()
expects parameter 1 to be resource, boolean given in
/home/davofvpt/public_html/system/library/log.php on line 39Warning:
fclose()
expects parameter 1 to be resource, boolean given in
/home/davofvpt/public_html/system/library/log.php on line 39
Here is my config.php in the public folder
This is my config.php in the admin folder
I managed to resolve this issue by tracing the error message:
I created ($touch storage/logs/error.log) The file name is mentioned in the error message
I applied the permissions (chmod 777 storage/logs/error.log)
Did 1,2 for openbay.log
I noticed that the storage folder the owner _www which I changed to my user name (I dont think this step is required - just 1-3 should do the trick)
Note: I started with deleting the storage folder contents
You have moved your "storage" folder from the main directory (such as system/storage) to other location.
please restore folder to moved location.
or install Opencart using auto installer.
If you are not expert in Opencart, then follow these steps.
Install new opencart(your required version).
Download or copy the config file from admin folder.
Upload your modified admin and catalog folder to server (using FTP).
Re-upload the downloaded config file to admin folder.
Now it works same as on localserver

how can I troubleshoot these new php-pdf font errors?

Today our web server started throwing these errors when generating a pdf with php-pdf. Path is wrong but the pdf still generates. Unsure why this path issue started or how to fix it. Also concerned that it just started seemingly on its own.
Warning: fopen(/tmp/cachedTimes-Roman.php) [function.fopen]: failed to open stream: Permission denied in /home/site/public_html/include/pdf-php/src/Cpdf.php on line 2039
Warning: fwrite() expects parameter 1 to be resource, boolean given in /home/site/public_html/include/pdf-php/src/Cpdf.php on line 2040
Warning: fclose() expects parameter 1 to be resource, boolean given in /home/site/public_html/include/pdf-php/src/Cpdf.php on line 2041
Most likely the device where /tmp is may have run out of space, so that new files can not be created there.
df -h in console should get you started.
If you are the system administrator, even rm -rf /tmp/* might help, but may also have consequences if any files currently in use are stored there.
The warnings were caused by the script not being able to find the font files. The problem was solved by explicitly setting the tempPath.
$pdf->tempPath = '../include/pdf-php/src/fonts';

PHP include file in class, wrong paths

I have class called client, and there i have function, in which i'm trying to include/execute php file, but when i'm doing it all path's in that file which i'm trying to include goes wrong.
class function:
public static function SendSSHCommand($ssh_cmd) {
include('../Core/core_class.php');
$ssh = new samp_panel();
$ssh->SendCommand($ssh_cmd);
}
I would like get a solution, how to include file, that all directory path's in that file wouldn't go wrong.
I get many errors like that:
Warning: include(Net/SSH2.php): failed to open stream: No such file or directory in /home/vlkg/domains/vlkg.lt/public_html/naujas/Core/core_class.php on line 30
Warning: include(Net/SSH2.php): failed to open stream: No such file or directory in /home/vlkg/domains/vlkg.lt/public_html/naujas/Core/core_class.php on line 30
Warning: include(): Failed opening 'Net/SSH2.php' for inclusion (include_path='.:/usr/share/pear:Core/NetModule') in /home/vlkg/domains/vlkg.lt/public_html/naujas/Core/core_class.php on line 30
Fatal error: Class 'Net_SSH2' not found in /home/vlkg/domains/vlkg.lt/public_html/naujas/Core/core_class.php on line 366
I always change my include directory when I run a script. For me it just makes it easier if I set a point of reference for all my included files.
http://php.net/manual/en/function.set-include-path.php
Put something like this at the top of your file
set_include_path('/usr/www/2/main');
include('include1.php');
include('subdir_of_include_path/include2.php');
There are several options but this is the one I find useful with my projects. This way I force and know what my include path is.

Permission denied error in php when try to write in a txt file

I'm trying to write in a txt file the data i get from a html form, but I get this error: Warning: fopen(/var/www/4/datos.txt): failed to open stream: Permission denied in /var/www/4/ComprobacionFormulario.php on line 13 Warning: fwrite() expects parameter 1 to be resource, boolean given in /var/www/4/ComprobacionFormulario.php on line 16 Warning: fclose() expects parameter 1 to be resource, boolean given in /var/www/4/ComprobacionFormulario.php on line 17
'datos.txt' Is the file where i'm trying to write. Here is my php code:
error_reporting(E_ALL);
ini_set('display_errors', true);
$des=$_POST['description'];
$cant=$_POST['quantity'];
$prec=$_POST['price'];
$nombrearchivo="datos.txt";
$content="Description: $des\tQuantity: $cant\tPrice: $prec\n";
$handle=fopen($nombrearchivo, 'w');
fwrite($handle, $content);
fclose($handle);
From the manual: [fopen] Returns a file pointer resource on success, or FALSE on error.
Looks like your fopen call is failing. Try using an absolute URL to your text file. Make sure your folder is CHMODded correctly and the file also (777 permissions)

PHP Error - Can't Open Files

I am building a small PHP system, and I can't open files like CSS Styles, PHP Include function and Images.
I also got some errors:
Warning: include(includes/functions.php) [function.include]: failed to open stream: No such file or directory in /home/chezki/public_html/XXX.XXX/cp/CMS/index.php on line 2
Warning: include(includes/functions.php) [function.include]: failed to open stream: No such file or directory in /home/chezki/public_html/XXX.XXX/cp/CMS/index.php on line 2
Warning: include() [function.include]: Failed opening 'includes/functions.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/chezki/public_html/XXX.XXX/cp/CMS/index.php on line 2
Built by YYY.YYY
logo // Thats the Logo alt
Fatal error: Call to undefined function getlists() in /home/chezki/public_html/XXX.XXX/cp/CMS/index.php on line 28
Title Actions // Some images alt
Edit: On Windows, It is Ok, but on Linux, It is doing those errors
More edit: Solved
From your error messages, your script appears to be this:
/home/chezki/public_html/XXX.XXX/cp/CMS/index.php
Your are trying to load this file:
includes/functions.php
Since you get this error message:
No such file or directory
... the obvious conclusion is that this file does not exist:
/home/chezki/public_html/XXX.XXX/cp/CMS/includes/functions.php
Feel free to edit your question and provide more details if this is not the case.
Edit: the file must have that precise name. If it's called e.g. Functions.php, it's a different file.
You have permission problems. Your web server cannot read functions.php due to wrong permissions. Adjust permissions with chown and chmod.

Categories