Roshan Book

My Tech Notebook

Monthly Archives: January 2012

PHP Mysql notes

MYSQL

Index from : http://www.developphp.com/list_mysql.php

Connect to database script

$sqlCommand = “SELECT pagebody FROM pages WHERE id=’$pageid’ LIMIT 1”;
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error());
while ($row = mysqli_fetch_array($query)) {
$body = $row[“pagebody”];
}
mysqli_free_result($query);

 

Query the database 

 

PHP Crud

PHP CMS

PHP user authtication system

[SOLVED] “Could not reliably determine the server’s fully qualified domain name, using … for ServerName” « RussenReaktor’s Weblog

Missing Top and Side Panels in Unity: Troubleshooting, Ubuntu Natty / Oneiric – TuxGarage: Tutorials, News, Troubleshooting

Download Youtube playlist videos on ubuntu

Source:http://www.ubuntubuzz.com/2011/10/how-to-download-all-videos-of-youtube.html

Imagine you have a playlist on YouTube that contains hundreds of videos in it and you want to download them, what will you do? Do you really want to download them one by one? I think that’s not a good idea. So, in this my first post, I’d like to show you how download all videos of YouTube playlist by simply type a few commands.

Applications used:
In order to getting this trick done, we have to install two applications called umph and youtube-dl. Umph is such an application that can parse YouTube feeds, it can parse playlists, favourite lists, and user upload lists. Youtube-dl is well-known command line tool for downloading YouTube videos by giving their video links.

Installing applications:
Fortunately, I’ve created a PPA contains those two applications. Simply type the following command to install them:

  • sudo add-apt-repository ppa:tldm217/tahutek.net
  • sudo apt-get update
  • sudo apt-get install umph youtube-dl

Usage instructions:

  • umph playlist_ID | youtube-dl -l -a –

You can get playlist_ID from playlist URL, for example, we will download all videos in PHPAcademy 200 JQuery Tutorials, see the picture below for more details.

Take a look at part marked with red box, you will get the weird phrase “PL46408891B63317A4”. By removing the “PL” characters, now you have the playlist ID: 46408891B63317A4. You’re ready to go:

  • umph 46408891B63317A4 | youtube-dl -l -a –

By default, umph will parse 25 videos. So, by executing the above command you will download the first video until 25th video. If you want to download all videos (200 videos) you must add an argumen “-m 200”.

  • umph -m 200 46408891B63317A4 | youtube-dl -l -a –

The tricky part is in umph command line arguments, please take look at this documentation for further information.

Increase activeCollab upload limit using htaccess

for activecollab

Source:http://www.tildemark.com/increase-activecollab-upload-limit-using-htaccess/

 

From hostgator

http://forums.hostgator.com/php-file-upload-limit-t13618.html

General
http://api.tweetmeme.com/button.js?url=http%3A//www.alvinpoh.com/edit-htaccess-to-increase-phps-max-file-upload/&&source=vinpoh&style=normal&service=bit.ly&b=2&o=http%3A//www.google.co.in/url%3Fsa%3Dt%26rct%3Dj%26q%3Dincrease%2520upload%2520size%2520limit%2520through%2520.htaccess%2520file%26source%3Dweb%26cd%3D10%26ved%3D0CHAQFjAJ%26url%3Dhttp%253A%252F%252Fwww.alvinpoh.com%252Fedit-htaccess-to-increase-phps-max-file-upload%252F%26ei%3DSw0YT_f0NtCrrAfJ88XVDQ%26usg%3DAFQjCNHj8gRDEuLEdLV_EYqjvX99w5uygg

To increase the upload file size limit on your website, you need to edit PHP’s configuration settings. Unfortunately, not everyone has their own web server, so most of the time people are constrained by the limits of shared hosting. But you can still modify your base php.ini file by creating your own php.ini with the edits that you want.

Your php.ini file needs to be in every folder that’s going to be affected, or at least in the folder where the php script is being called from. Unfortunately if you have dozens of folders that need this edit, then you’ll need dozens of php.ini files.

An alternative is to then use .htaccess. By just placing a.htaccess file in your root folder, all folders beneath it will also have the change. The code to change your PHP max file upload size is:

RewriteEngine On
php_value post_max_size 1000M
php_value upload_max_filesize 1000M
php_value max_execution_time 6000000

You can edit it to suit your needs. 1000M = 1GB, so edit accordingly. Do note that your host will need to allow PHP edits though.

Source: http://www.alvinpoh.com/edit-htaccess-to-increase-phps-max-file-upload/

Source: http://www.maheshchari.com/increase-php-file-upload-limit/

 

 

