Category Archives: Email Scripts

Quick PHP Snippet to Send Email

Just a Quick PHP Snippet to Send Email using the default PHP mail() function.

    $to  = 'admin@domain.com';
    $subject = 'subject';

    $message = '
    <html>
    <head>
      <title>'
.$title.'</title>
    </head>
    <body>'
. $message . '</body>
    </html>
    '
;

    // To send HTML mail, the Content-type header must be set
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

    // Additional headers
    $headers .= 'To: Admin <admin@domain.com>' . "\r\n";
    $headers .= 'From: Cron Daemon <crondaemon@domain.com>' . "\r\n";

    debug($message);
    mail($to, $subject, $message, $headers);

PHP Scripts for GentleSource File Download

GentleSource File Download can be used to provide files for download on your website. The script triggers the download dialogue so that visitors can choose to download the file instead of opening it in the browser. This affects mostly images and PDF files but also works with every other file type.The script also hides the location of the download file and prevents visitors from accessing the download folder directly. The download folder can even be outside of the web root.

 

<?php

/**
* File Download/Download Center Lite - index.php
*
* @author Ralf Stadtaus
* @link http://www.stadtaus.com/ Homepage
* @link http://www.stadtaus.com/forum/ Support/Contact
* @copyright Copyright &amp;copy; 2005, Ralf Stadtaus
* @version 0.3
*/


/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY
* OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED   TO  THE WARRANTIES  OF  MERCHANTABILITY,
* FITNESS    FOR    A    PARTICULAR    PURPOSE   AND
* NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
* OR  OTHER  LIABILITY,  WHETHER  IN  AN  ACTION  OF
* CONTRACT,  TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR  IN  CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/





/*****************************************************
** Script configuration - for a documentation of the
** following variables please take a look at the
** documentation file in the 'docu' directory.
*****************************************************/


$referring_server      = '';         /* i.e.: www.example.com, example.com*/
$allow_empty_referer   = 'yes';      /* (yes, no) */

$ip_banlist            = '';         /* i.e.: 127.0.0.1, 192.168.0.1, ... */

$language              = 'en';       /* (en, de, it, sv, fr)  */

$show_error_messages   = 'yes';      /* (yes, no) */


$log_downloads         = 'no';       /* (yes, no) */
$count_downloads       = 'no';       /* (yes, no) */


$path['downloads']     = './downloads/';
$path['templates']     = './templates/';
$path['logfiles']      = './logfiles/';

$file['template']      = 'index.tpl.html';
$file['log']           = 'log.txt';
$file['count']         = 'count.txt';




/*****************************************************
** Add further words, text, variables and stuff
** that you want to appear in the template here.
*****************************************************/

$add_text = array(

'txt_additional' => 'Additional', //  {txt_additional}
'txt_more'       => 'More'        //  {txt_more}

);





/*****************************************************
** Do not edit below this line - Ende der Einstellungen
*****************************************************/















/*****************************************************
** Send safety signal to included files
*****************************************************/

define('IN_SCRIPT', 'true');




/*****************************************************
** Load script code
*****************************************************/

$script_root           = './';

include($script_root . 'inc/download_center_lite.inc.php')




?>

&amp;nbsp;

PHP Scripts for GentleSource Form Mail allows

GentleSource Form Mail allows you to put a contact form on your website. The input of that form will be sent per e-mail to your e-mail address. The script can log all the messages that are sent.The layout of your forms, and e-mail, can be customized as you wish. You can also choose if the user will be redirected to a thank-you-page, or sees the information from the form displayed again,It also has multiple layers of security that reduce the possibility of unauthorized use.

 

<?php

/*****************************************************
** Title........: Form Mail Script
** Filename.....: index.php
** Author.......: GentleSource
** Homepage.....: http://www.gentlesource.com/
** Notes........: This file contains the configuration
** Last changed.:
** Last change..:
*****************************************************/


/*****************************************************
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY
** OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
** LIMITED   TO  THE WARRANTIES  OF  MERCHANTABILITY,
** FITNESS    FOR    A    PARTICULAR    PURPOSE   AND
** NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR
** COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
** OR  OTHER  LIABILITY,  WHETHER  IN  AN  ACTION  OF
** CONTRACT,  TORT OR OTHERWISE, ARISING FROM, OUT OF
** OR  IN  CONNECTION WITH THE SOFTWARE OR THE USE OR
** OTHER DEALINGS IN THE SOFTWARE.
**
*****************************************************/





/*****************************************************
** Script configuration - for a documentation of the
** following variables please take a look at the
** documentation file in the 'docu' directory.
*****************************************************/

$script_root           = './';

$referring_server      = '';       // Example: $referring_server = 'example.com, www.example.com';

$language              = 'en';     // see folder /languages/

$ip_banlist            = '';

$ip_address_count      = '0';
$ip_address_duration   = '48';

$show_limit_errors     = 'yes';    // (yes, no)

$log_messages          = 'yes';     // (yes, no) -- make folder "logfile" writable with: chmod 777 logfile

$text_wrap             = '72';

$show_error_messages   = 'yes';

