
M.O.S. Studios
-
Posts
307 -
Joined
-
Last visited
Community Answers
-
M.O.S. Studios's post in PCloud abd curl was marked as the answer
So, after giving up on the documentation I gave postman.com a gander.
All the parameters are supposed to be sent within the URL, and the file as the only information in the post field. They also allow you to send plain text, and they will encode it for you.
So here is what I did:
$uploadPath = str_replace("/".basename($args['uploadPath']), '', $args['uploadPath']); $accessToken = getPcloudToken(); $query = array('filename'=>'file.csv', 'nopartial'=>'1', 'path'=> $uploadPath); $product_data = $args['product_data']; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://api.pcloud.com/uploadfile?'.http_build_query($query)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt($ch, CURLOPT_POST, 1 ); curl_setopt($ch, CURLOPT_POSTFIELDS, $product_data); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain', 'Authorization: Bearer '.$accessToken)); curl_exec($ch); curl_close($ch); I was able to take the whole temp file creation out. so that was nice
-
M.O.S. Studios's post in Validating e was marked as the answer
function spamTest($header){ $output_array = preg_grep('/^(X-Spam-Score:)\s([-+]?\d{1,3}\.\d)?/i', explode("\n", $header)); list($xSpamScore, $score) = explode(": ", $output_array[array_key_first($output_array)]); return ($score < 5); } I ran the email header into this and it seems to work.
-
M.O.S. Studios's post in Quick members area was marked as the answer
Fancy isn't important as I am the only one using it.
However easy is ideal.
I was thinking of using htaccess, htpasswd, .htaccess. I have never used those before, but I think they will be pretty simple to set up.
My only concern is that I use Ajax to reference other pages, and I am worry that will interfere
-
M.O.S. Studios's post in Making a Image from CSV was marked as the answer
Figured it out.
Here is my round about way to take a CSV file, and visualize it as a table.
<?php require('fpdf.php'); $file = file.csv'; function near5($v){ return round($v * 2) / 2; } function content($file){ $header = array(); if (($handle = fopen($file, "r")) !== FALSE){ $body = array(); $header = fgetcsv($handle); $header[0] = 'Category/Weight(Lbs)'; while (($data = fgetcsv($handle)) !== FALSE){ $body[] = $data; } fclose($handle); } return array($header, $body); } class PDF extends FPDF{ // Simple table function BasicTable($header, $data, $kcal){ // Header $first = 30; foreach($header as $col){ $v = is_numeric($col) ? round(($col*2.2),1) : $col; $this->Cell($first,7,$v,1,0,'C'); $first = 10; } $this->Ln(); // Data foreach($data as $row){ $first = 30; foreach($row as $col){ $v = (is_numeric($col)) ? near5($col/$kcal) : $col; $this->Cell($first,7,$v,1,0,'C'); $first = 10; } $this->Ln(); } } } // Column headings content($file); list($header, $row) = content($file); // Data loading $pdf = new PDF(); $pdf->SetFont('Arial','',5); $pdf->AddPage(); $pdf->BasicTable($header,$row, $kcal); $output = $pdf->Output('S'); $im = new imagick(); $im->setResolution(300, 300); $im->readImageBlob($output); $im->setImageFormat('png'); $im->setImageCompression(imagick::COMPRESSION_JPEG); $im->setImageCompressionQuality(100); $im->borderImage("#ffffff", 20, 20); $im->trimImage(0.3); $im->setImagePage($im->getImageWidth(), $im->getImageHeight(), 0, 0); header("Content-Type: image/" . $im->getImageFormat()); echo $im->getImageBlob(); $im->clear(); $im->destroy(); ?>
-
M.O.S. Studios's post in Ajax on safari was marked as the answer
Got it working
function UrlWorks(instaUrl){ var url = '../' + instaUrl.split('.com/p/').pop().toLowerCase(); jQuery.ajax({ url: url, datatype: 'text', type: 'Get', success: function(){window.location.href = url}, error: function(){window.location.href = instaUrl} }); } $('a.sbi_photo[href]').each(function() { var $t = $(this); var newHref = $t.attr('href'); $t.removeAttr( "href" ); $t.click(function(){UrlWorks(newHref);}); });