Gratis onderhouds script

Gestart doorPropje17 reacties76 weergaven

18 berichten · pagina 1 van 2

Propje

Lid · Topicstarter

Berichten
2.517
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo,

ik ben bezig om meer php enzovoort te leren en wil mijn ervaring delen met jullie,
ik heb een onderhouds script gemaakt. Het script mag niet verkocht worden en de copyright moet blijven staan.

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]//Copyright © propje @ one2xs[/COLOR]
[COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]SELECT onderhoud FROM website WHERE onderhoud = "0"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]error[/COLOR][COLOR= #007700]);[/COLOR] 
[COLOR= #0000BB]$rij[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$rij[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]onderhoud[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]site is wel online[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]site is momenteel offline[/COLOR][COLOR= #007700];
 }[/COLOR]
?>


mysql db:

CREATE TABLE `website` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `onderhoud` varchar(30) COLLATE latin1_general_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=2 ;


Succes er meethumbsup
gr propje
0
Berichten
3.112
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Je selecteert iets waar onderhoud 1 is, en daarna kijk je of hij niet 0 is?
0
Propje

Lid · Topicstarter

Berichten
2.517
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dat was dus een foutje wink
0
Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nu selecteer je ets die 0 is en dan ga je kijken of dat zo is. Als je zoals nu wt blijven doen moet je mysql num rows gebruiken, anders moet je je SQL aanpassen door de WHERE weg te halen. Heb je het wel uitgetest? confused
0
Berichten
1.053
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Is er vraag naar een onderhoud systeem? Want dan wil ik wel een uitgebreidere maken?
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Waarom zou je dit in de database willen opslaan? Wat nou als je de site in onderhoud wilt plaatsen als je de database aan het verhuizen bent? wink
Juist smile
Om die reden heb ik in de config een true of false mogelijkheid i.c.m een IP-whitelist.
Zo kan ik er wel op, bij onderhoud, en anderen niet.

Een echo is verder niet zon rocketsience wink
0
Berichten
2.609
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
En volgens mij gebruik je "or die" als jij iets fout doet ga je toch ook niet dood? (Bron: Aarcarly)yummie
0
Berichten
4.912
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
    [URL="http://www.php.net/class"]class[/URL] onderhoud
        [COLOR= #007700]{
        function[/COLOR] check[COLOR= #007700]([/COLOR][COLOR= #0000BB]$answer[/COLOR][COLOR= #007700])
            {[/COLOR]
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$answer[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #DD0000]ja[/COLOR][COLOR= #007700])
                {[/COLOR]
                    [URL="http://www.php.net/return"]return[/URL] TRUE[COLOR= #007700];
                }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
                    [URL="http://www.php.net/return"]return[/URL] FALSE[COLOR= #007700];
                }
            }
        function[/COLOR] style[COLOR= #007700]()
            {[/COLOR]
            [URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]onderhoud.html[/COLOR][COLOR= #007700];
            }
        }[/COLOR]
        [COLOR= #0000BB]$onderhoud[/COLOR] [COLOR= #007700]= new[/COLOR] onderhoud[COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$onderhoud[/COLOR][COLOR= #007700]->[/COLOR]check[COLOR= #007700]([/COLOR][COLOR= #DD0000]ja[/COLOR][COLOR= #007700]) ==[/COLOR] TRUE[COLOR= #007700])
            {[/COLOR]
            [COLOR= #0000BB]$onderhoud[/COLOR][COLOR= #007700]->[/COLOR]style[COLOR= #007700]();[/COLOR]
            [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]();
            }[/COLOR]
?>


ik gebruik het zo (Niet getest.)
0
Berichten
1.631
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Of zo:

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]//Copyright © propje @ one2xs[/COLOR]
[COLOR= #0000BB]$online[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]jup[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$rij[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Website is offline we zien je graag terug.[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$whitelist[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]127.0.0.1[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$online[/COLOR] [COLOR= #007700]!=[/COLOR] [COLOR= #DD0000]jup[/COLOR][COLOR= #007700]){[/COLOR] [COLOR= #FF8000]//als hij dus offline is[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #0000BB]$whitelist[/COLOR][COLOR= #007700]){[/COLOR]
        [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$error[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]//We willen natuurlijk dat ze de website niet te zien krijgen.[/COLOR]
    [COLOR= #007700]}
}[/COLOR]
?>
0
Berichten
4.912
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wouterp schreef:
Of zo:

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]//Copyright © propje @ one2xs[/COLOR]
[COLOR= #0000BB]$online[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]jup[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$rij[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Website is offline we zien je graag terug.[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$whitelist[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]127.0.0.1[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$online[/COLOR] [COLOR= #007700]!=[/COLOR] [COLOR= #DD0000]jup[/COLOR][COLOR= #007700]){[/COLOR] [COLOR= #FF8000]//als hij dus offline is[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #0000BB]$whitelist[/COLOR][COLOR= #007700]){[/COLOR]
        [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$error[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]//We willen natuurlijk dat ze de website niet te zien krijgen.[/COLOR]
    [COLOR= #007700]}
}[/COLOR]
?>
Nee gewoon niet.
waarom is er een $rij variable als die niks ophaalt?
en dan ook nog jup? waarom niet yes or no of ja en nee?
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Nog toffer als je de whitelist als een array gebruikt smile
En waarom zou je willen vergelijken met jup, je was hopelijk al bekend met true/false booleans?
0
Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$online[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Website is offline we zien je graag terug.[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$whitelist[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]127.0.0.1[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]11.22.33.44[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]55.66.77.88[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$online[/COLOR] [COLOR= #007700]===[/COLOR] false [COLOR= #007700]&& ![/COLOR][URL="http://www.php.net/in_array"]in_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$whitelist[/COLOR][COLOR= #007700])) {[/COLOR]
    [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$error[/COLOR][COLOR= #007700]);
}[/COLOR]
?>
0
Berichten
1.631
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Smiegles schreef:
Eerdere citaten tonen
Wouterp schreef:
Of zo:
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]//Copyright © propje @ one2xs[/COLOR]
[COLOR= #0000BB]$online[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]jup[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$rij[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Website is offline we zien je graag terug.[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$whitelist[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]127.0.0.1[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$online[/COLOR] [COLOR= #007700]!=[/COLOR] [COLOR= #DD0000]jup[/COLOR][COLOR= #007700]){[/COLOR] [COLOR= #FF8000]//als hij dus offline is[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #0000BB]$whitelist[/COLOR][COLOR= #007700]){[/COLOR]
        [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$error[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]//We willen natuurlijk dat ze de website niet te zien krijgen.[/COLOR]
    [COLOR= #007700]}
}[/COLOR]
?>

Nee gewoon niet.
waarom is er een $rij variable als die niks ophaalt?
en dan ook nog jup? waarom niet yes or no of ja en nee?

Vergeten weg te halen. Maakt niet zoveel uit.
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Jponsen schreef:
[COLOR= #0000BB]<?php
$online[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Website is offline we zien je graag terug.[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$whitelist[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]127.0.0.1[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]11.22.33.44[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]55.66.77.88[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$online[/COLOR] [COLOR= #007700]===[/COLOR] false [COLOR= #007700]&& ![/COLOR][URL="http://www.php.net/in_array"]in_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$whitelist[/COLOR][COLOR= #007700])) {[/COLOR]
    [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$error[/COLOR][COLOR= #007700]);
}[/COLOR]
?>
Zo heb ik het ook. En ja, die die() zien we maar even door de vingers.
0
Berichten
5.795
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Waarom moet dit een "Ik gebruik het zo, de mijne is beter" topic?
Als hij dit wil delen en zoals hij zij, En dat hij het leerde.
Als je dan je eigen script wil laten zien maak dan even een eigen topic aan
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