| Server IP : 172.67.201.108 / Your IP : 216.73.216.101 Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5 System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/banners/domains/mcifa.com/public_html/ |
Upload File : |
<?php
/**
* Shared utility functions for mcifa.com PHP conversion
*/
require_once __DIR__ . '/mail_config.php';
/**
* HTML-escape shorthand for XSS protection
*/
function h($string) {
return htmlspecialchars((string)$string, ENT_QUOTES, 'UTF-8');
}
/**
* Check if the current user is logged in
*/
function isLoggedIn() {
return !empty($_SESSION['Member']) && $_SESSION['Member'] !== '-1' && $_SESSION['Member'] !== -1;
}
/**
* Require login - include error page and exit if not authenticated.
* Checks session first, then falls back to cookie.
*/
function requireLogin() {
// First check session
if (!empty($_SESSION['Member']) && $_SESSION['Member'] !== '' && $_SESSION['Member'] !== '-1' && $_SESSION['Member'] !== -1) {
return true;
}
// Fallback: check cookie
if (!empty($_COOKIE['Member']) && $_COOKIE['Member'] !== '') {
$_SESSION['Member'] = $_COOKIE['Member'];
return true;
}
// Not authorized
require __DIR__ . '/myErrorFile.php';
exit;
}
/**
* ColdFusion ParagraphFormat equivalent
* Converts double newlines to <p> tags and single newlines to <br>
*/
function paragraphFormat($text) {
$text = trim((string)$text);
if ($text === '') return '';
$text = str_replace("\r\n", "\n", $text);
$text = str_replace("\r", "\n", $text);
// Double newlines become paragraph breaks
$paragraphs = preg_split('/\n{2,}/', $text);
$result = '';
foreach ($paragraphs as $p) {
$p = nl2br(trim($p));
$result .= "<p>{$p}</p>\n";
}
return $result;
}
/**
* Port of CF_MakeLinks custom tag
* Converts URLs in text to clickable links, images to <img> tags,
* and emoticon strings to emoji images
*/
function makeLinks($text, $protos = 'http,https,ftp,telnet,gopher,mailto') {
$input = (string)$text;
$input = str_replace('</p>', ' ', $input);
$protoList = explode(',', $protos);
$raw = [];
// Find URLs for each protocol
foreach ($protoList as $proto) {
$proto = trim($proto);
$prefix = ($proto === 'mailto') ? $proto . ':' : $proto . '://';
$pos = 0;
while (($found = stripos($input, $prefix, $pos)) !== false) {
// Extract the URL token (until whitespace)
$rest = substr($input, $found);
if (preg_match('/^(\S+)/', $rest, $m)) {
$raw[] = $m[1];
$pos = $found + strlen($m[1]);
} else {
break;
}
}
}
// Refine URLs - strip trailing punctuation
foreach ($raw as &$url) {
while (strlen($url) > 0) {
$last = substr($url, -1);
if (in_array($last, [',', ';', ':', '.', ')', '('])) {
$url = substr($url, 0, -1);
} else {
break;
}
}
}
unset($url);
// Replace URLs with HTML
$out = $input;
foreach ($raw as $url) {
$isGif = (stripos($url, '.gif') !== false);
$isJpg = (stripos($url, '.jpg') !== false);
if ($isGif || $isJpg) {
$out = str_replace($url, '<img src="' . $url . '">', $out);
// Clean up nested tags
$out = str_ireplace('<img src=<img src=', '<img src=', $out);
$out = str_ireplace('>>', '>', $out);
} else {
$out = str_replace($url, '<a target="new" href="' . $url . '">' . $url . '</a>', $out);
}
}
// Emoticon replacements
$emoticons = [
':-)' => '<img src="happy.gif">',
';-)' => '<img src="wink.gif">',
':-(' => '<img src="sad.gif">',
';)' => '<img src="wink.gif">',
':(' => '<img src="sad.gif">',
':-D' => '<img src="icon_smile_big.gif">',
':D' => '<img src="icon_smile_big.gif">',
'8-)' => '<img src="icon_smile_cool.gif">',
'8)' => '<img src="icon_smile_cool.gif">',
']:o(' => '<img src="fire.gif">',
']:o)' => '<img src="evilgrin.gif">',
'@.@' => '<img src="rolleyes.gif">',
'8-o' => '<img src="surprised.gif">',
'):)' => '<img src="heart.gif">',
':lol:' => '<img src="laugh.gif">',
'8-O' => '<img src="scared.gif">',
];
foreach ($emoticons as $code => $img) {
$out = str_replace($code, $img, $out);
}
// Handle paragraph vs line break output
if (substr(trim($out), 0, 3) === '<P>') {
$out = str_replace(' ', ' ', $out);
} else {
$out = str_replace(["\r\n", "\n"], '<br>', $out);
}
return $out;
}
/**
* Build parameterized search criteria for dynamic WHERE clauses
* Port of CurrentSearch_AppendCriteria.cfm
*
* @return array ['sql' => string, 'params' => array]
*/
function buildSearchCriteria($fieldName, $fieldType, $operator, $value) {
$sql = '';
$params = [];
$fieldType = strtoupper($fieldType);
if (in_array($fieldType, ['CHAR', 'MEMO'])) {
switch (strtoupper($operator)) {
case 'EQUAL':
$sql = "{$fieldName} = ?";
$params[] = $value;
break;
case 'NOT_EQUAL':
$sql = "{$fieldName} <> ?";
$params[] = $value;
break;
case 'GREATER_THAN':
$sql = "{$fieldName} > ?";
$params[] = $value;
break;
case 'SMALLER_THAN':
$sql = "{$fieldName} < ?";
$params[] = $value;
break;
case 'CONTAINS':
$sql = "{$fieldName} LIKE ?";
$params[] = '%' . $value . '%';
break;
case 'BEGINS_WITH':
$sql = "{$fieldName} LIKE ?";
$params[] = $value . '%';
break;
case 'ENDS_WITH':
$sql = "{$fieldName} LIKE ?";
$params[] = '%' . $value;
break;
}
} elseif (in_array($fieldType, ['INT', 'FLOAT', 'BIT', 'DATETIME'])) {
switch (strtoupper($operator)) {
case 'EQUAL':
$sql = "{$fieldName} = ?";
$params[] = $value;
break;
case 'NOT_EQUAL':
$sql = "{$fieldName} <> ?";
$params[] = $value;
break;
case 'GREATER_THAN':
$sql = "{$fieldName} > ?";
$params[] = $value;
break;
case 'SMALLER_THAN':
$sql = "{$fieldName} < ?";
$params[] = $value;
break;
}
}
return ['sql' => $sql, 'params' => $params];
}
/**
* Send an email using PHP mail() with configured SMTP
* Centralizes email sending previously scattered across send*.cfm files
*/
function sendEmail($to, $from, $subject, $body, $fromName = '') {
if (empty($fromName)) {
$fromName = DEFAULT_FROM_NAME;
}
$headers = "From: {$fromName} <{$from}>\r\n";
$headers .= "Reply-To: {$from}\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
return mail($to, $subject, $body, $headers);
}