sábado, 22 de agosto de 2015

preg_match()

<?php

acepta solo letras y espacio y  el numero 1

$string="ambiorix1";


$name = $string;
if (!preg_match("/^[a-zA-Z 1]*$/",$name)) {
  echo "Only letters and white space allowed";
}

else  {


echo "OK";

}

viernes, 21 de agosto de 2015

for each Statement and Multi dimensionals arrays

<?php


$food=array('healthy'=>array('salad','fruit','meat'),'unhealthy'=>array('cocacola','icecream','mcdonald'));

//$a es un arreglo y ahora b tambien es un arreglo

foreach( $food as $a=>$b) {


echo $a."<br>";


//b  es otro arreglo  q nace de a

foreach($b as $c)


echo $c."<br>";




}
?>

healthy
salad
fruit
meat
unhealthy
cocacola
icecream
mcdonald

jueves, 20 de agosto de 2015

Facebook Singup PHP

http://webtutsdepot.com/2009/12/19/facebook-api-tutorial-with-php/

http://www.krizna.com/general/login-with-facebook-using-php/

domingo, 9 de agosto de 2015

Guardando salida de un query en HTML

mysql  -H -e  " select * from asterisk.cdr limit 0,1" -p1234 > /var/www/cdr.html



Luego podemos acceder desde la web

http://75.11.118.23/cdr.html

id_callcalldateclidsrcdstdcontextchanneldstchannellastapplastdatadurationbillsecdispositionamaflagsaccountcodeuniqueiduserfieldunixtime
1385942015-04-11 02:10:52"919859582174" <919859582174>919859582174scontestSIP/con1-0000122aPlayback/var/lib/asterisk/sounds/contest/main11ANSWERED31428732652.139500

viernes, 7 de agosto de 2015

Algunas funciones de tiempo

Selecionando  la hora,  minuto y año de una fecha que esta en unix time

SELECT HOUR( FROM_UNIXTIME( cp_time ) ) , MINUTE( FROM_UNIXTIME( cp_time ) ) , YEAR( FROM_UNIXTIME( cp_time ) )
FROM `campaing`
LIMIT 0 , 30



SELECT * 
FROM `campaing`
WHERE HOUR( FROM_UNIXTIME( cp_time ) ) =16 and MINUTE( FROM_UNIXTIME( cp_time ) )>=01 and YEAR( FROM_UNIXTIME( cp_time ) )>=2015


SELECT FROM_UNIXTIME( cp_time )
FROM `campaing`
WHERE 1
LIMIT 0 , 30


2015-07-21 00:30:00
2015-08-02 16:02:00

MYSQL event

In this tutorial, you will learn about MySQL event scheduler and how to create MySQL events to automate database tasks.
A MySQL event is a task that runs based on a predefined schedule therefore sometimes it is referred to as a scheduled event. MySQL event is also known as “temporal trigger” because it is triggered by time, not by table update like a trigger. A MySQL event is similar to a cron job in UNIX or a task scheduler in Windows.
You can use MySQL events in many cases such as optimizing database tables, cleaning up logs, archiving data, or generate complex reports during off-peak time.

miércoles, 15 de julio de 2015

PHP whitepage API



root@asterisk-dominicana:~# php whitepage.php 2066013560


<?php
//$json = file_get_contents('http://proapi.whitepages.com/2.1/phone.json?phone=2066013560&api_key=3f9f57e7df15d5eea2ddd06ed88d4889');


$json = file_get_contents("http://proapi.whitepages.com/2.1/phone.json?phone=$argv[1]&api_key=3f9f57e7df15d5eea2ddd06ed88d4889");

$data = json_decode($json,true);



//print_r($data['results'][0]['belongs_to'][0]);


//var_dump($data['results'][0]['belongs_to'][0]);
echo "Customer Name : ".$data['results'][0]['belongs_to'][0]['best_name'];
echo "<br>";
echo "Customer Reputation ".$data['results'][0]['reputation']['level'];

exit;
?>