Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 990 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 990 Rev 1105
Line 31... Line 31...
31
	 * @param string $url
31
	 * @param string $url
32
	 */
32
	 */
33
	public function setUrl($url = '') {
33
	public function setUrl($url = '') {
34
		$this->contenu = $url;
34
		$this->contenu = $url;
35
	}
35
	}
36
	
36
 
37
	/**
37
	/**
38
	 * Taille du QRcode en pixel. Cela sera forcément un carré.
38
	 * Taille du QRcode en pixel. Cela sera forcément un carré.
39
	 *
39
	 *
40
	 * @param string $taille
40
	 * @param string $taille
41
	 */
41
	 */
42
	public function setTaille($taille) {
42
	public function setTaille($taille) {
43
		$this->taille = $taille;
43
		$this->taille = $taille;
44
	}
44
	}
45
	
45
 
46
	/**
46
	/**
47
	 * Generate QR code image
47
	 * Generate QR code image
48
	 *
48
	 *
49
	 * @param string $filename
49
	 * @param string $filename
50
	 * @return bool
50
	 * @return bool
Line 54... Line 54...
54
			$idQrCode .= '.png';
54
			$idQrCode .= '.png';
55
		}
55
		}
56
		$cheminImg = $this->dossierQrCode.$idQrCode;
56
		$cheminImg = $this->dossierQrCode.$idQrCode;
57
		if (file_exists($cheminImg) == false) {
57
		if (file_exists($cheminImg) == false) {
58
			$ch = curl_init();
58
			$ch = curl_init();
-
 
59
			// For Debugging
-
 
60
			//curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
-
 
61
			//curl_setopt($ch, CURLOPT_STDERR, $f = fopen("$cheminImg.txt", "w+"));
-
 
62
 
59
			curl_setopt($ch, CURLOPT_URL, $this->API_CHART_URL);
63
			curl_setopt($ch, CURLOPT_URL, $this->API_CHART_URL);
60
			curl_setopt($ch, CURLOPT_POST, true);
64
			curl_setopt($ch, CURLOPT_POST, true);
61
			curl_setopt($ch, CURLOPT_POSTFIELDS, "chs={$this->taille}x{$this->taille}&cht=qr&chl=".urlencode($this->contenu));
65
			curl_setopt($ch, CURLOPT_POSTFIELDS, "chs={$this->taille}x{$this->taille}&cht=qr&chl=".urlencode($this->contenu));
62
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
66
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
63
			curl_setopt($ch, CURLOPT_HEADER, false);
67
			curl_setopt($ch, CURLOPT_HEADER, false);
64
			curl_setopt($ch, CURLOPT_TIMEOUT, 30);
68
			curl_setopt($ch, CURLOPT_TIMEOUT, 30);
65
			$img = curl_exec($ch);
69
			$img = curl_exec($ch);
66
			curl_close($ch);
70
			curl_close($ch);
67
			
71
 
-
 
72
			// For Debugging
-
 
73
			//fclose($f);
-
 
74
 
68
			file_put_contents($cheminImg, $img);
75
			file_put_contents($cheminImg, $img);
69
		}
76
		}
70
		$urlQrCode = sprintf($this->urlQrCodeTpl, $idQrCode);
77
		$urlQrCode = sprintf($this->urlQrCodeTpl, $idQrCode);
71
		return $urlQrCode;
78
		return $urlQrCode;
72
	}
79
	}