Forums
May 15, 2024, 11:20 AM

Author Topic: PHP expert needed!  (Read 5316 times)

0 Members and 1 Guest are viewing this topic.

Re: PHP expert needed!
« Reply #30 on: March 29, 2012, 02:15 PM »
If you wanna make your site really SEO friendly, then you can use subdomains (hu.site.com) or simulate subdirectories (site.com/hu) using Apache's mod_rewrite (if you are running this web server). Internationalization isn't a simple task, because there are many things which can be different (time format, money, etc), but (ye, again :D) frameworks allow to solve it with minimum effort and you can learn how to do that in a good way by reading their source code :)


dt`wreckz: zooks are effected my win

Offline Ray

Re: PHP expert needed!
« Reply #31 on: March 29, 2012, 02:57 PM »
www.celpont-music.com

Just change the language at the top left and see how the news change their date formats. ;) The website is not anywhere near broad enough to really need a framework, it's absolutely unnecessary. I will use those once my skills are on a level when I make huge projects, until then
Quote
(ye, again :D)
I'll keep practising the coding.

I am familiar with mod-rewrite - as much as anyone can be, what a pain in the ass .htaccess is, jesus... - and I do use it for friendly urls, such as domain.com/download/something.zip -> domain.com/download.php?file=something.zip, you get what I'm saying. But the idea is: like tus-wa.com, you change the language, but the url does not change.

So back to my previous post: any better ideas? :)

Re: PHP expert needed!
« Reply #32 on: March 29, 2012, 03:05 PM »
Better idea than sessions? Cookies then! A session will be "destroyed" when you'll close your browser, a user will need to select language again and again... But as u said, it's not seo-friendly way. I mean it's a good idea to save user language, but translated pages should be also accessable via site.com/language_id/page_id or smth like that.


dt`wreckz: zooks are effected my win

Offline Ray

Re: PHP expert needed!
« Reply #33 on: March 29, 2012, 03:22 PM »
Yea, the use of cookies is a good idea, but I think you didn't get what my question was. Anyway, I'm going with my idea on this one.

Offline Ray

Re: PHP expert needed!
« Reply #34 on: April 30, 2012, 12:59 PM »
I love this topic. :D

How do you manually send out 404 message to a browser? On this website, I use only the index.php file, every single sub-page is inside that, like this: celpont-music.com/index.php?1=calendar

Now, if you are given this url: celpont-music.com/index.php?1=calendarrrr the page does not generate 404, even though that is not actually a page.

I tried the following code in the top line:

Code: [Select]
$pages = array('', 'home', 'calendar', 'biography', 'discography', 'gallery');
if (isset($_GET[1]) && !in_array($_GET[1], $pages)) header('HTTP/1.0 404 Not Found');

Apparently, it does not work, since it loads the page instead of sending the user to the 404 error page. :-X

Re: PHP expert needed!
« Reply #35 on: April 30, 2012, 01:12 PM »
header('HTTP/1.0 404 Not Found') doesn't automatically show the error page. It just sends headers... Probably you want smth like:

Code: [Select]
header('HTTP/1.0 404 Not Found');
die('ZOMG THE ERROR!!!');

 :D


dt`wreckz: zooks are effected my win

Offline Ray

Re: PHP expert needed!
« Reply #36 on: April 30, 2012, 01:20 PM »
I love how you never understand my questions. :D

I want to achieve that the web server actually understands that by giving wrong values to $_GET[1] it should respond with a 404. But since the web server understands the index.php file to be it's resource, that file can be served and it returns with a 200 response.

That of course leads to empty pages being able to be indexed and all kinds of mess. I need a workaround for this.

Offline MonkeyIsland

Re: PHP expert needed!
« Reply #37 on: April 30, 2012, 02:24 PM »
Do you want an error page similar to the 404 error your webserver is giving? This error you mean?

If so, here are 2 ways to achieve that:
1. Define all your pages in .htaccess file, then if that didn't qualify, htaccess automatically tell web server to show 404 error.
2. Trick your php to act like your webserver 404. For example this is the HTML code of your web server 404 page:

Code: [Select]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>DotRoll Kft. </title>
<link rel="stylesheet" href="/http-error/style.css" type="text/css"/>
</head>

<body>

<div class="upper"></div>
<div class="empty"><img src="/http-error/img/logo.jpg" width="329" height="89" /></div>
    <div class="middle"><div class="info"><img src="/http-error/img/404.jpg" width="120" height="75" alt="404error" /></div>
    <div class="info">
        <p><strong>&nbsp;&nbsp;Az oldal nem található | Not found</strong></p>
       
      </div>
    </div>
    <div class="empty"><p><br /></p><a href="/">Vissza a főoldalra</a></div>
    <div class="footer"></div>
   
   
</body>
</html>

Now as Statik said, include the header and let the script die on this html:

Code: [Select]
header('HTTP/1.0 404 Not Found');
echo {desired htrml};
exit;
Due to massive misunderstandings: MonkeyIsland refers to an island not a monkey. I would be a monkey, if my name was IslandMonkey meaning a monkey who is or lives on an island. MonkeyIsland is an island which is related to monkeys. Also there's been a legend around saying MonkeyIsland is a game. So please, think of me as an island or a game.

Re: PHP expert needed!
« Reply #38 on: April 30, 2012, 02:28 PM »
You just don't understand me Ray, I clearly see what u mean. HTTP headers are just few lines in the HTTP response. You can send 404 Not Found and render the whole page, browser will display it, but search engines will ignore.


dt`wreckz: zooks are effected my win

