"); print_r($str); print(""); } } // ############################################################################################ // NEWSLETTER SIGNUP FORM SETTINGS /* These variables are referenced in the following file: - newsletter-process.php - process.php */ $elistid = 's2o_swiftfoxcabslz'; //ElistManager ID no. // ############################################################################################ // CUSTOM ADMIN SETTINGS /* These variables are referenced in the following files: - edit/themes/default/defaultTheme.php - edit/custom-admin/index.php - edit/custom-admin/user_admin.php */ //Enable custom admin (Adds extra button to CMS top menu for additional functionality) $custom_admin = 0; //1=yes; 0=no. If set to 1, make sure edit/custom-admin/_CUSTOM_ADMIN_SETUP.php is edited as well. //Menu text $custom_admin_menutext = "Support Admin"; //Menu text for link on main CMS menu bar //Modules $custom_admin_modules = array( //Add modules to this array using the format: module_name => 'module_url.php' //Module name should be how you want it to be displayed but convetred to lowercase with spaces converted to underscores. //Comment out items to disable. 'user_admin' => 'user_admin.php', //Enable user admin section (If enabled, configure USER ADMIN SETTINGS below) 'password_protected_pages' => 'password_protected_pages.php', //Enable protected pages section --- MAKE SURE REDIRECT URL IS SET TO CORRECT PAGE IN login.php IN ROOT FOLDER ); //User Admin settings (not required if not using user_admin module) $enable_add_user = 1; //Include ability for admin to manually add users (adds a link to 'add_user.php' on 'user_admin.php') // ############################################################################################ // USER ADMIN SETTINGS /* These variables are referenced in the following files: - edit/custom-admin/user_admin.php - edit/custom-admin/pending_users.php - edit/custom-admin/add_user.php */ // LOGIN REMINDER EMAIL: // (Can be manually sent to a user by the administrator) // Used by edit/custom-admin/user_admin.php // IMPORTANT: Also make sure the form fields and SQL fields are updated as required in edit/custom-admin/user_admin.php // These will vary depending on what data is being recorded against each user (e.g. Name, Address, Company, etc.) //Subject line of login reminder email $loginreminder_emailsubject = "website account details reminder"; //Text to go at start of login reminder email (before username and password) $loginreminder_emailcontent_start = "

This is a reminder of your login details.

Your username and password are:

"; //Text to go at end of login reminder email (after username and password) $loginreminder_emailcontent_end = "

Kind regards

"; // ACCOUNT ACTIVATION EMAIL: // (Is automatically sent to a user when their pending account is activated by the administrator.) // Used by edit/custom-admin/pending_users.php //Subject line of account activation email $accountactivation_emailsubject = "website account activation"; //Text to go at start of account activation email (before username and password) $accountactivation_emailcontent_start = "

Your account is now active.

Your username and password are:

"; //Text to go at end of account activation email (after username and password) $accountactivation_emailcontent_end = "

Kind regards

"; // ACCOUNT SETUP EMAIL: // (Is automatically sent to a user when a new account is set up for them by the administrator.) // Used by edit/custom-admin/add_user.php // IMPORTANT: Also make sure the form fields and SQL fields are updated as required in edit/custom-admin/add_user.php // These will vary depending on what data is being recorded against each user (e.g. Name, Address, Company, etc.) //Subject line of account setup email $newaccount_emailsubject = "website account setup"; //Text to go at start of account setup email (before username and password) $newaccount_emailcontent_start = "

We have just set up a new account for you.

Your username and password are:

"; //Text to go at end of account setup email (after username and password) $newaccount_emailcontent_end = "

Please do not disclose your account details to anyone else. If you ever forget your password there is a facility on the website to request a new one. To change the email address (username) you use to log in to your account, please contact us directly.

Kind regards

"; // ############################################################################################ // USER REGISTRATION SETTINGS /* These variables are referenced in the following file: - register.php */ // REGISTRATION AUTORESPONDSER EMAIL: // (Is automatically sent to a user when they register) // Used by register.php // IMPORTANT: Also make sure the form fields in the CMS registration page form, SQL fields in register.php, and database fields are updated as required. // These will vary depending on what data is being recorded against each user (e.g. Name, Address, Company, etc.) // NOTE: When a user registers they are added to the 'pending users' list. Each user has to be activated by the administrator before they are actually registered. // (****Still need to build in functionality to enable/disable this feature**** //Subject line of registration autoresponder email $registration_emailsubject = "Website Registration"; //Registration form labels/field names (These fields must match the fields in the 'users' database table, and the form and SQL fields in edit/custom-admin/user_admin.php and CMS registration page form) $registration_fields = array( "Name" => "name", "Company" => "company", "Address" => "address", "Telephone" => "phone", "Email" => "email" ); //Text for registration autoresponder email $registration_auto_responder_text = "