$attachment            = 'yes';    // (yes, no) -- make folder "temp" writable with: chmod 777 temp
$attachment_files      = 'jpg, gif, png, zip, txt, pdf, doc, ppt, tif, bmp, mdb, xls, txt, vcf, csv, vcs';
$attachment_size       =  9000000;

$captcha               = 'no';   // (yes, no) -- make folder "temp" writable with: chmod 777 temp

$filepath['logfile']       = $script_root . 'logfile/';
$filepath['templates']     = $script_root . 'templates/';

$file['default_html']  = 'form.tpl.html';
$file['default_mail']  = 'mail.tpl.txt';




/*****************************************************
** Add further words, text, variables and stuff
** that you want to appear in the templates here.
** The values are displayed in the HTML output and
** the e-mail.
*****************************************************/

$add_text = array(
'txt_additional' => 'Additional', //  {txt_additional}
'txt_more'       => 'More',        //  {txt_more}
'domain'         => $_SERVER['SERVER_NAME'],

);




/*****************************************************
** Do not edit below this line - Ende der Einstellungen
*****************************************************/















/*****************************************************
** Send safety signal to included files
*****************************************************/

define('IN_SCRIPT', 'true');




/*****************************************************
** Load formmail script code
*****************************************************/

include($script_root . 'inc/formmail.inc.php');

echo $f6l_output;




?>

&amp;nbsp;

PHP Scripts for GentleSource Link Manager

GentleSource Link Manager can be used as link section of a website or a personal bookmark manager. You can publish your links for everyone to see or hide them behind a login.Manage any number of groups,Define a name, description, background color and position for each group,Sort groups by name, create date or an individual order,Create any number of links in each group,Define name, URL, description, text color for each link,Sort links by name, create date, views or an individual order,Export and import data (backup).

 

<?php

/**
* GentleSource Comment Script
*
* (C) Ralf Stadtaus http://www.gentlesource.com/
*/





// Settings
define('C5T_ROOT', '../');
define('C5T_ALTERNATIVE_TEMPLATE', 'admin');
define('C5T_LOGIN_LEVEL', 1);

$c5t_detail_template    = 'backup.tpl.html';

// -----------------------------------------------------------------------------




// Include
require C5T_ROOT . 'include/core.inc.php';

// Start output handling
$out = new c5t_output($c5t_detail_template);

// -----------------------------------------------------------------------------




require 'backup.class.inc.php';
$backup = new c5t_backup;


// Export database into file
if (c5t_gpc_vars('do') == 'ex') {
if (false == $c5t['demo_mode']) {
if ($backup->export()) {
header('Location: ' . $c5t['server_protocol'] . $c5t['server_name'] . dirname($_SERVER['PHP_SELF']) . '/backup.php?e=s');
exit;
}
} else {
$c5t['message'][] = $c5t['text']['txt_disabled_in_demo_mode'];
}
}
if (c5t_gpc_vars('e') == 's') {
$c5t['message'][] = $c5t['text']['txt_export_successful'];
}

// -----------------------------------------------------------------------------




// Delete backup file
$delete_confirmation = array('dialogue' => 0);
if ($file = c5t_gpc_vars('f')
and c5t_gpc_vars('do') == 'de') {
$delete_confirmation = array(
'dialogue'      => 1,
'file' => $file
);
}
$out->assign('delete_confirmation', $delete_confirmation);
if ($identifier_id = c5t_gpc_vars('f')
and c5t_gpc_vars('do') == 'dec') {
if (false == $c5t['demo_mode']) {
if ($backup->delete($file)) {
$c5t['message'][] = $c5t['text']['txt_delete_file_successful'];
} else {
$c5t['message'][] = $c5t['text']['txt_delete_file_failed'];
}
} else {
$c5t['message'][] = $c5t['text']['txt_disabled_in_demo_mode'];
}
}

// -----------------------------------------------------------------------------




// Import backup file
$import_confirmation = array('dialogue' => 0);
if ($file = c5t_gpc_vars('f')
and c5t_gpc_vars('do') == 'im') {
$import_confirmation = array(
'dialogue'      => 1,
'file'          => $file
);
}
$out->assign('import_confirmation', $import_confirmation);
if ($identifier_id = c5t_gpc_vars('f')
and c5t_gpc_vars('do') == 'imc') {
if (false == $c5t['demo_mode']) {
if ($backup->import($file)) {
header('Location: ' . $c5t['server_protocol'] . $c5t['server_name'] . dirname($_SERVER['PHP_SELF']) . '/backup.php?i=s');
exit;
} else {
$c5t['message'][] = $c5t['text']['txt_import_failed'];
}
} else {
$c5t['message'][] = $c5t['text']['txt_disabled_in_demo_mode'];
}
}
if (c5t_gpc_vars('i') == 's') {
$c5t['message'][] = $c5t['text']['txt_import_successful'];
}

// -----------------------------------------------------------------------------




// Download backup file
if ($file = c5t_gpc_vars('f')
and c5t_gpc_vars('do') == 'dl') {
require_once 'download.class.inc.php';
if (is_file(C5T_ROOT . $c5t['backup_directory'] . $file)){
c5t_download::send(C5T_ROOT . $c5t['backup_directory'] . $file);
}
}

// -----------------------------------------------------------------------------




// List available backup files
$out->assign('backup_files', $backup->file_list());

// -----------------------------------------------------------------------------




// Output
$out->finish();






?>

&amp;nbsp;
  • Track link views
  • Different built-in layout templates
  • Create your own layout templates
  • Web-based installation
  • HTML layout templates

GentleSource Comments is a PHP script

GentleSource Comments is a PHP script that can be included in existing websites and allows the visitors to leave comments on a page. The comments can be edited and deleted in the admin area.Once the script has been installed, it can be included it in any existing PHP or HTML page. By default the script shows the form fields “Name”, “E-mail”, “Homepage”, “Title”, and “Comment”.In order to prevent the script from being filled with spam, you can activate the various anti spam features like Akismet, Captcha, IP and content block.

 

<?php

/**
* GentleSource Comment Script
*
* (C) Ralf Stadtaus http://www.gentlesource.com/
*/


/*****************************************************
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY
** OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
** LIMITED   TO  THE WARRANTIES  OF  MERCHANTABILITY,
** FITNESS    FOR    A    PARTICULAR    PURPOSE   AND
** NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR
** COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
** OR  OTHER  LIABILITY,  WHETHER  IN  AN  ACTION  OF
** CONTRACT,  TORT OR OTHERWISE, ARISING FROM, OUT OF
** OR  IN  CONNECTION WITH THE SOFTWARE OR THE USE OR
** OTHER DEALINGS IN THE SOFTWARE.
**
*****************************************************/





// Settings
if (!defined('C5T_ROOT')) {
define('C5T_ROOT', './');
}


$c5t_detail_template        = 'comment.tpl.html';

define('C5T_LOGIN_LEVEL', 0);



// Include
require C5T_ROOT . 'include/core.inc.php';

if ($c5t_cache_output == true) {
return;
}

require 'comment.class.inc.php';

// -----------------------------------------------------------------------------




// Check for module standalone call
if (c5t_gpc_vars('module')) {
$module_data = array('data' => c5t_gpc_vars('module'));
c5t_module::call_module('standalone', $module_data, $c5t['module_additional']);
exit;
}

// -----------------------------------------------------------------------------




require_once 'HTML/QuickForm/Renderer/ArraySmarty.php';
require_once 'HTML/QuickForm.php';

// -----------------------------------------------------------------------------


// Start output handling
$c5t_out = new c5t_output($c5t_detail_template);


// Start comment handling
$c5t_comment = new c5t_comment;


// Start form handler
$c5t_form_action = getenv('REQUEST_URI');
if (c5t_gpc_vars('c5t_ssi') or c5t_gpc_vars('c5t_ssi_redirect')) {
$c5t_form_action = $c5t['script_url'] . 'include.php';
}
$c5t_form = new HTML_QuickForm('form', 'POST', $c5t_form_action . '#c5t_form');




// Add redirect URL
if (c5t_gpc_vars('c5t_ssi') or c5t_gpc_vars('c5t_ssi_redirect')) {
$c5t_form->addElement('hidden', 'c5t_ssi_redirect');
if ($c5t_ssi_redirect = c5t_gpc_vars('c5t_ssi_redirect')) {
$c5t['alternative_template'] = 'standalone';
} else {
$c5t_ssi_redirect = getenv('REQUEST_URI');
}
$c5t_form->setDefaults(array('c5t_ssi_redirect' => $c5t_ssi_redirect));
}

// -----------------------------------------------------------------------------




// Get form configuration
require 'comment_form.inc.php';

$c5t_form->setDefaults($c5t_comment->remembered_user());


// Validate form
$c5t_message = array();
if ($c5t['display_comment_form'] == 'Y') {
$c5t_show_form = 'yes';
if (c5t_gpc_vars('save')) {
if ($c5t_form->validate()) {
if ($c5t_comment->put()) {
$c5t_show_form = 'no';
}
if ($c5t_ssi_redirect = c5t_gpc_vars('c5t_ssi_redirect')) {
header('Location: ' . $c5t['server_protocol'] . $c5t['server_name'] . $c5t_ssi_redirect);
exit;
}
} else {
if (sizeof($c5t['_post']) > 0) {
$c5t['message'][] = $c5t['text']['txt_fill_out_required'];
}
}
}

$c5t_out->assign('show_form', $c5t_show_form);

$c5t_form_renderer = new HTML_QuickForm_Renderer_ArraySmarty($c5t_out->get_object, true);
$c5t_form->accept($c5t_form_renderer);
$c5t_out->assign('form', $c5t_form_renderer->toArray());
}

if ($c5t['display_comment_form'] != 'Y' and $c5t['display_turn_off_messages'] == 'Y') {
$c5t_message[]['message'] = $c5t['text']['txt_comment_form_turned_off'];
$c5t_show_form = 'yes';
} else {
$c5t_show_form = 'no';
}

// -----------------------------------------------------------------------------




// Get comment data
$c5t_comment_data = array();
if ($c5t['display_comments'] == 'Y') {
c5t_benchmark::mark('Begin Comment List');
require 'commentlist.class.inc.php';
$c5t_list_setup = array('direction' => $c5t['frontend_order'],
'limit'     => 0);
if ((int) $c5t['frontend_result_number'] >= 1) {
$c5t_list_setup['limit'] = (int) $c5t['frontend_result_number'];
// Pagination does not work with SSI
if (c5t_gpc_vars('c5t_ssi')) {
$c5t_list_setup['limit'] = 0;
}
$c5t_out->assign('display_pagination', true);
}
$c5t_comment_list = new c5t_comment_list(false, $c5t_list_setup);
if ($c5t_comment_data_temp = $c5t_comment_list->get_list(c5t_comment::identifier())) {
$c5t_comment_data = $c5t_comment_data_temp;
}
$c5t_comment_list_values = $c5t_comment_list->values();
c5t_benchmark::mark('End Comment List');
$c5t_out->assign($c5t_comment_list_values);
if ($c5t_comment_list_values['result_limit'] > 0){
$c5t_page = ceil(($c5t_comment_list_values['result_number'] + 1) / $c5t_comment_list_values['result_limit']);
} else {
$c5t_page = 1;
}
$c5t_form->setConstants(array('page' => $c5t_page));


// Pagination form
$c5t_next_page = new HTML_QuickForm('nextpage', 'POST', $c5t_form_action .'#c5t_comment');
$c5t_next_page->addElement('submit', 'next', $c5t['text']['txt_next_page']);
$c5t_next_page->addElement('hidden', 'page');
$c5t_next_page->setConstants(array('page' => $c5t_comment_list_values['next_page']));
$c5t_next_page_renderer = new HTML_QuickForm_Renderer_ArraySmarty($c5t_out->get_object, true);
$c5t_next_page->accept($c5t_next_page_renderer);
$c5t_next_page_renderer_to_array = $c5t_next_page_renderer->toArray();
$c5t_out->assign('nextpage', $c5t_next_page_renderer_to_array);


$c5t_end_page = new HTML_QuickForm('endpage', 'POST', $c5t_form_action .'#c5t_comment');
$c5t_end_page->addElement('submit', 'end', $c5t['text']['txt_end']);
$c5t_end_page->addElement('hidden', 'page');
$c5t_end_page->setConstants(array('page' => $c5t_comment_list_values['result_pages']));
$c5t_end_page_renderer = new HTML_QuickForm_Renderer_ArraySmarty($c5t_out->get_object, true);
$c5t_end_page->accept($c5t_end_page_renderer);
$c5t_end_page_renderer_to_array = $c5t_end_page_renderer->toArray();
$c5t_out->assign('endpage', $c5t_end_page_renderer_to_array);

$c5t_start_page = new HTML_QuickForm('startpage', 'POST', $c5t_form_action .'#c5t_comment');
$c5t_start_page->addElement('submit', 'start', $c5t['text']['txt_start']);
$c5t_start_page->addElement('hidden', 'page');
$c5t_start_page->setConstants(array('page' => 1));
$c5t_start_page_renderer = new HTML_QuickForm_Renderer_ArraySmarty($c5t_out->get_object, true);
$c5t_start_page->accept($c5t_start_page_renderer);
$c5t_start_page_renderer_to_array = $c5t_start_page_renderer->toArray();
$c5t_out->assign('startpage', $c5t_start_page_renderer_to_array);


$c5t_previous_page = new HTML_QuickForm('previouspage', 'POST', $c5t_form_action .'#c5t_comment');
$c5t_previous_page->addElement('submit', 'previous', $c5t['text']['txt_previous_page']);
$c5t_previous_page->addElement('hidden', 'page');
$c5t_previous_page->setConstants(array('page' => $c5t_comment_list_values['previous_page']));
$c5t_previous_page_renderer = new HTML_QuickForm_Renderer_ArraySmarty($c5t_out->get_object, true);
$c5t_previous_page->accept($c5t_previous_page_renderer);
$c5t_previous_page_renderer_to_array = $c5t_previous_page_renderer->toArray();
$c5t_out->assign('previouspage', $c5t_previous_page_renderer_to_array);
}
$c5t_out->assign('comment_list', $c5t_comment_data);

if ($c5t['display_comments'] != 'Y' and $c5t['display_turn_off_messages'] == 'Y') {
$c5t_turned_off = array('comment_title'         => $c5t['text']['txt_comment_display_turned_off'],
'comment_author_name'   => $c5t['text']['txt_administrator'],
'comment_number'        => 1,
'comment_date'          => c5t_time::format_date(c5t_time::current_timestamp()),
'comment_time'          => c5t_time::format_time(c5t_time::current_timestamp())
);
$c5t_out->assign('comment_list', array($c5t_turned_off));
}

// -----------------------------------------------------------------------------




// Get current page data
require_once 'identifier.class.inc.php';
$page_data = c5t_comment::select_identifier(c5t_comment::identifier());
$c5t_out->assign('page_data', $page_data);

// -----------------------------------------------------------------------------




// Output
$c5t_output = $c5t_out->finish(false);
//echo $c5t_output;

?>

&amp;nbsp;

PHP Scripts for GentleSource Disposable E-mail

GentleSource Disposable E-mail (Temporary E-mail) allows you to create a website that provides the users with disposable e-mail addresses which expire after a certain time. The user can read and reply to e-mails that are sent to the temporary e-mail address within the given time frame.With a click on a button the user generates a new e-mail address. That address will be stored in the database along with its creation time. The e-mail address is assigned to the user by a session cookie.The user then uses the e-mail for any purpose where an e-mail address is required. Most commonly that will be some kind of registration.In the background the script checks continuously for arriving e-mails. Once an e-mail that has been sent to a generated e-mail address arrives, the script displays it.

 

