Posted on 30 December 2008.
Truncate is a handy function which can truncate a long text into specific length string and adds elipsis (…) after it.
This is an example of how the function “truncate($text,47)” works :
function truncate ($str, $length=10, $trailing=’…’)
{
/*
** $str -String to truncate
** $length – length to truncate
** $trailing – the trailing character, default: “…”
*/
// take off chars for the trailing
$length-=mb_strlen($trailing);
if (mb_strlen($str)> $length)
{
// string exceeded length, truncate and add trailing dots
return mb_substr($str,0,$length).$trailing;
}
else
{
// string was already short enough, return the string
$res = $str;
}
return $res;
}
Posted in PHP
Posted on 29 December 2008.
< ?php
$fruits = array('apple', 'banana', 'cranberry');
echo end($fruits); // cranberry
echo current($fruits); // apple
?>
Posted in Programming
Posted on 23 December 2008.
How I know this function when I use insert Record transaction (advanced) and the redirect page has recordset that use $_POST['name for mysql_insert_id() '] for select record from db?
$ins_sivut->registerTrigger(“END”, “Trigger_Default_Redirect”, 99, “sisallot_edit.php?Id={the_field_from_the_transaction_selected_as_primary_key}”);
Posted in PHP
Posted on 18 December 2008. Tags: as2, as3, development, Flash, programming
Full FlashMX 2004 rule set:
The following will validate that the page complies fully with the flashMX 2004 specification.
valid_elements : “”
+”a[href|target],”
+”b,”
+”br,”
+”font[color|face|size],”
+”img[src|id|width|height|align|hspace|vspace],”
+”i,”
+”li,”
+”p[align|class],”
+”h1,”
+”h2,”
+”h3,”
+”h4,”
+”h5,”
+”h6,”
+”span[class],”
+”textformat[blockindent|indent|leading|leftmargin|rightmargin|tabstops],”
+”u”
add custom buttons http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/theme_advanced_buttons_1_n
Posted in Flash, HTML - XHTML, JavaScript - Ajax, Programming
Posted on 15 December 2008. Tags: as2, as3, development, Flash, programming
onClipEvent (load)
{
//this.loadVariables(_global.VARGAL1+”tips.php”);
this.loadVariables(“all_pdf.php”);
}
onClipEvent (data)
{
xcount = 0;
yxount = 0;
trace(total);
for (var i = 1; i <= total; i++)
{
media0.duplicateMovieClip(“media” + i, i);
eval(“media” + i).pdfpath = eval(“pdfpath” + i);
eval(“media” + i).pdftitle = eval(“pdftitle” + i);
eval(“media” + i)._x = media0._x + xcount * 22;
eval(“media” + i)._y = media0._y + yxount * 22;
xcount++;
if (xcount > 0)
{
xcount = 0;
yxount++;
}
}break;
_parent.media._visible = true;
}
Posted in Flash
Posted on 15 December 2008. Tags: as2, as3, development, Flash, programming
dynsef._visible=false;
stop();
//_global.lang=”gr”;
_level2.done=undefined;
loadVariablesNum(“sef.php?lang=”+_global.lang, 2);
//_parent._parent.pop_prod.food_photo.url=_level2.photo1;
//_parent._parent.pop_prod.food_unbaked.url=_level2.unbaked1;
//trace(_level2.code1);
function checkParamsLoaded() {
if (_level2.done == undefined) {
//trace(“not yet.”);
} else {
trace(_level2.done);
trace(_level2.pdfpath);
trace(_level2.pdftitle);
//trace(“finished loading. killing interval.”);
clearInterval(param_interval);
if(_level2.pdftitle!= “”){
dynsef._visible=true;
}
}
}
var param_interval:Number = setInterval(checkParamsLoaded, 10);
Posted in Flash
Posted on 13 December 2008.
Header
<script type=”text/javascript” src=”Scripts/fckeditor/fckeditor.js”></script>
Body
<script type=”text/javascript”>
window.onload = function()
{
var oFCKeditor = new FCKeditor( ‘n_message_<?php echo $cnt1; ?>’ ) ;
oFCKeditor.BasePath = “Scripts/fckeditor/” ;
oFCKeditor.Height = 600 ;
oFCKeditor.Width = 800 ;
oFCKeditor.ReplaceTextarea() ;
}
</script>
Config
\Scripts\editors\fckeditor\editor\filemanager\connectors\php
end edit the config.php
// Path to user files relative to the document root.
$Config['UserFilesPath'] = ‘http://ns2/***/images/’ ;
$Config['UserFilesAbsolutePath'] = ‘C:/xampp/htdocs/***/images/’ ;
Posted in HTML - XHTML, PHP, Programming
Posted on 12 December 2008. Tags: ajax, JavaScript - Ajax, jquery, mootools, prototype
Image protection is a hot topic on the net these days, and why shouldn’t it be? If you spent two hours designing an awesome graphic, would you want it ripped of in matter of seconds? Hell no! That’s why I’ve created an image protector class to help designers and artists protect their images. Here’s how it helps:
- Prevents right-click “Save Image As”.
- Prevents dragging an image to the desktop.
- Prevents right-click “Save Background As”.
- Prevents right-click “View Background Image”
All I needed was a small MooTools script.\
//protector class
var dwProtector = new Class({
//implements
Implements: [Options],
//options
options: {
image: ‘blank.gif’,
elements: $$(‘img’),
zIndex: 10
},
//initialization
initialize: function(options) {
//set options
this.setOptions(options);
//make it happen
this.protect();
},
//a method that does whatever you want
protect: function() {
//for each image that needs be protected…
this.options.elements.each(function(el) {
//get the element’s position, width, and height
var size = el.getCoordinates();
//create the protector
var p = new Element(‘img’, {
src: this.options.image,
width: size.width,
height: size.height,
styles: {
‘z-index’: this.options.zIndex,
‘left’: size.left + ‘px’,
‘top’: size.top + ‘px’,
‘position’: ‘absolute’
}
}).inject($(document.body),’top’);
},this);
}
});
http://davidwalsh.name/mootools-image-protector-dwprotector
Posted in JavaScript - Ajax
Posted on 11 December 2008.
You adjust XAMPP settings with plain-text configuration files. The following files exist:
- Apache basic configuration: .\xampp\apache\conf\httpd.conf
- Apache SSL: .\xampp\apache\conf\ssl.conf
- Apache Perl (only addon): .\xampp\apache\conf\perl.conf
- Apache Tomcat (only addon): .\xampp\apache\conf\java.conf
- Apache Python (only addon): .\xampp\apache\conf\python.conf
- PHP: .\xampp\apache\bin\php.ini
(with the apache actually running php version)
- MySQL: .\xampp\mysql\bin\my.cnf
- phpMyAdmin: .\xampp\phpMyAdmin\config.inc.php
- FileZilla FTP: .\xampp\FileZillaFTP\FileZilla Server.xml
- Mercury Mail basic configuration: .\xampp\MercuryMail\MERCURY.INI
- Sendmail: .\xampp\sendmail\sendmail.ini
Posted in PHP, Windows
Posted on 10 December 2008.
// See related links for more status codes
// Use this header instruction to fix 404 headers
// produced by url rewriting…
header(‘HTTP/1.1 200 OK’);
// Page was not found:
header(‘HTTP/1.1 404 Not Found’);
// Access forbidden:
header(‘HTTP/1.1 403 Forbidden’);
// The page moved permanently should be used for
// all redrictions, because search engines know
// what’s going on and can easily update their urls.
header(‘HTTP/1.1 301 Moved Permanently’);
// Server error
header(‘HTTP/1.1 500 Internal Server Error’);
// Redirect to a new location:
header(‘Location: http://www.example.org/’);
// Redriect with a delay:
header(‘Refresh: 10; url=http://www.example.org/’);
print ‘You will be redirected in 10 seconds’;
// you can also use the HTML syntax:
//
header(‘Content-Transfer-Encoding: binary’);
// load the file to send:
readfile(‘example.zip’);
// Disable caching of the current document:
header(‘Cache-Control: no-cache, no-store, max-age=0, must-revalidate’);
header(‘Expires: Mon, 26 Jul 1997 05:00:00 GMT’); // Date in the past
header(‘Pragma: no-cache’);
// set content type:
header(‘Content-Type: text/html; charset=iso-8859-1′);
header(‘Content-Type: text/html; charset=utf-8′);
header(‘Content-Type: text/plain’); // plain text file
header(‘Content-Type: image/jpeg’); // JPG picture
header(‘Content-Type: application/zip’); // ZIP file
header(‘Content-Type: application/pdf’); // PDF file
header(‘Content-Type: audio/mpeg’); // Audio MPEG (MP3,…) file
header(‘Content-Type: application/x-shockwave-flash’); // Flash animation
// show sign in box
header(‘HTTP/1.1 401 Unauthorized’);
header(‘WWW-Authenticate: Basic realm=”Top Secret”‘);
print ‘Text that will be displayed if the user hits cancel or ‘;
print ‘enters wrong login data’;
Posted in PHP, Programming