[PHP] url friends

Stato
Chiusa ad ulteriori risposte.

avatar

Utente Attivo
3 Gen 2017
97
0
6
54
scusami Marcus ma io non sono programmatore e non capisco niente di php , se mi dici come devo fare e meglio
 

avatar

Utente Attivo
3 Gen 2017
97
0
6
54
PHP:
} else if ((isset ($_GET ["do"])) and ($_GET ["do"] === "hublist")) { // do=hublist
    $html = str_replace ("[class_news]", "menu", $html);
    $html = str_replace ("[class_work]", "menu", $html);
    $html = str_replace ("[class_network]", "menu", $html);
    $html = str_replace ("[class_forum]", "menu", $html);
    $html = str_replace ("[class_gallery]", "menu", $html);
    $html = str_replace ("[class_hublist]", "menu active", $html);
    $html = str_replace ("[class_tools]", "menu", $html);
    $html = str_replace ("[class_stats]", "menu", $html);
    $html = str_replace ("[class_about]", "menu", $html);
    $html = str_replace ("[class_login]", "menu", $html);
    $html = str_replace ("[class_client]", "menu", $html);
    $html = str_replace ("[class_clientdc]", "menu", $html);
    $html = str_replace ("[class_Lists]", "menu", $html);

    if ($nosc) { // dont count visitors for plain text pages
        $html = str_replace ("[visit_page]", 0, $html);
        $html = str_replace ("[visit_country]", 0, $html);
    } else {
        $visit = visitcount ("hublist");
        $html = str_replace ("[visit_page]", $visit ["page"], $html);
        $html = str_replace ("[visit_country]", $visit ["country"], $html);
    }

    $echo = true;

    if ((isset ($_GET ["id"])) and ($_GET ["id"] !== "")) { // specific id
        if (($sql = $mysql->query ("select * from `hublist` where `id` = " . intval ($_GET ["id"]) . " OR `rediraddr` = '" . $mysql->escape_string ($_GET ["id"]) . "'" )) and ($sql->num_rows > 0) and ($row = $sql->fetch_array ())) {
            if ((isset ($_GET ["action"])) and ($_GET ["action"] === "comment")) { // action=comment
                $html = str_replace ("%title%", "HublistDc++ хабов Huburi" . safetext ((($row ["name"]) and ($row ["name"] !== "")) ? $row ["name"] : $row ["address"] . ((intval ($row ["port"]) !== 411) ? ":" . $row ["port"] : "")) . " - Comment", $html);
                $html = str_replace ("%id%", "hublist" . safetext ((($row ["id"]) and ($row ["id"] !== "")) ? $row ["id"] : $row ["address"] . ((intval ($row ["port"]) !== 411) ? ":" . $row ["port"] : "")) . "&action=comment", $html);
                $content = "";
                $err_author = false;
                $err_text = false;
                $err_vote = false;
                $err_code = false;
                $err_string = "";

                if (isset ($_POST ["comment_send"])) {
                    if ((isset ($_POST ["comment_author"])) and ($_POST ["comment_author"] !== "") and ($authorized === 0) and ($sql = $mysql->query ("select `class` from `accounts` where `username` = '" . $mysql->escape_string ($_POST ["comment_author"]) . "'")) and ($sql->num_rows > 0)) {
                        $err_author = true;
                        $err_string = "Author value is reserved, please use something else.";
                    } else if ((!isset ($_POST ["comment_text"])) or ($_POST ["comment_text"] === "")) {
                        $err_text = true;
                        $err_string = "Comment field is required.";
                    } else if ((isset ($_POST ["comment_vote"])) and ($_POST ["comment_vote"] !== "") and ($_POST ["comment_vote"] !== "good") and ($_POST ["comment_vote"] !== "bad")) {
                        $err_vote = true;
                        $err_string = "Vote field value is invalid.";
                    } else if (($authorized === 0) and ((!isset ($_POST ["comment_code"])) or ($_POST ["comment_code"] === ""))) {
                        $err_code = true;
                        $err_string = "Code field is required.";
                    } else if (($authorized === 0) and (!captcharesult ($_POST ["comment_codea"], $_POST ["comment_codeb"], $_POST ["comment_codec"], $_POST ["comment_code"]))) { // ($_POST ["comment_code"] !== (((isset ($_SESSION ["key"])) and ($_SESSION ["key"] !== "")) ? $_SESSION ["key"] : "123456"))
                        $err_code = true;
                        $err_string = "Invalid security code.";
                    } else if ((isset ($_POST ["comment_vote"])) and ($_POST ["comment_vote"] !== "") and ($istor)) {
                        $err_vote = true;
                        $err_string = "You can't vote for this hub because you're using Tor.";
                    } else if ((isset ($_POST ["comment_vote"])) and ($_POST ["comment_vote"] !== "") and (intval ($row ["banned"]) === 1)) {
                        $err_vote = true;
                        $err_string = "You can't vote for this hub because it's banned.";
                    } else {
                        $ok = true;

                        if ((isset ($_POST ["comment_vote"])) and ($_POST ["comment_vote"] !== "")) { // submit vote if we have one
                            if (($sql = $mysql->query ("select `id`, `time` from `hubvotes` where `addr` = '" . $mysql->escape_string ($_SERVER ["REMOTE_ADDR"]) . "' and `hub` = " . $row ["id"] . " limit 1")) and ($sql->num_rows > 0) and ($vote = $sql->fetch_array ())) {
                                if (($diff = (time () - $vote ["time"])) < 86400) {
                                    $err_vote = true;
                                    $err_string = sprintf ("You can't vote for this hub more than once a day, wait another %s.", uptimefromsec (86400 - $diff));
                                    $ok = false;
                                } else {
                                    $mysql->query ("update `hubvotes` set `vote` = '" . (($_POST ["comment_vote"] === "good") ? "+" : "-") . "', `time` = " . time () . ", `notify` = 0 where `id` = " . $vote ["id"]);
                                }
                            } else {
                                $mysql->query ("insert into `hubvotes` (`vote`, `time`, `addr`, `hub`) values ('" . (($_POST ["comment_vote"] === "good") ? "+" : "-") . "', " . time () . ", '" . $mysql->escape_string ($_SERVER ["REMOTE_ADDR"]) . "', " . $row ["id"] . ")");
                            }

                            if ($ok) {
                                $mysql->query ("update `hublist` set `" . $_POST ["comment_vote"] . "vote` = `" . $_POST ["comment_vote"] . "vote` + 1 where `id` = " . $row ["id"]);
                            }
                        }

                        if ($ok) {
                            $mysql->query ("insert into `comments` (`author`, `text`, `time`, `ip`, `type`, `type_id`) values (" . (((isset ($_POST ["comment_author"])) and ($_POST ["comment_author"] !== "")) ? "'" . $mysql->escape_string ($_POST ["comment_author"]) . "'" : "null") . ", '" . $mysql->escape_string ($_POST ["comment_text"]) . "', " . time () . ", '" . $mysql->escape_string ($_SERVER ["REMOTE_ADDR"]) . "', 5, " . $row ["id"] . ")");
                            header ("Location: https://andress/?do=hublist&id=" . $row ["id"] . "#" . $mysql->insert_id);
                            $echo = false;
 

macus_adi

Utente Attivo
5 Dic 2017
1.343
91
48
IT/SW
se mi dici come devo fare e meglio
Devi parametrizzare le richieste....
Come devo dirtelo???
Hai bisogno di un router altrimenti non funziona...
Crea un piccolo helper per settare le variabili in _GET.

"Se utilizzi molte variabili in get"
ES: arriva la stringa /do/hublist/id/10
Come devo fare?
PHP:
function createGET(){
    $expl=explode('/',$_SERVER['REQUEST_URI']);
    $my_get=[];
    $parametri_da_considerare=['do','id']
     foreach($expl as $key=>$item){
          if(in_array($item,$parametri_da_considerare) && isset($expl[$key+1]) && !isset($my_get[$item])){
                 $my_get[$item]=$expl[$key+1];
          }
     }
    //SERVE SOLO PER VEDERE SE FUNZIONA TUTTO CORRETTAMENTE
     print_r($my_get);
     //questo passaggio lo lascio solo a scopo dimostrativo, sarebbe meglio aggiungerlo all'interno del primo ciclo
    foreach($my_get as $k=>$v){
          $_GET[$k]=$v;
    }
}
Nel file index.php o dove ti piace di più, ammettendo che tu abbia importato l'helper di cui sopra o la funzione...


index.php
PHP:
/**********************PRIMA DI TUTTO IL TUO CODICE ******************/
createGET();
/**********************INIZIA IL TUO CODICE*****************************/

Tutto qui, se magari crei una definizione di rotte è meglio....
 

avatar

Utente Attivo
3 Gen 2017
97
0
6
54
pensavo che era facile , invece non ho capito niente , tu mi dici le cose come se io fossi un programmatore , non ho capito nemmeno 1 parola di quello che hai scritto , scusa
 

avatar

Utente Attivo
3 Gen 2017
97
0
6
54
il primo codice dove lo inserisco ? devo creare un file.php ? secondo codice che hai scritto lo devo mettere nella index all'inizio dopo <?php ??
 

avatar

Utente Attivo
3 Gen 2017
97
0
6
54
se inserisco tutto il codice della index di 20618 linee mi potresti aiutare meglio ?
 

avatar

Utente Attivo
3 Gen 2017
97
0
6
54
buon giorno , Marcus inserendo tutti e 2 codici nella index.php il sito non funziona , errore 500
 

avatar

Utente Attivo
3 Gen 2017
97
0
6
54
gentilmente mi puoi dire con parole povere dove e cosa devo fare per inserire i 2 codici ?
 

macus_adi

Utente Attivo
5 Dic 2017
1.343
91
48
IT/SW
Vabbè...
PHP:
function createGET(){
    $expl=explode('/',$_SERVER['REQUEST_URI']);
    $my_get=[];
     //qui mancava il ";"
    $parametri_da_considerare=['do','id'];
     foreach($expl as $key=>$item){
          if(in_array($item,$parametri_da_considerare) && isset($expl[$key+1]) && !isset($my_get[$item])){
                 $my_get[$item]=$expl[$key+1];
          }
     }
    //SERVE SOLO PER VEDERE SE FUNZIONA TUTTO CORRETTAMENTE
     print_r($my_get);
     //questo passaggio lo lascio solo a scopo dimostrativo, sarebbe meglio aggiungerlo all'interno del primo ciclo
    foreach($my_get as $k=>$v){
          $_GET[$k]=$v;
    }
}
/**********************PRIMA DI TUTTO IL TUO CODICE ******************/
createGET();
/**********************INIZIA IL TUO CODICE*****************************/
Hai controllato eventuali ; mancati o hai fatto copia incolla?
Prova.... Però devi controllare non si copia->incolla senza capire....
 

avatar

Utente Attivo
3 Gen 2017
97
0
6
54
errore 500 non ce , ma nel sito spunta questo Array ( ) e le pagine sono sempre tutte uguali
 

avatar

Utente Attivo
3 Gen 2017
97
0
6
54
tutto il codice inserito da te io faccio solamente copia e incolla e inserisco tutto nella index.php
 

avatar

Utente Attivo
3 Gen 2017
97
0
6
54
buon giorno , all'inizio della pagina web spunta questo Array ( ) e le pagine sono sempre tutte uguali
 

Max 1

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
29 Feb 2012
4.449
338
83
@avatar
Non avevi rinunciato?
Ti chiedo di non fare tanti post con poche parole (diventa anche difficile seguirti) riassumi tutto in un post
Grazie
 

avatar

Utente Attivo
3 Gen 2017
97
0
6
54
un Grazie a Marco per Aiuto e tempo dedicato per aiutarmi , Grazie Molto
 

avatar

Utente Attivo
3 Gen 2017
97
0
6
54
buona sera , Google indicizza URL cosi , dominio/hublist invece dovrebbe essere dominio/hublist/nomedellapagina , forse perché url e troppo lungo e viene indicizzato più corto da Google ? ( sarebbe buono se si puo fare dominio/nomedellapagina ed eliminare hublist ) un aiutino grazie grazie
 
Ultima modifica:
Stato
Chiusa ad ulteriori risposte.
Discussioni simili
Autore Titolo Forum Risposte Data
P Rimozione automatica url da sitemap.xml con PHP PHP 1
MarcoGrazia [PHP] [regex] Validare un url PHP 2
L [PHP] cambiare gli if in un url semplice PHP 1
I [PHP] generazione url "uguale" che punta a due immagini diverse PHP 0
L [PHP] Riscrivere url PHP 0
maxnegri Eliminare url index.php con variabili e reindirizzare alla home del sito PHP 7
L [PHP] convertire gli url ad forma semplice PHP 3
A [PHP] Inserimento url dinamici in pagina html PHP 3
I [PHP] Login Facebook SDK returned an error: No URL set! PHP 0
G [PHP] togliere sotto directory dall'url PHP 0
G [PHP] [HTML] Sito web URL e altro PHP 3
G Siti web URL e altro (PHP, HTML) Presentati al Forum 1
K [PHP] Invio dati tramite url PHP 2
C [PHP] Url Rewrite titolo pagina in url PHP 3
C [PHP] Potezione url PHP 2
S [PHP] estrarre le email da un elenco di url PHP 21
Zea URL dinamico senza GET php PHP 24
A [PHP] Url pagamento paypal in email PHP 2
SebaGravi [PHP] problema url semantici con .htaccess PHP 3
giannit [PHP] Cambio url su menu css PHP 15
C [PHP] Url sparisce lo 0 PHP 2
booklisa [PHP] Impostare constanti nelle url PHP 7
E [PHP] Redirect Alias su dominio principale con url primario PHP 4
M sostituire parte di URL con espressioni regolari PHP PHP 8
F redirect url php PHP 1
Jonn Creare URL SEO con PHP PHP 7
A Alternativa al <meta http-equiv="refresh" content="5;url=code.php" > HTML e CSS 5
M Php e mysql: tabella con URL che restituisce ID PHP 2
A Salva immagini da url via script php PHP 6
marcellokabora come modificare un url attraverso un .htaccess (swf-php-htaccess-urlrewriting) PHP 2
G Modificare URL di Pagine PHP per renderle Seo Friendly PHP 0
B Come faccio a passare l'URL dove mi trovo ad un iframe php Javascript 2
S [PHP] Esistenza Url PHP 5
F Cerco Hosting con VECCHIE versioni di php Hosting 0
Cosina Captcha php PHP 1
S passare un valore da un form a un file .php con metodo post PHP 4
N php msyql PHP 6
N php problemi a visualizzare video PHP 3
A menu a tendina php PHP 1
D protezione cartelle: blocco visualizzazione/scaricamento contenuto, ma abilitazione utilizzo dati da parte di file .php presenti sul sito Web Server 1
F Php date_diff PHP 1
K [PHP] Aggiungere caratteri ad una stringa in base alla lunghezza della stessa PHP 2
C Wp-admin a file php WordPress 5
Lino80 [Retribuito] Cerco programmatore php per modifica/inserimento funzione/valori da un plugin importer wordpress Offerte e Richieste di Lavoro e/o Collaborazione 0
csi Inviare file jpg in locale alla stampante con php PHP 0
M Passaggio variabili array php su un tasto jq PHP 3
E Php aggiornamento tabella PHP 9
G phpmailer e php 8.1 con estensione mysqli PHP 6
M Invio dati database via email php PHP 0
K [php] Problema con inner join PHP 4

Discussioni simili