Created
July 7, 2015 14:37
-
-
Save prochor666/e9f44a723cccc9226ee5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function MW_setmenuwebmap($parent){ | |
| global $uniweb; | |
| $html = ""; | |
| $d1="SELECT * FROM "._SQLPREFIX_."_links WHERE xt=0 AND lng LIKE '"._LNG_."' AND id_public = 1 AND id_map = 1 AND secure IN(0,2) "; | |
| $d1.=_SUBDOMAINMODE_ ? " AND id_subdomain = '"._CONTENTPATH_."' " : null; | |
| $d1.=" ORDER BY id_position,public_ord,title,id"; | |
| $__PRECACHE = WEEBO_cached_result($d1); | |
| $html .= "<ul class=\"webmap\">\n"; | |
| foreach($__PRECACHE as $db) | |
| { | |
| if($db['param']) | |
| { | |
| $link = " href=\"".$db['param']."\""; | |
| }else{ | |
| $link = " href=\""._SRVPATH_."/".$db['legend'].".html\""; | |
| } | |
| if($db['id_blank']==1) | |
| { | |
| $link .= " target=\"_blank\""; | |
| } | |
| if($db['display_script'] == 'mwshop/output/catalogue.php'){ | |
| $html .= '<li><strong>'.$db['title'].'</strong>'. MWSHOP_list_category_tree(array( | |
| 'id_sub' => '0', | |
| 'css_id' => 'x-webmap', | |
| 'css_classes' => 'webmap' | |
| )).'</li>'; | |
| }else{ | |
| $html .= "<li><a ".$link.">".$db['title']."</a>"; | |
| $sub="SELECT * FROM "._SQLPREFIX_."_links WHERE xt='".$db['id']."' AND lng LIKE '"._LNG_."' AND id_public = 1 AND id_map = 1 AND secure IN(0,2) "; | |
| $sub.=_SUBDOMAINMODE_ ? " AND id_subdomain = '"._CONTENTPATH_."' " : null; | |
| $sub.=" ORDER BY id_position,public_ord,title,id "; | |
| $__SUB_PRECACHE = WEEBO_cached_result($sub); | |
| $myorder = isset($db['default_order']) && strlen($db['default_order'])>0 ? $db['default_order']: "public_ord, id"; | |
| $html .= MW_getmapcontent($db['id'],$db['legend'],$myorder); | |
| if(count($__SUB_PRECACHE)>0){ | |
| // subsecs lvl 2 | |
| $html .= MW_setsubwebmap($db['id'],$__SUB_PRECACHE); | |
| } | |
| $html .= "</li>"; | |
| } | |
| } | |
| $html .= "</ul>"; | |
| return $html; | |
| } | |
| function MW_setsubwebmap($parent,$subget) | |
| { | |
| global $uniweb; | |
| $html = "<ul class=\"swebmap\">\n"; | |
| foreach($subget as $sub){ | |
| if($sub['param']) | |
| { | |
| $link = " href=\"".$sub['param']."\""; | |
| }else{ | |
| $link = " href=\""._SRVPATH_."/".$sub['legend'].".html\""; | |
| } | |
| if($sub['id_blank']==1) | |
| { | |
| $link .= " target=\"_blank\""; | |
| } | |
| $html .= "<li> | |
| <a ".$link.">".$sub['title']."</a>"; | |
| $sub3="SELECT * FROM "._SQLPREFIX_."_links WHERE xt='".$sub['id']."' AND lng='"._LNG_."' AND id_public = 1 AND id_map = 1 AND secure IN(0,2) "; | |
| $sub3.=_SUBDOMAINMODE_ ? " AND id_subdomain = '"._CONTENTPATH_."' " : null; | |
| $sub3.=" ORDER BY id_position,public_ord,title,id "; | |
| $__SUB_PRECACHE = WEEBO_cached_result($sub3); | |
| $myorder = isset($sub['default_order']) && strlen($sub['default_order'])>0 ? $sub['default_order']: "public_ord, id"; | |
| $html .= MW_getmapcontent($sub['id'],$sub['legend'],$myorder); | |
| if(count($__SUB_PRECACHE)>0){ | |
| // subsecs lvl 2 | |
| $html .= MW_setsubwebmap($sub['id'],$__SUB_PRECACHE); | |
| } | |
| $html .= "</li>"; | |
| } | |
| $html .= "\n </ul>"; | |
| return $html; | |
| } | |
| function MW_getmapcontent($parent,$folder,$order) | |
| { | |
| global $uniweb; | |
| // main content | |
| $html = null; | |
| $d1="SELECT * FROM "._SQLPREFIX_."_content WHERE id_link='".$parent."' AND id_public=1 AND id_brief_allow IN(1,2) AND secure IN(0,2) "; | |
| $d1.= " ORDER BY ".$order; | |
| @$qq = WEEBO_cached_result($d1); | |
| $rec = count($qq); | |
| if($rec>0){ | |
| $html .= "<ul class=\"swebmapcontent\">\n"; | |
| foreach($qq as $db){ | |
| $html .= "<li> | |
| <a href=\""._SRVPATH_."/".$folder."/".$db['legend'].".html\">".$db['title']."</a> | |
| </li>"; | |
| } | |
| $html .= "</ul>"; | |
| } | |
| return $html; | |
| } | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <? | |
| function WEEBO_random_content(){ | |
| $_KEY = isset($_GET['key']) ? $_GET['key']: null; | |
| return MW_generate_random_content($_KEY); | |
| } | |
| function WEEBO_rss(){ | |
| $rss = New WeeboRSSManager; | |
| return $rss->output_rss(); | |
| } | |
| function WEEBO_sitemap(){ | |
| $rss = New WeeboSitemap; | |
| return $rss->build_sitemap(); | |
| } | |
| function WEEBO_show_request_data(){ | |
| global $uniweb, $ulng, $iserver, $login; | |
| $fn = trim($_GET['weeboapi']); | |
| $qsa = isset($_GET['qs']) ? explode("|",$_GET['qs']): array(); | |
| $_SESSION['weeboapi_white_list'] = isset($_SESSION['weeboapi_white_list']) && is_array($_SESSION['weeboapi_white_list']) ? array_unique($_SESSION['weeboapi_white_list']): array(); | |
| if(function_exists($fn) && is_array($_SESSION['weeboapi_white_list']) && in_array($fn, $_SESSION['weeboapi_white_list'])){ | |
| return call_user_func_array($fn,$qsa); | |
| } | |
| if(!function_exists($fn)){ $s[] = 'NO FUNCTION AVAILABLE'; } | |
| if(!is_array($_SESSION['weeboapi_white_list'])){ $s[] = 'NO WHITELIST'; } | |
| if(is_array($_SESSION['weeboapi_white_list']) && !in_array($fn, $_SESSION['weeboapi_white_list'])){ $s[] = 'FUNCTION '.$fn.' IS NOT ALLOWED'; } | |
| return 'REQUEST NOT ALLOWED BECAUSE: '.implode(',',$s); | |
| } | |
| function WEEBO_api_whitelist($list='reset'){ | |
| if($list=='reset'){ | |
| $_SESSION['weeboapi_white_list'] = false; | |
| }elseif(strlen($list)>0){ | |
| $s = explode(',',$list); | |
| foreach($s as $v){ | |
| $_SESSION['weeboapi_white_list'][] = trim($v); | |
| } | |
| } | |
| } | |
| /* set lng */ | |
| function MW_set_lng(){ | |
| $lng =_WEEBODEFAULTLNG_; | |
| if(isset($_GET['map']) && strlen($_GET['map'])>0){ | |
| $q="SELECT lng FROM "._SQLPREFIX_."_links WHERE legend LIKE '".$_GET['map']."' LIMIT 1"; | |
| @$qq = MW_query($q); | |
| $rec = !$_SESSION['mysql_error'] ? mysql_num_rows($qq): 0; | |
| if($rec>0){ | |
| $d=mysql_fetch_assoc($qq); | |
| $lng = $d['lng']; | |
| mysql_free_result($qq); | |
| } | |
| } | |
| return $lng; | |
| } | |
| /* email validate */ | |
| function MW_checkmail($m){ | |
| /* | |
| $u = '[-a-z0-9!#$%&\'*+/=?^_`{|}~]'; | |
| $d = '[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])'; | |
| return eregi("^".$u."+(\\.".$u."+)*@(".$d."?\\.)+".$d."\$", $m); | |
| */ | |
| return filter_var($m, FILTER_VALIDATE_EMAIL) === false ? false: true; | |
| } | |
| /* Check record in DB */ | |
| function MW_checkindb($table,$field,$str,$ex=0){ | |
| global $uniweb; | |
| $str = MW_gpc_addslashes($str); | |
| $q1 = "SELECT id,".$field." FROM ".$table." WHERE ".$field." = '".$str."' AND id != ".$ex.""; | |
| @$qq1 = MW_query($q1); | |
| $rec = !$_SESSION['mysql_error'] ? mysql_num_rows($qq1): 0; | |
| mysql_free_result($qq1); | |
| return $rec; | |
| } | |
| /* Check record in DB */ | |
| function MW_getfromdb($table,$field,$value="0",$where="id",$operator="="){ | |
| global $uniweb; | |
| $value = MW_gpc_addslashes($value); | |
| $q1 = "SELECT id,".$field." FROM ".$table." WHERE ".$where." ".$operator." '".$value."' LIMIT 1"; | |
| @$qq1 = MW_query($q1); | |
| $rec = !$_SESSION['mysql_error'] ? mysql_num_rows($qq1): 0; | |
| if($rec==1){ | |
| $d = mysql_fetch_assoc($qq1); | |
| $v = $d[$field]; | |
| mysql_free_result($qq1); | |
| }else{ | |
| $v = null; | |
| } | |
| return $v; | |
| } | |
| /* Resize images */ | |
| function MW_imageresize($filename,$copypath,$MaxWidth,$MaxHeight) | |
| { | |
| global $uniweb, $ulng; | |
| list($OrigWidth, $OrigHeight) = getimagesize($filename); | |
| if ($MaxWidth == 0) $MaxWidth = $OrigWidth; | |
| if ($MaxHeight == 0) $MaxHeight = $OrigHeight; | |
| $pw = $OrigWidth / $MaxWidth; | |
| $ph = $OrigHeight / $MaxHeight; | |
| if ($pw > $ph) $p = $pw; else $p = $ph; if ($p < 1) $p = 1; | |
| $NewWidth = (int)$OrigWidth / $p; $NewHeight = (int)$OrigHeight / $p; | |
| $image_p = imagecreatetruecolor($NewWidth, $NewHeight); | |
| $image = imagecreatefromjpeg($filename); | |
| imagecopyresampled($image_p, $image, 0, 0, 0, 0, $NewWidth, $NewHeight, $OrigWidth, $OrigHeight); | |
| imagejpeg($image_p, $copypath, 95); | |
| } | |
| function MW_showmyavatar() | |
| { | |
| global $login, $datapath; | |
| if(file_exists(_AVATARFOLDERREL_."/".$login->user_image) && !is_dir(_AVATARFOLDERREL_."/".$login->user_image)){ return "<img src=\"".$datapath._AVATARFOLDER_."/".$login->user_image."\" alt=\"".$login->username."\" />"; }else{ return false; } | |
| } | |
| function MW_delete_my_avatar() | |
| { | |
| global $login; | |
| if(file_exists(_AVATARFOLDERREL_."/".$login->user_image)){ unlink(_AVATARFOLDERREL_."/".$login->user_image); } | |
| } | |
| /* Random string */ | |
| function MW_genpw($l) | |
| { | |
| $ar='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; | |
| $str=""; | |
| while(strlen($str) < $l) | |
| { | |
| $str .= substr($ar, mt_rand(0, strlen($ar) - 1), 1); | |
| } | |
| return($str); | |
| } | |
| /* AddSlashes insert */ | |
| function MW_gpc_addslashes($str) { | |
| return get_magic_quotes_gpc() ? $str : addslashes($str); | |
| } | |
| /* add to some array */ | |
| function MW_to_arr($arr_name,$str) { | |
| $_SESSION[$arr_name] = isset($_SESSION[$arr_name]) && is_array($_SESSION[$arr_name]) ? $_SESSION[$arr_name] : array(); | |
| array_push($_SESSION[$arr_name], $str); | |
| } | |
| /* read from array */ | |
| function MW_from_arr($arr_name) { | |
| if(isset($_SESSION[$arr_name]) && is_array($_SESSION[$arr_name])) { | |
| $html = "<!-- start read session array ".$arr_name." --> \n"; | |
| foreach($_SESSION[$arr_name] as $an) { | |
| $html.= $an." \n"; | |
| } | |
| unset($_SESSION[$arr_name]); | |
| $html.= "<!-- end read session array ".$arr_name." --> \n"; | |
| } else { | |
| $html = "<!-- no data in session array ".$arr_name." --> \n"; | |
| } | |
| return $html; | |
| } | |
| /* strickt clear string */ | |
| function MW_strclearstrict($str) | |
| { | |
| $safechars = array( | |
| "a","b","c","d","e","f","g","h","i", | |
| "j","k","l","m","n","o","p","q","r", | |
| "s","t","u","v","w","x","y","z", | |
| "а","б","в","г","д","е","ж","з","и","к","л","м","н","о","п","р","с","т","у","ф","х","ц","ч","ш","щ","ъ","ы","ь","э","ю","я", | |
| "0","1","2","3","4","5","6","7","8","9" | |
| ); | |
| $chars = preg_split('//', $str); | |
| $strnew = ''; | |
| foreach($chars as $one) | |
| { | |
| $strnew .= in_array($one, $safechars) ? $one : "" ; | |
| } | |
| return $strnew; | |
| } | |
| function MW_obj_is_allowed($display='0',$security='0'){ | |
| global $login; | |
| if($login->is_logged==1 && $login->is_blocked!=1){ | |
| $userallow = $security==1 || $security==0 ? 1: 0; | |
| }else{ | |
| $userallow = $security==2 || $security==0 ? 1: 0; | |
| } | |
| return $display==1 && $userallow==1 ? true: false; | |
| } | |
| function rootURL($param="") { | |
| // returns full url or server name only if $param not set | |
| $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : ""; | |
| $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s; $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]); | |
| $d = explode("/",$_SERVER['SCRIPT_NAME']); | |
| $x = count($d)-1; | |
| $sd = strlen($d[$x]) + 1; | |
| $request_folder = substr($_SERVER['SCRIPT_NAME'],0,-$sd); | |
| $rp = explode("/",$_SERVER['REQUEST_URI']); | |
| $rp = array_slice($rp,0,2); | |
| $request_dir_name = implode("/",$rp); | |
| switch($param){ | |
| case "complete": | |
| return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI']; | |
| break; case "dir": | |
| return $protocol."://".$_SERVER['SERVER_NAME'].$request_dir_name; | |
| break; case "dir-only": | |
| return $request_dir_name; | |
| break; case "request": | |
| return $protocol."://".$_SERVER['SERVER_NAME'].$request_folder; | |
| break; default: | |
| return $protocol."://".$_SERVER['SERVER_NAME']; | |
| } | |
| } | |
| function strleft($s1, $s2) { | |
| return substr($s1, 0, strpos($s1, $s2)); | |
| } | |
| function mwtrunc($string, $length) { | |
| if (strlen($string)<=$length) { | |
| return $string; | |
| } | |
| $pos = strrpos($string," "); | |
| if ($pos>=$length-4) { | |
| $string = substr($string,0,$length-4); | |
| $pos = strrpos($string," "); | |
| } | |
| if ($pos>=$length*0.4) { | |
| return substr($string,0,$pos)." ..."; | |
| } | |
| return substr($string,0,$length-4)." ..."; | |
| } | |
| /* New mail method */ | |
| function MW_run_mailman($main_data,$sub,$admin_copy=false,$mailto="",$mailfrom="",$content_type="text/plain") | |
| { | |
| global $uniweb, $mwmail, $iserver; | |
| if(isset($mailto) && MW_checkmail($mailto)==1){ | |
| $real_mailto = $mailto; | |
| }elseif(isset($_POST['email']) && MW_checkmail($_POST['email'])==1){ | |
| $real_mailto = $_POST['email']; | |
| }else{ | |
| $real_mailto = null; | |
| } | |
| $subject = mb_strlen($sub)>0 ? $sub : _WEEBOSITETITLE_; | |
| $namefrom = isset($_POST['name']) ? str_replace(",","-",$_POST['name']): _WEEBOSITETITLE_; | |
| $mailfrom = isset($mailfrom) && MW_checkmail($mailfrom)==1 ? $mailfrom : _ADMINMAIL_; | |
| $subject ='=?UTF-8?B?'.base64_encode($subject).'?='; | |
| $namefrom ='=?UTF-8?B?'.base64_encode($namefrom).'?='; | |
| if(_USINGSMTP_==true){ | |
| $mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch | |
| $mail->IsSMTP(); // telling the class to use SMTP | |
| try { | |
| $mail->SMTPAuth = _USINGSMTP_; | |
| if(_SMTPPORT_== 587){ | |
| $mail->SMTPSecure = "tls"; | |
| } | |
| $mail->Host = _SMTPSERVER_; | |
| $mail->Port = _SMTPPORT_; | |
| $mail->Username = _SMTPUSER_; | |
| $mail->Password = _SMTPPASSWORD_; | |
| $mail->AddReplyTo($mailfrom, $namefrom); | |
| $mail->AddAddress($real_mailto, $real_mailto); | |
| $mail->SetFrom($mailfrom, $namefrom); | |
| $mail->CharSet = "UTF-8"; | |
| $mail->Encoding = "8bit"; | |
| $mail->ContentType = $content_type; | |
| $mail->Subject = $subject; | |
| $mail->AltBody = strip_tags($main_data); | |
| $mail->MsgHTML($main_data); | |
| /* | |
| $mail->AddAttachment('images/phpmailer.gif'); // attachment | |
| $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment | |
| */ | |
| $mail->Send(); | |
| $ecode = "Message Sent OK</p>\n"; | |
| if($admin_copy === true){ | |
| $mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch | |
| $mail->IsSMTP(); // telling the class to use SMTP | |
| $mail->SMTPAuth = _USINGSMTP_; | |
| if(_SMTPPORT_== 465){ | |
| $mail->SMTPSecure = "ssl"; | |
| } | |
| $mail->Host = _SMTPSERVER_; | |
| $mail->Port = _SMTPPORT_; | |
| $mail->Username = _SMTPUSER_; | |
| $mail->Password = _SMTPPASSWORD_; | |
| $mail->AddReplyTo($real_mailto, $real_mailto); | |
| $mail->AddAddress($mailfrom, $namefrom); | |
| $mail->SetFrom($real_mailto, $real_mailto); | |
| $mail->CharSet = "UTF-8"; | |
| $mail->Encoding = "8bit"; | |
| $mail->ContentType = $content_type; | |
| $mail->Subject = $subject; | |
| $mail->AltBody = strip_tags($main_data); | |
| $mail->MsgHTML($main_data); | |
| $mail->Send(); | |
| } | |
| } catch (phpmailerException $e) { | |
| $ecode = $e->errorMessage(); //Pretty error messages from PHPMailer | |
| } catch (Exception $e) { | |
| $ecode = $e->getMessage(); //Boring error messages from anything else! | |
| } | |
| }else{ | |
| $mail = new PHPMailer(); | |
| $mail->AddReplyTo($mailfrom, $namefrom); | |
| $mail->AddAddress($real_mailto, $real_mailto); | |
| $mail->SetFrom($mailfrom, $namefrom); | |
| $mail->CharSet = "UTF-8"; | |
| $mail->Encoding = "8bit"; | |
| $mail->ContentType = $content_type; | |
| $mail->Subject = $subject; | |
| $mail->AltBody = strip_tags($main_data); | |
| $mail->MsgHTML($main_data); | |
| if(!$mail->Send()) { | |
| $ecode = "Mailer Error: " . $mail->ErrorInfo; | |
| } else { | |
| $ecode = "Message sent!"; | |
| } | |
| if($admin_copy === true){ | |
| $mail = new PHPMailer(); | |
| $mail->AddReplyTo($real_mailto, $real_mailto); | |
| $mail->AddAddress($mailfrom, $namefrom); | |
| $mail->SetFrom($mailfrom, $namefrom); | |
| $mail->CharSet = "UTF-8"; | |
| $mail->Encoding = "8bit"; | |
| $mail->ContentType = $content_type; | |
| $mail->Subject = $subject; | |
| $mail->AltBody = strip_tags($main_data); | |
| $mail->MsgHTML($main_data); | |
| $mail->Send(); | |
| } | |
| } | |
| return $ecode; | |
| } | |
| /* Old mail method */ | |
| function MW_run_mailman2($main_data,$sub,$admin_copy=false,$mailto="",$mailfrom="",$content_type="text/plain") | |
| { | |
| global $uniweb, $mwmail, $iserver; | |
| if(isset($mailto) && MW_checkmail($mailto)==1){ | |
| $real_mailto = $mailto; | |
| }elseif(isset($_POST['email']) && MW_checkmail($_POST['email'])==1){ | |
| $real_mailto = $_POST['email']; | |
| }else{ | |
| $real_mailto = null; | |
| } | |
| $subject = strlen($sub)>0 ? $sub : _WEEBOSITETITLE_; | |
| $mailcontent = null; | |
| $mailcontent .=$main_data." \n"; | |
| $namefrom = isset($_POST['name']) ? str_replace(",","-",$_POST['name']): _WEEBOSITETITLE_; | |
| $mailfrom = isset($mailfrom) && MW_checkmail($mailfrom)==1 ? $mailfrom : _ADMINMAIL_; | |
| $subject ='=?UTF-8?B?'.base64_encode($subject).'?='; | |
| $namefrom ='=?UTF-8?B?'.base64_encode($namefrom).'?='; | |
| $othercontent = "Content-Type: ".$content_type."; charset=UTF-8" . "\r\n"; | |
| $othercontent .= "MIME-Version: 1.0" . "\r\n"; | |
| $othercontent .= "X-Priority: 3" . "\r\n"; | |
| $othercontent .= "X-MSMail-Priority: Normal" . "\r\n"; | |
| $othercontent .= "X-MimeOLE: WEEBO-mailer-module(20100728)" . "\r\n"; | |
| $othercontent .= "X-Mailer: WEEBO mailer module v"._PRODUCTVERSION_." " . "\r\n"; | |
| $othercontent .= "Content-Transfer-Encoding: 8bit" . "\r\n"; | |
| $othercontent .= "From: ".$namefrom." <".$mailfrom.">" . "\r\n"; | |
| if(_USINGSMTP_==true){ | |
| // using smtp auth | |
| if(MW_checkmail($mailfrom) && $admin_copy){ | |
| $xcode = @MW_authSendEmail($mailfrom, $namefrom, $mailfrom, $namefrom, $subject, $mailcontent, $othercontent); | |
| } | |
| if(isset($real_mailto) && MW_checkmail($real_mailto)==1){ | |
| $xcode = @MW_authSendEmail($mailfrom, $namefrom, $real_mailto, $real_mailto, $subject, $mailcontent, $othercontent); | |
| } | |
| $ecode = isset($xcode) && strlen($xcode)>0 ? "MAILER ERROR - SMTPAUTH MODE: ".$xcode : "OK - SMTPAUTH MODE"; | |
| }else{ | |
| // using simple mail function | |
| $othercontent .= "From: ".$namefrom." <".$mailfrom.">" . "\n"; | |
| if(MW_checkmail($mailfrom) && $admin_copy){ | |
| $xcode = mail($mailfrom,$subject,$mailcontent,$othercontent); | |
| } | |
| if(isset($real_mailto) && MW_checkmail($real_mailto)==1){ | |
| $xcode = mail($real_mailto,$subject,$mailcontent,$othercontent); | |
| } | |
| $ecode = !isset($xcode) ? "MAILER ERROR - SIMPLE MODE" : "OK - SIMPLE MODE"; | |
| } | |
| return $ecode; | |
| } | |
| /* * * * * * * * * * * * * * SEND EMAIL FUNCTIONS * * * * * * * * * * * * * */ | |
| //Authenticate Send - 21st March 2005 | |
| //This will send an email using auth smtp and output a log array | |
| //logArray - connection, | |
| function MW_authSendEmail($from, $namefrom, $to, $nameto, $subject, $message, $header_info) | |
| { | |
| global $login; | |
| //SMTP + SERVER DETAILS | |
| /* * * * RECONFIGURATION START * * * */ | |
| $smtpServer = _SMTPSERVER_; | |
| $port = _SMTPPORT_; | |
| $timeout = _SMTPTIMEOUT_; | |
| $username = _SMTPUSER_; | |
| $password = _SMTPPASSWORD_; | |
| $localhost = _SMTPLOCALE_; | |
| $newLine = _SMTPNEWLINE_; | |
| /* * * * RECONFIGURATION END * * * * */ | |
| //Connect to the host on the specified port | |
| $smtpConnect = fsockopen($smtpServer, $port, $errno, $errstr, $timeout); | |
| $smtpResponse = fgets($smtpConnect, 515); | |
| if(empty($smtpConnect)) | |
| { | |
| $output = "Failed to connect: ".$smtpResponse; | |
| return $output; | |
| } | |
| else | |
| { | |
| $logArray['connection'] = "Connected: ".$smtpResponse; | |
| } | |
| echo $output; | |
| //Request Auth Login | |
| fputs($smtpConnect,"AUTH LOGIN" . $newLine); | |
| $smtpResponse = fgets($smtpConnect, 515); | |
| $logArray['authrequest'] = "$smtpResponse"; | |
| //Send username | |
| fputs($smtpConnect, base64_encode($username) . $newLine); | |
| $smtpResponse = fgets($smtpConnect, 515); | |
| $logArray['authusername'] = "$smtpResponse"; | |
| //Send password | |
| fputs($smtpConnect, base64_encode($password) . $newLine); | |
| $smtpResponse = fgets($smtpConnect, 515); | |
| $logArray['authpassword'] = "$smtpResponse"; | |
| //Say Hello to SMTP | |
| fputs($smtpConnect, "HELO $smtpServer" . $newLine); | |
| $smtpResponse = fgets($smtpConnect, 515); | |
| $logArray['heloresponse'] = "$smtpResponse"; | |
| //Email From | |
| fputs($smtpConnect, "MAIL FROM: $from" . $newLine); | |
| $smtpResponse = fgets($smtpConnect, 515); | |
| $logArray['mailfromresponse'] = "$smtpResponse"; | |
| //Email To | |
| fputs($smtpConnect, "RCPT TO: $to" . $newLine); | |
| $smtpResponse = fgets($smtpConnect, 515); | |
| $logArray['mailtoresponse'] = "$smtpResponse"; | |
| //The Email | |
| fputs($smtpConnect, "DATA" . $newLine); | |
| $smtpResponse = fgets($smtpConnect, 515); | |
| $logArray['data1response'] = "$smtpResponse"; | |
| //Construct Headers | |
| $headers = $header_info; | |
| fputs($smtpConnect, "To: $nameto <$to>\nFrom: $namefrom <$from>\nSubject: $subject\n$headers\n\n$message\n.\n"); | |
| $smtpResponse = fgets($smtpConnect, 515); | |
| $logArray['data2response'] = "$smtpResponse"; | |
| // Say Bye to SMTP | |
| fputs($smtpConnect,"QUIT" . $newLine); | |
| $smtpResponse = fgets($smtpConnect, 515); | |
| $logArray['quitresponse'] = "$smtpResponse"; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment