Anonymní profil peter – Programujte.com
 x   TIP: Přetáhni ikonu na hlavní panel pro připnutí webu

Anonymní profil peter – Programujte.comAnonymní profil peter – Programujte.com

 

Příspěvky odeslané z IP adresy 2001:718:2601:26c:2029:ac...–

peter
JavaScript, AJAX, jQuery › event onmousemove ve Firefoxu
29. 1. 2016   #208212

Prisel jsi na to, nezna. Googluj reseni, ne? "crossbrowser mouse event javascript"
Pripadne tam je mozna vic zadrhelu. Dej si alertovat treba event. Ten by FF take nemel znat.

movemouse()
movemouse(event)
event = event ? event : window.event;

clientX si ted nevzpomenu, cim se nahrazuje.
scrollX zascrolovani na strance take neresis, koukam.

Tim kodem od tebe se ani mema smysl zabyvat. To kdyz zkopiruji do souboru, tak to samo o sobe nic nedela. Neda se to testovat, musel bych tam dopsat furu dalsich veci. Skoda casu.

peter
PHP › Funkce PHP Mail
29. 1. 2016   #208206

Jo, jeste mne napada, v tom kodu nemas vubec error_reporting(). Bez toho to nezobrazi chybove hlasky php. Bez te chybove hlasky nema vubec smyl toto tema zakladat, pokud se nejaka zobrazi. A pokud se nezobrazi a mela by se, tak je treba prijit na to proc se nezobrazi. Cili, zapnout error_reporting a zkusit pouzit treba neexistujici promennou. echo $XYZ. Pokud to nevypise chybovou hlasku, tak je neco spatne.

peter
PHP › Funkce PHP Mail
29. 1. 2016   #208204

- Funkce mail vraci true/false jestli byl mail odeslan z php. Ty tento stav nekontrolujes.
- Zkousel jsi ten kod spustit i na jinem hostingu?
- Do hlavicky mailu se vetsinou pridava kod, ze mail odesila php
- Nemas to ve spamu?
- Zkousel jsi pouzit priklad z online dokumentace php.net/mail? Tam by meli totiz aspon nektere fungovat na rozdil od nahodne zkopirovaneho kodu z internetu.

 Kdysi jsem si delal vlastni class, ktera vyuziva tez mail()

<?php
class classMail
{
public $uid;
public $sep_body;
public $sep_line;
public $head;
public $subj;
public $body;
public $tmp = array();
//private $log = null;

	function __construct()
	{
	$this->newMail();
	}

	function __destruct()
	{
	}

	public function newMail()
	{
	$this->tmp = array(
		'head'=>array(),
		'body'=>array()
		);
	$this->tmp['head'] = array(
		'from' => '',
		'to'   => '',
		'subj' => '',
		'notify' => false
		);
	}

//	function clear()
//	{
//	$this->head = array();
//	$this->body = array();
//	}

	public function addFrom($str)	{$this->tmp['head']['from'] = $str;}
	public function addTo($str)	{$this->tmp['head']['to']   = $str;}
	public function addSubj($str)	{$this->tmp['head']['subj'] = $str;}
	public function addBody($arr)
		{
		$pos  = strrpos($arr['path'],'/');
		$arr['file'] = $pos!==false ? substr($arr['path'],$pos+1) : $arr['path'];
		$this->tmp['body'][] = $arr;
		}
	public function addFile($path,$type='',$mime='')
		{
		$type = $type=='' ? 'file' : $type;
		$this->addBody(array('type'=>$type,'path'=>$path,'file'=>'','text'=>'','mime'=>$mime));
		}
	public function addText($msg,$path='')
		{
		$this->addBody(array('type'=>'text','path'=>$path,'file'=>'','text'=>$msg));
		}
	public function addHtml($msg,$path='')
		{
		$this->addBody(array('type'=>'html','path'=>$path,'file'=>'','text'=>$msg));
		}

