Wordpres and git – config tweaks

October 19th, 2012
It’s annoying to play around with different wp-config.php Configurations when using Git to deploy. But you can use a simple Switch to get the right setting on the current domain.
switch ( $_SERVER["HTTP_HOST"] )
{
    case "caj.local" :
      /** Local Config **/
      define("DB_NAME", "<local databasename>");
      define("DB_USER", "<local username>");
      define("DB_PASSWORD", "<pass>");
      define("DB_HOST", "localhost");
      break;
    case "caj.donkeymedia.eu" :
      /** Testing Server Config **/
      define("DB_NAME", "<testing databasename>");
      define("DB_USER", "<testing username>");
      define("DB_PASSWORD", "<testing pass>");
      define("DB_HOST", "localhost");
      break;
    case "caj-koeln.de" :
      /** Life Config  .... **/
      break;
    default:
        die("We have a Error :( "); 
        
        break;
}

/** MySQL General **/
define("DB_CHARSET", "utf8");
define("DB_COLLATE", "");

/** force wordpress to use direct file access and set the propper Permissions **/
define("FS_METHOD", "direct");
define( "FS_CHMOD_DIR", 0775 );
define( "FS_CHMOD_FILE", 0664 );

A small Shell Script to start dropbear at my android

August 5th, 2012
You can execute it on a rooted phone using the Smanager App
#!/system/bin/sh
DROPBEAR=`which dropbear`;
#echo $DROPBEAR

case $1 in
  start|Start) 
  	echo "starting dropbear ..."
  	cd /data/dropbear
  	su -c "$DROPBEAR -v -s -g"
   	;;
  stop|Stop)
  	 echo "stopping dropbear ..."
  	 killall dropbear ;;
  *) echo "usage: dropbear.sh [start|stop]" ;;
esac
http://tn.genano.de/wordpress/2009/09/18/howtotutorial-dropbear-ssh-fur-android-cyanogenmod-konfigurieren/

WordPress plugin Cachify cache clear

May 1st, 2012
This little WordPress plug-in will allow any logged in user to clear the cachify cache manually. Will only work if the cachify cache mode is set to “cache ondisk”.

/*
Plugin Name: Clear Cachify cache
Description: Enables Clear cache buttons for all users
Version: The Plugin"s Version Number, e.g.: 1.0
Author: Thorsten Krug
License: GPL
*/

// prepare cachlink
$currenturl = substr($_SERVER["REQUEST_URI"], 0, strpos($_SERVER["REQUEST_URI"], "?"))."?";
$getvars = $_GET; 
if(! in_array("clearifycache", $getvars)){
  $getvars["clearifycache"]="clearifycache";
}
foreach ($getvars as $key =>$val){
  $currenturl .=$key."=".$val."&";
}
$GLOBALS["cache-clear-uri"] = substr($currenturl,0,-1);

// action
function clearcachify_go(){
  if(isset($_GET["clearifycache"]) and is_user_logged_in() ){

  if (CACHIFY_CACHE_DIR){
    if( 0 == shell_exec ( "rm -rf ".CACHIFY_CACHE_DIR."/*"  ) ){
        add_action("admin_notices", "clearcachify_cleared");
      }
    }
  }
}

function clearcachify_cleared(){
    echo "<div class="updated settings-error"><p>Cache cleared</p></div>";
}

function newMenu() { 
?>
<li class="wp-has-submenu wp-not-current-submenu menu-top toplevel_page_wibstats menu-top-last">
  <div class="wp-menu-image">
    <a href="<?php print $GLOBALS["cache-clear-uri"]; ?>" class="menu-top  menu-top-first menu-top-last" style="line-height: 26px;">
    <img alt="" src="/wp-admin/images/generic.png" style="margin-right: 5px;"> Clear Cache
    </a>
  </div>
  <br />
</li>
<?php }


//this inputs our custom menu
add_filter("adminmenu", "newMenu");
add_action( "admin_init", "clearcachify_go" );


Unban IP blocked by fail2ban

July 26th, 2011
Login to the Server as root Use to and search for the banned ip.
iptables -L -n
You’ll get something like
Chain fail2ban-pam-generic (1 references)
target     prot opt source               destination
RETURN     all  --  0.0.0.0/0            0.0.0.0/0           

