PHP Calendar Basic is a free and easy to use PHP Calendar. You may choose whether to let people post events or add them yourself.The script is compatible with all major web browsers and is very easy to install and use.
<?php
require_once('common.php');
require_once('myform.php');
$form_output = '';
$filename = 'config.php';
if (!is_writable($filename))
{
$form_output = '<p><font color="red">Please change the file permissions to <strong>777</strong> for the following files and/or folders:</font><br /> <strong>config.php</strong></p>';
}
else
{
$form = new myform(); // not a database form
$form->set('hostname', array(
'type' => 'text',
'label' => 'Hostname:',
'value' => 'localhost',
'html' => 'size="60" maxlength="60"',
'validation' => 'validate_mysql_access',
'required' => 1,
'error' => 'A MySQL hostname is required.',
));
$form->set('database', array(
'type' => 'text',
'label' => 'Database:',
'value' => '',
'html' => 'size="20" maxlength="60"',
'required' => 1,
'error' => 'A MySQL database is required.',
));
$form->set('username', array(
'type' => 'text',
'label' => 'MySQL Username:',
'value' => 'root',
'html' => 'size="20" maxlength="60"',
'required' => 1,
'error' => 'A MySQL username is required.',
));
$form->set('password', array(
'type' => 'text',
'label' => 'MySQL Password:',
'value' => '',
'html' => 'size="20" maxlength="60"',
'required' => 0,
'error' => '',
));
$form->set('affiliate_id', array(
'type' => 'text',
'label' => 'Calendar.com id:',
'value' => '',
'html' => 'size="20" maxlength="60"',
'required' => 1,
'error' => 'A calendar.com affiliate ID is required.',
));
$form->set('products_per_page', array(
'type' => 'text',
'label' => 'Products per page:',
'value' => '10',
'process' => 'process_products',
'validation' => 'validate_products',
'html' => 'size="10" maxlength="10"',
'required' => 1,
'error' => 'Number of products to display per page is required.',
));
$form->set('datafeed_dir', array(
'type' => 'text',
'label' => 'Datafeed Directory:',
'value' => '../datafeeds',
'html' => 'size="30" maxlength="60"',
'required' => 1,
'error' => 'Datafeed directory is required.',
));
$form->set('admin_userid', array(
'type' => 'text',
'label' => 'Admin Userid:',
'value' => 'admin',
'html' => 'size="20" maxlength="60"',
'required' => 1,
'error' => 'An admin userid is required.',
));
$form->set('admin_password', array(
'type' => 'text',
'label' => 'Admin Password:',
'value' => '',
'html' => 'size="20" maxlength="60"',
'required' => 1,
'error' => 'An admin password is required.',
));
$form->set('default_category', array(
'type' => 'text',
'label' => 'Default category:',
'value' => '0',
'process' => 'process_category',
'validation' => 'validate_category',
'html' => 'size="10" maxlength="10"',
'required' => 1,
'error' => 'A default category is required. Use 0 if not sure.',
));
$form_output = $form->process();
if ($form_output == '1')
{
$hostname = custom_post('hostname');
$database = custom_post('database');
$username = custom_post('username');
$password = custom_post('password');
restore_database($hostname, $database, $username, $password, 'database.sql');
include ('write_config.php');
header("location: install_step2.php");
exit();
}
}
// generate page
$tpl = new template();
$tpl->set('form_output',$form_output);
$main_content = $tpl->fetch('templates/install.tpl');
$tpl2 = new template();
$tpl2->set('main_content',$main_content);
echo $tpl2->fetch('templates/install_master.tpl');
function validate_category($value)
{
if (!is_numeric($value))
{
return ('Category must be numeric.');
}
}
function process_category($value)
{
return strtolower(trim($value));
}
function validate_products($value)
{
if (!is_numeric($value))
{
return ('Number of results to return must be numeric.');
}
if ($value < 1 || $value > 100)
{
return ('Number of results to return must be between 1 and 100.');
}
}
function process_products($value)
{
return strtolower(trim($value));
}
function validate_mysql_access($value)
{
$hostname = custom_post('hostname');
$database = custom_post('database');
$username = custom_post('username');
$password = custom_post('password');
$mydb = @mysql_connect($hostname, $username, $password);
if (!$mydb)
{
return mysql_error();
}
$mytest = mysql_select_db($database, $mydb);
if (!$mytest)
{
return mysql_error();
}
return;
}
?>
&nbsp;