function inStr ($needle, $haystack) { $needlechars = strlen($needle); $i = 0; for($i=0; $i < strlen($haystack); $i++) { if(substr($haystack, $i, $needlechars) == $needle) { return true; } } return false; } function iif($expression, $returntrue, $returnfalse = '') { return ($expression ? $returntrue : $returnfalse); } // sql_to_xml($result, "members", "users"); function sql_to_xml($result, $root_name="root", $root_attrib="", $element_name="row") { $xml= new SimpleXMLElement("<$root_name $root_attrib>$root_name>"); while ($line = $result->fetchRow()) { $row=$xml->addChild($element_name); foreach($line as $column => $value) { $row->$column="$value"; } } //return htmlentities($xml->asXML()); return $xml->asXML(); } function SendEmail($smtpTo, $smtpSubject, $smtpBody, $html=true) { require_once(dirname($_SERVER['DOCUMENT_ROOT']) . '/openlib/PHPMailer_v5.0.0/class.phpmailer.php'); $retval=0; $mail = new PHPMailer(); // Instantiate your new class $mail->IsSMTP(); // set mailer to use SMTP $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Host = 'smtp.gmail.com'; // specify main and backup server $mail->SMTPSecure= 'ssl'; // Used instead of TLS when only POP mail is selected $mail->Port = 465; // Used instead of 587 when only POP mail is selected $mail->Username = 'service@toneable.com'; $mail->Password = 'b3z#22!'; $mail->From = 'service@toneable.com'; $mail->FromName = 'service@toneable.com'; $mail->Subject = $smtpSubject; if ($html==true) { $mail->IsHTML(true); } $mail->Body = $smtpBody; $mail->AddAddress($smtpTo, $smtpTo); if(!$mail->Send()) { $smtpstatus = $mail->ErrorInfo; $retval=-1; }else{ $smtpstatus = "Message has been sent"; $retval=1; } $db = new MySQL(); $sql = "call stp_logemail('{$smtpTo}','{$smtpSubject}','{$smtpBody}','{$smtpstatus}')"; $update = $db->query($sql); return $retval; } function quote_smart($value) { $link = mysql_connect(db_host, db_user, db_pass); // Stripslashes if (get_magic_quotes_gpc()) { $value = stripslashes($value); } // Quote if not integer if (!is_numeric($value)) { $value = mysql_real_escape_string($value, $link); } mysql_close($link); return trim($value); } function token() { for($i=1;$i<33;$i++) { $seed .= chr(rand(0,255)); } return md5($seed); } function str_pad_html($strInput = "", $intPadLength, $strPadString = " ", $intPadType = STR_PAD_RIGHT) { if (strlen(trim(strip_tags($strInput))) < intval($intPadLength)) { switch ($intPadType) { // STR_PAD_LEFT case 0: $offsetLeft = intval($intPadLength - strlen(trim(strip_tags($strInput)))); $offsetRight = 0; break; // STR_PAD_RIGHT case 1: $offsetLeft = 0; $offsetRight = intval($intPadLength - strlen(trim(strip_tags($strInput)))); break; // STR_PAD_BOTH case 2: $offsetLeft = intval(($intPadLength - strlen(trim(strip_tags($strInput)))) / 2); $offsetRight = round(($intPadLength - strlen(trim(strip_tags($strInput)))) / 2, 0); break; // STR_PAD_RIGHT default: $offsetLeft = 0; $offsetRight = intval($intPadLength - strlen(trim(strip_tags($strInput)))); break; } $strPadded = str_repeat($strPadString, $offsetLeft) . $strInput . str_repeat($strPadString, $offsetRight); unset($strInput, $offsetLeft, $offsetRight); return $strPadded; } else { return $strInput; } } function passwordgen() { $totalChar = 7; // number of chars in the password $salt = "abcdefghijklmnpqrstuvwxyz123456789!@#$%&*"; // salt to select chars from srand((double)microtime()*1000000); // start the random generator $password=""; // set the inital variable for ($i=0;$i<$totalChar;$i++) // loop and create password $password = $password . substr ($salt, rand() % strlen($salt), 1); return $password; } ?>