Monday, November 5, 2012

Install and configure OAuth in Ubuntu

http://djpate.com/2010/10/07/how-to-install-oauth-support-for-php-on-ubuntu/



First of all you need to make sure you already have php-pear and php5-dev.
If you are unsure just run
1sudo apt-get install php-pear php5-dev make
now run
1sudo pecl install oauth
Personnaly I had an error while compiling
1/usr/include/php5/ext/pcre/php_pcre.h:29: fatal error: pcre.h:
To fix that just install : libpcre3-dev
1sudo apt-get install libpcre3-dev
Once it’s done just add extension=oauth.so at the end of your php.ini (located in /etc/php5/apache2/php.ini) file and restart Apache.

Wednesday, September 26, 2012

Drupal Blog Page Not Found

If you have the problem of not being able to see the Blog Module page after enabling it, and you are using Clean URL for your site, then it's *probably* because you have accidentally created a subdomain with the name 'blog' (e.g. http://blog.example.com), or you have a subdirectory named 'blog' on your website's root folder (www, htdocs or public_html). You should be able to see Drupal's Blog Module after you remove the subdomain / subdirectory with that same name.

The reason you cannot view the Blog Module at your website's URL (e.g. http://www.example.com/blog) when you have a subdomain / subdirectory with the same name is because when using Clean URL, Drupal rewrites the Blog Module address (http://www.example.com/?q=blog to http://www.example.com/blog) using .htaccess file. This causes confusion on the webserver, because when we try to access http://www.example.com/blog, it doesn't know which URL it is suppose to display. It could be the URL that Drupal has rewritten, or it could also be the subdirectory that you have in your web root folder.

The same concept also apply with all the URL Aliases that you have created with your Drupal. Make sure you don't have a folder with the same name as your aliases, or else you will get a Page Not Found error.



Thursday, September 6, 2012

Wordpress - Exclude images from showing in the_content() - Resolved

<?php
   ob_start();
   the_content('Read the full post',true);
   $postOutput = preg_replace('/<img[^>]+./','', ob_get_contents());
   ob_end_clean();
   echo $postOutput;
?>

Ref. Link: http://wordpress.org/support/topic/exclude-images-from-showing-in-the_content

Wednesday, September 5, 2012

XML Sitemap generation with php and mysql


<?php
$host = "localhost"; // host name
$user = "user"; // database user name
$pass = "password"; // database password
$database = "dbname"; // database name
// connecting to database
$connect = @mysql_connect($host,$user,$pass)or die (@mysql_error());
// selecting database
@mysql_select_db($database,$connect) or die (@mysql_error());

// default header(don't delete)
header("Content-Type: text/xml;charset=iso-8859-1");
echo '<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';

// mytable = your content table name
$query = @mysql_query("SELECT * FROM mytable");
while($row = @mysql_fetch_array($query)){
// [url] = content url
$url = $row['url'];
// [time] = content date
$date = date("Y-m-d", $row['time']);

// NO CHANGES BELOW
echo
    '<url>
     <loc>' . $url .'</loc>
     <lastmod>'. $date .'</lastmod>
     <changefreq>daily</changefreq>
     <priority>0.8</priority>
     </url>
    ';
}
echo '</urlset>';?>



.htaccess code ( Optional )


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule (.*)\.xml(.*) $1.php$2 [nocase]
</IfModule>



Tuesday, August 21, 2012

Reset Mysql Root Password in Xampp -- Resolved


  • Go to your xampp\mysql\bin\ folder
  • Edit my.ini and insert skip-grant-tables below [mysqld]
  • Restart MySQL
  • Set new password for your root user by running UPDATE mysql.user SET Password=PASSWORD('new_password') WHERE User='root' in phpMyAdmin in the mysql database (or just leave it like this if MySQL cannot be accessed from remote hosts)

Tuesday, July 17, 2012

XAMPP Apache server not working on internal network


The problem was that the Windows Firewall had port 80 blocked. To fix this, I opened Windows Firewall, clicked Change Settings, went to the Exceptions tab, and then "Add Port". I set Name to "Web Server (TCP 80)", Port Number to 80, and Protocol to TCP and that was it.

Thursday, June 28, 2012

Theming the contact form in Drupal 6


3 Different Ways

1)So I copy page.tpl.php to page-contact.tpl.php and did changes

2)A different method would be to theme the contact form not the whole page.

function YOURTHEMENAME_theme() {
  return array(
    
'contact_mail_page' => array(
      
'arguments' => array('form' => $form),
    ),         
  );
}function
YOURTHEMENAME_contact_mail_page($form) {
  
$output = drupal_render($form);
  
$output .= '
'. t('Text to add to bottom of form') .'
'
;
  return 
$output;
}

?>