sábado, 22 de octubre de 2016

web audio recorder

https://github.com/cwilso/AudioRecorder

http://subinsb.com/html5-record-mic-voice

Record, Play, Download Microphone Sound With HTML5

http://subinsb.com/html5-record-mic-voice

$_SERVER array

<?php
foreach($_SERVER as $key=>$value){
echo  "$key : $value<br>";

}
?>


HTTP_HOST : 65.181.118.232
HTTP_CONNECTION : keep-alive
HTTP_CACHE_CONTROL : max-age=0
HTTP_UPGRADE_INSECURE_REQUESTS : 1
HTTP_USER_AGENT : Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36
HTTP_ACCEPT : text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
HTTP_ACCEPT_ENCODING : gzip, deflate, sdch
HTTP_ACCEPT_LANGUAGE : es-ES,es;q=0.8,en;q=0.6
PATH : /usr/local/bin:/usr/bin:/bin
SERVER_SIGNATURE :
Apache/2.4.6 (Ubuntu) Server at 65.181.118.232 Port 80

SERVER_SOFTWARE : Apache/2.4.6 (Ubuntu)
SERVER_NAME : 65.181.118.232
SERVER_ADDR : 65.181.118.232
SERVER_PORT : 80
REMOTE_ADDR : 148.103.149.6
DOCUMENT_ROOT : /var/www
REQUEST_SCHEME : http
CONTEXT_PREFIX :
CONTEXT_DOCUMENT_ROOT : /var/www
SERVER_ADMIN : webmaster@localhost
SCRIPT_FILENAME : /var/www/test.php
REMOTE_PORT : 50257
GATEWAY_INTERFACE : CGI/1.1
SERVER_PROTOCOL : HTTP/1.1
REQUEST_METHOD : GET
QUERY_STRING :
REQUEST_URI : /test.php
SCRIPT_NAME : /test.php
PHP_SELF : /test.php
REQUEST_TIME_FLOAT : 1477189544.259
REQUEST_TIME : 1477189544

miércoles, 19 de octubre de 2016

forcing download

<?php
header('Content-Type: application/pdf');
readfile("/var/www/hosting/asterisk/books/vicidial/ViciBox_Redux-Install.pdf");
?>

sábado, 15 de octubre de 2016

Uploading multiple files

Example #1 
<?php
$uploads_dir 
'/uploads';
foreach (
$_FILES["pictures"]["error"] as $key => $error) {
    if (
$error == UPLOAD_ERR_OK) {
        
$tmp_name $_FILES["pictures"]["tmp_name"][$key];
        
// basename() may prevent filesystem traversal attacks;
        // further validation/sanitation of the filename may be appropriate
        
$name basename($_FILES["pictures"]["name"][$key]);
        
move_uploaded_file($tmp_name"$uploads_dir/$name");
    }
}
?>
http://php.net/manual/en/function.move-uploaded-file.php

Example with rename()

Example #1 Example with rename()
<?php
rename
("/tmp/tmp_file.txt""/home/user/login/docs/my_file.txt");?>
http://php.net/manual/en/function.rename.php

viernes, 14 de octubre de 2016

Handy one liner to parse a CSV file into an array


<?php

$csv 
array_map('str_getcsv'file('data.csv'));
?>

http://php.net/manual/en/function.str-getcsv.php

Read and print the entire contents of a CSV file

Example #1 Read and print the entire contents of a CSV file
<?php
$row 
1;
if ((
$handle fopen("test.csv""r")) !== FALSE) {
    while ((
$data fgetcsv($handle1000",")) !== FALSE) {
        
$num count($data);
        echo 
"<p> $num fields in line $row: <br /></p>\n";
        
$row++;
        for (
$c=0$c $num$c++) {
            echo 
$data[$c] . "<br />\n";
        }
    }
    
fclose($handle);
}
?>
http://php.net/manual/en/function.fgetcsv.php

Reading a file line by line

Examples ¶

Example #1 Reading a file line by line
<?php
$handle 
= @fopen("/tmp/inputfile.txt""r");
if (
$handle) {
    while ((
$buffer fgets($handle4096)) !== false) {
        echo 
$buffer;
    }
    if (!
feof($handle)) {
        echo 
"Error: unexpected fgets() fail\n";
    }
    
fclose($handle);
}
?>
http://php.net/manual/en/function.fgets.php

lunes, 3 de octubre de 2016

The special NULL value represents a variable with no value. NULL is the only possible value of type null.
A variable is considered to be null if:
  • it has been assigned the constant NULL.
  • it has not been set to any value yet.
  • it has been unset().
If a variable is  equal to  0, "",'' is  equal to be null

<?php
$r="";

if(!$r)
{
echo " var is null ";
}


else {
echo " var has a value";
}

?>