Html-, css- és php-help
Jelentkezz be a hozzászóláshoz.
ASUS B550-PLUS, AMD 5600X, 32 GB DDR4, EVGA RTX 3070, SM-OB1, HD 600 + Asus Xonar DX, TonePort UX1 + Alesis Elevate 5, Novation Circuit \o/
Kicsit tovább kutakodtam és találtam egy működő megoldást (VPN-nel teszteltem), berakom ide is hátha valakinek jól jön majd.
geoplugin.class.php
Spoiler (katt a megjelenítéshez)
<?php
/*
This PHP class is free software: you can redistribute it and/or modify
the code under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
However, the license header, copyright and author credits
must not be modified in any form and always be displayed.
This class is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@author geoPlugin ([email protected])
@copyright Copyright geoPlugin ([email protected])
$version 1.01
This PHP class uses the PHP Webservice of http://www.geoplugin.com/ to geolocate IP addresses
Geographical location of the IP address (visitor) and locate currency (symbol, code and exchange rate) are returned.
See http://www.geoplugin.com/webservices/php for more specific details of this free service
*/
class geoPlugin {
//the geoPlugin server
var $host = 'http://www.geoplugin.net/php.gp?ip={IP}&base_currency={CURRENCY}';
//the default base currency
var $currency = 'USD';
//initiate the geoPlugin vars
var $ip = null;
var $city = null;
var $region = null;
var $areaCode = null;
var $dmaCode = null;
var $countryCode = null;
var $countryName = null;
var $continentCode = null;
var $latitude = null;
var $longitude = null;
var $currencyCode = null;
var $currencySymbol = null;
var $currencyConverter = null;
function geoPlugin() {
}
function locate($ip = null) {
global $_SERVER;
if ( is_null( $ip ) ) {
$ip = $_SERVER<'REMOTE_ADDR'>'REMOTE_ADDR'>;
}
$host = str_replace( '{IP}', $ip, $this->host );
$host = str_replace( '{CURRENCY}', $this->currency, $host );
$data = array();
$response = $this->fetch($host);
$data = unserialize($response);
//set the geoPlugin vars
$this->ip = $ip;
$this->city = $data<'geoplugin_city'>'geoplugin_city'>;
$this->region = $data<'geoplugin_region'>'geoplugin_region'>;
$this->areaCode = $data<'geoplugin_areaCode'>'geoplugin_areaCode'>;
$this->dmaCode = $data<'geoplugin_dmaCode'>'geoplugin_dmaCode'>;
$this->countryCode = $data<'geoplugin_countryCode'>'geoplugin_countryCode'>;
$this->countryName = $data<'geoplugin_countryName'>'geoplugin_countryName'>;
$this->continentCode = $data<'geoplugin_continentCode'>'geoplugin_continentCode'>;
$this->latitude = $data<'geoplugin_latitude'>'geoplugin_latitude'>;
$this->longitude = $data<'geoplugin_longitude'>'geoplugin_longitude'>;
$this->currencyCode = $data<'geoplugin_currencyCode'>'geoplugin_currencyCode'>;
$this->currencySymbol = $data<'geoplugin_currencySymbol'>'geoplugin_currencySymbol'>;
$this->currencyConverter = $data<'geoplugin_currencyConverter'>'geoplugin_currencyConverter'>;
}
function fetch($host) {
if ( function_exists('curl_init') ) {
//use cURL to fetch data
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $host);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'geoPlugin PHP Class v1.0');
$response = curl_exec($ch);
curl_close ($ch);
} else if ( ini_get('allow_url_fopen') ) {
//fall back to fopen()
$response = file_get_contents($host, 'r');
} else {
trigger_error ('geoPlugin class Error: Cannot retrieve data. Either compile PHP with cURL support or enable allow_url_fopen in php.ini ', E_USER_ERROR);
return;
}
return $response;
}
function convert($amount, $float=2, $symbol=true) {
//easily convert amounts to geolocated currency.
if ( !is_numeric($this->currencyConverter) || $this->currencyConverter == 0 ) {
trigger_error('geoPlugin class Notice: currencyConverter has no value.', E_USER_NOTICE);
return $amount;
}
if ( !is_numeric($amount) ) {
trigger_error ('geoPlugin class Warning: The amount passed to geoPlugin::convert is not numeric.', E_USER_WARNING);
return $amount;
}
if ( $symbol === true ) {
return $this->currencySymbol . round( ($amount * $this->currencyConverter), $float );
} else {
return round( ($amount * $this->currencyConverter), $float );
}
}
function nearby($radius=10, $limit=null) {
if ( !is_numeric($this->latitude) || !is_numeric($this->longitude) ) {
trigger_error ('geoPlugin class Warning: Incorrect latitude or longitude values.', E_USER_NOTICE);
return array( array() );
}
$host = "http://www.geoplugin.net/extras/nearby.gp?lat=" . $this->latitude . "&long=" . $this->longitude . "&radius={$radius}";
if ( is_numeric($limit) )
$host .= "&limit={$limit}";
return unserialize( $this->fetch($host) );
}
}
?>
index.php
Spoiler (katt a megjelenítéshez)
<?php
require_once('geoplugin.class.php');
$geoplugin = new geoPlugin();
$geoplugin->locate();
$countryCode = $geoplugin->countryCode;
if($countryCode == "HU"😉 {
header("Location: http://example.com/hu"😉;
} elseif($countryCode == "DE"😉 {
header("Location: http://example.com/de"😉;
} else {
header("Location: http://example.com/en"😉;
}
?>
Utoljára szerkesztette: Blum, 2015.11.15. 21:47:26
unzip ; touch ; finger ; mount ; gasp ; yes ; umount ; sleep
SG troll, ban, büntetőpont, hsz törlés FAQ: http://kocsog.eu/ban/
Igazából böngésződben nyomsz egy F12-t, network fül, F5, elsőre katt és megnézed mi van alapból a headerben.
“A distributed system is one in which the failure of a computer you didn't even know existed can render your own computer unusable” _____/|_____\o/___ Cápatámadás
(\__/) ( X.x) ( } . { )
Végülis ha én most megnézem a weboldalt akkor pengén átdob /hu-ra. Ha pl. Hollandiából nézném meg akkor átirányítana /en-re? Hogy tudnám letesztelni? (Találtam értelmes ingyenes játszós hostingot, szóval nem a localhostnak kéne külföldinek hazudni magam)
<?php
$locale = locale_accept_from_http($_SERVER<'HTTP_ACCEPT_LANGUAGE'>'HTTP_ACCEPT_LANGUAGE'>);
if($locale = "hu_HU"😉 {
header("Location: http://example.com/hu/"😉;
} elseif($locale = "de_DE"😉 {
header("Location: http://example.com/de/"😉;
} else {
header("Location: http://example.com/en/"😉;
}
?>
Utoljára szerkesztette: Blum, 2015.11.15. 14:12:31
unzip ; touch ; finger ; mount ; gasp ; yes ; umount ; sleep
“A distributed system is one in which the failure of a computer you didn't even know existed can render your own computer unusable” _____/|_____\o/___ Cápatámadás
Kösz srácok! <#szeret>#szeret>
Utoljára szerkesztette: Blum, 2015.11.10. 13:09:22
unzip ; touch ; finger ; mount ; gasp ; yes ; umount ; sleep
SG troll, ban, büntetőpont, hsz törlés FAQ: http://kocsog.eu/ban/
Ha azt szeretném, hogy a user az általam megírt üzenetet lásson és az "igazi" hibát egy külön, csak általam vagy más devek által olvasható text fájlba dobja át akkor azt hogy illenék megcsinálni? <#ticking>#ticking>
Utoljára szerkesztette: Blum, 2015.11.10. 12:18:19
unzip ; touch ; finger ; mount ; gasp ; yes ; umount ; sleep
Illik ezt úgy csinálni, hogy a user lát egy Hiba feliratot vagy hasonlót (semmi köze hozzá, hogy mi a probléma az oldalon) és az exception üzenetét meg logolod.
“A distributed system is one in which the failure of a computer you didn't even know existed can render your own computer unusable” _____/|_____\o/___ Cápatámadás
#22169: Áháá, szóval a PDO mindenképp a saját hibaüzenetét adja vissza, akkoris ha megmondom neki, hogy az általam meghatározott Exception-nel szálljon el?
Komolyan, tegnap előtt olyan faszán sikerült megoldanom..csak nemtudom, hogy hogyan 😞
Utoljára szerkesztette: Blum, 2015.11.10. 10:32:11
unzip ; touch ; finger ; mount ; gasp ; yes ; umount ; sleep
ez aranyos, magyarázat követelek attól miért lesz jobb
SG troll, ban, büntetőpont, hsz törlés FAQ: http://kocsog.eu/ban/
“A distributed system is one in which the failure of a computer you didn't even know existed can render your own computer unusable” _____/|_____\o/___ Cápatámadás
PHP Exception-nel szeretném megoldani, hogy egy általam meghatározott hibaüzenetet írjon ki a kód ha valahol elhasal de nem működik. A poén az az, hogy egyszer már pengén megoldottam de volt egy rendszer reinstall és a hülye fejemmel elfelejtettem lementeni most meg amit megírok az sehogy se jó. <#idiota>#idiota>
Szóval ha pl. próbálok egy ilyet:
Spoiler (katt a megjelenítéshez)
<?php
class Database {
private $dbd;
private $db_user;
private $db_pass;
public $DBH;
public function __construct() {
$this->dbd = "mysql:host=127.0.0.1;dbname=project;charset=utf8";
$this->db_user = "root";
$this->db_pass = "";
try {
$this->DBH = new PDO($this->dbd, $this->db_user, $this->db_pass);
if(!$this->DBH) {
throw new Exception("Sikertelen csatlakozás"😉;
}
echo "Sikeres csatlakozás";
} catch(Exception $e) {
echo "Error: ", $e->getMessage();
}
}
public function getConnection() {
return $this->DBH;
}
}
?>
<!DOCTYPE html>
<html lang="hu">
<head>
<meta charset="utf-8">
</head>
<body>
<?php
$DBH = new Database;
?>
</body>
</html>
Ha működik akkor kiírja, hogy Sikeres csatlakozás de ha nem (mert pl. az adatbázis nevét átírom djdkjfsfdsdfdsaf-re akkor nem azt írja ki, hogy "Hiba: Sikertelen csatlakozás" hanem a standard üzenetet kapom: "Hiba: SQLSTATE<42000>42000> <1049>1049> Unknown database 'djdkjfsfdsdfdsaf'". MIÉRT???!!! 😄
Utoljára szerkesztette: Blum, 2015.11.10. 09:48:37
unzip ; touch ; finger ; mount ; gasp ; yes ; umount ; sleep
Köszi a segítséget, erről nem tudtam.
“A distributed system is one in which the failure of a computer you didn't even know existed can render your own computer unusable” _____/|_____\o/___ Cápatámadás
<input type="submit" name="accept" value="Accept" />
<input type="submit" name="decline" value="Decline" />
És amelyikkel elküldöd a formot, az benne lesz a $_POST-ban vagy $_GET-ben, isset-el lehet ellenőrizni
“A distributed system is one in which the failure of a computer you didn't even know existed can render your own computer unusable” _____/|_____\o/___ Cápatámadás
Jelenleg úgy van, hogy 2 formban van a 2 gomb, accept gombnál van egy hidden input ami jelzi, hogy accept, decline-nál pedig egy textarea a szöveggel, mindkettő form action-je ugyanoda mutat. A probléma ugye az, hogy, ha az accept formba is akarnék textarea-t rakni akkor 2 lenne az oldalon.
Egyetlen workaround ami eszembe jut, hogy nem accept/decline hanem egy select-ben állítja, hogy mi akar vele, de jobb lenne 2 gombbal és 1 textarea-val.
“A distributed system is one in which the failure of a computer you didn't even know existed can render your own computer unusable” _____/|_____\o/___ Cápatámadás
valami tömbbe belerakod a placeholdereket, meg a hozzájuk tartozó képek útvonalát, és a template-ben meg ng-show -zol meg ng-hide-olsz meg ng-clickelsz
SG troll, ban, büntetőpont, hsz törlés FAQ: http://kocsog.eu/ban/
Mondjuk következő lépés a placeholderre kattintás, majd arra kép betöltés jön. jQueryvel nem lenne gond, de most gondolkodóba estem, hogy itt hogy jön össze 😊
/ha van valami tuti tipp jöhet, de még én úgyis utána nézek, de azért leírtam ~~
ASUS B550-PLUS, AMD 5600X, 32 GB DDR4, EVGA RTX 3070, SM-OB1, HD 600 + Asus Xonar DX, TonePort UX1 + Alesis Elevate 5, Novation Circuit \o/
ilyenekre az szokott lenni, hogy egy scope változót true-ra állítasz, ha minden promise megérkezett, és csak akkor jeleníted meg ng-show-val vagy ng-iffel a contentet, ha az a változó true
SG troll, ban, büntetőpont, hsz törlés FAQ: http://kocsog.eu/ban/
Egyik típusú oldalnál, vannak adatok amik szépen betöltődnek, egy kép csak valamivel később, mivel több időt igényel, mire betöltöm (data:img..). Böngészőben tesztelem: ha egyik másik viewról váltok az előbb leírt oldalra, akkor a szövegek meg minden betöltődik, de a kép nem. Ha F5 el frissítek, akkor 1mp után megjelenik a kép. (timeout, http, 1000, de ha duplájára állítom akkor sem tölti be az oldalra navigáláskor).
Ez miért lehet?
Jó lenne ha az oldalra navigáláskor valahogy be lehetne tölteni a gépet, mobilon nem lesz F5, ami frissítené az oldalt, csak hogy megjelenjen egy kép is.
csak kivettem a timeoutot és jó lett O.o
Utoljára szerkesztette: Jim Morrison, 2015.11.04. 19:33:36
ASUS B550-PLUS, AMD 5600X, 32 GB DDR4, EVGA RTX 3070, SM-OB1, HD 600 + Asus Xonar DX, TonePort UX1 + Alesis Elevate 5, Novation Circuit \o/
Erre nem is gondoltam. Kösz srácok!
unzip ; touch ; finger ; mount ; gasp ; yes ; umount ; sleep
“A distributed system is one in which the failure of a computer you didn't even know existed can render your own computer unusable” _____/|_____\o/___ Cápatámadás
Megint bénázok...
Szóval adott egy class, azon belül néhány funkció. Hogy tudom megoldani azt, hogy ha egy adott function-on belül egy feltétel elhasal akkor a túloldalon hiába van meghívva a következő function (jelen esetben registerUser()) akkor ott meg is akadjon és ne futassa azt le?
Hiába írok be két különböző értéket a két jelszó mezőbe, akkor is beregisztrálja a usert. Mit nézek be már megint ilyen csúnyán? 😊 Van egy olyan sejtésem, hogy az a die() dolog az nem oda való. Próbáltam exit()-et is de ugyanúgy lemegy.
Mutatom:
Spoiler (katt a megjelenítéshez)
register.php
$username = $_POST<'username'>'username'>;
$username = filter_var($username, FILTER_SANITIZE_STRING);
$email = $_POST<'email'>'email'>;
$email = filter_var($email, FILTER_SANITIZE_EMAIL);
$password = $_POST<'password'>'password'>; /* Titkosítva lesz ofkorz */
$password2 = $_POST<'password2'>'password2'>;
include '../Init/init.php';
$db = new Database();
$conn = $db->DBConnect();
$user = new User($conn);
$user->checkPasswordMatch($password, $password2);
$user->registerUser($username, $email, $password);
echo $user->regStatus;
User.class.php
class User {
private $conn;
protected $username;
protected $email;
public $regStatus;
public function __construct($conn) {
$this->conn = $conn;
}
public function checkPasswordMatch($password, $password2) {
if($password != $password2) {
return $this->regStatus = "A két jelszó nem egyezik meg. Kérlek ellenőrizd. <br />";
die();
}
}
public function registerUser($username, $email, $password) {
$query = "INSERT INTO users (username, email, password)
VALUES (:username, :email, :password)";
$stmt = $this->conn->prepare($query);
$stmt->bindParam(':username', $username);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':password', $password);
if($stmt->execute()) {
return $this->regStatus = "Sikeres regisztráció <br />";
} else {
return $this->regStatus = "Sikertelen regisztráció 😞 <br />";
}
}
}
Utoljára szerkesztette: Blum, 2015.10.27. 22:16:45
unzip ; touch ; finger ; mount ; gasp ; yes ; umount ; sleep
Ha két egymásba ágyazott elemet találsz, akkor megoldható úgy, hogy nem keretet teszel rá, hanem az egyik elemre teszel before és afterrel egy egy egy pixeles oszlpot a két szélére, és a másik elemre teszel before és after segítségével egy egy sort fent és lent, és ebből a négy részből áll össze a kereted, ebben az esetben a benne lévő részek elérhetőek maradnak az egér számára.
A döntés hogy melyikkel oldod meg az attól függ, hogy módosíthatod-e a html-t ha igen akkor rakj rá egy sima divet és adj neki classt, arra rakd a keretet, ha mindenképp hacker megoldás kell, akkor javascript a megoldás, ha meg csak gyakorolni akarsz akkor érdemes ezt a másodszor felvázolt rendszert is megpróbálni ez esetben a
div#contacts:before
div#contacts:after
div#contacts table:before
div#contacts table:after
lenne a nyerő, a div relativ poziciója fog hatni a táblázat before és after elemére is, így a méretek nem fognak problémát okozni (elméletileg 😊) ).
All hail the double x!
pl. egy class, ami barmi kore rak paddingot, meg bordert? es amire akarod ezt a fura utomegoldast, arra rarakod ezt a classt?
SG troll, ban, büntetőpont, hsz törlés FAQ: http://kocsog.eu/ban/
A z-index: -1 nem megoldas mert eltunik a keret es nem lathato. Jol erzem, hogy mas megoldas nincs erre a problemara?
z-index:-1-el be tudod rakni a gomb mögé, bár úgy rémlik, nem minden böngésző szereti
Utoljára szerkesztette: passatgt, 2015.10.26. 22:57:02
az... jó
ne tedd?!
máhogy.. ne tedd.
SG troll, ban, büntetőpont, hsz törlés FAQ: http://kocsog.eu/ban/
egyébként csendben jótanács: tökjó hangzatos szavakat használsz, de azok helyett érdemes inkább gyakorolni, sokat, aztán gyakorolni mégtöbbet 😊
SG troll, ban, büntetőpont, hsz törlés FAQ: http://kocsog.eu/ban/
Mi okozza, hogy az adott divben, melyen a :before pseudo-class van minden inaktivva valik?
Koszonom.
[merlinw.org]
SG troll, ban, büntetőpont, hsz törlés FAQ: http://kocsog.eu/ban/
ez a Skrollr.js van használva tán az ilyeneknél
SG troll, ban, büntetőpont, hsz törlés FAQ: http://kocsog.eu/ban/