Jan
29
2010
0

Class Cat_Cache revision 1

I found in my class for cache data an error that return incorrect value if the cache isn’t in the cache directory. This error return improperly a boolean true value instead of false.

I correct the error with a new version of the class.
Click HERE for see the code of this class

download
Size: 4.9 KB
Hits : 17

Written by Davide in: Library, php, scripts | Tags: , , ,
Oct
26
2009
4

mootools Edit In Place

Here is my Mootools class that I use for make edit in place text.

VIEW THE EXAMPLE FILE

Use this class is very simple:

First need to have mootools 1.2 javascript library
Second download MooEip class

download
Size: 43.19 KB
Hits : 92

(more…)

Written by Davide in: Library, javascript, mootools, php | Tags: , , ,
Jul
10
2009
0

Secure image capcha revisited

I found a nice script http://www.phpcaptcha.org/ for made form capcha named secureimage and add some code for have random background and font for the capcha image

Here are the class modification that I made on the class:

- Porting the class for use in php5
- Remove the define for images: SI_IMAGE_JPEG, SI_IMAGE_PNG, SI_IMAGE_GIF
- Add define for ttf font path SI_PATH_TTF_FONTS
- Add define for gd font path SI_PATH_GD_FONTS
- Add define for random background imagess path SI_PATH_BACKGROUND
- Add define for audio path SI_PATH_AUDIO
- Add define for wordlist path SI_PATH_WORDS
- Set static var for $charset
- Add var $automatic_random for enable / disable random font and background image
- Add var $lang_wordlist for have wordlist for any language
- Delete var $wordlist_file: the file now is on SI_PATH_WORDS.’wordlist-’.$lang_wordlist.’.txt’
- Add var $use_random_bg_image for set random extraction for the background image
- Modify var $gd_font_file: now can set only filename
- Modify var $gd_font_file: now can set only filename
- Modify var $audio_path: now can set only filename
- Add options array to the constructor function: $img = new Securimage(array(‘automatic_random’=>false,’lang_wordlist’=>’it’));
- Add generic function for set var in the class: (void)setOption($name, $value);
- Add generic function for set var in the class: (void)setBgImage(‘/path-to-my-bg-image/image-name.jpg’);
- Modify function show() and added the code for have random background and font in the class
- Added function getRandom() for charge random files

download
Size: 846.85 KB
Hits : 30

Written by Davide in: Library, php, scripts | Tags: , , ,
Jun
30
2009
0

PHP pdf invoice

I need for my cms a class that can print invoice payment in pdf format.

Wel I find a nice script for oscommerce ( http://www.oscommerce.com/community/contributions,5321/category,12/search,pdf_customer_invoice ) that have a nice view of  the pdf invoice; Than I port this script and make a class for use in all indipendent cms …

Here can download the example output of the invoice class:

Ininvoice pdf

download
Size: 81.96 KB
Hits : 70

(more…)

Written by Davide in: Library, php | Tags: , , , ,
Apr
15
2009
0

Open inviter front and translation revision 1

I make some modification in the class and add one forgot translation and correct the dobble error message bug in the class; I’ve change the css for better present the email  subject.

Here is the file that You can download the OpenInviter front class with this features in:

download
Size: 46.36 KB
Hits : 182

Written by Davide in: Library, php | Tags: , , ,
Apr
01
2009
0

Open inviter front and translation

I make a modification to openinviter class ( http://openinviter.com ) for my use because the class don’t have a public class defined and forget the translation … So I made it :)

The actual languages disponibles are:

  • Italian
  • English
  • Spanish
  • French
Written by Davide in: Library, php | Tags: , , ,
Feb
16
2009
0

Cat_Cache

Cat Cache

My class for caching datas.

Click HERE for see the code of this class

This is a simple cache system written for php5 used for caching any type of data in files. It use all static method for render quickly the cache.

This class is able to manage data to be stored in cache files in a way that it may be safely stored and retrieved even when there may be many concurrent processes attempting to access the same data.

This is an example of the class uses:

< ?php
// Include the cache library
include('cat-cache.inc.php');

// Take te cache if exist
$options = array(
'cache_path' =>'/my-cache-path/',
'cache_lifetime' =>7200,
'cache_group' =>'news',
'cache_prefix' =>'_my_prefix'
);
if (!$content = Cat_Cache_Datas::get('unique id', $options)) {

$content = 'Bla bla bla';

Cat_Cache_Datas::save('unique id', $content, $options);
}
echo $content;

// Delete all group cache if is expired or not
$options = array(
'cache_path' =>'/my-cache-path/'
);
Cat_Cache_Datas::clean('my_group', false, $options);

// Delete all expired cache
$options = array(
'cache_path' =>'/my-cache-path/'
);
Cat_Cache_Datas::clean(false, false, $options);

// Delete all cache if is expired or not
$options = array(
'cache_path' =>'/my-cache-path/'
);
Cat_Cache_Datas::clean(false, true, $options);

// Delete ID cache if is expired or not
$options = array(
'cache_path' =>'/my-cache-path/'
);
Cat_Cache_Datas::del('my-cache-unique-id', $options);

// Take name of the ID cache
$options = array(
'cache_path' =>'/my-cache-path/'
);
Cat_Cache_Datas::get_name('my-cache-unique-id');
?>
download
Size: 4.9 KB
Hits : 17

Written by Davide in: Library, php | Tags: , ,
Oct
18
2008
0

Cat Sitemap

Cat Sitemap

My class for make sitemap.

Work fine on my sites and have option for use crontab for create the sitemap.

Click HERE for see the code of this class

This is an example of the class uses:

 < ?php
// Set the path to webserver root
$path = $_SERVER['DOCUMENT_ROOT'].'/';
// Set url to webserver root
$url = 'http://'.$_SERVER['HTTP_HOST'].'/';

// include library
require(cat-sitemap.inc.php');

// inizialize the sitemap class
$map = new Cat_Sitemap($url.'/', $path, array('debug'=>true,'log_path'=>$path.'write/'));

// Make query
$sql = " SELECT page_name, url, lastmodify FROM my_database_table".
" WHERE 1 ORDER BY lastmodify DESC";
if (!$results = mysql_query($sql)) {
// No results ...
exit;
}
while($val = mysql_fetch_assoc($results)) {
// Here you need to set frequency and all datas for the url
$map->add_item($val->url, 'daily', 1, $val->lastmodify);
//$map->add_item($val->url, 'weekly', 0.6, $val->lastmodify);
//$map->add_item($val->url, 'monthly', 0.8, $val->lastmodify);
}
// Create sitemap
if (!$map->create()) {
trigger_error('Can create the sitemap !!', E_USER_WARNING);
}
// Print the log for this sitemap
echo $map->get_logDatas();
// Destroy the class
$map->__destruct();
?>
download
Size: 8.78 KB
Hits : 10

Written by Davide in: Library, php | Tags: , ,
Oct
13
2008
0

Cat Prototype Edit Inline

Class Cat Prototype Edit Inline

Simple class for “edit in line” with prototype javascript library.

Click HERE for see the code of this class

Here is an example to use this class:

< ?php
// Include the library
include(cat-prototype.inc.php');

$eip = new Cat_Edit_Inline('js/', $_SERVER['PHP_SELF'].'?ajax=on');

// Check if there is an ajax request return false if there isn't data return false
$request = $eip->getAjaxDatas();

if ($request && isset($_GET['ajax'])) {
// set php header
$this->setHeaderPhp(false, true);

// empty id
if (!isset($request['id']) || !isset($request['option_id'])) {
print("Incorrected datas - No id sent !");
}
// continue
else {
// Update the database
/* update_function(); */

// Print text
print ($request['content']);
}
}
// No ajax data sent
else {
// Set default size of textarea
$this->setInitEditOptions('size', 80);
// Setto default cols of textarea
$this->setInitEditOptions('cols', 60);
// Set saving_text
$this->setInitEditOptions('saving_text', 'Saving...');
// Set text field
$this->setElement(array('id'=>'field_name','ajax_data'=>array('option_id'=>1)));
// Set body text
$bodyOptions = array('html_start'=>"<em>description of the field</em>");
// Set body element
$this->setElementBody('option_name', 'option_value', $bodyOptions);
// Set textarea field
$this->setElement(array('id'=>'field_name', 'type'=>'textarea', 'ajax_data'=>array('option_id'=>2)));
// Set body textarea
$bodyOptions = array('html_start'=>"<em>description of the field</em>");
// Set body element
$this->setElementBody('option_name', 'option_value', $bodyOptions);
// Select / Option yes / no
$optionsSelect = array('yes'=>'yes', 'no'=>'no');
$this->setElement(array('id'=>'field_name', 'type'=>'select', 'options'=>$optionsSelect, 'ajax_data'=>array('option_id'=>2)));
// Set body select
$bodyOptions = array('html_start'=>"<em>description of the field</em>");
// Set body element
$this->setElementBody('option_name', 'option_value', $bodyOptions);
// Inizialize class
$eip->initEditInline();
// Get header havascript e css
$header = $eip->getJavascript().$eip->getCss();

echo
"< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
Eip demo".
$header."
</head>
<body>

<h1>Eip Demo</h1>
<div>
".$eip->getBody()."
</div>

</body>
</html>";
}
?>
download
Size: 18.96 KB
Hits : 11

Written by Davide in: Library, javascript, php | Tags: , , ,
Oct
13
2008
0

Cat Rss

Class Cat Rss

Simple class for print rss file.

Click HERE for see the code of this class

< ?php
// Include the library
include('cat-rss.inc.php');

// Inizialize the class
$rss = new Cat_Rss('Feed Title', 'feedPath' , 'feed desc, array('language'=>'en_EN'));

// Check if there is a logo feed
if (file_exists('rss-logo.jpg')) {
// Add feed image
$rss->add_image('feed title', 'rss-logo.jpg', 'http://url-file-feed');
}

$rss->add_article('title news', 'http://link-to-the-news', 'text of the news ...', 'lastmodify-date', array('guid'=>'http://link-to-permanent-link'));
$rss->add_article('title news', 'http://link-to-the-news', 'text of the news ...', 'lastmodify-date', array('guid'=>'http://link-to-permanent-link'));
$rss->add_article('title news', 'http://link-to-the-news', 'text of the news ...', 'lastmodify-date', array('guid'=>'http://link-to-permanent-link'));

// Take the xml file
$fileXml = $rss->get_rss();

// set header
header("Content-type: application/xml");

// Print rss
echo $fileXml;

$rss->__destruct();
?>
download
Size: 2.37 KB
Hits : 7

Written by Davide in: Library, php | Tags: , ,

Theme: TheBuckmaker.com Magazine Style Templates