	private function mailAddBody($item)	//$type='',$path='',$filename='',$message='',$mime=''
	{
	$body = array();
	if ($item['type']!='')
		{
		switch ($item['type'])
			{
			case 'text':
				{
				$mime   = 'text/plain';
				$body[] = 'Content-type:'.$mime.'; charset=utf-8';	//'Content-type: text/html; charset=iso-8859-1',
				$body[] = 'Content-Transfer-Encoding: quoted-printable';
				$body[] = '';
				if ($item['text']!='')
					{
					$body[] = $item['text'];
					}
				elseif (file_exists($item['path']))
					{
					$body[] = chunk_split(base64_encode(file_get_contents($path)));
					}
				else	{return;}
				break;
				}
			case 'html':
				{
				$mime   = 'text/html';
				$body[] = 'Content-type:'.$mime.'; charset=utf-8';
				$body[] = '';
				if ($item['text']!='')
					{
					$body[] = $item['text'];
					}
				elseif (file_exists($item['path']))
					{
					$body[] = chunk_split(base64_encode(file_get_contents($path)));
					}
				else	{return;}
				break;
				}
			case 'file':
				if (file_exists($item['path']))
					{
					$mime = $item['mime']=='' ? 'application/octet-stream' : $item['mime'];
					$body[] = 'Content-Type:'.$mime.'; name="'.$item['file'].'"';
					$body[] = 'Content-Transfer-Encoding: base64';
					$body[] = 'Content-Disposition: attachment; filename="'.$item['file'].'"';
					$body[] = '';
					$body[] = chunk_split(base64_encode(file_get_contents($item['path'])));
					}
				else	{return;}
				break;
			default: return;
				break;
			}
		}
	$this->body[] = $this->sep_body;
	$this->body[] = implode($this->sep_line, $body);
	$this->body[] = '';
	$this->body[] = '';
	}

	// $head = array('from'=>'','to'=>'','notify'=>true/false)
	private function createMail($head=array(),$body=array())
	{
	$this->uid = '--NextPart uid='.substr(sha1(uniqid(time())),0,20);
	$this->sep_body = '--'.$this->uid;
	$this->sep_line = PHP_EOL;	// "\r\n";
	$this->head = array();
	$this->head[] = 'From: '.$head['from'];
	$this->head[] = 'Reply-To: '.$head['from'];
	if ($head['notify']==true)
		{
		$this->head[] = 'Disposition-Notification-To: '.$head['from'];
		$this->head[] = 'Return-Receipt-To: '.$head['from'];
	//	$this->head[] = 'X-pmrqc: 1';
	//	$this->head[] = 'X-Confirm-Reading-To: '.$mail['from'];
	//	$this->head[] = 'Delivery-Status-Notification: '.$mail['from'];
		}
	$this->head[] = 'MIME-Version: 1.0';
	$this->head[] = 'X-Mailer: PHP/' . phpversion();
	$this->head[] = 'Content-Type: multipart/mixed; boundary="'.$this->uid.'"';
	$this->head[] = 'This is a multi-part message in MIME format.';
	$this->subj   = "=?UTF-8?B?".base64_encode($head['subj'])."?=";
	$this->body   = array();
//var_dump($body);
	foreach($body as $item)
		{
		$this->mailAddBody($item);
		}
	$this->body[] = $this->sep_body;
	$this->head = implode($this->sep_line, $this->head);
	$this->body = implode($this->sep_line, $this->body);
	//var_dump($this->head,$this->subj,$this->body);
	}
	
	public function send()
		{
		$head = $this->tmp['head'];
		if (       isset($head['from']) && $head['from']!==""
			&& isset($head['to'  ]) && $head['to'  ]!==""
			&& isset($head['subj']) && $head['subj']!==""
			&& count($this->tmp['body'])>0)
			{
			$this->createMail($head,$this->tmp['body']);
			return mail($head['to'], $head['subj'], $this->body, $this->head);
			}
		}
	}


	                                    	
				$mail = new classMail;
				$mail->addFrom($cfg_admin['mail']);
				$mail->addTo($mail_to);
				$mail->addSubj($subj);
				$mail->addText($msg);
				$bool = $mail->send();
				if ($bool)
					{$notice[] = 'odeslano';}
				else	{$notice[] = 'chyba';}
?>

 

 

Hostujeme u Českého hostingu       ISSN 1801-1586       ⇡ Nahoru Webtea.cz logo © 20032020 Programujte.com
Zasadilo a pěstuje Webtea.cz, šéfredaktor Lukáš Churý