Check if key array is exist with function array_key_exists
Syntax
Syntax
function getLink($url){
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,$url);
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,0);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$result = curl_exec($curl_handle);
curl_close($curl_handle);
return $result;
}
$file_contents = getLink("http://sample-site.com");
$data = array();
preg_match_all('/<div class=\"abc\">(.*?)<\/div>/s',$file_contents,$data);
foreach($data[1] as $idx=>$valx){
$detail1 = array();
preg_match_all('/<a href=\"(.*?)\"(.*?)<\/a>/s',$valx,$detail1);
$link = $detail1[1][0];
echo $link;
}
<html>
<head><title>Sample Title</title></head>
<body>
<div class="abc"><a href="http://google.com" title="Google">Google</a></div>
<div class="abc"><a href="http://yahoo.com" title="Yahoo">Yahoo</a></div>
<div class="abc"><a href="http://facebook.com" title="facebook">Facebook</a></div>
</body>
</html>
preg_match_all('/<div class=\"abc\">(.*?)<\/div>/s',$file_contents,$data);
| Regular Expression | Will match... |
| foo | The string "foo" |
| ^foo | "foo" at the start of a string |
| foo$ | "foo" at the end of a string |
| ^foo$ | "foo" when it is alone on a string |
| [abc] | a, b, or c |
| [a-z] | Any lowercase letter |
| [^A-Z] | Any character that is not a uppercase letter |
| (gif|jpg) | Matches either "gif" or "jpeg" |
| [a-z]+ | One or more lowercase letters |
| [0-9\.\-] | Аny number, dot, or minus sign |
| ^[a-zA-Z0-9_]{1,}$ | Any word of at least one letter, number or _ |
| ([wx])([yz]) | wy, wz, xy, or xz |
| [^A-Za-z0-9] | Any symbol (not a number or a letter) |
| ([A-Z]{3}|[0-9]{4}) | Matches three letters or four numbers |
var fruits = ["Banana", "Orange", "Apple", "Mango"];fruits.push("Kiwi")
var y = [1, 2, 3];
var removeItem = 2;
y = jQuery.grep(y, function(value) {
return value != removeItem;
});
orvar y = [1, 2, 3];
var removeItem = 2;
y.splice( $.inArray(removeItem, y), 1 );
orvar y = [1, 2, 3];
y.remove(2);
function redirect_post($url, array $data) {
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function closethisasap (){
document.forms["redirectpost"].submit();
}
</script>
<body onload="closethisasap();">
<form name="redirectpost" method="post" action="<? echo $url; ?>" >
<?
if (!is_null($data)) {
foreach ($data as $k => $v) {
echo '<input type="hidden" name="'.$k.'" value="'.$v.'"> ';
}
}
?>
</form>
</body>
</head>
</html>
<?
exit();
}
function fx_terbilang($bilangan){
$bilangan = abs($bilangan);
$angka = array("Nol","satu","dua","tiga","empat","lima","enam","tujuh","delapan","sembilan","sepuluh","sebelas");
$temp = "";
if($bilangan < 12){
$temp = " ".$angka[$bilangan];
}else if($bilangan < 20){
$temp = terbilang($bilangan - 10)." belas";
}else if($bilangan < 100){
$temp = terbilang($bilangan/10)." puluh".terbilang($bilangan%10);
}else if ($bilangan < 200) {
$temp = " seratus".terbilang($bilangan - 100);
}else if ($bilangan < 1000) {
$temp = terbilang($bilangan/100). " ratus". terbilang($bilangan % 100);
}else if ($bilangan < 2000) {
$temp = " seribu". terbilang($bilangan - 1000);
}else if ($bilangan < 1000000) {
$temp = terbilang($bilangan/1000)." ribu". terbilang($bilangan % 1000);
}else if ($bilangan < 1000000000) {
$temp = terbilang($bilangan/1000000)." juta". terbilang($bilangan % 1000000);
}
return $temp;
}
sudo gedit /etc/php5/apache2/php.ini
2. Setelah itu ubah konfigurasinya cari settingan memory_limit, upload_max_filesize dan post_max_sizenya.memory_limit = 32M upload_max_filesize = 10M post_max_size = 20M3. Restart apache
sudo service apache2 restart
<!DOCTYPE html>
<html>
<head>
<title>Video.js | HTML5 Video Player</title>
<!-- Chang URLs to wherever Video.js files will be hosted -->
<link href="video-js.css" rel="stylesheet" type="text/css">
<!-- video.js must be in the <head> for older IEs to work. -->
<script src="video.js"></script>
<!-- Unless using the CDN hosted version, update the URL to the Flash SWF -->
<script>
videojs.options.flash.swf = "video-js.swf";
</script>
</head>
<body>
<video id="example_video_1" class="video-js vjs-default-skin" controls preload="none" width="640" height="264"
poster="http://video-js.zencoder.com/oceans-clip.png"
data-setup="{}">
<source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4' />
<source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm' />
<source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg' />
<track kind="captions" src="demo.captions.vtt" srclang="en" label="English"></track><!-- Tracks need an ending tag thanks to IE9 -->
<track kind="subtitles" src="demo.captions.vtt" srclang="en" label="English"></track><!-- Tracks need an ending tag thanks to IE9 -->
</video>
</body>
</html>
sudo apt-get install php-pear2. Lalu jalankan perintah di bawah ini
sudo pear install http://downloads.jasig.org/cas-clients/php/current.tgz3. Setelah instalasi selesai maka phpCAS sudah bisa digunakan
/**
* The purpose of this central config file is configuring all examples
* in one place with minimal work for your working environment
* Just configure all the items in this config according to your environment
* and rename the file to config.php
*
* PHP Version 5
*
* @file config.php
* @category Authentication
* @package PhpCAS
* @author Joachim Fritschi <jfritschi@freenet.de>
* @author Adam Franco <afranco@middlebury.edu>
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://wiki.jasig.org/display/CASC/phpCAS
*/
$phpcas_path = '/usr/share/php';
///////////////////////////////////////
// Basic Config of the phpCAS client //
///////////////////////////////////////
// Full Hostname of your CAS Server
$cas_host = 'sso.sample.com';
// Context of the CAS Server
$cas_context = '/cas/';
// Port of your CAS server. Normally for a https server it's 443
$cas_port = 443;
// Path to the ca chain that issued the cas server certificate
//$cas_server_ca_cert_path = '/path/to/cachain.pem';
//////////////////////////////////////////
// Advanced Config for special purposes //
//////////////////////////////////////////
// The "real" hosts of clustered cas server that send SAML logout messages
// Assumes the cas server is load balanced across multiple hosts
$cas_real_hosts = array('cas-real-1.example.com', 'cas-real-2.example.com');
// Database config for PGT Storage
$db = 'pgsql:host=localhost;dbname=phpcas';
//$db = 'mysql:host=localhost;dbname=phpcas';
$db_user = 'phpcasuser';
$db_password = 'mysupersecretpass';
$db_table = 'phpcastabel';
$driver_options = '';
///////////////////////////////////////////
// End Configuration -- Don't edit below //
///////////////////////////////////////////
// Generating the URLS for the local cas example services for proxy testing
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
$curbase = 'https://' . $_SERVER['SERVER_NAME'];
} else {
$curbase = 'http://' . $_SERVER['SERVER_NAME'];
}
if ($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
$curbase .= ':' . $_SERVER['SERVER_PORT'];
}
$curdir = dirname($_SERVER['REQUEST_URI']) . "/";
// CAS client nodes for rebroadcasting pgtIou/pgtId and logoutRequest
$rebroadcast_node_1 = 'http://cas-client-1.example.com';
$rebroadcast_node_2 = 'http://cas-client-2.example.com';
// access to a single service
$serviceUrl = $curbase . $curdir . 'example_service.php';
// access to a second service
$serviceUrl2 = $curbase . $curdir . 'example_service_that_proxies.php';
$pgtBase = preg_quote(preg_replace('/^http:/', 'https:', $curbase . $curdir), '/');
$pgtUrlRegexp = '/^' . $pgtBase . '.*$/';
$cas_url = 'https://' . $cas_host;
if ($cas_port != '443') {
$cas_url = $cas_url . ':' . $cas_port;
}
$cas_url = $cas_url . $cas_context;
// Set the session-name to be unique to the current script so that the client script
// doesn't share its session with a proxied script.
// This is just useful when running the example code, but not normally.
session_name(
'session_for:'
. preg_replace('/[^a-z0-9-]/i', '_', basename($_SERVER['SCRIPT_NAME']))
);
// Set an UTF-8 encoding header for internation characters (User attributes)
header('Content-Type: text/html; charset=utf-8');
<?php
/**
* Small script to add some info about the example script that is running.
* Adds some info that makes it easier to distinguish different proxy sessions
*
* PHP Version 5
*
* @file script_info.php
* @category Authentication
* @package PhpCAS
* @author Joachim Fritschi <jfritschi@freenet.de>
* @author Adam Franco <afranco@middlebury.edu>
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://wiki.jasig.org/display/CASC/phpCAS
*/ ?>
<dl style='border: 1px dotted; padding: 5px;'>
<dt>Current script</dt><dd><?php print basename($_SERVER['SCRIPT_NAME']); ?></dd>
<dt>session_name():</dt><dd> <?php print session_name(); ?></dd>
<dt>session_id():</dt><dd> <?php print session_id(); ?></dd>
</dl>
<?php
/**
* Example for a simple cas 2.0 client
*
* PHP Version 5
*
* @file example_simple.php
* @category Authentication
* @package PhpCAS
* @author Joachim Fritschi <jfritschi@freenet.de>
* @author Adam Franco <afranco@middlebury.edu>
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://wiki.jasig.org/display/CASC/phpCAS
*/
// Load the settings from the central config file
require_once 'config.php';
// Load the CAS lib
require_once $phpcas_path . '/CAS.php';
// Uncomment to enable debugging
phpCAS::setDebug();
// Initialize phpCAS
phpCAS::client(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_context);
// For production use set the CA certificate that is the issuer of the cert
// on the CAS server and uncomment the line below
// phpCAS::setCasServerCACert($cas_server_ca_cert_path);
// For quick testing you can disable SSL validation of the CAS server.
// THIS SETTING IS NOT RECOMMENDED FOR PRODUCTION.
// VALIDATING THE CAS SERVER IS CRUCIAL TO THE SECURITY OF THE CAS PROTOCOL!
phpCAS::setNoCasServerValidation();
// force CAS authentication
phpCAS::forceAuthentication();
// at this step, the user has been authenticated by the CAS server
// and the user's login name can be read with phpCAS::getUser().
// logout if desired
if (isset($_REQUEST['logout'])) {
phpCAS::logout();
}
// for this test, simply print that the authentication was successfull
?>
<html>
<head>
<title>phpCAS simple client</title>
</head>
<body>
<h1>Successfull Authentication!</h1>
<?php require 'script_info.php' ?>
<p>the user's login is <b><?php echo phpCAS::getUser(); ?></b>.</p>
<p>phpCAS version is <b><?php echo phpCAS::getVersion(); ?></b>.</p>
<p><a href="?logout=">Logout</a></p>
</body>
</html>
function GetRomawiFromNumber($n){
$result = "";
$iromawi = array("","I","II","III","IV","V","VI","VII","VIII","IX","X",
20=>"XX",30=>"XXX",40=>"XL",50=>"L",60=>"LX",
70=>"LXX",80=>"LXXX",90=>"XC",100=>"C",200=>"CC",
300=>"CCC",400=>"CD",500=>"D",600=>"DC",
700=>"DCC",800=>"DCCC",
900=>"CM",1000=>"M",
2000=>"MM",3000=>"MMM");
if(array_key_exists($n,$iromawi)){
$result = $iromawi[$n];
}elseif($n >= 11 && $n <= 99){
$i = $n % 10;
$result = $iromawi[$n-$i] . GetRomawiFromNumber($n % 10);
}elseif($n >= 101 && $n <= 999){
$i = $n % 100;
$result = $iromawi[$n-$i] . GetRomawiFromNumber($n % 100);
}else{
$i = $n % 1000;
$result = $iromawi[$n-$i] . GetRomawiFromNumber($n % 1000);
}
return $result;
}
curl -sS https://getcomposer.org/installer | phpsebelumnya bisa diinstal dulu curl jika anda pengguna linux ubuntu maka anda cukup mengteikan perintah berikut atau mendownload source-nya di sini
apt-get install php5-curljika anda pengguna windows maka anda bisa melihat tutorialnya di sini.
php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"setelah itu instal compozer dengan perintah berikut
curl -sS https://getcomposer.org/installer | php -- --install-dir=[instal_dir]silahkan ganti instal dir dengan direktori /usr/local/bin
mv composer.phar /usr/local/bin/composerOke sampai sini tahap menginstal compozer selesai ^_^
$number="";
for($i=1;$i<=100;$i++){
$number.=($i.",");
}
$number=substr($number,0,strlen($number)-1);
$url = "http://192.168.2.201/form/Download?uid=".$number."&sdate=2013-09-10&edate=2013-09-10";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
$data = array();
$record = explode("\n",$server_output);
foreach($record as $r){
$r = str_replace("\t"," ",$r);
$isi = explode(" ",$r);
array_push($data, $isi);
}
print_r($data);
sudo apt-get install jpegoptim
jpegoptim yourimage.jpg --max=x
jpegoptim --helpor
man jpegoptim
sudo gedit /etc/apache2/sites-available/defaultLalu tambahkan perintah berikut pada baris paling bawah
<VirtualHost *:80>
ServerName namaserver.com
DocumentRoot /var/www/lokasi_file_website
<Directory /var/www/lokasi_file_website>
Options Indexes FollowSymLinks MultiViews
AllowOverride AuthConfig FileInfo
Order allow,deny
allow from all
</Directory>
</VirtualHost>
sudo gedit /etc/hostsLalu sisipkan perintah berikut di bawah localhost
127.0.0.1 namaserver.com
sudo service apache2 restart4. Coba jalankan pada browser dengan mengetikan namaserver.com pada address bar
sudo add-apt-repository ppa:webupd8team/sublime-text-2
sudo apt-get update
sudo apt-get install sublime-text

storage/views directory is writable. #chmod a+w your_path/storage/views -R

ALTER TABLE yourtable ADD COLUMN id2 INT(11) UNSIGNED NOT NULL AFTER `id`; SET @a:=0; UPDATE yourtable SET id2=@a:=@a+1 ORDER BY id; ALTER TABLE yourtable DROP id; ALTER TABLE yourtable CHANGE id2 id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY(id);
CREATE TABLE yourtable (x INT(8) ZEROFILL NOT NULL, y INT(8) NOT NULL);
INSERT INTO yourtable (x,y) VALUES
(1, 1),
(12, 12),
(123, 123),
(123456789, 123456789);
SELECT x, y FROM yourtable;
TRUEif the givenkeyis set in the array.keycan be any value possible for an array index.<?php
$search_array = array('first' => null, 'second' => 4);
// returns falseisset($search_array['first']);
// returns truearray_key_exists('first', $search_array);?>