<?php

/**
* Garbage Collector -   garbage_collector.class.inc.php
*
* (C) Ralf Stadtaus http://www.stadtaus.com/
*/


include 'Find.php';



/**
*
*/

class garbage_collector
{


/**
* Number of files to be deleted at once
*/

var $number = 20;

/**
* Time in minutes until a file gets deleted
*/

var $time = 120;

/**
* Directory that contains the garbage
*/

var $directory = '';

// -----------------------------------------------------------------------------




/**
* Constructor
*/

function garbage_collector($config)
{

// Extract configuration array
if (is_array($config)) {
$valid = array_keys(get_class_vars(get_class($this)));
while (list($key, $val) = each($config))
{
if (in_array($key, $valid)) {
$this->$key = $val;
}
}
}
}

// -----------------------------------------------------------------------------




/**
* Get file list
*/

function file_list()
{
if (!is_dir($this->directory)) {
return false;
}
$items = &amp;File_Find::glob(  '#([a-zA-Z0-9])\.png#',
$this->directory,
'perl');
if (!is_array($items) or sizeof($items) <= 0) {
return false;
}
$list = array();
while (list($key, $val) = each($items))
{
if (sizeof($list) >= ($this->number - 1)) {
return $list;
}
$diff = (time() - filectime($this->directory . $val))/60;

if ($diff > $this->time) {
$list[] = $val;
}
}
return $list;
}

// -----------------------------------------------------------------------------




/**
* Display file list
*/

function display()
{
if ($list = $this->file_list()) {
$list = join('<br />', $list);
echo $list;
}
}

// -----------------------------------------------------------------------------




/**
* Delete files
*/

function delete()
{
if ($list = $this->file_list()) {
if (!is_array($list)) {
return false;
}
reset($list);
while (list($key, $val) = each($list))
{
if (!is_file($this->directory . $val)) {
continue;
}
unlink($this->directory . $val);
}
}
}

// -----------------------------------------------------------------------------




} // Scool's out








?>

&amp;nbsp;

PHP formmailer script

Form Mail Script will allow you to send information from forms on your web site, by e-mail, to one, or to multiple recipients. It lets you send e-mail as text, or as HTML. The script can also log all the messages that are sent.The layout of your forms, and e-mail, can be customized as you wish. You can also choose if the user will be redirected to a thank-you-page, or sees the information from the form displayed againIt also has multiple layers of security that reduce the possibility of unauthorized use.

 

<?php

/**
* Extends the template class
*
* @author Ralf Stadtaus
* @copyright Copyright &amp;copy; 2004, Ralf Stadtaus
* @version 0.2
*/





/**
* Extends the template class
*
*/

