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 path processing #12

Merged
merged 1 commit into from
Nov 10, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _bpcs_files_/common.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function getline(){
return trim(fgets(STDIN));
}
function getpath($path){
return '/apps/'.urlencode(trim(file_get_contents(CONFIG_DIR.'/appname')).'/'.$path);
return '/apps/'.rawurlencode(trim(file_get_contents(CONFIG_DIR.'/appname')).str_replace('/./', '/', '/'.$path));
}
function oaerr($arr,$exitonerror = 1){
if(isset($arr['error'])){
Expand Down
1 change: 1 addition & 0 deletions _bpcs_files_/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ function get_quota($access_token){
function upload_file($access_token,$path,$localfile,$ondup='newcopy'){
$path = getpath($path);
$url = "https://c.pcs.baidu.com/rest/2.0/pcs/file?method=upload&access_token=$access_token&path=$path&ondup=$ondup";
$localfile = escapeshellarg($localfile);
$add = "--form file=@$localfile";
$cmd = "curl -X POST -k -L $add \"$url\"";
$cmd = cmd($cmd);
Expand Down