Google Maps

latitude, longitude Drawing on map marker info windows Waypoints polyline polygons Directions service Keywords : travel modes, street view      

14/01/2015

mysql group every n row

by the way, you can calculate the data like for every  5 minutes ( in database each row  for 20 seconds interval ).   example below : grouped  every  5 row in series as group then you can make function like math avg , count etc. [code] set @i :=0; SELECT *, @i:=@i+1 as rownum, FLOOR(@i/5) AS `datagrp` FROM table_name_muslum21 [/code]

14/01/2015

bootstrap & fancybox conflict

it can be solved by  fancy  beforeLoad
$(document).ready(function() {
 var fancy_top = "";
 $("[id^='fancy_popup']").fancybox({
 'width' : '75%',
 'height' : '75%',
 'autoScale' : false,
 'transitionIn' : 'none',
 'transitionOut' : 'none',
 'type' : 'iframe',
 'afterClose' : function() {
   document.body.scrollTop=fancy_top; 
  $('html, body').animate({ scrollTop:fancy_top });},
 'beforeLoad' : function() { 
  var fancy_top = document.body.scrollTop; 
 }

 });

 $('.fancybox').fancybox();

 });

14/01/2015

How to install php gd library in linux

Gd library installation  

1-  open terminal

2- login  as root

3-  in terminal console   " apt-get install php5-gd"

4- then [Y/n] appears on screen  press y  ,press ENTER

5- Finish


14/01/2015

Cron Job Commands List

PHP Command to run a PHP5 cron job: php /home/username/public_html/cron.php Optional flags are sometimes required for a PHP cron job: php -q /home/username/public_html/cron.php Command to run a PHP4 cron job: /usr/local/php4/bin/php /home/strong>username/public_html/cron.php Command to use a specific php.ini file: php -c /home/username/public_html/php.ini /home/username/public_html/myscript.php Command to GET a remote file:  /usr/bin/GET http://www.example.com/file.php

PHP