class my_template extends template
{
var $err_array;
var $err_var_names;
var $include_path;
var $req_array;
var $req_var_names;
var $syn_array;
var $syn_var_names;




/**
* Set path where include path starts
*
* @access public
* @param String path Absolute server path starting from server root
* @return Void
*/

function set_include_path($path)
{
$this->include_path = $path;
}




/**
* Register error variables
*
*/

function required_register($file_id, $var_name)
{
if(is_array($var_name)) {
$this->req_array($file_id, $var_name);
} elseif ($var_name != ''){
if (is_long(strpos($var_name, ',')) == TRUE){
$var_name = explode(',', $var_name);
for(reset($var_name); $current = current($var_name); next($var_name)) $this->req_var_names[$file_id][] = trim($current);
} else {
$this->req_var_names[$file_id][] = $var_name;
}
}
}




/**
* Register alternative variables
*
*/

function error_register($file_id, $var_name)
{
if(is_array($var_name)){
$this->err_array($file_id, $var_name);
} elseif ($var_name != '') {
if(is_long(strpos($var_name, ',')) == TRUE){
$var_name = explode(',', $var_name);
for(reset($var_name); $current = current($var_name); next($var_name)) $this->err_var_names[$file_id][] = trim($current);
}else{
$this->err_var_names[$file_id][] = $var_name;
}
}
}




/**
* Register syntax variables
*
*/

function syntax_register($file_id, $var_name)
{
if(is_array($var_name)){
$this->syn_array($file_id, $var_name);
} elseif ($var_name != ''){
if(is_long(strpos($var_name, ',')) == TRUE){
$var_name = explode(',', $var_name);
for(reset($var_name); $current = current($var_name); next($var_name)) $this->syn_var_names[$file_id][] = trim($current);
}else{
$this->syn_var_names[$file_id][] = $var_name;
}
}
}




/**
* Register error variables
*
*/

function required_parse($file_id)
{
$file_ids = explode(',', $file_id);
for(reset($file_ids); $file_id = trim(current($file_ids)); next($file_ids))
{
if(isset($this->req_var_names[$file_id]) AND count($this->req_var_names[$file_id]) > 0){
for($i=0; $i<count($this->req_var_names[$file_id]); $i++)
{
$temp_var = $this->req_var_names[$file_id][$i];
$this->files[$file_id] = preg_replace('#' . $this->start . 'required:' . $temp_var . '=\'(.*)\':endrequired' . $this->end . '#', '$1', $this->files[$file_id]);
}
}
}
}




/**
* Register alternative variables
*
*/

function error_parse($file_id)
{
$file_ids = explode(',', $file_id);
for(reset($file_ids); $file_id = trim(current($file_ids)); next($file_ids))
{
if(isset($this->err_var_names[$file_id]) AND count($this->err_var_names[$file_id]) > 0) {
for($i=0; $i<count($this->err_var_names[$file_id]); $i++)
{
$temp_var = $this->err_var_names[$file_id][$i];
//                    $this->files[$file_id] = preg_replace('#' . $this->start . 'error:' . $temp_var . '=(.*)\|\|=(.*)' . $this->end . '#', '$2', $this->files[$file_id]);
$this->files[$file_id] = preg_replace('#\{error:' . $temp_var . '=\'(.*)\'\|\|=\'(.*)\':enderror\}#', '$2', $this->files[$file_id]);
}
}
}
}




/**
* Register alternative variables
*
*/

function syntax_parse($file_id)
{
$file_ids = explode(',', $file_id);
for(reset($file_ids); $file_id = trim(current($file_ids)); next($file_ids))
{
if(isset($this->syn_var_names[$file_id]) AND count($this->syn_var_names[$file_id]) > 0) {
for($i=0; $i<count($this->syn_var_names[$file_id]); $i++)
{
$temp_var = $this->syn_var_names[$file_id][$i];
$this->files[$file_id] = preg_replace('#' . $this->start . 'syntax:' . $temp_var . '=\'(.*)\':endsyntax' . $this->end . '#', '$1', $this->files[$file_id]);
}
}
}
}




/**
* Clean up unreplaced markers
*
*/

function clean_up($file_id)
{
$file_ids = explode(',', $file_id);
for(reset($file_ids); $file_id = trim(current($file_ids)); next($file_ids))
{
$this->files[$file_id] = preg_replace('#' . $this->start . 'syntax:(.*)=\'(.*)\':endsyntax' . $this->end . '#', '', $this->files[$file_id]);
$this->files[$file_id] = preg_replace('#' . $this->start . 'required:(.*)=\'(.*)\':endrequired' . $this->end . '#', '', $this->files[$file_id]);
$this->files[$file_id] = preg_replace('#' . $this->start . 'error:(.*)=\'(.*)\'\|\|=\'(.*)\':enderror' . $this->end . '#', '$2', $this->files[$file_id]);
}
}



/**
* Include filese - PHP code is parsed and executed
*
*/

function include_file($file_id, $filename)
{
if ($filename{0} == '/') {
$new_filename = $this->include_path . '/' . $filename;
$new_filename = str_replace('//', '/', str_replace('//', '/', $new_filename));
} else {
$new_filename = $filename;
}

if (is_file($new_filename)) {
ob_start();
include $new_filename;
$content = ob_get_contents();
ob_end_clean();
} else {
$content = '[ERROR: "' . $new_filename . '" does not exist.]';
}

if (isset($content)) {
$tag = substr($this->files[$file_id], strpos(strtolower($this->files[$file_id]), '<include filename="'.$filename.'">'), strlen('<include filename="'.$filename.'">'));
$this->files[$file_id] = str_replace($tag, $content, $this->files[$file_id]);
}
}




}



?>

 

 

PHP SMS scripts

PHP SMS API, script using our HTTP API can be integrated into your application and can be customized to suite your requirements. And among some of the Open source PHP applications that are currently customized to use MySMSaddress.com International SMS gateway are PHPNuke, Mambo, Joomla, PHP Point Of Sale, that we are aware of. to use this script you need a valid account with mysmsaddress.com . If you are not a registered user you can signup free.

<?

/*

File: smppclass.php
Implements: SMPPCLass()
*/


/*

The following are the SMPP PDU types that we are using in this class.
Apart from the following 3 PDU types, there are a lot of SMPP directives
that are not implemented in this version.

*/


define(CM_BIND_TRANSMITTER, 0x00000002);
define(CM_SUBMIT_SM, 0x00000004);
define(CM_UNBIND, 0x00000006);

