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: , ,
Oct
12
2008
0

Cat Skype Status

Class Skype Status

Simple class for print skype status.

< ?php
// Include library
include('cat-skype-status.inc.php');

$skype = new Cat_Skype_Status('skype_username', 'en_EN');

// Return skype button
$ret .= $skype->getStatusButton();

// destroy
$skype->__destruct();
?>
download
Size: 66.89 KB
Hits : 70

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

Cat Video

Class Video

Simple class for wrap link in text to video script.

 // Set video from text
$video = new Cat_Video_Link;
$text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.



Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
$text = $video->set_all(nl2br($text));

// Get video youTube
$you = new Cat_You_Tube();
$video = $you->get_video('h0JX5jWv-tk');

// Get video image
$you = new Cat_You_Tube();
$video = $you->get_img('h0JX5jWv-tk');
?>
download
Size: 3.39 KB
Hits : 11

Written by Davide in: Library, php | Tags: , ,
Oct
12
2008
1

Cat PayPal Buttom

Class PayPal Buttom

Simple class for make payment with paypal.

< ?php
$options_class = array(
'custom'=>'my custom passthrough variable',
'currencycode'=>'EUR',
'form_target'=>'_blank',
'style_class'=>'paypalbutton',
'width'=>'150',
'image_url'=>'http://www.jc21.com.au/paypal/logo.jpg',
'buttonimage'=>'/paypal/purchase.jpg',
'buttontext'=>'I agree, proceed to Payment',
'no_shipping'=>1,
'return'=>'http://my-syte/paypal.php',
'notify_url'=>'http://my-syte/paypal/ipn.php',
'cancel_return'=>'http://my-syte/paypal_cancel.php'
);
$button = new Cat_Paypal_Buttom($options_class);
// Cart elements
$options = array(
'name'=>'Nome prodotto',
'quantity'=>1,
'amount'=>18,0,
'item_number'=>'prod11',
'shipping'=>5,0,
'tax'=>1,8
);
$buttom->AddItem($options);
$options = array(
'name'=>'Nome prodotto 1',
'quantity'=>1,
'amount'=>18,0,
'item_number'=>'prod11',
'shipping'=>5,0,
'tax'=>1,8
);
$buttom->AddItem($options);

echo $button->OutputButton();
$button->__destruct();
?>
download
Size: 4.14 KB
Hits : 14

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

Cat Compressor

Class Compressor

Simple compression class for css and javascript files.

For use the compression is very simple:

insert the folder named “files” and the .htaccess file in your css and javascript folders.

On this moment the files are compressed from the php class :)

download
Size: 7.24 KB
Hits : 21

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

Cat Calendar

Calendar class

This is my simple class for make calendar with linked days that have events in.

< ?php
// set get value passed
$y = (!empty($_GET['y'])) ? $_GET['y'] : '';
$m = (!empty($_GET['m'])) ? $_GET['m'] : '';
$d = (!empty($_GET['d'])) ? $_GET['d'] : '';

// Set url
$url = 'http://www.example.com/archive/';

// Start calendar class sometime need to put EN_en@euro, <a href="mailto:it_IT@euro">it_IT@euro
$calendar = new Cat_Calendar($url, $y, $m, $d);

// Take range date for sql 'date_start' is the database field for date
$sqlCondiction = $calendar->get_db_range('date_start');

$sql = " SELECT date_start".
" FROM news WHERE".
$sqlCondiction.
" AND [ .......... ]";

// Group condiction for have onli one record for date
$sql.= ' GROUP BY date_start ORDER BY date_start DESC';

// Default linked days
$days = array();

// Make query example
if ($res = mysql_query($sql)) {
while($month_info = mysql_fetch_object($res)) {
// Prepare data
$db_days_tmp = explode('-', $month_info->date_start);
// Put in $days array all the query month day
array_push($days, $db_days_tmp[2]);
}
}

// Print returned calendar
echo $calendar->get_calendar($days);
?>
download
Size: 5.57 KB
Hits : 30

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

Theme: TheBuckmaker.com Magazine Style Templates