Thank you for registering.

We'll be in touch shortly with further details.

Kind regards

"; //If set to 1 sends a notification email to the administrator. $registration_notify_admin = 1; //Email address where registration notification email should be sent to (usually the administrator), if $notify_admin = 1 $registration_notify_admin_sendto = ""; // ############################################################################################ // USER LOGIN SETTINGS /* These variables are referenced in the following file: - login.php */ //Page to redirect to when logged in $login_redirect_url = 'some-page.html'; // ############################################################################################ // FORGOTTEN PASSWORD SETTINGS /* These variables are referenced in the following file: - forgotten-password.php */ //Subject line for password reset email $forgottenpass_emailsubject = "New Password for Website"; //Text to go at start of password reset email (before username and password) $forgottenpass_emailcontent_start = "

Please find your new login details below.

"; //Text to go at end of password reset email (after username and password) $forgottenpass_emailcontent_end = "

If you have any further problems please contact us with any questions you may have.

Best regards

;" ?> aFonts = $aFonts; $this->SetNumChars(CAPTCHA_NUM_CHARS); $this->SetNumLines(CAPTCHA_NUM_LINES); $this->DisplayShadow(CAPTCHA_CHAR_SHADOW); $this->SetOwnerText(CAPTCHA_OWNER_TEXT); $this->SetCharSet(CAPTCHA_CHAR_SET); $this->CaseInsensitive(CAPTCHA_CASE_INSENSITIVE); $this->SetBackgroundImages(CAPTCHA_BACKGROUND_IMAGES); $this->SetMinFontSize(CAPTCHA_MIN_FONT_SIZE); $this->SetMaxFontSize(CAPTCHA_MAX_FONT_SIZE); $this->UseColour(CAPTCHA_USE_COLOUR); $this->SetFileType(CAPTCHA_FILE_TYPE); $this->SetWidth($iWidth); $this->SetHeight($iHeight); } function CalculateSpacing() { $this->iSpacing = (int)($this->iWidth / $this->iNumChars); } function SetWidth($iWidth) { $this->iWidth = $iWidth; if ($this->iWidth > 500) $this->iWidth = 500; // to prevent perfomance impact $this->CalculateSpacing(); } function SetHeight($iHeight) { $this->iHeight = $iHeight; if ($this->iHeight > 200) $this->iHeight = 200; // to prevent performance impact } function SetNumChars($iNumChars) { $this->iNumChars = $iNumChars; $this->CalculateSpacing(); } function SetNumLines($iNumLines) { $this->iNumLines = $iNumLines; } function DisplayShadow($bCharShadow) { $this->bCharShadow = $bCharShadow; } function SetOwnerText($sOwnerText) { $this->sOwnerText = $sOwnerText; } function SetCharSet($vCharSet) { // check for input type if (is_array($vCharSet)) { $this->aCharSet = $vCharSet; } else { if ($vCharSet != '') { // split items on commas $aCharSet = explode(',', $vCharSet); // initialise array $this->aCharSet = array(); // loop through items foreach ($aCharSet as $sCurrentItem) { // a range should have 3 characters, otherwise is normal character if (strlen($sCurrentItem) == 3) { // split on range character $aRange = explode('-', $sCurrentItem); // check for valid range if (count($aRange) == 2 && $aRange[0] < $aRange[1]) { // create array of characters from range $aRange = range($aRange[0], $aRange[1]); // add to charset array $this->aCharSet = array_merge($this->aCharSet, $aRange); } } else { $this->aCharSet[] = $sCurrentItem; } } } } } function CaseInsensitive($bCaseInsensitive) { $this->bCaseInsensitive = $bCaseInsensitive; } function SetBackgroundImages($vBackgroundImages) { $this->vBackgroundImages = $vBackgroundImages; } function SetMinFontSize($iMinFontSize) { $this->iMinFontSize = $iMinFontSize; } function SetMaxFontSize($iMaxFontSize) { $this->iMaxFontSize = $iMaxFontSize; } function UseColour($bUseColour) { $this->bUseColour = $bUseColour; } function SetFileType($sFileType) { // check for valid file type if (in_array($sFileType, array('gif', 'png', 'jpeg'))) { $this->sFileType = $sFileType; } else { $this->sFileType = 'jpeg'; } } function DrawLines() { for ($i = 0; $i < $this->iNumLines; $i++) { // allocate colour if ($this->bUseColour) { $iLineColour = imagecolorallocate($this->oImage, rand(100, 250), rand(100, 250), rand(100, 250)); } else { $iRandColour = rand(100, 250); $iLineColour = imagecolorallocate($this->oImage, $iRandColour, $iRandColour, $iRandColour); } // draw line imageline($this->oImage, rand(0, $this->iWidth), rand(0, $this->iHeight), rand(0, $this->iWidth), rand(0, $this->iHeight), $iLineColour); } } function DrawOwnerText() { // allocate owner text colour $iBlack = imagecolorallocate($this->oImage, 0, 0, 0); // get height of selected font $iOwnerTextHeight = imagefontheight(2); // calculate overall height $iLineHeight = $this->iHeight - $iOwnerTextHeight - 4; // draw line above text to separate from CAPTCHA imageline($this->oImage, 0, $iLineHeight, $this->iWidth, $iLineHeight, $iBlack); // write owner text imagestring($this->oImage, 2, 3, $this->iHeight - $iOwnerTextHeight - 3, $this->sOwnerText, $iBlack); // reduce available height for drawing CAPTCHA $this->iHeight = $this->iHeight - $iOwnerTextHeight - 5; } function GenerateCode() { // reset code $this->sCode = ''; // loop through and generate the code letter by letter for ($i = 0; $i < $this->iNumChars; $i++) { if (count($this->aCharSet) > 0) { // select random character and add to code string $this->sCode .= $this->aCharSet[array_rand($this->aCharSet)]; } else { // select random character and add to code string $this->sCode .= chr(rand(65, 90)); } } // save code in session variable if ($this->bCaseInsensitive) { $_SESSION[CAPTCHA_SESSION_ID] = strtoupper($this->sCode); $GLOBALS[CAPTCHA_SESSION_ID] = strtoupper($this->sCode); } else { $_SESSION[CAPTCHA_SESSION_ID] = $this->sCode; $GLOBALS[CAPTCHA_SESSION_ID] = $this->sCode; } } function DrawCharacters() { // loop through and write out selected number of characters for ($i = 0; $i < strlen($this->sCode); $i++) { // select random font $sCurrentFont = $this->aFonts[array_rand($this->aFonts)]; // select random colour if ($this->bUseColour) { $iTextColour = imagecolorallocate($this->oImage, rand(0, 100), rand(0, 100), rand(0, 100)); if ($this->bCharShadow) { // shadow colour $iShadowColour = imagecolorallocate($this->oImage, rand(0, 100), rand(0, 100), rand(0, 100)); } } else { $iRandColour = rand(0, 100); $iTextColour = imagecolorallocate($this->oImage, $iRandColour, $iRandColour, $iRandColour); if ($this->bCharShadow) { // shadow colour $iRandColour = rand(0, 100); $iShadowColour = imagecolorallocate($this->oImage, $iRandColour, $iRandColour, $iRandColour); } } // select random font size $iFontSize = rand($this->iMinFontSize, $this->iMaxFontSize); // select random angle $iAngle = rand(-30, 30); // get dimensions of character in selected font and text size $aCharDetails = imageftbbox($iFontSize, $iAngle, $sCurrentFont, $this->sCode[$i], array()); // calculate character starting coordinates $iX = $this->iSpacing / 4 + $i * $this->iSpacing; $iCharHeight = $aCharDetails[2] - $aCharDetails[5]; $iY = $this->iHeight / 2 + $iCharHeight / 4; // write text to image imagefttext($this->oImage, $iFontSize, $iAngle, $iX, $iY, $iTextColour, $sCurrentFont, $this->sCode[$i], array()); if ($this->bCharShadow) { $iOffsetAngle = rand(-30, 30); $iRandOffsetX = rand(-5, 5); $iRandOffsetY = rand(-5, 5); imagefttext($this->oImage, $iFontSize, $iOffsetAngle, $iX + $iRandOffsetX, $iY + $iRandOffsetY, $iShadowColour, $sCurrentFont, $this->sCode[$i], array()); } } } function writeDB($id) { $handle = mysql_connect(CAPTCHA_DB_HOST, CAPTCHA_DB_USER, CAPTCHA_DB_PASS) or die('Could not connect: ' . mysql_error()); mysql_select_db(CAPTCHA_DB_NAME) or die('Could not select database'); // check to see if exists first $sql = "SELECT 1 from captcha WHERE id='".$id."'"; $data = mysql_query($sql); if(mysql_num_rows($data)>0) { $sql="UPDATE captcha SET idcode='".$this->sCode."' WHERE id='".$id."'"; } else { $sql="INSERT INTO captcha (id,idcode) values ('".$id."','".$this->sCode."')"; } mysql_query($sql); mysql_close(); } function WriteFile($sFilename) { if ($sFilename == '') { // tell browser that data is jpeg header("Content-type: image/$this->sFileType"); } switch ($this->sFileType) { case 'gif': $sFilename != '' ? imagegif($this->oImage, $sFilename) : imagegif($this->oImage); break; case 'png': $sFilename != '' ? imagepng($this->oImage, $sFilename) : imagepng($this->oImage); break; default: $sFilename != '' ? imagejpeg($this->oImage, $sFilename) : imagejpeg($this->oImage); } } function Create($sFilename = '',$id) { // check for required gd functions if (!function_exists('imagecreate') || !function_exists("image$this->sFileType") || ($this->vBackgroundImages != '' && !function_exists('imagecreatetruecolor'))) { return false; } // get background image if specified and copy to CAPTCHA if (is_array($this->vBackgroundImages) || $this->vBackgroundImages != '') { // create new image $this->oImage = imagecreatetruecolor($this->iWidth, $this->iHeight); // create background image if (is_array($this->vBackgroundImages)) { $iRandImage = array_rand($this->vBackgroundImages); $oBackgroundImage = imagecreatefromjpeg($this->vBackgroundImages[$iRandImage]); } else { $oBackgroundImage = imagecreatefromjpeg($this->vBackgroundImages); } // copy background image imagecopy($this->oImage, $oBackgroundImage, 0, 0, 0, 0, $this->iWidth, $this->iHeight); // free memory used to create background image imagedestroy($oBackgroundImage); } else { // create new image $this->oImage = imagecreate($this->iWidth, $this->iHeight); } // allocate white background colour imagecolorallocate($this->oImage, 255, 255, 255); // check for owner text if ($this->sOwnerText != '') { $this->DrawOwnerText(); } // check for background image before drawing lines if (!is_array($this->vBackgroundImages) && $this->vBackgroundImages == '') { $this->DrawLines(); } $this->GenerateCode(); $this->DrawCharacters(); $sql = $this->writeDB($id); // write out image to file or browser $this->WriteFile($sFilename); // free memory used in creating image imagedestroy($this->oImage); return $this->sCode; } // call this method statically function Validate($sUserCode, $bCaseInsensitive = true) { if ($bCaseInsensitive) { $sUserCode = strtoupper($sUserCode); } if (!empty($_SESSION[CAPTCHA_SESSION_ID]) && $sUserCode == $_SESSION[CAPTCHA_SESSION_ID]) { // clear to prevent re-use unset($_SESSION[CAPTCHA_SESSION_ID]); return true; } return false; } } // this class will only work correctly if a visual CAPTCHA has been created first using PhpCaptcha class AudioPhpCaptcha { var $sFlitePath; var $sAudioPath; var $sCode; function AudioPhpCaptcha( $sFlitePath = CAPTCHA_FLITE_PATH, // path to flite binary $sAudioPath = CAPTCHA_AUDIO_PATH // the location to temporarily store the generated audio CAPTCHA ) { $this->SetFlitePath($sFlitePath); $this->SetAudioPath($sAudioPath); // retrieve code if already set by previous instance of visual PhpCaptcha if (isset($_SESSION[CAPTCHA_SESSION_ID])) { $this->sCode = $_SESSION[CAPTCHA_SESSION_ID]; } } function SetFlitePath($sFlitePath) { $this->sFlitePath = $sFlitePath; } function SetAudioPath($sAudioPath) { $this->sAudioPath = $sAudioPath; } function Mask($sText) { $iLength = strlen($sText); // loop through characters in code and format $sFormattedText = ''; for ($i = 0; $i < $iLength; $i++) { // comma separate all but first and last characters if ($i > 0 && $i < $iLength - 1) { $sFormattedText .= ', '; } elseif ($i == $iLength - 1) { // precede last character with "and" $sFormattedText .= ' and '; } $sFormattedText .= $sText[$i]; } $aPhrases = array( "The %1\$s characters are as follows: %2\$s", "%2\$s, are the %1\$s letters", "Here are the %1\$s characters: %2\$s", "%1\$s characters are: %2\$s", "%1\$s letters: %2\$s" ); $iPhrase = array_rand($aPhrases); return sprintf($aPhrases[$iPhrase], $iLength, $sFormattedText); } function Create() { $sText = $this->Mask($this->sCode); $sFile = md5($this->sCode.time()); // create file with flite shell_exec("$this->sFlitePath -t \"$sText\" -o $this->sAudioPath$sFile.wav"); // set headers header('Content-type: audio/x-wav'); header("Content-Disposition: attachment;filename=$sFile.wav"); // output to browser echo file_get_contents("$this->sAudioPath$sFile.wav"); // delete temporary file @unlink("$this->sAudioPath$sFile.wav"); } } // example sub class class PhpCaptchaColour extends PhpCaptcha { function PhpCaptchaColour($aFonts, $iWidth = CAPTCHA_WIDTH, $iHeight = CAPTCHA_HEIGHT) { // call parent constructor parent::PhpCaptcha($aFonts, $iWidth, $iHeight); // set options $this->UseColour(true); } } ?>