Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command line interface to upload videos #29

Merged
merged 3 commits into from
Jun 5, 2017

Conversation

Yetangitu
Copy link
Contributor

Add command line interface to upload videos. Use php -f upload.php -- -h in view/mini-upload-form for instructions.

The -g parameter takes a comma-separated list of NUMERICAL groups (group IDs, actually) as argument, this due to the current absence of an easy way to get groups by their name, this can be changed when such has been implemented. I have not done this yet as there are things of higher concern, eg. the abundance of SQL injection opportunities in the code...).

Use: php -f upload.php -u <user> -f <file> [-d <description>] [-g "group1[,group2]] [-c] [-h]

    -u user     valid username
    -f file     input filename
    -d descr    description
    -g group(s) comma-separated numerical groups for which this item will be visible,
                item will be public if this is left out
    -c          copy original to destination directory (file will be moved if this is left out)
    -h          this help message

The easiest way to use this is to call the php code from a script, like so:

#!/bin/bash
srcdir="/var/src/YouPHPTube"

pushd "${srcdir}/view/mini-upload-form/" > /dev/null
sudo -u www-data php -f upload.php -- "$@"
popd > /dev/null

(adjust srcdir and www-data to your environment)

Yetangitu added 3 commits June 4, 2017 18:52
… -h in

view/mini-upload-form for instructions on use or read on...

Use: php -f upload.php -u <user> -f <file> [-d <description>] [-g "group1[,group2]] [-c] [-h]

    -u user     valid username
    -f file     input filename
    -d descr    description
    -g group(s) comma-separated numerical groups for which this item will be visible,
                item will be public if this is left out
    -c          copy original to destination directory (file will be moved if this is left out)
    -h          this help message
@DanielnetoDotCom DanielnetoDotCom self-assigned this Jun 5, 2017
Copy link
Member

@DanielnetoDotCom DanielnetoDotCom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good

@DanielnetoDotCom
Copy link
Member

DanielnetoDotCom commented Jun 5, 2017

I have tested the command line help and didn't show me the help
image
Show me the PHP help instead upload.php help

@DanielnetoDotCom
Copy link
Member

DanielnetoDotCom commented Jun 5, 2017

what the -f after php means?
php -f upload.php
i have remove it and works as expected
image

image

@DanielnetoDotCom DanielnetoDotCom merged commit b26e509 into WWBN:master Jun 5, 2017
@Yetangitu
Copy link
Contributor Author

The '-f' parameter tells php to parse and execute a file:

$ php -h
Usage: php [options] [-f] <file> [--] [args...]
 ...
  -f <file>        Parse and execute <file>.
 ...

Add a double dash after upload.php to tell php it should stop parsing parameters. The remaining parameters will be parsed by upload.php, like so:

$ sudo -u www-data php -f upload.php -- -h

Use: php -f upload.php -u <user> -f <file> [-d <description>] [-g "group1[,group2]] [-c] [-h]

    -u user     valid username
    -f file     input filename
    -d descr    description
    -g group(s) comma-separated numerical groups for which this item will be visible,
                item will be public if this is left out
    -c          copy original to destination directory (file will be moved if this is left out)
    -h          this help message

@DanielnetoDotCom
Copy link
Member

With double dash works perfect.
But I think -f after php command is useless (at least for ubuntu)
What OS are u using?

@Yetangitu
Copy link
Contributor Author

Yetangitu commented Jun 5, 2017

Try again with the double dash to see if it works for you with -f, it should. I'm using Debian, not that far from Ubuntu.

BTW, I notice a lot of files with DOS/Windows line endings, do you edit on Windows?

@DanielnetoDotCom
Copy link
Member

DanielnetoDotCom commented Jun 5, 2017 via email

@Yetangitu
Copy link
Contributor Author

Yetangitu commented Jun 5, 2017

From man 1 php:

If none of -r -f -B -R -F -E or -S is present but a single parameter is given then this parameter
is taken as the  filename  to  parse  and  execute (same as with -f). If no parameter is present 
then the standard input is read and executed.

In other words, leaving out -f works if there are no other parameters for php but there is a single unnamed parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants