Wednesday, February 25, 2015

Cross-Origin Request Blocked ?

ERROR : Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at the url. This can be fixed by moving the resource to the same domain or enabling CORS.



Solution :

If you are working on web project  and want to get data from different site , Sometime you get such type of error 

" Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at the url. This can be fixed by moving the resource to the same domain or enabling CORS. "

then you have to use .htaccess file 

update code

<FilesMatch "\.(php)$">
  <IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
  </IfModule>
</FilesMatch>           




if you havn't    .htaccess file then create a file in root folder and update following code 
Following code for wordpress project please change according to your Project 


# BEGIN WordPress
<IfModule mod_rewrite.c>
  RewriteEngine On

 RewriteBase /
  RewriteRule ^index\.php$ - [L]
  RewriteCond
   %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]
</IfModule>
<FilesMatch "\.(php)$">
   <IfModule mod_headers.c>   
     Header set Access-Control-Allow-Origin "*"
   </IfModule>
</FilesMatch>
# END WordPress



Enjoy Coding  :) 



comment please :)
Read more....

Wednesday, February 11, 2015

Subtracting a certain number of hours, days, months or years from date

Subtracting a certain number of hours, days, months or years from date


you can subtract For hours:
function get_offset_hours($hours)
{
    return date('Y-m-d H:i:s', time() + 3600 * $hours);
}
Something like that will work well for hours and days (use 86400 for days), but for months and year it's a bit trickier...
Also you can also do it this way:
$date = strtotime(date('Y-m-d H:i:s') . ' +1 day');
$date = strtotime(date('Y-m-d H:i:s') . ' +1 week');
$date = strtotime(date('Y-m-d H:i:s') . ' +2 week');
$date = strtotime(date('Y-m-d H:i:s') . ' +1 month');
$date = strtotime(date('Y-m-d H:i:s') . ' +30 days');
$date = strtotime(date('Y-m-d H:i:s') . ' +1 year');

echo(date('Y-m-d H:i:s', $date));
you get required result .  :) 
Happy Coding   
Read more....

Tuesday, February 10, 2015

How to Install and Configure phpMyAdmin on Ubuntu 14.04

phpMyAdmin is an open source tool used for the administration of MySQL. In addition to offering the capability to perform administration tasks such as creating, editing, or deleting databases, and managing users and permissions

Step 1: Install phpMyAdmin

apt-get -y update                                                                       
apt-get -y install phpmyadmin                                                            

Step 2: Basic Configuration

select apache2 by using the space bar, then hit enter to continue.  
At the second screen, which asks “configure the database for phpmyadmin with dbconfig-common?”, select Yes , then hit enter to continue. 
At the third screen enter your MySQL password, then hit enter to continue. 
And finally at the fourth screen set the password you’ll use to log into phpmyadmin, hit enter to continue, and confirm your password.

Step 3: Finish the Configuration of Apache

vim /etc/apache2/apache2.conf                                                         

# phpMyAdmin Configuration                                                            

Include /etc/phpmyadmin/apache.conf                                                   



Then exit and save the file with the command :wq .
And, restart Apache 2 with the following command:
 
service apache2 restart                                                               

  update curl                                                                 


I believe that the package php5-curl should do the trick. Use the package manager of your choice and the deps should be taken care of.

sudo apt-get install php5-curl
 
You will need to restart the server afterwards:

sudo service apache2 restart
 
Alternatively, if you are using php-fpm, you'll need to restart php5-fpm instead

sudo service php5-fpm restart
 
 
 
Error reporting Strat 
 
 
<?php

ini_set('display_errors', 1);
error_reporting(E_ALL);

?> 





                       eNJOY :)  HAPPY coding ... ...                                    

                                                                  


Read more....

Wednesday, February 4, 2015

CDN's google hosted

CDN's


Load libraries from the CDN via HTTPS, 
The following section lists all of the libraries currently hosted.

AngularJS
snippet:  
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js"></script>
site: angularjs.org

Angular Material
snippet: 
 <script src="https://ajax.googleapis.com/ajax/libs/angular_material/0.7.1/angular-material.min.js"></script>
site: material.angularjs.org
snippet: <script src="https://ajax.googleapis.com/ajax/libs/dojo/1.10.3/dojo/dojo.js"></script>
site: dojotoolkit.org

Ext Core
snippet: 
<script src="https://ajax.googleapis.com/ajax/libs/ext-core/3.1.0/ext-core.js"></script>
site: sencha.com/products/extcore

jQuery
1.x snippet: 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
2.x snippet:  
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
site: jquery.com

jQuery Mobile
snippet:  
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.3/jquery.mobile.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.3/jquery.mobile.min.js"></script>
site: jquerymobile.com
note: This library depends on jQuery. You must also load jQuery before loading this module.

jQuery UI
snippet
 link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
site: jqueryui.com
note: This library depends on jQuery. You must also load jQuery before loading this module. Version 1.8.3 is not hosted due to its short life, and the alias 1.8.3 actually loads 1.8.4.

MooTools
snippet: <script src="https://ajax.googleapis.com/ajax/libs/mootools/1.5.1/mootools-yui-compressed.js"></script>
site: mootools.net

Prototype
snippet: <script src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.2.0/prototype.js"></script>
site: prototypejs.org

script.aculo.us
snippet: <script src="https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js"></script>
site: script.aculo.us
note: This library depends on Prototype. Before loading this module, you must load Prototype.

SPF
snippet: <script src="https://ajax.googleapis.com/ajax/libs/spf/2.1.2/spf.js"></script>
site: youtube.github.io/spfjs
versions: 2.1.2, 2.1.1, 2.1.0, 2.0.1, 2.0.0

SWFObject
snippet: <script src="https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
site: code.google.com/p/swfobject/
versions: 2.2, 2.1

three.js
snippet: <script src="https://ajax.googleapis.com/ajax/libs/threejs/r69/three.min.js"></script>
site: threejs.org
versions: r67, r68, r69

Web Font Loader
snippet: <script src="https://ajax.googleapis.com/ajax/libs/webfont/1.5.10/webfont.js"></script>
site: github.com/typekit/webfontloader
Read more....
Related Posts Plugin for WordPress, Blogger...