Chain fail2ban-ssh (1 references)
target     prot opt source               destination
DROP       all  --  193.xxx.2.142        0.0.0.0/0
DROP       all  --  202.120.xxx.87       0.0.0.0/0
DROP       all  --  88.xxx.223.148       0.0.0.0/0
RETURN     all  --  0.0.0.0/0            0.0.0.0/0
Check which of the rules (e.g. fail2ban-pam-generic or fail2ban-ssh) the banned ip is targeted. Now you can remove the ip from iptables:
iptables -D fail2ban-pam-generic -s  -j DROP

Disable Update for WordPress Plugin

April 18th, 2011
In order to prevent a User from updating a hacked WordPress Plugin, you should implement to following
add_filter('site_transient_update_plugins', 'ap_remove_update_nag'); 
function ap_remove_update_nag($value) {  unset($value->response[ plugin_basename(__FILE__) ]);
return $value;
}
Thanks to hacksandmore.com

Clear OS-X font cache

January 6th, 2011
I did it again. Messed up something after installing font. So after removing duplicate fonts I need to clear the font cache. Its simple:
  • Close all running applications.
  • Type: sudo atsutil databases -remove into Terminal as Admin
  • Restart immediatly
This removes all font cache files. (system and all user font cache files)

How to remove the depreceated target=”_blank” in WordPress TinyMCE?

