Salta al contenuto

Coding

17.9k Discussioni 86.7k Post

PHP, HTML, CSS, MySQL, Javascript, Python e tutto il resto

  • Controllo username e password

    10
    thedarkita
    0 Votazioni
    10 Post
    4k Visualizzazioni
    wow avrò letto 10 volte ma nn ho capito niente
  • password con javascript?

    Spostato
    5
    sanvy
    0 Votazioni
    5 Post
    4k Visualizzazioni
    sanvy ma come fa il codice a sapere qual è la password?? Maledetto inglese Comunque ci sono le istruzioni nel codice var pass1 = "password"; // place password here Tradotto var pass1 = "password"; // Impostare la password qui
  • Script per mettere un watermark ad una foto.

    5
    enricoeur
    0 Votazioni
    5 Post
    2k Visualizzazioni
    Allora, lo script che devo modificare è il seguente: function imw_gen_image_post() { global $wpdb; $_exif = function_exists('exif_read_data'); /* POST Actions */ if( $_REQUEST['postact'] == 'genpost' ) { // GO! $siteurl = get_settings('siteurl'); $num_perpage = intval($_REQUEST['num_perpage']); $skip_resize = intval($_REQUEST['skip_resize']); $base = str_replace("\\",'/', $_REQUEST['base_url']); $path = str_replace("\\",'/', $_REQUEST['base_path']); if( $path == '' ) { $location = $PHP_SELF . "?page={$_REQUEST['page']}&msg=1"; header("Location: $location"); exit(); } $append = $_REQUEST['append']; $prepend = $_REQUEST['prepend']; $path = str_replace(ABSPATH, '', trim($path)); $dir = ABSPATH . $path; if($base == '' ) { $base = trailingslashit($siteurl) . $path; } if ( '/' == substr($base, -1)) $base = substr($base, 0, -1); if ( '/' == substr($dir, -1)) $dir = substr($dir, 0, -1); if( !file_exists($dir) ) { $location = $PHP_SELF . "?page={$_REQUEST['page']}&msg=2"; header("Location: $location"); exit(); } $width = intval($_REQUEST['i_width']); //$width = $width ? $width : 640; $height = intval($_REQUEST['i_height']); //$height = $height ? $height : 480 $html = ''; $n = 0; $files = array(); if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $files[] = $file; } } closedir($handle); } sort($files, SORT_STRING); if ( ! $skip_resize && ! wp_mkdir_p( "$dir/th" ) ) { echo sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), "$dir/th"); die(); } foreach( $files as $file) { $img = "$dir/$file"; if( ! is_file($img) ) continue; if( ($is = getimagesize($img)) === false ) continue; if( $is[2] >= 1 && $is[2] <= 6 && $is[2] ) $fn = $file; $bigmode = false; if( ! $skip_resize && $is[2] != 4 ) { $fn = 'th/' . strtolower(str_replace('.','_thumb.', $file)); iw_resize( $img, "$dir/$fn" , $width, $height); watermark($img); <--------------------- $bigmode = true; } $prepend1 = str_replace('%file%', $file, $prepend); $append1 = str_replace('%file%', $file, $append); $prepend1 = str_replace('%width%', $is[0], $prepend1); $append1 = str_replace('%width%', $is[0], $append1); $prepend1 = str_replace('%height%', $is[1], $prepend1); $append1 = str_replace('%height%', $is[1], $append1); $prepend1 = str_replace('%url%', "{$base}/{$file}", $prepend1); $append1 = str_replace('%url%', "{$base}/{$file}", $append1); if($_exif) { $exif_data = exif_read_data("$dir/$file", 0, true); if( !( $exif_data === false ) ) { $val2 = ''; foreach ($exif_data as $key => $section) { foreach ($section as $name => $val) { $k0 = strtolower($key); $k1 = strtolower($name); $val2 .= strtolower($key.'.'.$name)." = $val<br />"; $prepend1 = str_replace('%'.$k0.'.'.$k1.'%', $val, $prepend1); $append1 = str_replace('%'.$k0.'.'.$k1.'%', $val, $append1); } } $prepend1 = str_replace('%exif%', $val2, $prepend1); $append1 = str_replace('%exif%', $val2, $append1); } } if( $is[2] != 4 ) { $is = getimagesize("$dir/$fn"); $params = " {$is[3]} vspace=\"4\" alt=\"{$file}\""; $html .= $prepend1; if( $bigmode ) $html .= "<a href=\"javascript:void(0)\" onclick=\"window.open(\'{$base}/{$file}\');\" >"; $html .= "<img src=\"{$base}/{$fn}\" $params />"; if( $bigmode ) $html .= "</a>"; $html .= $append1; $n++; }else{ } // $n++; if( $num_perpage && ($n%$num_perpage==0) ) { $html .= "\n<!--more-->\n"; } } $_POST['comment_status'] = 'open'; $_POST['advanced_view'] = 1; $_POST['post_category'] = array(); $_POST['post_status'] = $_REQUEST['post_type']; $_POST['content'] = $html; $_POST['post_title'] = $_POST['post_title'] ? $_POST['post_title'] : 'Image Wizard Draft'; $post_ID = write_post(); if( $post_ID ) { $location = "post.php?action=edit&post=$post_ID"; } else { $location = $PHP_SELF . "?page={$_REQUEST['page']}"; } header("Location: $location"); exit(); } /* END */ ?> In pratica fa questo si legge tutte le immagini in una cartella, e crea per ciascuna una miniatura, salvandola in un subdirectory della cartella madre tramite la funzione seguente: function iw_resize($image_path, $target_path, $max_width, $max_height) { //echo "<br/>Processing $image_path --> $target_path<br/>"; # Load image $img = null; $ext = strtolower(end(explode('.', $image_path))); if ($ext == 'jpg' || $ext == 'jpeg') { $img = @imagecreatefromjpeg($image_path); } else if ($ext == 'png') { $img = @imagecreatefrompng($image_path); # Only if your version of GD includes GIF support } else if ($ext == 'gif') { $img = @imagecreatefrompng($image_path); } # If an image was successfully loaded, test the image for size if ($img) { # Get image size and scale ratio $width = imagesx($img); $height = imagesy($img); $scale = min($max_width/$width, $max_height/$height); # If the image is larger than the max shrink it if ($scale < 1) { $new_width = floor($scale*$width); $new_height = floor($scale*$height); # Create a new temporary image $tmp_img = imagecreatetruecolor($new_width, $new_height); # Copy and resize old image into new image //imagecopyresized imagecopyresampled imagecopyresampled($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagedestroy($img); $img = $tmp_img; } } # Create error image if necessary if (!$img) { $img = imagecreate($max_width, $max_height); imagecolorallocate($img,0,0,0); $c = imagecolorallocate($img,70,70,70); imageline($img,0,0,$max_width,$max_height,$c2); imageline($img,$max_width,0,0,$max_height,$c2); } # Save the image imagejpeg($img, $target_path); } Bene allora ho detto mettiamo una funzione watermark($img) che applico a ciscuna delle immagini nel loop principale, (l'ho indicata in nero nel codice - vedi primo blocco) La funzione, per quel poco che ne capisco di PHP l'ho scritta così: function watermark($image_path) { echo "<br/>Applicazione watermark $image_path<br/>"; # Load image $img = null; $ext = strtolower(end(explode('.', $image_path))); if ($ext == 'jpg' || $ext == 'jpeg') { $img = @imagecreatefromjpeg($image_path); } else if ($ext == 'png') { $img = @imagecreatefrompng($image_path); # Only if your version of GD includes GIF support } else if ($ext == 'gif') { $img = @imagecreatefrompng($image_path); } # If an image was successfully loaded, test the image for size if ($img) { # Get image size and scale ratio //$larghezza = imagesx($img); //$altezza = imagesy($img); //$copyright = www.miosito.com; $tmp_img = $img; $textcolor = imagecolorallocate($tmp_img, 255, 255, 255); imagestring($tmp_img, 5, 6, 6, www.miosito.com, $textcolor); //$scale = min($max_width/$width, $max_height/$height); imagedestroy($img); $img = $tmp_img; # If the image is larger than the max shrink it /* if ($scale < 1) { $new_width = floor($scale*$width); $new_height = floor($scale*$height); # Create a new temporary image $tmp_img = imagecreatetruecolor($new_width, $new_height); # Copy and resize old image into new image //imagecopyresized imagecopyresampled imagecopyresampled($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagedestroy($img); $img = $tmp_img; } */ } # Create error image if necessary if (!$img) { echo "<br/>Errore nell'immagine sorgente<br/>"; } # Save the image imagejpeg($img, $image_path, 75); } In pratica vorrei che: il programma si scorre le immagini, per ciascuna crea la miniatura e poi piglia l'iimagine originale, vi applica l'watermark ( una semplice stringa col nome del mio sito ) e sovrascrive il file originale. Solo questo. L'errore che ricevo è il seguente, chiaramente l'watermark non me lo mette: Warning: imagejpeg(): 101 is not a valid Image resource in /home/content/a/m/a/amaporn86/html/wp-content/plugins/imagewiz.php on line 422 Warning: Cannot modify header information - headers already sent by (output started at /home/content/a/m/a/amaporn86/html/wp-content/plugins/imagewiz.php:372) in /home/content/a/m/a/amaporn86/html/wp-content/plugins/imagewiz.php on line 194 Resto in attesa di una dritta che mi illumini su cosa sbaglio. GRAZIE
  • inviare con mail() una pagina html

    6
    niko
    0 Votazioni
    6 Post
    3k Visualizzazioni
    $fileHtml lo puoi provare a passare a mail (al posto di $msg) ma vedrai che non la vedi formattata, per mandarla formattata puoi provare la funzione che ti ho postato prima o altre che sono in rete (in questo caso i parametri non saranno gli stessi!)
  • stampare file inseriti

    5
    matti
    0 Votazioni
    5 Post
    964 Visualizzazioni
    Esattamente con il codice che ti ho postato. Dove c'é il commento // TUO CODICE fai la echo dei campi che ti interessano.
  • modifica database con php

    7
    moonswolf
    0 Votazioni
    7 Post
    2k Visualizzazioni
    A grandi linee, ma dovresti provare tu, devi fare come ti ho detto prima nel form. Nella pagina di atterraggio qualcosa di simile a questo: [COLOR=#000000][COLOR=#0000bb]$nome_tabella [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#dd0000]"wp_posts"[/COLOR][COLOR=#007700]; [/COLOR][COLOR=#0000bb]$visua [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#dd0000]"select ID, ordine from $nome_tabella "[/COLOR][COLOR=#007700]; [/COLOR][COLOR=#0000bb]$risult [/COLOR][COLOR=#007700]= @[/COLOR][COLOR=#0000bb]mysql_query[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$visua[/COLOR][COLOR=#007700],[/COLOR][COLOR=#0000bb]$connessione[/COLOR][COLOR=#007700]) or die ([/COLOR][COLOR=#dd0000]"Non si possono vedere i risultati."[/COLOR][COLOR=#007700]); [/COLOR][COLOR=#007700]while ([/COLOR][COLOR=#0000bb]$row [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]mysql_fetch_array[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$risult[/COLOR][COLOR=#007700])) { [/COLOR][COLOR=#0000bb]$ID [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]$row[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]'ID'[/COLOR][COLOR=#007700]]; [/COLOR][COLOR=#0000bb]$ordine [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]$row[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]'ordine'[/COLOR][COLOR=#007700]]; [/COLOR][/COLOR]$nomeOrdine = 'ordine' . $ID; [COLOR=#000000][COLOR=#0000bb]$valOrdine [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]$_POST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]$nomeOrdine[/COLOR][COLOR=#007700]]; [/COLOR][/COLOR][COLOR=#000000][COLOR=#0000bb]$upd [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#dd0000]"UPDATE $nome_tabella SET valore_ordine = '$valOrdine' WHERE id = '$ID'"; [/COLOR][COLOR=#0000bb]$risultUpd [/COLOR][COLOR=#007700]= @[/COLOR][COLOR=#0000bb]mysql_query[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$upd[/COLOR][COLOR=#007700],[/COLOR][COLOR=#0000bb]$connessione[/COLOR][COLOR=#007700]) or die ([/COLOR][COLOR=#dd0000]"Non riesco a salvare."[/COLOR][COLOR=#007700]); [/COLOR][/COLOR] }
  • Problema con il formato data

    3
    ignazio79
    0 Votazioni
    3 Post
    2k Visualizzazioni
    massimux ti conviene studiarti la funzione Mktime^_^ Ok grazie del suggerimento
  • variabili

    9
    moreno
    0 Votazioni
    9 Post
    1k Visualizzazioni
    grazie adesso funziona
  • join in php

    1
    dariol86
    0 Votazioni
    1 Post
    1k Visualizzazioni
    Nessuno ha risposto
  • News sul mio sito

    Spostato
    3
    marcosh
    0 Votazioni
    3 Post
    2k Visualizzazioni
    grazie mille funziona solo sotto registrazione , ma funziona molto bene Grazie ancora
  • Numero files in directory

    5
    lunas
    0 Votazioni
    5 Post
    2k Visualizzazioni
    La funzione scandir(), esclusivamente in PHP5, ritorna automaticamente un elenco di tutti i file e cartelle contenuti in una directory, senza il bisogno di dover impostare un ciclo. Da quì poi personalizzi in base alle tue esigenze array scandir ( string directory [, int sorting_order [, resource context]] ) @ http://www.php.net/manual/en/function.scandir.php
  • echo con windowclose

    5
    matti
    0 Votazioni
    5 Post
    870 Visualizzazioni
    massy te lo ha scritto in modo chiaro^_^ ma anche così va bene
  • Problema in php

    13
    dariol86
    0 Votazioni
    13 Post
    2k Visualizzazioni
    mi sto spaccando la testa non riesco prprio a farlo andare ora ho provato così <? session_start(); session_register("nickname1"); $nickname1=$_GET['nickname1']; session_register("password1"); $password1=$_GET['password1']; ?> <html> ... ... solo che quando torno indietro mi dice Undefined index su password1 e nickname1 quelle due varibili gle le dò nel'index e gle le passo a questa pagina tramite url e sono $_GET['nickname1'] non sono delle varibili di questa pagina nn so come fare!! sono disperato, Poi non posso toglere quegli avvisi perchè fin che nn risolco il problema quando l'utente trona in quella pagina non viene riconosciuto. Poi forse sbaglio a mettere la sessione. V messa dove inserisco nick e password o nella paginariservato dove gle li passo dalla pagina prima?
  • funzione

    6
    massimux
    0 Votazioni
    6 Post
    949 Visualizzazioni
    purtroppo il inserisco una query in online che mi verifica se ci sono o meno e non voglio fare nessun update^^ devo risolvere in quel modo^^ e per le sessioni iniziali è lo stesso^^
  • [Tutorial] La Gestione degli utenti in PHP e MySQL

    Spostato
    62
    pater
    0 Votazioni
    62 Post
    43k Visualizzazioni
    Ciao ragazzi, io ho provato questo metodo ma non riesco a capire se è giusto... Se visualizzo l'archivio con PhpMyAdmin il campo password è rimasto uguale... non dovrebbe essere registrato criptato? Purtroppo ho iniziato da poco a programmare in php e MySql e non sono molto capace. Grazie e Buona Giornata a tutti!
  • Bordo tabella tratteggiato ...

    Spostato
    6
    raul
    0 Votazioni
    6 Post
    5k Visualizzazioni
    Grazie funziona alla grande! Anche con IE
  • Dimensioni in pixel di una scritta

    Spostato
    2
    seabird
    0 Votazioni
    2 Post
    2k Visualizzazioni
    Grazie Ludus! Un po' complicato e lungo, però funziona. A dire il vero però, speravo in un metodo più semplice Come a cosa mi serve? Ad evitare gli "a capo" e a mettere più celle in una stessa riga.
  • PAgina PHP solo per Registrati?

    6
    gexxy
    0 Votazioni
    6 Post
    2k Visualizzazioni
    gexxy il modulo sono riuscito a farlo peroì non mi compare la colonna destra del sito...mentre la parte sinistra superiore e inferiore escono con che comando posso farla uscire? Grazie 1000 Ciao gexxy, se non sbaglio devi settare la variabile $index = 1; nel tuo modulo. Saluti.
  • Creare Pagina aggiungi record DB

    Spostato
    47
    la.maglia.rosanero
    0 Votazioni
    47 Post
    6k Visualizzazioni
    si scusa allora..... niente mi arriva la mail : Inserito Nuovo Record con queste Caratteristiche Titolo: Anno: Partita: Data: Marcatori: Size: Parole Chiave: URL: usando questo codice : Set objMail.Configuration = objConfig objMail.From = "[email protected]" ' Mittente objMail.To = "[email protected]" ' Destinatario objMail.Subject = "Inserito nuovo record nel DB" ' Oggetto body = body & "Inserito Nuovo Record con queste Caratteristiche" & vbCrLf body = body & "Titolo: " & titolo & vbCrLf body = body & "Anno: " & anno & vbCrLf body = body & "Partita: " & partita & vbCrLf body = body & "Data: " & data & vbCrLf body = body & "Marcatori: " & marcatori & vbCrLf body = body & "Size: " & size & vbCrLf body = body & "Parole Chiave: " & parole_chiave & vbCrLf body = body & "URL: " & url & vbCrLf objMail.HTMLBody = body objMail.Send() Set objMail = Nothing %> non mi inserisce neanche cio che ho scritto nei campi!
  • Provare le classi.

    Spostato
    7
    andreax
    0 Votazioni
    7 Post
    1k Visualizzazioni
    Hai Top Style free o a pagamento? Esiste per Mac TopStyle?
Home Accedi Registrati