neat_trim($your_text, 100);

function neat_trim( $string, $n, $close = '…' ) {

$len = strlen( $string );

if ($len > $n) {
preg_match('/(.{' . $n . '}.*?)b/', $string, $matches);
return rtrim($matches[1]) . $close;
} else {
return $string;
}

}

look in your /system/application/errors/ and find the error_404.php and put this (edited to match your site of course)

<?php
header(“HTTP/1.1 404 Not Found”);
header(“location:http://www.tldomain.com/index.php?/controller/sitemap/404″);
?>

So when the 404 page loads the 404 still gets logged by apache etc… but once that happens it gets rushed of to (in this case) the site map. The 404 variable tells the controller method in this case the site map to display a this page cannot be found message.

Many applications store MD5-crypted passwords in the database. If you want to quickly create a new MD5-ed password, or you have forgotten your password, use the following query to get a new one:

SELECT MD5(”m0ntypy7hon”);

This query will return “4f249cbc2c10d41f866b64decd365e39″ which is the encrypted version of the string “ m0ntypy7hon”.

There are other function that crypt stings in MySQL using different algorithms, most notably PASSWORD() which is using MySQL”s own crypting algorithm.

SELECT PASSWORD( “m0ntypy7hon” ) ;

returns: “5216be9f6ead4434”

The XML

<data>

<button handle=”prim_butt1″ text=”Larry” x=”60″ y=”160″ ></button>

<button handle=”prim_butt2″ text=”Moe” x=”170″ y=”160″ ></button>

<button handle=”prim_butt3″ text=”Curly” x=”280″ y=”160″ ></button>

<button handle=”prim_butt4″ text=”Shemp” x=”390″ y=”160″ ></button>

</data>

Now The Actionscript:

package {

import flash.display.MovieClip;
import flash.events.*;
import flash.net.*;
import flash.text.*;

import mc_button_primary;

public class StarterClass extends MovieClip {

private var i:Number;
private var primButtonCount:Number;
private var xmlLoader:URLLoader;
private var dataXML:XML;
private var buttonPrimary:mc_button_primary;
private var urlArray = new Array();

public function StarterClass() {

trace(“StarterClass……….√ check”);

// create a loader for our xml file
xmlLoader = new URLLoader(new URLRequest(“nav_primary.xml”));
// oops couldn't get our xml file
xmlLoader.addEventListener(IOErrorEvent.IO_ERROR, noFile);
// got our file now go do something (myInitMethod) with it
xmlLoader.addEventListener(Event.COMPLETE, myInitMethod);

// THROW ERROR IF XML SHOOTS CRAPS
function noFile(evt:IOErrorEvent):void {
trace(“Error. Data file not found.”);
}

}

// and now to do something with our data
private function myInitMethod(evt:Event):void {

trace(“myInitMethod……….√ check”);

// make sure flash knows it xml
dataXML = XML(xmlLoader.data);

// number of buttons in our xml
primButtonCount = dataXML.button.length();

// loop thru each button and make the data useful
for (i=0; i< primButtonCount; i++) {

trace("foo > “+dataXML.button[i].@handle );

// this is an array that contains the button text and it looks like
// urlArray[”prim_butt1″] == “Larry”

// it's referenced it in the click event
urlArray[dataXML.button[i].@handle] = dataXML.button[i].@text;

// create a new button from the library object
buttonPrimary = new mc_button_primary();
// give it a name
buttonPrimary.name = dataXML.button[i].@handle.toString();
// put it on the stage
addChild( buttonPrimary );

// find our new named button and give it a handle
var bttn_handle = getChildByName( buttonPrimary.name );
// now use the handle to move it and add text
bttn_handle.x = dataXML.button[i].@x;
bttn_handle.y = dataXML.button[i].@y;
bttn_handle.button_Text.text = dataXML.button[i].@text;
// add a listener so you can do something when you click it
bttn_handle.addEventListener( MouseEvent.CLICK, myButton_CLICK );

}

}

// here is the click event
function myButton_CLICK(event:MouseEvent):void {

// the name comes fom the urlArray ceated above
trace( “The button clicked was > “+urlArray[ event.target.name ]);

}

}

}
StarterClass_xml_basic.zip

UPDATE yourtable SET targetfield = REPLACE(targetfield, “foo”,“bar”);

This statement will replace all occurrences of the string “foo” with the string “bar” in all records of the “ targetfield” column. Apart from the string “bar” the rest of the text contained in the field will be unchanged.

This is for debugging only. Ok, again…. this is for debugging only. If you use this REMOVE it once it goes live. At worst you forget to add the tag that clears the log file each time and it bloats horribly and your site gets progressively slower and slower, then your server will crash, you’ll get fired and end up homeless. But if you remove it when your done it’s pretty handy.

This goes in a helper file of your choosing and make sure you load it:

$this->load->helper('the_helper_where_you_put_this_code');

Then put this in the helper file you loaded

if ( ! function_exists('app_log')) {

function app_log($arg) {

// this is your log file, so I referenced it by viewing
// domain.com/applog.htm
$log = './applog.htm';

// to empty the file and start over the first call should begin with init_log
if( preg_match(“/^init_log/”, $arg) ) {

// writes the the file name and whatever the arg is at the start of the file
if (!write_file($log, ''.$arg, 'w') ) {

// or dies
die( 'Unable to write to log file');

}

} else {

// adds whatever the $arg is to the end of the file
if ( ! write_file($log, ''.$arg, 'a+')) {

// or dies
die( 'Unable to write to log file');

}

}

}

}

To use the helper:

app_log('init_log -> Whatever you want goes here');

I usually make the above call in the constructor, then after that in your methods whatever you want to track use:

app_log('blah blah blah');

Save a text file as “login.command” or whatever but thats what I’m calling mine.

Enter this:

#!/bin/sh
ssh yourusername@yourdomain.com

Then you’ll need to make the file executable
“cd” to wherever your file is then run

chmod +x login.command

You may also have to do a get info and then select “Terminal” under “Open With”. You should now be able to double click the file and then the terminal will open and login to your server. If you drag that file under your “Places” in the sidebar your now one click away.

 

 

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

// for this example I just want to count down 30 Seconds
var remainingSeconds:int = 30;

// this is the function that the setInterval function calls
function countDownSeconds() {

// not a second off of the current number of seconds
remainingSeconds--;

// if we have run out of seconds do this
if (remainingSeconds == 0) {

trace(“DONE”);
clearInterval(myInterval);

} else {

trace(“tic”);

}

}

// this is the line that calls the specified function
// in this case “countDownSeconds” and it calls it every
// 1000 milliseconds in this case.

var myInterval = setInterval(countDownSeconds, 1000);

 

Here is roughly how I did that:

http://www.jamesborder.local/URLRequest.php (your url should be wherever your data is)

<?php

// create an array to put your junk in… then put it there
$variablesArray = array();
$variablesArray['var1'] = “foo”;
$variablesArray['var2'] = “bar”;

// let php build a nice string for you
$variablesArrayString = http_build_query($variablesArray);

echo $variablesArrayString;
// var1=foo&var2=bar

?>

-=-=-=-=-=-=-=-=-=-

Here is roughly what is in the .fla

// build your request…. your url/file will go here
var request:URLRequest = new URLRequest(“http://www.jamesborder.local/URLRequest.php”);
request.method = URLRequestMethod.GET;

// create
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, onCompleteHandler);
loader.load(request);

function onCompleteHandler(event:Event) {

trace(“completeHandler(“+event+”)”);
var var1 = event.target.data.var1;
var var2 = event.target.data.var2;

trace ('variable one: ' + var1);
trace ('variable two: ' + var2);

}

© 2012 James Border Suffusion theme by Sayontan Sinha