class SMPPClass {
// public members:
/*
Constructor.
Parameters:
none.
Example:
$smpp = new SMPPClass();
*/

function SMPPClass()
{
$this->_socket = NULL;
$this->_command_status = 0;
$this->_sequence_number = 1;
$this->_source_address = "";
}

/*
For SMS gateways that support sender-ID branding, the method
can be used to set the originating address.
Parameters:
$from    :    Originating address
Example:
$smpp->SetSender("31495595392");
*/

function SetSender($from)
{
if (strlen($from) > 20) {
// todo
echo "Error: sender id too long.\n";
return;
}
$this->_source_address = $from;
}

/*
This method initiates an SMPP session.
It is to be called BEFORE using the Send() method.
Parameters:
$host        : SMPP ip to connect to.
$port        : port # to connect to.
$username    : SMPP system ID
$password    : SMPP passord.
$system_type    : SMPP System type
Example:
$smpp->Start("smpp.chimit.nl", 2345, "chimit", "my_password", "client01");
*/

function Start($host, $port, $username, $password, $system_type)
{
$this->_socket = fsockopen($host, $port, $errno, $errstr);
// todo: sanity check on input parameters
if (!$this->_socket) {
echo "Error opening SMPP session.\n";
echo "Error was: $errstr.\n";
return;
}
socket_set_timeout($this->_socket, 1200);
$status = $this->SendBindTransmitter($username, $password, $system_type);
if ($status != 0) {
echo "Error binding to SMPP server. Invalid credentials?\n";
}
}

/*
This method sends out one SMS message.
Parameters:
$to    : destination address.
$text    : text of message to send.
Example:
$smpp->Send("31495595392", "This is an SMPP Test message.");
*/

function Send($to, $text)
{
if (strlen($to) > 20) {
echo "to-address too long.\n";
return;
}
if (strlen($text) > 160) {
echo "Message too long.\n";
return;
}
if (!$this->_socket) {
// not connected
return;
}
$service_type = "";
$source_addr_ton = 0;
$source_addr_npi = 0;
$source_addr = $this->_source_address;
$dest_addr_ton = 1;
$dest_addr_npi = 1;
$destination_addr = $to;
$esm_class = 0;
$protocol_id = 0;
$priority_flag = 0;
$schedule_delivery_time = "";
$validity_period = "";
$registered_delivery_flag = 0;
$replace_if_present_flag = 0;
$data_coding = 0;
$sm_default_msg_id = 0;
$sm_length = strlen($text);
$short_message = $text;
$status = $this->SendSubmitSM($service_type, $source_addr_ton, $source_addr_npi, $source_addr, $dest_addr_ton, $dest_addr_npi, $destination_addr, $esm_class, $protocol_id, $priority_flag, $schedule_delivery_time, $validity_period, $registered_delivery_flag, $replace_if_present_flag, $data_coding, $sm_default_msg_id, $sm_length, $short_message);
if ($status != 0) {
echo "SMPP server returned error $status.\n";
}
}

/*
This method ends a SMPP session.
Parameters:
none
Example: $smpp->End();
*/

function End()
{
if (!$this->_socket) {
// not connected
return;
}
$status = $this->SendUnbind();
if ($status != 0) {
echo "SMPP Server returned error $status.\n";
}
fclose($this->_socket);
$this->_socket = NULL;
}

// private members (not documented):

function ExpectPDU($our_sequence_number)
{
do {
$elength = fread($this->_socket, 4);
extract(unpack("Nlength", $elength));
$stream = fread($this->_socket, $length - 4);
/*    echo "Read PDU        : $length bytes.\n";
echo "Stream len      : " . strlen($stream) . "\n"; */

extract(unpack("Ncommand_id/Ncommand_status/Nsequence_number", $stream));
$command_id &amp;= 0x0fffffff;
/*            echo "Command id      : $command_id.\n";
echo "Command status  : $command_status.\n";
echo "sequence_number : $sequence_number.\n";

*/

switch ($command_id) {
case CM_BIND_TRANSMITTER:
//    echo "Got CM_BIND_TRANSMITTER_RESP.\n";
break;
case CM_UNBIND:
//    echo "Got CM_UNBIND_RESP.\n";
break;
case CM_SUBMIT_SM:
//    echo "Got CM_SUBMIT_SM_RESP.\n";
break;
default:
//    echo "Got unknown SMPP pdu.\n";
break;
}
} while ($sequence_number != $our_sequence_number);
return $command_status;
}

function SendPDU($command_id, $pdu)
{
$length = strlen($pdu) + 16;
$header = pack("NNNN", $length, $command_id, $this->_command_status, $this->_sequence_number);
/*    echo "Sending PDU, len == $length\n";
echo "Sending PDU, header-len == " . strlen($header) .  "\n";
echo "Sending PDU, command_id == " . $command_id  .  "\n";

*/

fwrite($this->_socket, $header . $pdu, $length);
$status = $this->ExpectPDU($this->_sequence_number);
$this->_sequence_number = $this->_sequence_number + 1;
return $status;
}

function SendBindTransmitter($system_id, $smpppassword, $system_type)
{
$system_id_len = strlen($system_id) + 1;
$smpppassword_len = strlen($smpppassword) + 1;
$system_type_len = strlen($system_type) + 1;
$pdu = pack("a{$system_id_len}a{$smpppassword_len}a{$system_type_len}CCCa1", $system_id, $smpppassword, $system_type, 3, 0, 0, "");
$status = $this->SendPDU(CM_BIND_TRANSMITTER, $pdu);
return $status;
}

function SendUnbind()
{
$pdu = "";
$status = $this->SendPDU(CM_UNBIND, $pdu);
return status;
}

function SendSubmitSM($service_type, $source_addr_ton, $source_addr_npi, $source_addr, $dest_addr_ton, $dest_addr_npi, $destination_addr, $esm_class, $protocol_id, $priority_flag, $schedule_delivery_time, $validity_period, $registered_delivery_flag, $replace_if_present_flag, $data_coding, $sm_default_msg_id, $sm_length, $short_message)
{
$service_type_len = strlen($service_type) + 1;
$source_addr_len = strlen($source_addr) + 1;
$destination_addr_len = strlen($destination_addr) + 1;
$schedule_delivery_time_len = strlen($schedule_delivery_time) + 1;
$validity_period_len = strlen($validity_period) + 1;
$message_len = $sm_length + 1;
//    echo "PDU spec: a{$service_type_len}cca{$source_addr_len}cca{$destination_addr_len}ccca{$schedule_delivery_time_len}a{$validity_period_len}ccccca{$message_len}\n";
$pdu = pack("a{$service_type_len}cca{$source_addr_len}cca{$destination_addr_len}ccca{$schedule_delivery_time_len}a{$validity_period_len}ccccca{$message_len}", $service_type, $source_addr_ton, $source_addr_npi, $source_addr, $dest_addr_ton, $dest_addr_npi, $destination_addr, $esm_class, $protocol_id, $priority_flag, $schedule_delivery_time, $validity_period, $registered_delivery_flag, $replace_if_present_flag, $data_coding, $sm_default_msg_id, $sm_length, $short_message);
$status = $this->SendPDU(CM_SUBMIT_SM, $pdu);
return $status;
}

};
?>

PHP Scripts for phMailer

phMailer is a very simple PHP contact form that supports attachments using PHP’s built-in mail() function. This is very helpful if you want your visitors to be able to contact you without them knowing your real email address. On great feature of this script is the ability to allow users to attach multiple files when sending an email directly from your site. Of course, you can disable this feature if you wish. Any file type is accepted as long as they are included in your file extension list. Another popular use for a PHP email form is protection against spam bots. Spam, is a major downside of email, and placing your email publicly on your website is asking for spam. Spam bots can take your email address right off your site and add it to thousands of spam databases. resulting in a never ending supply of spam for you. I coded this script, because I couldn’t find a simple mail script that would allow my visitors to send me attachments while keeping my email hidden from spam bots.

<html>
<head>
<title>phMailer Test Script</title>
</head>
<body>

<?php
If($_POST['submit']==true) {

extract($_POST, EXTR_SKIP);

If(mail($email,"Testing PHP Mail","This is a test email. Mail seems to be working fine =). Enjoy this script.","From: \"PHP Mail Test\" <$email>")) {
exit("Mail sent <b>ok</b>. Please check your email in a few minutes. If you received an email, then mail is setup correctly. If you got any errors or you did not receive any email, please contact your host as mail may not be available to you, or it is not working properly. <b> REMOVE THIS FILE AFTER USE </b>");
} Else {
exit("Sending mail <b>failed</b>. Please contact your host as php mail may not be available to you, or it is not working properly.");
}

}
?>

<form action="<?=$_SERVER['PHP_SELF'];?>" method="post">
Your Email: <input type="text" name="email"> <input type="hidden" name="submit" value="true"> <input type="submit" value=" Test Email ">
</form>
</body>
</html>

 

Message script PHP

This message board doesn’t require any SQL databases. It stores all posts as HTML pages so it doesn’t take up much of the server resources (what is usually the case with larger flat-text database message boards) so it is ideal for shared hosting. Features include support for smileys, instant “New post” notification, easy deletion of inappropriate posts etc. It even comes with a bad words filter which replaces all bad words with **** in new posts and a powerful SPAM filter.

 

<?php
// >>> SETUP YOUR MESSAGE BOARD <<< //
// Detailed information found in the readme.htm file
// Settings file version: 1.3

// Password for admin area
$settings['apass']='admin';

// Website title
$settings['website_title']="My lovely website";

// Website URL
$settings['website_url']='http://www.domain.com/';

// Message board title
$settings['mboard_title']="My lovely website - message board";

// URL to folder where message board is installed
// DO NOT a trailing "/" !
$settings['mboard_url']='http://www.domain.com/mboard';

/* Prevent automated submissions (recommended YES)? 0 = NO, 1 = YES, GRAPHICAL, 2 = YES, TEXT */
$settings['autosubmit']=1;

/* Checksum - just type some digits and chars. Used to help prevent SPAM */
$settings['filter_sum']='d83hfdwg34';

/* Use JunkMark(tm) SPAM filter (recommended YES)? 1 = YES, 0 = NO */
$settings['junkmark_use']=1;

/* JunkMark(tm) score limit after which messages are marked as SPAM */
$settings['junkmark_limit']=60;

// Allow smileys? 1 = YES, 0 = NO
$settings['smileys']=1;

// Send you an e-mail when a new entry is added? 1 = YES, 0 = NO
$settings['notify']=1;

// Your e-mail. Only required if $settings['notify'] is set to 1.
$settings['admin_email']='you@yourdomain.com';

// Display IP number of members posting? 1 = YES, 0 = NO
$settings['display_IP']=1;

// Maximum number of posts displayed on the first page
$settings['maxposts']=50;

// Keep or delete old posts? 1 = KEEP, 0 = DELETE
$settings['keepoldmsg']=0;

// File exstention for message files
$settings['extension']='html';

/* Filter bad words? 1 = YES, 0 = NO */
$settings['filter']=1;

/* Filter language. Please refer to readme for info on how to add more bad words
to the list! */

$settings['filter_lang']='en';

/* DO NOT EDIT BELOW */
if (!defined('IN_SCRIPT')) {die('Invalid attempt!');}
?>