Offline Ray

Re: PHP expert needed!
« Reply #39 on: April 30, 2012, 04:13 PM »
Define all your pages in .htaccess file, then if that didn't qualify, htaccess automatically tell web server to show 404 error.
That's what I need to do I believe. I will get rid of that ugly error page the webserver shows now, I'll have a custom one, the point is to avoid this from happening.

I didn't know that pages can be defined in .htaccess... I googled it, nothing found. What do you mean by that?

You can send 404 Not Found and render the whole page, browser will display it, but search engines will ignore.
Browsers should not render a non-existing page in my opinion, that is a strange behaviour.

Whenever a user navigates on a wrong link like this the webserver should give a 404 response and thus navigate the user away to the error page (this at the moment).

Re: PHP expert needed!
« Reply #40 on: April 30, 2012, 04:21 PM »
Good error page = user-friendly page. There should be site menu on it and maybe some tips. I can't agree browser shouldn't render non-existing page. Also you always try to find smth wrong in my words, but I'm explaining you the basics. Good luck, hope MI will help you more :P


dt`wreckz: zooks are effected my win

Offline MonkeyIsland

Re: PHP expert needed!
« Reply #41 on: April 30, 2012, 06:42 PM »
Whenever a user navigates on a wrong link like this the webserver should give a 404 response and thus navigate the user away to the error page (this at the moment).

How the webserver must recognize that celpont-music.com/index.php?1=biographys is not a valid url? If you insist on making the webserver that way, then htaccess is the way to go (if using Apache).
In this way, you gotta define your website pages inside htaccess, for example:

Code: [Select]
RedirectMatch 404 !^index.php?1=(home|biography|calendar)$

As you can see that only allows 3 pages. Each time you create a new page, you gotta edit your .htaccess to allow the new page.
That's why the php solution is better. When a page does not exist, with php you can show 404 error as I said in my previous post.
Due to massive misunderstandings: MonkeyIsland refers to an island not a monkey. I would be a monkey, if my name was IslandMonkey meaning a monkey who is or lives on an island. MonkeyIsland is an island which is related to monkeys. Also there's been a legend around saying MonkeyIsland is a game. So please, think of me as an island or a game.

Offline Ray

Re: PHP expert needed!
« Reply #42 on: May 01, 2012, 05:24 AM »
Well, since the only generated pages are actually the gallery albums, this is exactly what I need. This is a nice way, thank you.

EDIT: too bad it doesn't seem to work. :(

Offline Ray

Re: PHP expert needed!
« Reply #43 on: May 15, 2012, 04:11 PM »
I have the following array:

Code: [Select]
Array
(
[0] => Array ( [firstname] => Firstname [lastname] => Lastname [email] => email@domain.com [offer] => 500 )
[1] => Array ( [firstname] => Firstname [lastname] => Lastname [email] => email@domain.com [offer] => 450 )
[2] => Array ( [firstname] => Firstname [lastname] => Lastname [email] => email@domain.com [offer] => 670 )
[3] => Array ( [firstname] => Firstname [lastname] => Lastname [email] => email@domain.com [offer] => 600 )
)

(printed with print_r())

I want to sort it by the offers, ascending, to look like this:

Code: [Select]
Array
(
[0] => Array ( [firstname] => Firstname [lastname] => Lastname [email] => email@domain.com [offer] => 450 )
[1] => Array ( [firstname] => Firstname [lastname] => Lastname [email] => email@domain.com [offer] => 500 )
[2] => Array ( [firstname] => Firstname [lastname] => Lastname [email] => email@domain.com [offer] => 600 )
[3] => Array ( [firstname] => Firstname [lastname] => Lastname [email] => email@domain.com [offer] => 670 )
)

EXACTLY like this, it is very important to keep the ID's going from 0, 1... Any help would be appreciated! :-X

Re: PHP expert needed!
« Reply #44 on: May 15, 2012, 04:20 PM »


dt`wreckz: zooks are effected my win