* '; $FORM_NOT_REQUIRED_ITEM = '   '; $PER_SOCKET_SEND = 50; // used by the editor pages - autoresponders, compose, templates - to fix up improper characters. $BAD_ENCODED_CHARS = array('•'); $PROPER_ENCODED_CHARS = array('•'); $safe_mode = ini_get('safe_mode'); if (strtolower($safe_mode) == 'off') $safe_mode = 0; if (strtolower($safe_mode) == 'on') $safe_mode = 1; define('SAFE_MODE', $safe_mode); if (defined('SENDSTUDIO_VERSION') && SENDSTUDIO_VERSION == 2004) { function DisplayDate($Date){ GLOBAL $DateFormat; return date($DateFormat, $Date); } } if( !function_exists( 'html_entity_decode' ) ) { function html_entity_decode( $given_html, $quote_style = ENT_QUOTES ) { $trans_table = array_flip(get_html_translation_table( HTML_SPECIALCHARS, $quote_style )); $trans_table['''] = "'"; return ( strtr( $given_html, $trans_table ) ); } } /* This is used by the scheduler in case a newsletter is 'deleted' from the schedule. It is also called from send.php in case you get part way through creating a schedule and stop. */ function ResetPerMonth($SendID=0, $reset_amount=0) { global $CURRENTADMIN, $TABLEPREFIX; if ($reset_amount > 0) { $query = "UPDATE " . $TABLEPREFIX . "sends_permonth SET EmailsSent=EmailsSent - " . (int)$reset_amount . " WHERE AdminID='" . addslashes($CURRENTADMIN['AdminID']) . "' AND SendID='" . addslashes($SendID) . "' LIMIT 1"; } else { $query = "DELETE FROM " . $TABLEPREFIX . "sends_permonth WHERE AdminID='" . addslashes($CURRENTADMIN['AdminID'])."' AND SendID='" . addslashes($SendID) . "'"; } mysql_query($query); } /* This makes sure you have enough available 'slots' to send a newsletter to your list. It also updates itself and records how many you're about to send to. */ function CheckPerMonthSend($tosend=0, $ListID=0, $SendID=0, $time=0, $sendtype='Send') { global $CURRENTADMIN, $TABLEPREFIX, $SYSTEMTIME; if ($time == 0) $time = time(); $thismonth = mktime (0,0,1,date("m", $time),1,date("Y", $time)); $insert_query = "INSERT INTO " . $TABLEPREFIX . "sends_permonth (ThisMonth, AdminID, EmailsSent, ListID, TimeStamp, SendID, SendType) VALUES ('" . addslashes($thismonth) . "', '" . addslashes($CURRENTADMIN['AdminID']) . "', '" . addslashes($tosend) . "', '" . addslashes($ListID)."', '" . addslashes($SYSTEMTIME) . "', '" . addslashes($SendID)."', '" . addslashes($sendtype)."')"; if ($CURRENTADMIN['PerMonth'] <= 0) { mysql_query($insert_query); return true; } $query = "SELECT SUM(EmailsSent) AS EmailsSent FROM " . $TABLEPREFIX . "sends_permonth WHERE ThisMonth='" . addslashes($thismonth) . "' AND AdminID='" . addslashes($CURRENTADMIN['AdminID'])."'"; $result = mysql_query($query); if (mysql_num_rows($result) > 0) { $row = mysql_fetch_assoc($result); $emailssent = $row['EmailsSent']; } else { $emailssent = 0; } $emailssent = $emailssent + $tosend; if ($emailssent > $CURRENTADMIN['PerMonth']) { return false; } mysql_query($insert_query); return true; } function DisplayStrfDate($Date) { GLOBAL $StrDateFormat; return strftime($StrDateFormat, $Date); } function TableExists($tablename='') { global $TABLEPREFIX; if (!$tablename) return false; $qry = "SHOW TABLES LIKE '" . $TABLEPREFIX . $tablename . "'"; $result = mysql_query($qry); if (mysql_num_rows($result) > 0) return true; return false; } function LicenseCheck($die=true) { $LicenseError = ""; ssQmz44Rtt($LicenseError); // if this is defined, we should be doing the check (we're using a new license). // otherwise we're in the middle of an upgrade - forget the check! if (defined('SENDSTUDIO_VERSION') && SENDSTUDIO_VERSION == '2004') { if($LicenseError != "") { $GLOBALS['LicenseError'] = $LicenseError; $errormsg = "Your license key is invalid."; global $CURRENTADMIN; if ($CURRENTADMIN['Root'] && $CURRENTADMIN['Manager']) { $errormsg .= " ($LicenseError.) Click here to update your license key."; } else { $errormsg .= " Please contact your administrator."; } if ($die) { OutputPageHeader(false); ?>
Set('CharSet', SENDSTUDIO_ENCODING); if ($CURRENTADMIN['EmailServer'] || $CURRENTADMIN['EmailServer'] != '') { if (strpos($CURRENTADMIN['EmailServer'], ';') !== false) { list($servername, $username, $password) = explode(';', str_replace(' ', '', $CURRENTADMIN['EmailServer'])); } else { $servername = $CURRENTADMIN['EmailServer']; $username = $password = false; } $Email_API->SetSmtp($servername, $username, $password); } $Email_API->Set('FromAddress', $PreviewEmail); $Email_API->Set('ReplyTo', $PreviewEmail); $Email_API->Set('BounceAddress', $PreviewEmail); $Email_API->Set('Subject', stripslashes($Subject)); switch($Format) { case 2: $format = 'html'; $Email_API->AddBody('html', stripslashes($HTMLBODY)); break; case 1: $format = 'text'; $Email_API->AddBody('text', stripslashes($TEXTBODY)); break; case 3: $format = 'html'; $Email_API->AddBody('html', stripslashes($HTMLBODY)); $Email_API->AddBody('text', stripslashes($TEXTBODY)); $Email_API->Set('Multipart', true); break; } $Email_API->AddRecipient($PreviewEmail, '', $format, 0); if (!empty($attachments) && $attachments[0] != '') { $attachment_filename_result = mysql_query("SELECT AttachmentName, AttachmentFilename FROM " . $TABLEPREFIX . "attachments WHERE AttachmentID IN (" . implode(',', $attachments) . ")"); while($attachment_row = mysql_fetch_assoc($attachment_filename_result)) { $attachment_file = dirname(dirname(__FILE__)) . '/' . $attachment_row['AttachmentFilename']; $Email_API->AddAttachment($attachment_file, $attachment_row['AttachmentName']); } } $mail_result = $Email_API->Send(false); if ($mail_result['success'] > 0) { $email_result = true; } else { $email_result = false; } return array($email_result, $Email_API->Get('Error')); } /* Used by the templates and newsletters so when you upload a file, it can grab the contents. */ function ReadUploadedFile($file='') { if ($file == '') return -1; if (!isset($_FILES[$file]['tmp_name'])) return -1; if (!is_uploaded_file($_FILES[$file]['tmp_name'])) return -1; $contentfile = (isset($_FILES[$file])) ? $_FILES[$file] : array(); if (empty($contentfile)) return -1; $filename = $_FILES[$file]['tmp_name']; $body = ''; if($fp = fopen($filename, 'rb')) { while(!feof($fp)) { $body .= fgets($fp, 1024); } $body = addslashes($body); fclose($fp); return $body; } return false; } /* Used everywhere to display the ShowHelp() mouseovers. Also has the mergepopup javascript used by newsletters, autoresponders and templates. */ function JavaScriptFunctions() { ?> 0){ $PageOut=$ROOTURL."admin/index.php?p=" . str_replace('?', '&', $Page) . "&SSID=$SSID"; }else{ $PageOut=$ROOTURL."admin/index.php?p=$Page&SSID=$SSID"; } return $PageOut; } function FinishOutput(){ GLOBAL $OUTPUT, $ROOTDIR; include $ROOTDIR."admin/includes/admin.inc.php"; } /* This function is used by the email importer and bounce processor. */ function ConnectEmail($hostname='', $username='', $password='', $emailport='110') { if (!$hostname || !$username || !$password || !$emailport) return array(false, "Please provide login information"); $username = stripslashes($username); if (strpos($username, " ") !== false) { $username = urlencode($username); } $password = stripslashes($password); if (strpos($password, " ") !== false) { $password = urlencode($password); } $inbox = @imap_open('{' . addslashes($hostname) . ':' . addslashes($emailport).'/pop3/notls}INBOX', $username, $password); if (!$inbox) { return array(false, imap_last_error()); } return array(true, $inbox); } if (!function_exists('array_fill')) { function array_fill($iStart, $iLen, $vValue) { $aResult = array(); for ($iCount = $iStart; $iCount < $iLen + $iStart; $iCount++) { $aResult[$iCount] = $vValue; } return $aResult; } } /* Used by view-archive page. */ function RetrieveArchive($archivedir='', $member=array()) { if (!$archivedir || !is_array($member)) return false; if (!is_dir($archivedir)) return false; $format = $member['Format']; if ($format == 1) { $filetype = 'txt'; $newsformat = 'TEXT'; } else { $filetype = 'html'; $newsformat = strtoupper($filetype); } $archivefile = $html_archivefile = false; $files = list_files($archivedir); foreach($files as $file) { $ext = substr($file, (strrpos($file, '.')+1)); if ($ext == 'html') $html_archivefile = $file; if ($ext == $filetype) { $archivefile = $file; } } // default to the html archive file if there is one.. // this is the one most people will want to see anyway. if ($html_archivefile) { $newsformat = 'HTML'; $archivefile = $html_archivefile; } // default to the html newsletter if we can't find the proper one. if (!$archivefile) $archivefile = $html_archivefile; if ($archivefile) { // read in the file. ob_start(); readfile($archivedir . '/' . $archivefile); $contents = ob_get_contents(); ob_end_clean(); } return array($newsformat, $contents); } /* Used by createemails.inc.php and compose.php (for previews). */ function add_attachments($attachments=array(), $boundary='') { if (empty($attachments) || $boundary == '') return ''; global $TABLEPREFIX; $EmailBody = ''; $basedir = dirname(dirname(__FILE__)); foreach($attachments as $attachmentid) { if ($attachmentid == '') continue; $attachment_filename_result = mysql_query("SELECT AttachmentName, AttachmentFilename FROM " . $TABLEPREFIX . "attachments WHERE AttachmentID='".addslashes($attachmentid)."'"); if (mysql_num_rows($attachment_filename_result) < 1) { continue; } $attachment_row = mysql_fetch_assoc($attachment_filename_result); $GLOBALS['AttachmentDetails'][$attachmentid] = array( 'AttachmentName' => $attachment_row['AttachmentName'], 'AttachmentFilename' => $attachment_row['AttachmentFilename'] ); $attachment_row = stripslashes_array($attachment_row); $attachmentfile = $basedir . '/' . $attachment_row['AttachmentFilename']; if (!is_file($attachmentfile)) continue; $EmailBody .= "--" . $boundary . "\n"; $EmailBody .= "Content-type: application/octet-stream;\n"; $EmailBody .= "Content-Disposition: attachment;"; $EmailBody .= " filename=\"" . $attachment_row['AttachmentName'] . "\"\n"; $EmailBody .= "Content-Transfer-Encoding: base64\n\n"; $fp = fopen($attachmentfile, 'rb'); $filedata = fread($fp, filesize($attachmentfile)); fclose($fp); $EmailBody .= chunk_split(base64_encode($filedata)) . "\n" . "\n"; } return $EmailBody; } // recursive function to remove slashes from an array or single keyword. function stripslashes_array($array) { if (is_array($array)) { $return = array(); foreach($array as $key => $value) { $key = stripslashes($key); if (is_array($value)) { $return[$key] = stripslashes_array($value); continue; } $return[$key] = stripslashes($value); } } else { $return = stripslashes($array); } return $return; } function remove_directory($directory='') { if (!is_dir($directory)) return true; if (!$handle = opendir($directory)) { return false; } while (($file = readdir($handle)) !== false) { if ($file == '.' || $file == '..') continue; $f = $directory . '/' . $file; if (is_dir($f)) { remove_directory($directory . '/' . $f); } if (is_file($f)) { if (!unlink($f)) { closedir($handle); return false; } } } closedir($handle); return true; } /* Used by newsletters and mailing lists to clean up after themselves when deleted. */ function remove_newsletter_archives($id, $type='list') { global $ROOTDIR; $type = strtolower($type); $status = false; if ($type == 'list') { $status = remove_directory('../archive/' . $id); } if ($type == 'compose') { global $TABLEPREFIX; $query = "SELECT ListID FROM " . $TABLEPREFIX . "sends WHERE ComposedID='" . addslashes($id) . "'"; $result = mysql_query($query); if (mysql_num_rows($result) < 1) return true; while($row = mysql_fetch_assoc($result)) { $status = remove_directory($ROOTDIR . '/archive/' . $row['ListID'] . '/' . $id); } } return $status; } /* Mainly used by the importer functions. */ function list_files($dir='', $skip_files = null) { if (empty($dir) || !is_dir($dir)) return false; $file_list = array(); if (!$handle = opendir($dir)) { return false; } while (($file = readdir($handle)) !== false) { if ($file == '.' || $file == '..') continue; if (is_file($dir.'/'.$file)) { if (empty($skip_files)) { $file_list[] = $file; continue; } if (!empty($skip_files)) { if (is_array($skip_files) && !in_array($file, $skip_files)) { $file_list[] = $file; } if (!is_array($skip_files) && $file != $skip_files) { $file_list[] = $file; } } } } closedir($handle); return $file_list; } /* This is used by the database importer. */ function MySQLConnect($hostname='', $username='', $password='', $database='') { if ($hostname == '' || $username == '' || $database == '') return array(false, 'Either your hostname, username or database name are missing.
Please try again.'); $new_connection = ($password) ? mysql_connect($hostname, $username, $password) : mysql_connect($hostname, $username); if (!$new_connection) return array(false, mysql_error()); $select_db = mysql_select_db($database, $new_connection); if (!$select_db) return array(false, mysql_error()); return array(true, $new_connection); } /* This is used by the file importer. */ function ParseImportFile($ImportID, $JustHeaders=false, $importfile = false) { GLOBAL $ROOTDIR; GLOBAL $data, $MaxFields, $headers, $t; GLOBAL $C, $OUTPUT; GLOBAL $TABLEPREFIX; $imp = mysql_fetch_assoc(mysql_query("SELECT * FROM " . $TABLEPREFIX . "imports WHERE ImportID='".addslashes($ImportID)."'")); $file = $ROOTDIR.'/temp/'.$ImportID; if ($importfile) $file = $ROOTDIR.'/'.$importfile; $recdim = str_replace("NEWLINE","\n",$imp['RecordDelim']); $feidim = str_replace("NEWLINE","\n",$imp['FieldDelim']); $feidim = str_replace("TAB","\t",$imp['FieldDelim']); if (function_exists('file_get_contents')) { $data = file_get_contents($file); } else { $data = implode('', file($file)); } // in case it's a Mac file... $data = str_replace("\r", "\n", $data); $data = str_replace("\n\n", "\n", $data); $lines = explode($recdim,$data); $foundheaders = false; foreach($lines as $line) { if($imp['Headers']==1 && !$foundheaders) { $foundheaders = true; $headers=$line; } else { $DataLines[]=$line; } //maximum fields! $numf=substr_count($line,$feidim)+1; if($numf>$MaxFields) { $MaxFields=$numf; } } //headers! if(!$headers) { for($r=1;$r<=$MaxFields;$r++) { $H[$r]="Field $r"; } } else { $fields=explode($feidim,$headers); $x=0; foreach($fields as $f) { $x++; $f=trim($f); $H[$x]=$f; } } //data if($DataLines) { foreach($DataLines as $dl) { $i=1; $t++; $fields=explode($feidim,$dl); foreach($fields as $f) { $D[$t][$H[$i]]=trim($f); $i++; } } } $all['Headers']=$H; $all['Data']=$D; return $all; } function load_member($memberid=0, $listid=0) { if ($memberid <= 0) return false; global $TABLEPREFIX; $member_query = "SELECT * FROM " . $TABLEPREFIX . "members WHERE MemberID='" . addslashes($memberid) . "'"; if ($listid) $member_query .= " AND ListID='" . addslashes($listid) . "'"; $member_result = mysql_query($member_query); $member = stripslashes_array(mysql_fetch_assoc($member_result)); return $member; } function getmicrotime() { list($usec, $sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec); } function timedifference($timedifference) { if ($timedifference < 60) { $timechange = number_format($timedifference, 0) . ' second'; if ($timedifference > 1) $timechange .= 's'; } if ($timedifference >= 60 && $timedifference < 3600) { $num_mins = floor($timedifference / 60); $timechange = number_format($num_mins, 0) . ' minute'; if ($num_mins > 1) $timechange .= 's'; } if ($timedifference >= 3600) { $hours = floor($timedifference/3600); $mins = floor($timedifference % 3600) / 60; $timechange = number_format($hours, 0) . ' hour'; if ($hours > 1) $timechange .= 's'; $timechange .= ' and ' . number_format($mins, 0) . ' minute'; if ($mins > 1) $timechange .= 's'; } return $timechange; } /* Used by the scheduler and the send popup to send an email if you're sending through an SMTP server. */ function SendEmail($to, $from, $msg, $server, $port=25) { if ($port <= 0) $port = 25; $username = $password = false; if (strpos($server, ';') !== false) { list($servername, $username, $password) = explode(';', str_replace(' ', '', $server)); $server = $servername; } $timeout = 10; $crlf = "\r\n"; if (!isset($GLOBALS['EMAIL_SOCKET']) || !is_resource($GLOBALS['EMAIL_SOCKET'])) { $socket = fsockopen($server, $port, $errno, $errstr, $timeout); if (!$socket) { return array(false, 'Unable to connect to email server'); } $response = get_lines($socket); $responsecode = substr($response, 0, 3); // connecting too frequently? put in a random sleep. if ($responsecode == '450') { sleep(rand(1, 10)); fclose($socket); return array(false, 'Mail server not accepting our connections: ' . $response); } // not connecting too frequently? Just log the error and return. if ($responsecode != '220') { fclose($socket); return array(false, 'Mail server not accepting our connections: ' . $response); } $GLOBALS['EMAIL_SOCKET'] = $socket; // say hi! $data = 'EHLO ' . $server . $crlf; if (!fputs($GLOBALS['EMAIL_SOCKET'], $data, strlen($data))) { fclose($GLOBALS['EMAIL_SOCKET']); unset($GLOBALS['EMAIL_SOCKET']); return array(false, 'Server not accepting data (EHLO) - no bytes written'); } $response = get_lines($GLOBALS['EMAIL_SOCKET']); $responses = explode($crlf, $response); $requireauth = false; if ($username && $password) { foreach($responses as $line) { if (preg_match('%250[\s|-]auth(.*?)login%i', $line)) $requireauth = true; } } if ($requireauth) { $data = "AUTH LOGIN" . $crlf; if (!fputs($GLOBALS['EMAIL_SOCKET'], $data, strlen($data))) { fclose($GLOBALS['EMAIL_SOCKET']); unset($GLOBALS['EMAIL_SOCKET']); return array(false, 'Server not accepting data (AUTH LOGIN) - no bytes written'); } $response = get_lines($GLOBALS['EMAIL_SOCKET']); $responsecode = substr($response, 0, 3); if ($responsecode != '334') { $data = 'QUIT' . $crlf; fputs($GLOBALS['EMAIL_SOCKET'], $data, strlen($data)); fclose($GLOBALS['EMAIL_SOCKET']); unset($GLOBALS['EMAIL_SOCKET']); return array(false, 'Email server doesn\'t support "AUTH LOGIN" authentication'); } $data = base64_encode($username) . $crlf; if (!fputs($GLOBALS['EMAIL_SOCKET'], $data, strlen($data))) { fclose($GLOBALS['EMAIL_SOCKET']); unset($GLOBALS['EMAIL_SOCKET']); return array(false, 'Server not accepting data (USERNAME) - no bytes written'); } $response = get_lines($GLOBALS['EMAIL_SOCKET']); $responsecode = substr($response, 0, 3); if ($responsecode != '334') { $data = 'QUIT' . $crlf; fputs($GLOBALS['EMAIL_SOCKET'], $data, strlen($data)); fclose($GLOBALS['EMAIL_SOCKET']); unset($GLOBALS['EMAIL_SOCKET']); return array(false, 'Server replied strangely when providing the username (' . $response . ')'); } $data = base64_encode($password) . $crlf; if (!fputs($GLOBALS['EMAIL_SOCKET'], $data, strlen($data))) { $data = 'QUIT' . $crlf; fputs($GLOBALS['EMAIL_SOCKET'], $data, strlen($data)); fclose($GLOBALS['EMAIL_SOCKET']); unset($GLOBALS['EMAIL_SOCKET']); return array(false, 'Server not accepting data (PASSWORD) - no bytes written'); } $response = get_lines($GLOBALS['EMAIL_SOCKET']); $responsecode = substr($response, 0, 3); if ($responsecode != '235') { $data = 'QUIT' . $crlf; fputs($GLOBALS['EMAIL_SOCKET'], $data, strlen($data)); fclose($GLOBALS['EMAIL_SOCKET']); unset($GLOBALS['EMAIL_SOCKET']); return array(false, 'Invalid login details when connecting to smtp server'); } } } $data = "MAIL FROM: <" . $from . ">" . $crlf; if (!fputs($GLOBALS['EMAIL_SOCKET'], $data, strlen($data))) { $data = 'QUIT' . $crlf; fputs($GLOBALS['EMAIL_SOCKET'], $data, strlen($data)); fclose($GLOBALS['EMAIL_SOCKET']); unset($GLOBALS['EMAIL_SOCKET']); return array(false, 'Server not accepting data (MAIL FROM) - no bytes written'); } $response = get_lines($GLOBALS['EMAIL_SOCKET']); $responsecode = substr($response, 0, 3); if ($responsecode != '250') { $data = 'QUIT' . $crlf; fputs($GLOBALS['EMAIL_SOCKET'], $data, strlen($data)); fclose($GLOBALS['EMAIL_SOCKET']); unset($GLOBALS['EMAIL_SOCKET']); return array(false, 'Server doesn\'t support MAIL FROM (' . $response . ')'); } $data = "RCPT TO: <" . $to . ">" . $crlf; if (!fputs($GLOBALS['EMAIL_SOCKET'], $data, strlen($data))) { $data = 'QUIT' . $crlf; fputs($GLOBALS['EMAIL_SOCKET'], $data, strlen($data)); fclose($GLOBALS['EMAIL_SOCKET']); unset($GLOBALS['EMAIL_SOCKET']); return array(false, 'Server not accepting data (RCPT TO) - no bytes written'); } $response = get_lines($GLOBALS['EMAIL_SOCKET']); $responsecode = substr($response, 0, 3); if ($responsecode != '250') { $data = 'QUIT' . $crlf; fputs($GLOBALS['EMAIL_SOCKET'], $data, strlen($data)); fclose($GLOBALS['EMAIL_SOCKET']); unset($GLOBALS['EMAIL_SOCKET']); return array(false, 'Server doesn\'t support RCPT TO (' . $response . ')'); } $data = "DATA" . $crlf; if (!fputs($GLOBALS['EMAIL_SOCKET'], $data, strlen($data))) { $data = 'QUIT' . $crlf; fputs($GLOBALS['EMAIL_SOCKET'], $data, strlen($data)); fclose($GLOBALS['EMAIL_SOCKET']); unset($GLOBALS['EMAIL_SOCKET']); return array(false, 'Server not accepting data (DATA) - no bytes written'); } $response = get_lines($GLOBALS['EMAIL_SOCKET']); $responsecode = substr($response, 0, 3); if ($responsecode != '354') { $data = 'QUIT' . $crlf; fputs($GLOBALS['EMAIL_SOCKET'], $data, strlen($data)); fclose($GLOBALS['EMAIL_SOCKET']); unset($GLOBALS['EMAIL_SOCKET']); return array(false, 'Server doesn\'t support DATA (' . $response . ')'); } $msg = str_replace("\r\n","\n",$msg); $msg = str_replace("\r","\n",$msg); $lines = explode("\n",$msg); foreach($lines as $no => $line) { $data = $line . $crlf; if (!fputs($GLOBALS['EMAIL_SOCKET'], $data, strlen($data))) { $data = 'QUIT' . $crlf; fputs($GLOBALS['EMAIL_SOCKET'], $data, strlen($data)); fclose($GLOBALS['EMAIL_SOCKET']); unset($GLOBALS['EMAIL_SOCKET']); return array(false, 'Server not accepting data (CONTENT) - no bytes written'); } } $data = $crlf . "." . $crlf; if (!fputs($GLOBALS['EMAIL_SOCKET'], $data, strlen($data))) { $data = 'QUIT' . $crlf; fputs($GLOBALS['EMAIL_SOCKET'], $data, strlen($data)); fclose($GLOBALS['EMAIL_SOCKET']); unset($GLOBALS['EMAIL_SOCKET']); return array(false, 'Server not accepting data ( . - END OF MESSAGE ) - no bytes written'); } $response = get_lines($GLOBALS['EMAIL_SOCKET']); $responsecode = substr($response, 0, 3); if ($responsecode != '250') { $data = 'QUIT' . $crlf; fputs($GLOBALS['EMAIL_SOCKET'], $data, strlen($data)); fclose($GLOBALS['EMAIL_SOCKET']); unset($GLOBALS['EMAIL_SOCKET']); return array(false, 'Message not queued (' . $response . ')'); } return array(true, false); } function get_lines($socket=false) { if (!$socket) return; $data = ""; while($str = fgets($socket,515)) { $data .= $str; # if the 4th character is a space then we are done reading # so just break the loop if(substr($str,3,1) == " ") { break; } } return trim($data); } /* This is used by the 'manage members' and 'stats' pages. It turns an array into a urlencoded string. */ function EncodeFields($Fields=array(), $prefix='Fields') { $urldata = ''; if($Fields) { foreach($Fields as $FID=>$FVAL) { if (is_array($FVAL)) { // if it's a date box, we need to check whether it's enabled first or not before adding it to the string. if (isset($FVAL['type']) && !isset($FVAL['enable'])) continue; $FVAL = serialize($FVAL); } if ($FVAL == '') continue; $urldata .= $prefix . '[' . $FID . ']=' . urlencode(stripslashes($FVAL)) . '&'; } } return $urldata; } function ReplaceLinksAndImages($Content, $Format) { global $CURRENTADMIN; global $ROOTURL; global $TABLEPREFIX; if (TableExists('images')) { //images if($CURRENTADMIN["Manager"] == 1) { $images=mysql_query("SELECT * FROM " . $TABLEPREFIX . "images"); } else { $images=mysql_query("SELECT * FROM " . $TABLEPREFIX . "images WHERE AdminID='" . addslashes($CURRENTADMIN['AdminID']) . "'"); } while($i = mysql_fetch_assoc($images)) { $i = stripslashes_array($i); if($Format == "html") { $tv = ''; } else { $tv = $ROOTURL . '/temp/images/' . $i["ImageID"] . "." . $i["ImageType"]; } $protocol = substr($ROOTURL, 0, strpos($ROOTURL, ':')); $tv = str_replace($protocol.':/', $protocol.'://', str_replace('//', '/', $tv)); $Content = str_replace('%IMAGE:' . $i['ImageID'] . '%', $tv, $Content); } } if (TableExists('links')) { //links! if($CURRENTADMIN['Manager'] == 1) { $links = mysql_query("SELECT * FROM " . $TABLEPREFIX . "links"); } else { $links = mysql_query("SELECT * FROM " . $TABLEPREFIX . "links WHERE AdminID='" . addslashes($CURRENTADMIN["AdminID"]) . "'"); } while($l = mysql_fetch_assoc($links)) { $l = stripslashes_array($l); if($Format == 'html') { $tv = '= $max_depth) { return $indent."[Max Depth Reached]\n"; } if (empty($array)) return $indent."[Empty]\n"; reset($array); while ( list($key,$value) = each($array) ) { $print_key = str_replace("\n","\\n",str_replace("\r","\\r",str_replace("\t","\\t",addslashes($key)))); if ($ignore_ints && gettype($key) == "integer") continue; $type = gettype($value); if ($type == "array" || $type == "object") { $string .= $indent . ((is_string($key)) ? "\"$print_key\"": $key) . " => " . (($type == "array")?"array (\n":"") . (($type == "object")?"new ".get_class($value)." Object (\n":""); $string .= array_contents($value, $max_depth, $depth + 1, $ignore_ints); $string .= $indent . "),\n"; } else { if (is_string($value)) $value = str_replace("\n","\\n",str_replace("\r","\\r",str_replace("\t","\\t",addslashes($value)))); $string .= $indent . ((is_string($key)) ? "\"$print_key\"": $key) . " => " . ((is_string($value)) ? "\"$value\"": $value) . ",\n"; } } $string[ strlen($string) - 2 ] = " "; return $string; } # alias for pre_echo function bam($x='BAM!', $max_depth=0, $style='') { pre_echo($x, $max_depth, $style); } ################################################################################# # take any kind of variable and tries to print it out ############################################################################### function pre_echo($x='BAM!', $max_depth=0, $style='') { ?>