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:9100:26...–

peter
Python › spustenie
31. 3. 2016   #209522

https://repl.it/ (examples)


print "Hello, Python!" # python 2print('Hello World!') # python 3

http://www.tutorialspoint.com/python/python_basic_syntax.htm

peter
PHP › Zapomenuté heslo - neodešle…
31. 3. 2016   #209517

script plní funkci plně jak má ... neodešle se mail
Takze vlastne je spatne.

Zkus pouzit google a najdi si dalsi priklady pro odeslani mailu. Jestli ti to nikdy nefungovalo, tak nemuzes ocekavat, ze to fungovat bude. Predpokladam
- tvuj localhost / hosting nepodporuje mail funkci nebo k ni nema prirazeny program
- nebo mas v kodu chybu
Ani nekontrolujes stav funkce mail, zda funguje ci ne.

http://php.net/manual/en/function.mail.php
Example 1 ti funguje?
Ex 2 ti funguje?
Ex 4?
171 bimal at sanjaal dot com?
4 jimmytrojan009 at gmail dot com - vypis z php.ini (phpinfo();), prirazeni programu a nastaveni smtp ( ini_set("SMTP", "smtp.mujserver.cz");   )

Ja mam treba ted na odesilani mailu tuto funkci 

<?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);
			}
		}
	}

	                                    	
?>
peter
PHP › GPS matematika
31. 3. 2016   #209516

Zkus to vytahnout z google-map kodu, ne? Hlavni problem je to, ze Zeme je elipsoid, neco takoveho nesymetrickeho. Cili pro X plati jina rovnice nez pro Y.
Ta funkce, co jsi vypsal, je pomala. Neustale opakujes prevod stejnych hodnot na radiany. Cos je vetsinou taky pomaly.

google = prepocet+gps+na+povrchu+zeme+vzdalenost
https://www.google.cz/search?…

http://www.builder.cz/cz/forum/tema-1282706-vypocet-vzdalenosti-z-gps-8051-c/
http://www.path.cz/…iewtopic.php?…

peter
Python › spustenie
31. 3. 2016   #209515

Zkus z toho souboru uplne vsechno smazat. Sice se nic nezobrazi, ale tez by nemel zobrazovat chybu.

invalid syntax - je chyba v kodu, ne? A tez to vetsinou hlasi cislo radku. Python ma proti ostatnim jazykum zvlastni pravidla pro zapisy begin-end, if-else, cykly, ne-stredniky a pod. Proste bordel.

 

 

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