Skip to content

Instantly share code, notes, and snippets.

View palpalani's full-sized avatar

Palaniappan P palpalani

View GitHub Profile
@palpalani
palpalani / wp-admin.sql
Last active December 22, 2015 18:09
Creating WordPress admin account using PhpMyAdmin
/*
Creating admin user account for WordPress using PhpMyAdmin.
Please make the following changes and then run this SQL.
*** Change the Database name 'yourdbname'.
*** Change table names 'wp_users' and 'wp_usermeta' and also change 'wp_capabilities' and 'wp_user_level' according to table prefix.
*** Change username 'palpalani' and password 'password'
*** Change ID to whatever you need
*/
@palpalani
palpalani / monitrc.sh
Last active December 22, 2015 21:49
Monitor centminmod (http://centminmod.com) powered VPS or dedicated server using Moint (http://mmonit.com/monit).
//Monitor CentMinMod (https://community.centminmod.com/) server using Monit
//Mmonit 5.14 - http://mmonit.com/monit/
//How to: http://mmonit.com/wiki/Monit/HowTo
//Real-world configuration examples - http://mmonit.com/wiki/Monit/ConfigurationExamples
//Pushover notifications - http://mmonit.com/wiki/MMonit/Notification
//About Monit
Monit is a helpful program that automatically monitors and manages server programs to ensure that they not only stay online consistently, but that the file size, checksum, or permissions are always correct. Additionally monit comes with a basic web interface through which all of the processes can be set up. This tutorial will cover the most basic setup and configuration.
//Install Monit on CentOS 6.x
@palpalani
palpalani / wordpress-sandbox.sh
Last active December 22, 2015 22:09
WordPress sandbox install
#!/bin/sh
# WordPress Sandbox
# palPalani
# m3webware.com
# requires wp-cli
# usage: wordpress-sandbox
# or: ./wordpress-sandbox.sh
# Download WordPress
@palpalani
palpalani / mysql-backup.sh
Last active December 23, 2015 04:09
Shell Script To Backup MySql Database Server
#!/bin/bash
# Shell script to backup MySql database
# To backup MySql databases file to /backup directory and later pick up by your
# script. You can skip few databases from backup too.
# For more info please see (Installation info):
# http://www.cyberciti.biz/nixcraft/vivek/blogger/2005/01/mysql-backup-script.html
# Last updated: Nov - 2013
# --------------------------------------------------------------------
# This is a free shell script under GNU GPL version 2.0 or above
# Copyright (C) 2004, 2005 nixCraft project
@palpalani
palpalani / files-backup.sh
Last active July 6, 2024 08:34
Linux / UNIX Tar Full and Incremental Tape Backup Shell Script#!/bin/bash
# A UNIX / Linux shell script to backup dirs to tape device like /dev/st0 (linux)
# This script make both full and incremental backups.
# You need at two sets of five tapes. Label each tape as Mon, Tue, Wed, Thu and Fri.
# You can run script at midnight or early morning each day using cronjons.
# The operator or sys admin can replace the tape every day after the script has done.
# Script must run as root or configure permission via sudo.
# -------------------------------------------------------------------------
# Copyright (c) 1999 Vivek Gite <[email protected]>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
@palpalani
palpalani / functions.php
Created October 25, 2013 12:26
Limit number of posts an user can create in WordPress admin panel
<?php
/*
* If you, by any chance, want to limit the number of posts an user can create in your multi author WordPress blog, there is a nice way to do it. Add the following code in your theme’s functions.php file
*/
add_action("load-post-new.php","limit_user_by_post_count");
function limit_user_by_post_count(){
$user = get_current_user_id();
if (!current_user_can( 'manage_options')) {
//not an admin - so impose the limit
@palpalani
palpalani / functions.php
Last active December 26, 2015 13:19
Log in a WordPress user programmatically
<?php
/*
* Here is the function, drop it in your functions.php file
*/
function auto_login( $user ) {
$username = $user;
if ( !is_user_logged_in() ) {
$user = get_userdatabylogin( $username );
global $db;
$upload_dir = get_misc_data('upload_directory');
$thumb_dir = get_misc_data('upload_thdirectory');
$link_id = $this->_vars['link_id'];
$sql = sprintf("SELECT file_name FROM " . table_prefix . "files WHERE file_link_id='%d' AND file_size='240x650' AND file_comment_id=0", $link_id);
if ($thumbnail = $db->get_var($sql)) {
echo "<img src='". my_pligg_base . $thumb_dir ."/$thumbnail'> ";
}
@palpalani
palpalani / wordpress-plugins.html
Last active August 29, 2015 14:00
A recommended list of must have Wordpress plugins
<ul>
<li><a href="http://www.acunetix.com/websitesecurity/wordpress-security-plugin/" target="_blank">Acunetix Wordpress Security Plugin</a>. Check <a href="http://wordpress.org/support/plugin/wp-security-scan" target="_blank">support forum</a> for any issues.</li>
<li><a href="http://wordpress.org/plugins/sucuri-scanner/" target="_blank">Sucuri Security Malware Scanner</a>. Check <a href="http://wordpress.org/support/plugin/sucuri-scanner" target="_blank">support forum</a> for any issues.</li>
<li><a href="http://wordpress.org/plugins/akismet/" target="_blank">Akismet</a>. Check <a href="http://wordpress.org/support/plugin/akismet" target="_blank">support forum</a> for any issues.</li>
<li><a href="http://www.seoegghead.com/software/wordpress-firewall.seo" target="_blank">Wordpress Firewall</a></li>
<li><a href="http://wordpress.org/plugins/crayon-syntax-highlighter/" target="_blank">Crayon Syntax Highlighter</a>. Check <a href="http://wordpress.org/support/plugin/crayon-syntax-highlighter" target=
@palpalani
palpalani / functions.php
Created June 28, 2014 07:24
WordPress - Cloaking Email Addresses in Your Content
Have you ever needed to share an email address in your WordPress blog or website?
You most likely have, and if you ever cared about not getting caught by spam robots which crawl the web for email addresses, telephone numbers and things like that, you've searched for a solution to hide the email addresses from those tiny evil robots.
I know I have, and little did I know, there was already a core WordPress function for it: antispambot().
Usage
The usage of the function is pretty simple: