Upload script, helemaal gratis!

Gestart doorJanm41 reacties123 weergaven

42 berichten · pagina 2 van 3

Janm

Lid · Topicstarter

Berichten
6.170
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Sebastiaanh schreef:
Wel een leuk layoutje pompom
Ja zie mijn onderschrift, CSS is ook mijn beste taal smile.
FULL CSS, wat wil je nog meer emo
@radio, bedankt ga ik even nazoeken.

//offtopic: zie ook mijn topic bij tutorials hoe je zon tweet button maakt, kreeg er veel vragen over wink
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Ik open het script en mijn oog valt al meteen op onnodige code:

Codeblok (Regel 3/4):

1
2

$result = mysql_query("SELECT * FROM upload");
$num_rows = mysql_num_rows($result);

Waarom alles ophalen als je toch alleen de count wil?

Codeblok (index.php - regel 3/4):

1
2

$result = mysql_query("SELECT 1 FROM upload");
$num_rows = mysql_num_rows($result);

Codeblok (index.php - regel 13):

1

echo ""."$num_rows"."";?>

Waarom "". " gebruiken?

Codeblok (index.php - regel 13):

1

echo $num_rows; ?>

Hetzelfde met je header.php, daar heb je met sitenaam

<title>[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]""[/COLOR][COLOR= #007700].[/COLOR] [COLOR= #0000BB]$sitenaam[/COLOR] [COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR] ?></title>


ipv

<title>[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$sitenaam[/COLOR][COLOR= #007700];[/COLOR] ?></title>


Verde heb ik er niet echt naar gekeken, omdat het rommelige indenting heeft. Dit zou ik ook even aanpassen. Dit script aanpassen zoals het er nu uit ziet is namelijk een hel om te doen.

Zie dit niet als zomaar kritiek, maar als opbouwende kritiek. smile
upload_file ziet er dan zo uit, veel leesbaarder mijns inziens (mogelijk zitten er nog spaties in van oude code. Dan is de indenting alsnog fucked up):
Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]includes/header.php[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]includes/config.php[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$fileAllowed[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]image/gif[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]image/jpeg[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]image/pjpeg[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]image/png[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/in_array"]in_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"file"[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]"type"[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$fileAllowed[/COLOR][COLOR= #007700]) && ([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"file"[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]"size"[/COLOR][COLOR= #007700]] <[/COLOR] [COLOR= #0000BB]30000[/COLOR][COLOR= #007700]))
{[/COLOR]
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"file"[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]"error"[/COLOR][COLOR= #007700]] >[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])
    {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Return Code: "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"file"[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]"error"[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]"<br />"[/COLOR][COLOR= #007700];
    }[/COLOR]
      [URL="http://www.php.net/else"]else[/URL]
    [COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO upload (nummer, naam) VALUES (, "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"file"[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]"name"[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]")"[/COLOR][COLOR= #007700]);[/COLOR]
    ?>
    <div id="box">
        <div id="thumbnailheader" style="margin-left: 120px">
            <h1>Bestand geupload!</h1>
            <a href="https://twitter.com/share" class="twitter-share-button" data-url="[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$link[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$map[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"/"[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"file"[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]"name"[/COLOR][COLOR= #007700]];[/COLOR] ?>" data-text="[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$tweettekst[/COLOR][COLOR= #007700];[/COLOR] ?>" data-lang="nl" data-size="[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$buttonformaat[/COLOR][COLOR= #007700];[/COLOR] ?>" data-count="none">Tweeten</a>
            <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script><br /><br />
        </div>

        <div id="thumbnail" style="float: left; margin-top: -75px;">
            <a href=#vb><img src=[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$map[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"/"[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"file"[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]"name"[/COLOR][COLOR= #007700]];[/COLOR] ?> width=100px height=85px></a>;
        </div><br /><br />

        <table style=width: 100%>";
               <tr>
                <td style=padding: 0px; vertical-align: top;><strong>Naam:</strong></td>
                <td>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"file"[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]"name"[/COLOR][COLOR= #007700]];[/COLOR] ?></td>
            </tr>
            <tr>
                <td style=padding: 0px; vertical-align: top;><strong>Type:</strong></td>
                <td>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"file"[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]"type"[/COLOR][COLOR= #007700]];[/COLOR] ?></td>
            </tr>
            <tr>
                <td style=padding: 0px; vertical-align: top;><strong>Grootte:</strong></td>
                <td>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"file"[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]"size"[/COLOR][COLOR= #007700]][/COLOR] / [COLOR= #0000BB]1024[/COLOR][COLOR= #007700]);[/COLOR] ?> Kb</td>
            </tr>
        [COLOR= #0000BB]<?php[/COLOR]
        [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/file_exists"]file_exists[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]""[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$map[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"/"[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"file"[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]"name"[/COLOR][COLOR= #007700]]))
          {[/COLOR]
          ?>
              <tr>
                <td style=padding: 0px;><strong>Directe link:</strong></td>
                <td> <input type=text onclick="this.focus();this.select();" value=[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$link[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$map[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"/"[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"file"[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]"name"[/COLOR][COLOR= #007700]];[/COLOR] ?>/></td>
            </tr>
    
        [COLOR= #0000BB]<?php[/COLOR]
         [COLOR= #007700]}[/COLOR]
        [URL="http://www.php.net/else"]else[/URL]
          [COLOR= #007700]{[/COLOR]
              [URL="http://www.php.net/move_uploaded_file"]move_uploaded_file[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"file"[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]"tmp_name"[/COLOR][COLOR= #007700]],[/COLOR]  [COLOR= #0000BB]$map[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"/"[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"file"[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]"name"[/COLOR][COLOR= #007700]]);[/COLOR]
          ?>
              <tr>
                <td style=padding: 0px;><strong>Directe link:</strong></td>
                <td> <input type=text onclick="this.focus();this.select();" value=[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$link[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$map[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]/[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"file"[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]"name"[/COLOR][COLOR= #007700]];[/COLOR] ?>/></td>
            </tr>
         [COLOR= #0000BB]<?php[/COLOR]
          [COLOR= #007700]}[/COLOR]
          ?>
        </table><br />
          
        <div id="vb">
            <strong>Voorbeeld:</strong><br />
            <a id="example2" href="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$map[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]/[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"file"[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]"name"[/COLOR][COLOR= #007700]];[/COLOR] ?>">
                <img alt="example2" src=[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$map[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"file"[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]"name"[/COLOR][COLOR= #007700]];[/COLOR]?> width=100% height=75%>
               </a><br /><br />
      
               <input type="button" value="Terug" onClick="parent.location=index.php">
       </div>
       
    </div>
       
    [COLOR= #0000BB]<?php[/COLOR] 
        [URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]includes/footer.php[/COLOR][COLOR= #007700];
    }
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
      ?>
      <div id="box">
          <h1>Uploaden mislukt!</h1>
          Bestand te groot, een verkeerd bestandstype of je hebt helemaal niets geupload! <br /><br />       
 
         <input type="button" value="Terug" onClick="parent.location=index.php">
      </div>
      [COLOR= #0000BB]<?php[/COLOR] 
      [URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]includes/footer.php[/COLOR][COLOR= #007700];
}[/COLOR]
?>
0
Janm

Lid · Topicstarter

Berichten
6.170
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
@Rik bedankt, ik ga er aan werken.
Hoe heb je dat trouwens zo uitgelijnd gekregen? Heb je daar een tool voor of heb je dat gewoon aangeleerd?
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Janm schreef:
@Rik bedankt, ik ga er aan werken.
Hoe heb je dat trouwens zo uitgelijnd gekregen? Heb je daar een tool voor of heb je dat gewoon aangeleerd?
Mijn IDE (Integrated development environment) zorgt daar enigzins zelf voor. Maar als ik op tab druk insert hij als het goed is ook 4 spaties. Dit is de algemene standaard in zon beetje elke programmeertaal.

Dus na elke { indent je 4 naar rechts, en bij elke } keer je weer terug naar dat level:

[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]( ... ) {[/COLOR]

    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]iets[/COLOR][COLOR= #007700];[/COLOR]

    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]( ... ) {[/COLOR]

        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]iets 2[/COLOR][COLOR= #007700];

    }[/COLOR]

    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]oh hallo[/COLOR][COLOR= #007700];

}[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]hallo 2[/COLOR][COLOR= #007700];[/COLOR]

?>
0
Berichten
5.897
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Er bestaat daar ook een plugin voor in notepad++

Gebruik bij het invoegen in de DB ook mysql_real_escape_string
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
En je foutafhandeling in je query is met vakantie.
0
Janm

Lid · Topicstarter

Berichten
6.170
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
@Rik
Ja dat wist ik, alleen let ik daar niet steeds op als je snel iets wil testen typ je het snel en test je het uit. Werkt het dan snel weer verder gaan. En jij werkt met Adobe Dreamweaver toch? Werkt dat veel fijner dan NotePad ++.

@Maarten, ohja dat klopt. Zal ik toevoegen. Heb je ook even een PM gestuurd

@Aarclay, slordigheids foutje emo
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Ik werk met Adobe Dreamweaver CS5 ja. Is niet ideaal voor PHP maar het doet wat het moet doen en ik heb geen zin om een andere PHP IDE (bijvoorbeeld PHPed) te downloaden.

En zelfs al test ik iets snel, dan nog let ik op indenting. Het is gewoon iets dat je automatisch gaat doen als je langer aan het programmeren bent.
0
Janm

Lid · Topicstarter

Berichten
6.170
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Rik schreef:
Ik werk met Adobe Dreamweaver CS5 ja. Is niet ideaal voor PHP maar het doet wat het moet doen en ik heb geen zin om een andere PHP IDE (bijvoorbeeld PHPed) te downloaden.

En zelfs al test ik iets snel, dan nog let ik op indenting. Het is gewoon iets dat je automatisch gaat doen als je langer aan het programmeren bent.
Oké, ik heb nu Notepad# van Maarten, en het werkt wel goed. Het doet precies wat je zei met:

[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]( ... ) {[/COLOR]

    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]iets[/COLOR][COLOR= #007700];[/COLOR]

    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]( ... ) {[/COLOR]

        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]iets 2[/COLOR][COLOR= #007700];

    }[/COLOR]

    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]oh hallo[/COLOR][COLOR= #007700];

}[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]hallo 2[/COLOR][COLOR= #007700];[/COLOR]

?>
0
Berichten
3.112
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Maartenl schreef:
Er bestaat daar ook een plugin voor in notepad++

Gebruik bij het invoegen in de DB ook mysql_real_escape_string
Wat is die plug-in als ik vragen mag?
0
Berichten
186
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wel nice wink Ik heb hem gedownload wink
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Gamedealer schreef:
Eerdere citaten tonen
Maartenl schreef:
Er bestaat daar ook een plugin voor in notepad++
Gebruik bij het invoegen in de DB ook mysql_real_escape_string

Wat is die plug-in als ik vragen mag?
Indent by flod
0
Berichten
513
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Voor als je een andere editor wilt PHPDesigner Hij kan elke script taal
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Zullen we nu wel weer ontopic gaan smile
0
Berichten
3.425
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Leuk man, 1 of andere kleuter heeft een porno plaatje in V2 ge-upload.
Altijd weer die kinderachtige mensen die zo iets leuks moeten verpesten.
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren