CS174
Chris Pollett
Nov 16, 2016
http://www.yioop.com/s/news?f=rss&limit=20&num=30
url/my_obj/method1?arg_1_for_method1=value_1& arg_2_for_method1=value_2... url/my_obj/method2?arg_1_for_method2=value_1& arg_2_for_method2=value_2... ...
12.3 -- an example Number "hi there" -- an example String true -- an example Boolean, other possibility false
[1, 4, 9]
{"bob": 29, "sally" : 35}
myObj = eval( "(" + data + ")" );
<?php define ('YIOOP_NEWS_URL', 'https://www.yioop.com/s/news/'); // look at incoming request fields $query = (!empty($_REQUEST['f']) && in_array($_REQUEST['f'], ["rss", "json"])) ? "?f=" . $_REQUEST['f'] : ""; $url = YIOOP_NEWS_URL . $query; // Open the Curl session $request_handle = curl_init($url); // If we wanted to use post we could uncomment the lines below //curl_setopt ($request_handle, CURLOPT_POST, true); //curl_setopt ($request_handle, CURLOPT_POSTFIELDS, $postvars); // Don't bother with the HTTP headers. Do bother with the content back curl_setopt($request_handle, CURLOPT_HEADER, false); curl_setopt($request_handle, CURLOPT_RETURNTRANSFER, true); // Make proxy request $response_content = curl_exec($request_handle); //determine the content-type of the respeonse $pre_content_type = curl_getinfo($request_handle, CURLINFO_CONTENT_TYPE); $content_type = (empty($pre_content_type)) ? "text/html" : $pre_content_type; // Set the outgoing proxy content type header("Content-Type: $content_type"); echo $response_content; curl_close($request_handle);
// API callback myHandleDataCode({"language":"en-US","link":"http...etc...etc ...});
<script> function myHandleDataCode(obj) { // do something pretty with json data } <script> <script src="https://www.yioop.com/s/news?f=json&callback=myHandleDataCode" />
<script src="http://url_for_pdf.js/pdf.js" ></script> <script> </script> function renderPdfPage(media_obj, num) { if (media_obj.reflect_rendering) { return; } var media_name = media_obj.reflect_name; media_obj.reflect_page_num = num; media_obj.reflect_rendering = true; media_obj.getPage(num).then(function(page) { var viewport = page.getViewport(1.5, parseInt(media_obj.reflect_orientation)); var canvas = document.getElementById('area-' + media_name); var context = canvas.getContext('2d'); canvas.height = viewport.height; canvas.width = viewport.width; var renderContext = { canvasContext: context, viewport: viewport }; var renderTask = page.render(renderContext); renderTask.promise.then(function () { media_obj.reflect_rendering = false; }); }); } PDFJS.getDocument(url_of_document_viewing).then( function (pdf) { if (localStorage) { old_page = localStorage.getItem(url_of_document_viewing_old_page); renderPdfPage(pdf, old_page); } else { renderPdfPage(pdf, 1); } } );
my_promise = new Promise( function (resolve, reject) {} ); my_promise.then(function(arg_list) { // when anonymous function above calls resolve this code runs. }).catch(function(arg_list) { // when anonymous function above calls reject this code runs. } )
<form enctype="multipart/form-data" method="post" action="test_upload1.php" > <input type="hidden" name="MAX_FILE_SIZE" value="1000000" /> <!-- The size is also controlled by php.ini --> <input type="file" name="docname" /> <input type="submit" value="Upload" /> </form>
Array( [name] => mystyles.css [type] => text/css [tmp_name] => /private/var/folders/k-/k-GHnyslGhyOhMqq80ZXgk+++TI/-Tmp-/phpcSLlhk [error] => 0 [size] => 157)Hence, we can then do a command like:
move_uploaded_file($_FILES["docname"]["tmp_name"], "$where_we_want");to get the file where we would like.
Please type the following text:
<p><b>Please type in the following text:</b> <?php $md5 = md5(microtime() * mktime()); $captcha_string = substr($md5,0,5); $captcha_img = imagecreatetruecolor(70, 40); $color = imagecolorallocate($captcha_img, 255, 0, 255); $line = imagecolorallocate($captcha_img,233,239,239); imagestring($captcha_img, 5, 10, 10, $captcha_string, $color); imageline($captcha_img,0,0,39,29,$line); imageline($captcha_img,40,0,64,29,$line); imageline($captcha_img,0,40,64,0,$line); // get a output as jpeg into a string, 100=not-lossy ob_start(); imagejpeg($captcha_img, 100); $image_data = ob_get_contents(); ob_end_clean(); $data_url = "data:image/jpeg;base64," . base64_encode($image_data); imagedestroy($captcha_img); $_SESSION['key'] = $captcha_string; ?> <img src="<?=$data_url ?>" alt="captcha" style="position:relative; top:15px;"/> <input type="text" name="key" size="5" /></p>
function createThumb($base, $filename) { $image = imagecreatefromjpeg($base.$filename); //or could have imagecreatefromgif, etc $size = getimagesize($base.$filename); $thumb = imagecreatetruecolor(50, 50); imagecopyresampled($thumb, $image, 0,0, 0,0, 50, 50, $size[0],$size[1]); imagejpeg( $thumb, $base."thumb.jpg", 100 ); imagedestroy($image); imagedestroy($thumb); }
$message = "Here is a mail message"; mail("Someone@somewhere.com", "Here is the title", $message, "From: cpollett@somewhereelse.com");