August 29th, 2010
If you let your users set their Links in WordPress with TinyMCE editor, you might run into some validation Problem, because target=”_blank” is part of the XHTML-Strict Standard. To remove the Options in TinyMCE you need to edit two Files: in wp-includes/js/tinymce/themes/advanced/link.htm remove the Table Row offering the Link Target:
<tr>
<td><label id="targetlistlabel" for="targetlist">{#advanced_dlg.link_target}</label></td>
<td><select id="target_list" name="target_list"></select></td>
</tr>
in wp-includes/js/tinymce/themes/advanced/js/link.js comment out the the call to fillTargetList() in the init-function. If you still want to open external Links in new Windows (or Tabs) you can use this Little Javascript. Links to different Domains will be opened in a new Window.
/** Creating custom :external selector **/
  $.expr[':'].external = function(obj){
      return !obj.href.match(/^mailto\:/)
              && (obj.hostname != location.hostname);
  };
  // Add 'external' CSS class to all external links
  $('a:external').bind( 'click', function(){
      open(this.href);
      return false;
  });

WORDPRESS: Add CSS to Tinymce Editor

August 28th, 2010
There is an easy way to add custom styles to the Editor Panel in WordPress.
  • Create a custom CSS file in your Theme Folder
  • Add the following function to the functions.php file of your theme

if ( ! function_exists('tdav_css') ) {
	function tdav_css() {
		 .= ',' . get_bloginfo('stylesheet_directory') . '/css/tinymce.css';
		return ;
	}
}
add_filter( 'mce_css', 'tdav_css' );

I my Template I use a right Floatbox which can be Edited as a section:
div.tinymceSection + * {
  padding-top: 2em;
  border-top: 3px dashed #cc0000;
  clear: both; /* avoid Images floating into the next section in tinymce textarea */
}

Worpress Plug-in: Multilingual Contact Form

August 26th, 2010
With WordPress and the qtranslate plug-in it is easy to create multilingual websites for small business. My favorite contact form plug-in was discontinued I needed some replacement, which is usable on a multilingual site.

Features:

  • Simple and basic easy to use on any Page or Post
  • Enter and edit all text for fields and error messages in the Backend
  • Compatible with qtranslate and other multi-language Plugins
  • XHTML/HTM5 standard compliant

Read the rest of this entry »

Make All in One SEO and qtranslate work together

April 30th, 2010

In the main Plugin file all_in_one_seo_pack.php on lines #709 and #711, the $title_attrib and $menulabel variables are not created as Multilingual Variables. In order to make them so you need to add __() around the variables:

#709 :

$filtered = '<li class="page_item page-item-'.$postID.$matches[2].'"><a href="'.$matches[3].'" title="'.__($title_attrib).'">'.__($menulabel).'</a>';

#679 :

$filtered = '<li class="page_item page-item-'.$postID.$matches[2].'"><a href="'.$matches[3].'">'.__($menulabel).'</a>';

Thanks t Karlsan at this Forum

Easy Jquery Syntax Highlighter

April 25th, 2010
Searching for a proper syntax-highlighter for my WordPress Blog is not an easy thing. Many of them support only a few browsers, mass around with XHTML standards or make extensive use of libraries like prototype I don’t want to add to my site. Finally I found a jquery based syntax highlighter which requires only one file in the latest version. It is really easy to integrate into a WordPress template and doing it the smart way it is only loaded if you need it. After installing it to your website you just need to add the following to you jQuery document.ready function:
$(function ($) {
    var SyntaxRoot = template_directory+"/jquery-syntax/";
    if ($('.syntax').length) {
        $.getScript(SyntaxRoot + "jquery.syntax.min.js", function () {
            $.syntax({root: SyntaxRoot});
        });
    }
});
In order to use different jQuery Plugins I added my Template directory as a variable for javascript into the WordPress header:
<script type="text/javascript" charset="utf-8"><!--
var template_directory = "<?php echo get_bloginfo('template_directory'); ?>";
--></script>
In WordPress I use a php Plugin which enables to write php in every Post. With the following function in my Wordoress Theme template.php I can copy and paste my code right into a post by using <?php codeIt('myWhateverCodeSnipplet( echo \'Mind the quotes\' )', 'javascript'); ?>
/* Highlight code */
function codeIt($text, $brush="html"){
  echo '<pre class="syntax brush-'.$brush.'">'."\n".htmlentities($text)."\n".'</pre>'."\n";
}
I set the default brush to html (which recognizes basic <css…> and <script…> tags and optionally overwrite it with the used language. The only drawback i need to quote all single with a Slash to \’

Same template for Category and Subcategory

April 20th, 2010
Using the same template file for a category and its children is not possible with WordPress. In order to do you need to use Elevate Parent Category Template-Plugin. If you using the Plugin you’ll be able to use some adittional template functions:
  • get_category_child()
    returns the current post child category ID.
  • is_parent()
    checks if the current post is at the parent category.
  • get_category_title($id)
    gets the title of the category that is $id.
  • get_category_parent()
    returns the current post’s parent category ID.

jquery jcarousel circular with cache

April 19th, 2010
The jcarousel is a nice jQuery plugin which allows you to easily create javascript based slideshows. Even if not fully implemented it has a option to run in a circular mode, by dynamically creating the slide objects from a javascript array. Sorgala made an good commented example, just check the source. The problem with this approach is that each object is inserted and removed into the dom on every slide move. Using it for larger images results in a new request each time the slideshow comes to the same element. Another feature is the ability to preload the jcarousel images: I want them to be in cache already when it’s time to show up.

Read the rest of this entry »

Migrating Drupal

March 27th, 2010
Locally I use MAMP on my Macbook to develop Themes for Drupal. There’s a nice module called backup & migrate which you can use to get the relevant tables from your Drupal installation. Using admin/content/backup_migrate you can get and restore the Database quickly after after installing the module. If there was some larger Work on files like a drupal core update was done on my on-line Testing Server I get a new copy of the whole htdocs-directory into a blank new working-directory (e.g. /georgia/4-2009) into the project folder within MAMP htdocs on the macbook. If you safe the Database on the remote machine before downloading the files by ftp, the actual backup gets included. You can restore the database manually by locating the SQL file at /georgia/4-2009/htdocs/sites/yoursite/files/backup_migrate/manual/ and use PHPmydmin to restore. The local domain name georgia.local has its own settings file. Database settings are stored in a site folder for the local domain /georgia/4-2009/htdocs/sites/georgia.local. You create an new Database with PHPmyAdmin according to your Version Folders Name and edit the Connection settings in the database accordingly. If something appears strange be sure to empty drupal cache at admin/settings/performance and the testing servers have each their own settings file??? With MAMP-Pro I set up a working Domain (e.g. georgia.local) so I just need to change the disc location of the htdocs-directroy within my MAMP-Pro to the latest version.

Colormanagement in the internet

January 14th, 2010

My Thesis about colormanagement in the internet

Thesis and Lecture

Colormanagement according to the ICC-Standard has become common for pre-press within the past years. This document is an investigation on previous approaches for Colormanagement within world wide web and analyses recommendations for Colormanagement of the W3C in the field of cross-media publishing using XML-based documents.

Read the rest of this entry »