mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 23:55:19 +00:00
still working through some issues with curl magic-auth
fixed profile photo upload
This commit is contained in:
parent
30a5fe3061
commit
7d7f43c205
5 changed files with 30 additions and 6 deletions
|
@ -15,7 +15,7 @@ class CurlAuth {
|
|||
if($argc != 2)
|
||||
killme();
|
||||
|
||||
session_start();
|
||||
\App::$session->start();
|
||||
|
||||
$_SESSION['authenticated'] = 1;
|
||||
$_SESSION['uid'] = $argv[1];
|
||||
|
@ -23,6 +23,7 @@ class CurlAuth {
|
|||
$x = session_id();
|
||||
|
||||
$f = 'store/[data]/cookie_' . $argv[1];
|
||||
$c = 'store/[data]/cookien_' . $argv[1];
|
||||
|
||||
$e = file_exists($f);
|
||||
|
||||
|
@ -44,8 +45,10 @@ class CurlAuth {
|
|||
}
|
||||
}
|
||||
}
|
||||
$t = time() + (24 * 3600);
|
||||
file_put_contents($f, $output . 'HttpOnly_' . \App::get_hostname() . "\tFALSE\t/\tTRUE\t$t\tPHPSESSID\t" . $x, (($e) ? FILE_APPEND : 0));
|
||||
|
||||
file_put_contents($f, $output . 'HttpOnly_' . \App::get_hostname() . "\tFALSE\t/\tFALSE\t0\tPHPSESSID\t" . $x, (($e) ? FILE_APPEND : 0));
|
||||
file_put_contents($c,$x);
|
||||
|
||||
killme();
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ class SuperCurl {
|
|||
|
||||
private $request_method = 'GET';
|
||||
private $upload = false;
|
||||
private $cookies = false;
|
||||
|
||||
|
||||
private function set_data($s) {
|
||||
|
@ -62,6 +63,11 @@ class SuperCurl {
|
|||
case 'http_auth':
|
||||
$this->auth = $v;
|
||||
break;
|
||||
case 'magicauth':
|
||||
$this->magicauth = $v;
|
||||
\Zotlabs\Daemon\Master::Summon([ 'CurlAuth', $v ]);
|
||||
sleep(2);
|
||||
break;
|
||||
case 'custom':
|
||||
$this->request_method = $v;
|
||||
break;
|
||||
|
@ -90,8 +96,17 @@ class SuperCurl {
|
|||
|
||||
function exec() {
|
||||
$opts = $this->curlopts;
|
||||
$url = $this->url;
|
||||
if($this->auth)
|
||||
$opts['http_auth'] = $this->auth;
|
||||
if($this->magicauth) {
|
||||
$opts['cookiejar'] = 'store/[data]/cookie_' . $this->magicauth;
|
||||
$opts['cookiefile'] = 'store/[data]/cookie_' . $this->magicauth;
|
||||
$opts['cookie'] = 'PHPSESSID=' . trim(file_get_contents('store/[data]/cookien_' . $this->magicauth));
|
||||
$c = channelx_by_n($this->magicauth);
|
||||
if($c)
|
||||
$url = zid($this->url,$c['channel_address'] . '@' . \App::get_hostname());
|
||||
}
|
||||
if($this->custom)
|
||||
$opts['custom'] = $this->custom;
|
||||
if($this->headers)
|
||||
|
|
|
@ -50,7 +50,7 @@ class Cover_photo extends \Zotlabs\Web\Controller {
|
|||
|
||||
check_form_security_token_redirectOnErr('/cover_photo', 'cover_photo');
|
||||
|
||||
if((x($_POST,'cropfinal')) && ($_POST['cropfinal'] == 1)) {
|
||||
if((array_key_exists('cropfinal',$_POST)) && ($_POST['cropfinal'] == 1)) {
|
||||
|
||||
// phase 2 - we have finished cropping
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ class Profile_photo extends \Zotlabs\Web\Controller {
|
|||
|
||||
check_form_security_token_redirectOnErr('/profile_photo', 'profile_photo');
|
||||
|
||||
if((array_key_exists('postfinal',$_POST)) && (intval($_POST['cropfinal']) == 1)) {
|
||||
if((array_key_exists('cropfinal',$_POST)) && (intval($_POST['cropfinal']) == 1)) {
|
||||
|
||||
// phase 2 - we have finished cropping
|
||||
|
||||
|
@ -95,7 +95,6 @@ class Profile_photo extends \Zotlabs\Web\Controller {
|
|||
dbesc($image_id),
|
||||
dbesc(local_channel()),
|
||||
intval($scale));
|
||||
|
||||
if($r) {
|
||||
|
||||
$base_image = $r[0];
|
||||
|
|
|
@ -101,6 +101,9 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
|
|||
if(x($opts,'cookiefile'))
|
||||
@curl_setopt($ch, CURLOPT_COOKIEFILE, $opts['cookiefile']);
|
||||
|
||||
if(x($opts,'cookie'))
|
||||
@curl_setopt($ch, CURLOPT_COOKIE, $opts['cookie']);
|
||||
|
||||
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,
|
||||
((x($opts,'novalidate') && intval($opts['novalidate'])) ? false : true));
|
||||
|
||||
|
@ -258,6 +261,10 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) {
|
|||
if(x($opts,'cookiefile'))
|
||||
@curl_setopt($ch, CURLOPT_COOKIEFILE, $opts['cookiefile']);
|
||||
|
||||
|
||||
if(x($opts,'cookie'))
|
||||
@curl_setopt($ch, CURLOPT_COOKIE, $opts['cookie']);
|
||||
|
||||
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,
|
||||
((x($opts,'novalidate') && intval($opts['novalidate'])) ? false : true));
|
||||
|
||||
|
|
Loading…
Reference in a new issue