Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,151,969 members, 7,814,282 topics. Date: Wednesday, 01 May 2024 at 10:27 AM

Noobs Php Questions - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Noobs Php Questions (1798 Views)

Webmasters Enter Here If You Can Solve These PHP Questions... / Post Your Php Questions Here / Pls, Answer My Php Questions (2) (3) (4)

(1) (Reply) (Go Down)

Noobs Php Questions by netesy(m): 7:10pm On Mar 24, 2012
well a iam learning php so please forgive my annoying questions in advance.
Re: Noobs Php Questions by netesy(m): 7:41pm On Mar 24, 2012
please how does this work
 if (!defined('SMF')) die('Hacking attempt...');
i saw it in my smf script.
Re: Noobs Php Questions by Nobody: 11:45am On Mar 25, 2012
meaning if the constant SMF is not defined, it should show that, its usually when you try to access a file directly though the URL instead of via the index page, e.g smf/file.php instead of smf/page/
Re: Noobs Php Questions by bigboymegzy: 1:26pm On Mar 25, 2012
Using the define function is old school!
Re: Noobs Php Questions by yawatide(f): 3:05pm On Mar 25, 2012
^^^ So what is "new school"? Mind sharing so that the dumb ones like me can learn from it and also be a part of the "new school" coding standards?
Re: Noobs Php Questions by netesy(m): 5:02pm On Mar 25, 2012
please how do you define constants on php?
Re: Noobs Php Questions by DualCore1: 10:24pm On Mar 25, 2012
netesy: please how do you define constants on php?
<?php
define("SMF",1);
?>
Re: Noobs Php Questions by UsherRaymond1: 11:54pm On Mar 25, 2012
This is really crazy o. If naija programmers no sabi reason for something, them just say na nonsense o.
No mind seun, e don ban me again. . . .for attempting to sell a clone of the old nairaland.
Re: Noobs Php Questions by netesy(m): 12:33am On Mar 26, 2012
so if the text smf is changed to maybe goat the script stops working?
Re: Noobs Php Questions by DualCore1: 7:16am On Mar 26, 2012
netesy: so if the text smf is changed to maybe goat the script stops working?

It wont stop working. Because the code does not test to see if the constant "SMF" is holding a specific value. It just tests to see if the constant "SMF" is holding anything at all. So as long as the constant "SMF" is defined and holding any value, the code below will return FALSE

<?php
if(!defined('SMF'))die('Hacking attempt...');
?>

if SMF developers wanted to check if the contant was a specific value, lets say 1...the code will be something like

<?php
define('SMF', 1); //this part should be in another file. I have joined both parts for the purpose of learning.

if(constant('SMF') != 1) die('Hacking attempt...');
?>

So this won't only check that a constant is defined but also check that the constant is set to a particular value (1), else the code dies.
The function constant() is used to get the content of a PHP constant.
Re: Noobs Php Questions by netesy(m): 7:18pm On Mar 30, 2012
please how do i make a php site end with .aspx instead of .php
Re: Noobs Php Questions by Nobody: 8:54pm On Mar 30, 2012
not to sound offensive, but you can easily get the answer from google, anyway in the httpd.conf in your apache installation you can add the extensive to which Apache parses as php. not really sure ,check.
Re: Noobs Php Questions by DualCore1: 10:11pm On Mar 30, 2012
netesy: please how do i make a php site end with .aspx instead of .php
I guess the http.conf will have something you can work with.

Alternatively you could add some regular expression in your .httacces file
This may work, I am just writing it and cannot test it for you.
=================
Options +ExecCGI
AddHandler cgi-script .py

Options +FollowSymLinks

RewriteEngine On
RewriteRule ^$\.aspx $\.php
==================

If this does not work straight up, fiddle with that last line. Its the only line I am not sure of but that's the concept.
Re: Noobs Php Questions by netesy(m): 1:09am On Mar 31, 2012
i tried this from a forum without success
<IfModule mod_mimer.c>

AddType application/x-httpd-php .aspx
</IfModule>
Re: Noobs Php Questions by DualCore1: 9:12am On Mar 31, 2012
I have re-written a .httaccess rule and have tested it.

test link: http://www.sawyerrken.net/tada.aspx

It links up to http://www.sawyerrken.net/tada.php


.httaccess rule
==================
Options +ExecCGI
AddHandler cgi-script .py

Options +FollowSymLinks

RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+).aspx$ $1.php
==================

I will explain the regular expression in the last line:
^ = the beginning of the line

([a-zA-Z0-9]+) = This groups an optional range of characters a-z, A-Z and 0-9. This will match tada.aspx, dual.aspx but will not match tada_dual.aspx. The + sign means it can take 1 or more of any of the preceding characters.

$ = signifies the end of the line on the left hand side.

$1 = this stands for a variable that I created in the left hand side. The variable is anything that matches into ([a-zA-Z0-9]+). If I had a second variable like that on the left hand side then i will use $2 to refer to it. You can go on like that $3, $4 tillll $9.

Read up on regular expressions. They are a pain to learn and most of us ignore it but its really fun to learn and use, as it saves me some validation time.
Re: Noobs Php Questions by UsherRaymond1: 12:54pm On Mar 31, 2012
Interesante, I love this. .htaccess maggick. Karamba! Seun needs to learn that, the new nairaland does not do that properly.

If I register now with username webmasters, the .htaccess of nairaland wil not be able to different my pirated username from the webmasters board - lol.

Make I shut up before them ban me again (for like thousandth time or so)
Re: Noobs Php Questions by Dager(m): 1:49pm On Mar 31, 2012
Raymond, how did u get it?
Re: Noobs Php Questions by Nobody: 1:56pm On Mar 31, 2012
Because i uhm tested it. My original I.D used to be *dhtml ya know. . . . .
Re: Noobs Php Questions by netesy(m): 1:54am On Apr 01, 2012
is there a way anybody will know if the site using it is not realy a .aspx site!?
Re: Noobs Php Questions by DualCore1: 2:17am On Apr 01, 2012
netesy: is there a way anybody will know if the site using it is not realy a .aspx site!?
I can't answer that. Most things are possible on the internet depending on the internet user's level of skill.
Re: Noobs Php Questions by netesy(m): 2:41am On Apr 01, 2012
am getting
htaccess: invalid command 'RewriteRule^([a-zA-Z0-9]+).aspx', perhaps misspelled or define by a module not included in the server configuration,
AddType application/x-httpd-php .aspx seems to be working
Re: Noobs Php Questions by DualCore1: 2:57am On Apr 01, 2012
Re: Noobs Php Questions by netesy(m): 3:44am On Apr 01, 2012
Dual Core:
http://www.phpfreaks.com/forums/index.php?topic=260159.0
thanks dual will try it now
Re: Noobs Php Questions by netesy(m): 1:00pm On Apr 01, 2012
seun_is_a_fool: You know dey sleep ni? Haba!
knowledge doenst sleep and i want her
Re: Noobs Php Questions by netesy(m): 3:08pm On Apr 08, 2012
please how can i get the country of a person with out using his/her ip with php?
Re: Noobs Php Questions by DualCore1: 8:29pm On Apr 08, 2012
A visitor'ss location can only be automatically determined by the IP of the visiting user. Any other method will involve interaction with the visitor. e.g.asking the person.
Re: Noobs Php Questions by netesy(m): 1:43am On Apr 10, 2012
please any way to turn my login system to a login class?
Re: Noobs Php Questions by Nobody: 6:56pm On Aug 30, 2014
donjayzi: Because i uhm tested it. My original I.D used to be *dhtml ya know. . . . .
Hehehe, those were days, i cant stop laughing! falls off my chair!! adon dey troll tay tay o. Seun suppose give me trollin award.

(1) (Reply)

Pls I Really Need Help From A Webmaster Or One Familiar To Hub8.com Webhost / A Professional Digital Marketer Needed. / How Do I Backup My Emails Before Transfering To A New Host

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 24
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.