Command to run for a PHP5 cron job:
/usr/local/php5/bin/php5 /home/username/public_html/cron.php
Command to run for a PHP4 cron job:
/usr/bin/php /home/username/public_html/cron.php
File
delete all file in cache folder
rm home/username/public_html/cache/*
delete all file and folder in cache
rm -vrf  home/username/public_html/cache/
process cron.php file in admin fo
wget -O /dev/null/ http://www.muslum21.com/admin/cron.php > /dev/null
> /dev/null   ->  cancel sending email
SSH Command to run a code script cron job: /bin/sh /home/username/public_html/file.sh Mysql Command to import a database: mysql -u mysql_user -ppassword database_name < backup.sql Command to export a database: mysqldump -u mysql_user -ppassword database_name >backup.sql

14/01/2015

Multiple CKEditor replace by class with same class in one page

CKEditor replace  by class with same class in one page <textarea cols="80"  class="editor"   name="editor1" rows="10"> ddd</textarea> <textarea cols="80"    class="editor"  name="editor2" rows="10"> ddd</textarea>

<script>

var dd=1;
$(".editor").each(function(){

$(this).attr("id","editor"+dd);

CKEDITOR.replace( 'editor'+dd);
dd=dd+1;
});

</script>
										

14/01/2015

jQuery Conflict problem - is not a function

  TypeError: $ is not a function or Uncaught TypeError: Property '$' of object [object Object] is not a function Change  "$"  to  "jQuery"   Problem: is usually  caused by different version of jquery

14/01/2015

Creating SimpleXMLElement Example

[php] $xml = new SimpleXMLElement(''); $xml->addAttribute('version',"1.0"); $xml->addAttribute("encoding","iso-8859-9"); for ($i = 1; $i <= 8; ++$i) { $track = $xml->addChild('track'); $track->addChild('path', "song$i.mp3"); $track->addChild('title', "Track $i - Track Title"); } Header('Content-type: text/xml'); print($xml->asXML()); [/php] output  :
<xml version="1.0" encoding="iso-8859-9">
<track>
<path>song1.mp3</path>
<title>Track 1 - Track Title</title>
</track>
<track>
<path>song2.mp3</path>
<title>Track 2 - Track Title</title>
</track>
<track>
<path>song3.mp3</path>
<title>Track 3 - Track Title</title>
</track>
<track>
<path>song4.mp3</path>
<title>Track 4 - Track Title</title>
</track>
<track>
<path>song5.mp3</path>
<title>Track 5 - Track Title</title>
</track>
<track>
<path>song6.mp3</path>
<title>Track 6 - Track Title</title>
</track>
<track>
<path>song7.mp3</path>
<title>Track 7 - Track Title</title>
</track>
<track>
<path>song8.mp3</path>
<title>Track 8 - Track Title</title>
</track>
</xml>

14/01/2015

.htaccess file example

  RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule .? http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] description:  redirect to   from   http://muslum21.com    to  http://www.muslum21.com

14/01/2015

PHP ini Example

http://www.reallylinux.com/docs/php.ini  
;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

max_execution_time = 30     ; Maximum execution time of each script, in seconds
max_input_time = 60	; Maximum amount of time each script may spend parsing request data
memory_limit = 8M      ; Maximum amount of memory a script may consume (8MB)
 

14/01/2015

Php Curl Post Example

[PHP] //extract data from the post extract($_POST); //set POST variables $url = 'http://domain.com/get-post.php'; $fields = array( 'lname' => urlencode($last_name), 'fname' => urlencode($first_name), 'title' => urlencode($title), 'company' => urlencode($institution), 'age' => urlencode($age), 'email' => urlencode($email), 'phone' => urlencode($phone) ); //url-ify the data for the POST foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string, '&'); //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_POST, count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); //execute post $result = curl_exec($ch); //close connection curl_close($ch); [/PHP] ref: http://davidwalsh.name/curl-post

14/01/2015

php file system read all file in directory class

[php] class readd_all_file{ function __construct() { $this->index(); } function index(){ $this->all_pic=array(); $dir_name="images"; $this->open_dir($dir_name); $this->dbg2($this->all_pic); } function open_dir($dir_name){ $IMAGES_fold=scandir($dir_name); foreach($IMAGES_fold as $fold){ if(in_array($fold,array(".",".."))){continue;} if(!is_dir($dir_name."/".$fold)){ $this->all_pic[]=$dir_name."/".$fold; }else{ $this->open_dir($dir_name."/".$fold); } } } } [/php] [14] => images/Buttons/1320202803_button.png [15] => images/Buttons/1320203926_button.png [16] => images/Buttons/1320203948_button.png [17] => images/Buttons/1320203966_button.png [18] => images/Buttons/1337051437_button.png [19] => images/Buttons/1337051451_button.png [20] => images/Buttons/mcith/mcith_1320202803_button.png [21] => images/Buttons/mcith/mcith_1320203926_button.png [22] => images/Buttons/mcith/mcith_1320203948_button.png [23] => images/Buttons/mcith/mcith_1320203966_button.png [24] => images/Buttons/mcith/mcith_1337051437_button.png [25] => images/Buttons/mcith/mcith_1337051451_button.png [26] => images/Buttons/mcith/mcith_tukendi_buton.png [27] => images/Buttons/mcith/mcith_tukendi_buton_en.png [28] => images/Buttons/mcith/mcith_yeni_buton.png [29] => images/Buttons/mcith/mcith_yeni_buton_en.png [30] => images/Buttons/refrsh.jpeg [31] => images/Buttons/tukendi_buton.png [32] => images/Buttons/tukendi_buton_en.png [33] => images/Buttons/yeni_buton.png [34] => images/Buttons/yeni_buton_en.png [35] => images/MiniSlide/1335804630_1.png [36] => images/MiniSlide/1335810909_1.png [37] => images/MiniSlide/1335812296_1.png [38] => images/MiniSlide/1335812377_.jpeg [39] => images/MiniSlide/1335812456_1.png [40] => images/MiniSlide/1335812484_1.png [41] => images/MiniSlide/1335812493_1.png [42] => images/MiniSlide/1335813419_1.png [43] => images/MiniSlide/1335813426_1.png [44] => images/MiniSlide/1335917378_1.png [45] => images/MiniSlide/1335917394_1.png [46] => images/MiniSlide/1336410058_1.gif [47] => images/MiniSlide/1336410066_1.gif [48] => images/MiniSlide/1336410103_1.gif [49] => images/MiniSlide/1336550136_1.jpeg [50] => images/MiniSlide/1336555136_1.jpeg

14/01/2015

jQuery change select form by value

[php] function change_option_byvalue(select,value){ $(select).find("option:selected").removeAttr("selected"); $(select).find("option[value='"+value+"']").attr('selected','selected'); $(select).find("option[value='"+value+"']").trigger('click'); var selectparent =$(select).parent(); var newselect =$(select).clone(); $(select).remove(); selectparent.append(newselect); } change_option_byvalue("select[name='muslum']",21);  // it will select the option that has value of 21 by muslum21 [/php]

14/01/2015

HybridAuth, open source social sign on php library

The main goal of HybridAuth library is to act as an abstract api between your application and various social apis and identities providers such as Facebook, Twitter, MySpace, LinkedIn, Google and Yahoo.

http://hybridauth.sourceforge.net/


14/01/2015

next day function by muslum21

[php] function next_day(date,next_day){ var expire_date1= new Date(date); //console.log(expire_date1); expire_date1.setDate(expire_date1.getDate()+next_day); expire_date1.setMonth(expire_date1.getMonth()+1); return expire_date1.getMonth()+'/'+expire_date1.getDate()+'/'+expire_date1.getFullYear() ; } next_day('01/21/2013',2);  // return '01/23/2013' &nbsp; [/php]

14/01/2015

geting js ajax json object result to console as key value with jquery $each() function

dd geting js ajax json object result to console as  key value  with jquery $each() function [php]</p> <p>var result = jQuery.parseJSON(response.responseText);<br /> //console.log(result);<br /> $.each(result, function(key, value){<br /> $.each(value, function(key, value){</p> <p>console.log(key, value);<br /> });<br /> });</p> <p>[/php]

14/01/2015

objPHPExcel adjust to printing

 $objPHPExcel->getActiveSheet()->getPageSetup()->setFitToPage(true);
[php]

// Set Orientation, size and scaling
 $objPHPExcel->setActiveSheetIndex(0);
 $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT);
 $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
 $objPHPExcel->getActiveSheet()->getPageSetup()->setFitToPage(true);
 $objPHPExcel->getActiveSheet()->getPageSetup()->setFitToWidth(1);
 $objPHPExcel->getActiveSheet()->getPageSetup()->setFitToHeight(0);

[/php]





----

14/01/2015

Php Redirect with POST data.

/**
 * Redirect with POST data.
 *
 * @param string $url URL.
 * @param array $post_data POST data. Example: array('foo' => 'var', 'id' => 123)
 * @param array $headers Optional. Extra headers to send.
 */
public function redirect_post($url, array $data, array $headers = null) {
    $params = array(
        'http' => array(
            'method' => 'POST',
            'content' => http_build_query($data)
        )
    );
    if (!is_null($headers)) {
        $params['http']['header'] = '';
        foreach ($headers as $k => $v) {
            $params['http']['header'] .= "$k: $v\n";
        }
    }
    $ctx = stream_context_create($params);
    $fp = @fopen($url, 'rb', false, $ctx);
    if ($fp) {
        echo @stream_get_contents($fp);
        die();
    } else {
        // Error
        throw new Exception("Error loading '$url', $php_errormsg");
    }
}

http://stackoverflow.com/questions/5576619/php-redirect-with-post-data

14/01/2015

php strpos - javascript equivalent

http://phpjs.org/functions/strpos/ [php] function strpos (haystack, needle, offset) { // http://kevin.vanzonneveld.net // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: Onno Marsman // + bugfixed by: Daniel Esteban // + improved by: Brett Zamir (http://brett-zamir.me) // * example 1: strpos('Kevin van Zonneveld', 'e', 5); // * returns 1: 14 var i = (haystack + '').indexOf(needle, (offset || 0)); return i === -1 ? false : i; } strpos('Kevin van Zonneveld', 'e', 5); // return 1,14 [/php]

14/01/2015

codeigniter array_column

http://www.php.net/manual/en/function.array-column.php

$first_names = array_column($records, 'first_name');

[php]

<!--?php <br ?-->// Array representing a possible record set returned from a database
$records = array(
array(
'id' => 2135,
'first_name' => 'John',
'last_name' => 'Doe',
),
array(
'id' => 3245,
'first_name' => 'Sally',
'last_name' => 'Smith',
),
array(
'id' => 5342,
'first_name' => 'Jane',
'last_name' => 'Jones',
),
array(
'id' => 5623,
'first_name' => 'Peter',
'last_name' => 'Doe',
)
);

$first_names = array_column($records, 'first_name');
print_r($first_names);
?>
Array
(
    [0] => John
    [1] => Sally
    [2] => Jane
    [3] => Peter
)

<!--?php
// Using the $records array from Example #1
$last_names = array_column($records, 'last_name', 'id');
print_r($last_names);
?-->

Array
(
    [2135] => Doe
    [3245] => Smith
    [5342] => Jones
    [5623] => Doe
)
[/php]
										

14/01/2015