How To Convert an XHTML Website Template into a WordPress Theme

Source: http://www.jonbishop.com/2010/03/convert-html-wordpress/

So you have an XHTML valid website template and you would like to put it on top of WordPress. Whether you are starting from scratch or moving your existing website to WordPress as a CMS, this guide will help you get the conversion done.

Keep in mind that these are the basics and this is not a guide on how to develop themes for public release.

What You Will Need

Getting Started

First, let’s set up our theme files.

Prepare your files

For this tutorial we are going to use the minimum number of theme files needed to create a functional WordPress theme. Your existing template files should include the following:

  • An HTML Template File
  • A CSS Stylesheet
  • An images folder

You should rename your HTML Template File to ‘index.php’ and your CSS Stylesheet to ‘style.css’. This is important and is how WordPress knows which files are which.

This is an example of what your theme folder should look likeThis is an example of what your theme folder should look like

Add WordPress Theme Info (video)

This is where your WordPress Theme gets your theme name, description, author link, etc. All you need to do is create a commented out area at the top of your stylesheet as follows:

/*
Theme Name: Rose
Theme URI: the-theme’s-homepage
Description: a-brief-description
Author: your-name
Author URI: your-URI
Template: use-this-to-define-a-parent-theme–optional
Version: a-number–optional
.
General comments/License Statement if any.
.
*/
CSS Goes here…

Adding Template Tags To Your Theme

Template Tags are bits of code that WordPress uses to populate your website with content. Different tags display different bits of information from the WordPress database. These are the main tags needed to make your WordPress theme work.

Page Title – (video)

Change whatever is within your <title></title> tags to:

<?PHP wp_title(”); ?>

Stylesheet – (video)

We are going to need to swap out the call to our stylesheet with:

<link rel=”stylesheet” href=”<?PHP bloginfo(‘stylesheet_url’); ?>” type=”text/css” media=”screen” />

Plugin Hooks – (video)

Next you will need to add Action Hook Template Tags so WordPress plugins can access your theme. All you need to do is add:

<?PHP wp_head(); ?>

to your header (Usually write above the closing </head> tag).

Then you should add:

<?PHP wp_footer(); ?>

to your footer (Usually write above your </body> tag).

Media and Script Paths – (video)

By default, your paths will most likely reference your site root. You will need to point all of your multimedia, scripts and stylesheets to your new theme folder within the WordPress file structure using:

<?PHP bloginfo(‘template_directory’); ?>

The easiest way to do this is to do a search and replace for ‘src=’ and add the appropriate template tags. This is not fool proof as not all template structures are created equal but it will work a majority of the time.

Search and Replace to change paths to WordPress theme pathsSearch and Replace to change paths to WordPress theme paths

Adding The WordPress Loop

The WordPress loop is what handles all of your websites content. Its main components are:

  • A header
  • A permalink
  • Some Content

First you will need to identify where your content starts/repeats (if it repeats). The easiest way to do this is to look for your content’s header and begin The Loop there. The Loop will usually end immediately after your content unless you are displaying extra information below your entries. You will also need to identify where your content begins and ends. Scroll to the end of this section to view some example code.

The Loop Code – (video)

Beginning:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

End:

<?php endwhile; endif; ?>

Template Tags Within The Loop – (video)

The Title:

<?php the_title(); ?>

The Permalink

<?php the_permalink() ?>

The Content

<?php the_content(‘<p>Read more</p>’); ?>

Example Code

So this becomes this.

Navigation – (video)

Most themes will have the navigation within an unordered list. This makes things easy for you. All you need to do is replace the list elements (everything between the <ul></ul> tags) with the following:

<?PHP wp_list_pages(‘title_li=&depth=1&sort_column=menu_order&exclude=’); ?>

This is the most basic of menus and wont display child pages. You can exclude pages by simply adding the page ids separated by comas after “exclude=”. Learn more about wp_list_pages().

Upload and Activate Your Theme

Now all you have to do is upload your theme folder which should now consist of:

  • An index.php file with custom code
  • A CSS file with header information about the theme
  • An images folder with all of your images

If all goes accordingly you should have a functional WordPress theme that allows you to add new pages and posts as well as use most popular WordPress plugins. It is important to note that you will not be able to add widgets to your sidebar and people will not be able to comment on posts. There may also be some other limitations due to the themes simplicity.

2011 in review

The WordPress.com stats helper monkeys prepared a 2011 annual report for this blog.

Here’s an excerpt:

A San Francisco cable car holds 60 people. This blog was viewed about 3,300 times in 2011. If it were a cable car, it would take about 55 trips to carry that many people.

Click here to see the complete report.

%d bloggers like this: