4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: universal on May 15, 2005, 07:59:37 AM
-
version 1.1
Everything what is needed is:
config.php - from 4images
.htaccess file (must be in folder where who.php will be)
who.php (you can name it how you want)
now no test needed, just set your url and try it. I`ve tested it only on my server.
will work only with this link http://your_url/who/user name
not with http://your_url/who/user name/
.htaccess
<files *>
Options MultiViews
</files>
who.php
<?
// Settings
///////////////////////////////////////////
$url = "http://www.pramoga.net";
$table = "4images_users"; //do not edit if you have not changed table prefix
// Code
///////////////////////////////////////////
include "config.php";
$a_url = $_SERVER["REQUEST_URI"];
$i = explode("/", $a_url);
$b = count($i);
$b = $b-1;
$i = str_replace(array("%20"), " ", $i[$b]);
if (($i != "") and ($i != "guest"))
{
$db = mysql_connect("$db_host", "$db_user", "$db_password") or die ("Error");
@mysql_select_db("$db_name", $db) or die ("DB not found");
$result = mysql_query("SELECT user_id FROM `$table` WHERE user_name='$i'");
$row = mysql_fetch_array($result);
$id = $row['user_id'];
header("Location: ".$url."/member.php?action=showprofile&user_id=".$id."");
}
else
{
header("Location: ".$url."");
}
?>
version 1
Just a little script that I made for my site :)
A personal addres for users, to profile.
DEMO: http://www.pramoga.net/who/admin/ (admin is user name, existing in 4images gallery)
So, first I want to explain how it works :)
"who" is not a folder, it`s originaly a script called who.php, to use this script without extension .php you will need to put .htaccess file into the folder where who.php is. The code of .htaccess is:
<files *>
Options MultiViews
</files>
So the first thing is done :)
Second is very important for script who.php and it depends on your url, how many slashes "/" there is. I made a little test to find out what number for variables you will need.
test.php
<?
$url = "http://www.pramoga.net"; //your url
$url_extender = $_SERVER["REQUEST_URI"];
$all_url = $url.$url_extender;
print_r(explode("/", $all_url));
?>
Change url in this script and go to it like that
http://www.pramoga.net/test/admin (can be another user name)
or
http://www.pramoga.net/test.php/admin (can be another user name)
DEMO: http://www.pramoga.net/test/admin
We need a number of user name, So we take it from here
Array ( - => http: [1] => [2] => www.pramoga.net [3] => test.php [4] => admin )
The number is 4
We can go to final step :)
Script who.php
<?
/////////////////////////////////////////////
// Originaly made for http://www.pramoga.net
// If you made any modifications, feel free
// to contact with me and share your code ;)
/////////////////////////////////////////////
$url = "http://www.pramoga.net";
/////////////////////////////////////////////
include "config.php";
$url_extender = $_SERVER["REQUEST_URI"]; // gets url end
$all_url = $url.$url_extender; // i dont know why, but i make all url...
$i = explode("/", $all_url); // then I delete all slashes
$i = $i[4]; // when I get array of symbols, I take fourth symbol (it depends on url)
$i = str_replace(array("%20"), " ", $i); // replaces %20 with simple space " "
if (($i != "") and ($i != "guest")) //if url is with name and it`s not guest
{
$db = mysql_connect("$db_host", "$db_user", "$db_password") or die ("Error"); // connecting to db
@mysql_select_db("$db_name", $db) or die ("DB not found"); // selecting db
$result = mysql_query("SELECT user_id FROM `4images_users` WHERE user_name='$i'"); //querying mysql, and selecting users id from db
$row = mysql_fetch_array($result);
$id = $row['user_id']; //selected id seting to variable $id
//finally
header("Location: ".$url."/member.php?action=showprofile&user_id=".$id.""); //setting header location to members profile
}
else //if no name was given
{
header("Location: ".$url.""); //setting header location to index page
}
// thats all :)
?>
Find $i[4];
and change 4 to your number, that you find in test.php :)
It`s explained step by step, so it`s very simple :)
Upload it to the server and try :)
-
A little corection if somebody uses this plugin :)
A bug when user name contains spaces,
So add this code
$i = str_replace(array("%20"), " ", $i);
after this line
$i = $i[4]; // when I get array of symbols, I take fourth symbol (it depends on url)
more symbols can be added for replacing, by editing this array("%20","symbol","symbol","symbol")
-
who do i make the .htaccess file? with the Notepad?
-
yes, any text editors.
-
ok i did it i create the .htaccess and i run the test and i got the number 5 but when I point to /who/admin it goes to my home page :S
-
This code shows your browser to go to the homepage
else //if no name was given
{
header("Location: ".$url.""); //setting header location to index page
}
This code is active only when this code is true
if (($i != "") and ($i != "guest")) //if url is with name and it`s not guest
if no name was given or name was "guest"
-
so do i have to modify someything?
-
can you give me a link?
-
sure : http://www.girlsandgirls.net/who/admin
-
If it is not dificult to you
comment line header("Location: ".$url.""); //setting header location to index page
and write a line after echo $i,"<br>";
echo $all_url;
its strange... and i cant say what happened so i need to view these variables.
-
actualy for best result in debugin mod_rewrite is use this:
if ($user_info['user_level'] == ADMIN)
{
echo "<pre>GET:<br>";
print_r($_GET);
echo "<br><br>Query string:<br>";
echo "<b>".$_SERVER["QUERY_STRING"]."</b>";
echo "<br><br>Redirect query string:<br>";
echo "<b>".$_SERVER["REDIRECT_QUERY_STRING"]."</b>";
echo "</pre>";
}
-
try version 1.1 :) I`ve made some modifications, now you wont need any tests
-
I try the new version and it does not work :(:(
http://www.girlsandgirls.net/who/admin
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/bhfqyruw/public_html/who.php on line 21
Warning: Cannot modify header information - headers already sent by (output started at /home/bhfqyruw/public_html/who.php:21) in /home/bhfqyruw/public_html/who.php on line 23
-
maybe your table prefix is not "4images_" ?
-
yeah is girls_
-
ok thank you so much :) now it does work ;)
-
it`s not dificult to help ;)
-
how can i change http://www.vietnamphotos.net/member.php?action=showprofile&user_id=1 ( or other ) To http://vietdragon.vietnamphotos.net ??
:) I don't like http://www.vietnamphotos.net/who/vietdragon
Thank!
-
Are you talking about username.yourdomain.com? And if so, do you now something about subdomains? :)
-
a little addition to the code. It should automaticaly parse the url, without needed count how many slashes in the url of your server or such ;)
replace $all_url = $url.$url_extender; // i dont know why, but i make all url...
$i = explode("/", $all_url); // then I delete all slashes
$i = $i[4]; // when I get array of symbols, I take fourth symbol (it depends on url)
$i = str_replace(array("%20"), " ", $i); // replaces %20 with simple space " "
with:$array = explode("/", trim(str_replace(array("%20"), " ", $url_extender)));// replaces %20 with simple space " ", trim any trailing spaces and convert the url into an array
$total = count($array);
$start = false;
$add_slash = false;
$i = "";
for ($n=0; $n < $total; $n++)
{
if ($start)
{
if ($add_slash && !empty($array[$n]))
{
$i .= "/"; //add a slash, but only if its not last character (avoid adding trailing slash)
}
$i .= $array[$n];
if (!$add_slash)
{
$add_slash = true; //for next loop add a slash to the name (a fix for usernames that conteins slashes)
}
}
if ($array[$n] == "who")
{
$start = true; //use next item as a username
}
}
-
Hi, seems I've got a little problem with that one.
4images is located in www.72px.de/001/
so i placed the .htaccess and the who.php file into that directory. I used Version 1.1!
When I go to www.72px.de/001/who/christian it will only give me a 404 error.
I already changed the who.php code to the .../001 directory but it does not change anything.
Hope anyone of you has got an idea to solve that. Seems to be a very useful thing.
Thanks
Christian
P.S. Maybe this will help:
When I only enter http://www.72px.de/001/who.php it takes me to http://www.72px.de/001/member.php?action=showprofile&user_id=
-
looks like .htaccess now working...
-
You mean NOW working or NOT working?
Not working would explain a lot of course.
Any Idea what could have went wrong with the .htaccess?
Thanks for your reply. ;)
-
If I may assist you on this user_id tracking issue, here's what I got from who.php file :
replace this :
<?
/////////////////////////////////////////////
// Originaly made for http://www.pramoga.net
// If you made any modifications, feel free
// to contact with me and share your code ;)
/////////////////////////////////////////////
$url = "http://www.pramoga.net";
/////////////////////////////////////////////
include "config.php";
$url_extender = $_SERVER["REQUEST_URI"]; // gets url end
$all_url = $url.$url_extender; // i dont know why, but i make all url...
$i = explode("/", $all_url); // then I delete all slashes
$i = $i[4]; // when I get array of symbols, I take fourth symbol (it depends on url)
$i = str_replace(array("%20"), " ", $i); // replaces %20 with simple space " "
if (($i != "") and ($i != "guest")) //if url is with name and it`s not guest
{
$db = mysql_connect("$db_host", "$db_user", "$db_password") or die ("Error"); // connecting to db
@mysql_select_db("$db_name", $db) or die ("DB not found"); // selecting db
$result = mysql_query("SELECT user_id FROM `4images_users` WHERE user_name='$i'"); //querying mysql, and selecting users id from db
$row = mysql_fetch_array($result);
$id = $row['user_id']; //selected id seting to variable $id
//finally
header("Location: ".$url."/member.php?action=showprofile&user_id=".$id.""); //setting header location to members profile
}
else //if no name was given
{
header("Location: ".$url.""); //setting header location to index page
}
// thats all :)
?>
with :
<?php
/////////////////////////////////////////////
// Originaly made for http://www.pramoga.net
// If you made any modifications, feel free
// to contact with me and share your code ;)
/////////////////////////////////////////////
define('GET_CACHES', 1);
define('ROOT_PATH', './');
define('GET_USER_ONLINE', 1);
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
$url = SCRIPT_URL; // Uncomment out your SCRIPT_URL from includes/constants.php file and type your URL in that quote instead of here.
/////////////////////////////////////////////
$url_extender = $_SERVER["REQUEST_URI"]; // gets url end
$array = explode("/", trim(str_replace(array("%20"), " ", $url_extender)));// replaces %20 with simple space " ", trim any trailing spaces and convert the url into an array
$total = count($array);
$start = false;
$add_slash = false;
$i = "";
for ($n=0; $n < $total; $n++)
{
if ($start)
{
if ($add_slash && !empty($array[$n]))
{
$i .= "/"; //add a slash, but only if its not last character (avoid adding trailing slash)
}
$i .= $array[$n];
if (!$add_slash)
{
$add_slash = true; //for next loop add a slash to the name (a fix for usernames that conteins slashes)
}
}
if ($array[$n] == "who")
{
$start = true; //use next item as a username
}
}
if (($i != "") and ($i != "guest")) //if url is with name and it`s not guest
{
$sql = "
SELECT user_id, user_name
FROM ".USERS_TABLE."
WHERE user_name='$i' AND user_level > '".GUEST."' AND user_invisible = 0
";
$result = $site_db->query($sql);
$row = $site_db->fetch_array($result);
//finally
header("Location: ".$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row['user_id']).""); //setting header location to members profile
}
else //if no name was given
{
header("Location: ".$site_sess->url(ROOT_PATH."index.php", "&")); //setting header location to index page
}
// thats all :)
?>
Well, hope this is it. ;)
-
Hey..
First of all, thanks for the info but I got some problems with understanding what you mean:
- "$url = SCRIPT_URL; // Comment out your SCRIPT_URL from includes/constants.php file and type your URL in that quote instead of here."
In the costants.php file the SCRIPT_URL is already commented out ("// define('SCRIPT_URL', 'http://www.yourdomain.com/4images'); //no trailing slash")
What do you suggest I should fill in here? (Okay.. Its quite clear but do you want me to fill in "http://www.72px.de/001/" (cause thats the script Url.) And if so.. where exactly? ^^
;)
Thanks for your help!
PS. Did it without changes to your code but still gives me a 404: Try yourself: http://www.72px.de/001/who/christian
Maybe universal was right and it is a .htaccess-problem?
-
Thanks for posting this. I have just corrected my note on my post above. As for your URL, if : http://www.72px.de/001 points to your root path of 4images, then it's the right place. Remember though, do not add the trailing slash at the end of your URL. ;)
-
Okay, I did it.. but anyway.. gives me a 404! :(
Additionally.. by entering this "http://www.72px.de/001/who.php" it tells me: Parse error: parse error, unexpected ';' in /home/www/ncf61/html/001/who.php on line 63
-
Okay, I did it
Please post the precise steps that you did in order to achieve a 404 error page.
-
I did everything that was explained in the first post of this thread: Create a .htaccess in the directory that contains the who.php file, create the who.php file.
Guess thats it. Now I put YOUR code in the who.php file instead of universal's . But it doesn't change anything. So I consider the problem is not inside the who.php file but in the .htaccess file because the browser doesn't find the who.php file if it is entered without .php (http://www.72px.de/001/who/christian)
My .htaccess file looks like this:
<files *>
Options MultiViews
</files>
-
I have just modified my post above regarding the parse error message.
-
Thanks ;) But still gives me the exact same parse Error! ;)
But I guess the main problem is the 404 error because if this can be solved I can use universal's who.php as well...
It obviously worked well for other people!
-
Are you sure you replaced it with this line :
header("Location: ".$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row['user_id']).""); //setting header location to members profile
and not :
header("Location: ".$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row['user_id']."")); //setting header location to members profile
as I re-updated it 2 secs after I posted my update message. ;)
-
Hehe ;)
Okay the parse error is gone.. now "http://www.72px.de/001/who.php" takes me to my 4images homepage.
But the 404 is still there! :P
("http://www.72px.de/001/who/christian")
-
Then, ' now ' it is a .htaccess forwarding issue. ;)
-
;) I guess it already was such an issiue when I was still using universal's who.php file! :wink:
Mhm now.. any idea what could be the problem?
Thanks anyway! :)
-
I guess it already was such an issiue when I was still using universal's who.php file!
Since my method is more reliable to 4images's modules, I would deeply recommend to maintain my version of this MOD (especially for security & sessions issues).
Mhm now.. any idea what could be the problem?
Well, I believe, this part, you already know - it's an .htaccess redirection problem. ;)
Would you mind showing your .htaccess readings regarding this action ?
-
Yeah but this knowledge unfortunatly doesn't take me anywhere, cause I know as much about .htaccess-files as I know about building airplanes! ;)
Hehe okay lets modify posts! ;)
As postet before.. thats my .htaccess.. which is exactly what universal posted in the beginning :(
<files *>
Options MultiViews
</files>
-
as I know about building airplanes!
No offense there but there are airplanes who faces accidents - even if they're built from the best engineers in the world. Meaning, your .htaccess could have some errors too. ;)
If you could just post your results, I will take a look at them.
-
Maybe we have just a communication problem.. ;)
What exactly do you mean by "results"?
I guess I understood you wanted to see the .htaccess file but i guess i was wrong ! *sorry* ;)
-
And I should ban the word "guess" from my vocabulary.. ^^
-
I guess I understood you wanted to see the .htaccess file but i guess i was wrong ! *sorry*
No, you understood correctly. ;)
I just don't see how these simple tags :
<files *>
Options MultiViews
</files>
could forward to your private member page . . .
-
Mhm.. yeah I don't see either! ;)
Have a look at post 1 of this thread from universal. Thats what he postet. And it seems, this worket for some guys here...
Don't ask me, I'm a tourist :P
-
Well ... I'm not the .htaccess file specialist but, by looking at these readings ... if it does forward to the member's private page and works for some users ... I don't know what you tell you.
-
So how does your version work on your Site? :?: Guess you didn't just write this who.php file down in a minute, right? ;)
How ever it would be very nice of universal to explain, how his .htaccess works.. :|
-
So how does your version work on your Site?
I did not installed this MOD. I simply re-coded it. ;)
Guess you didn't just write this who.php file down in a minute, right? ;)
Actually, it really did took this short to re-code it. :mrgreen:
-
Mhm okay I'm impressed ^^
Anyway thanks a million for your help! :) Would be interesting to know how this works on other people's sites.. :?
-
Would be interesting to know how this works on other people's sites..
This reminds me, I actually have a place I could test this MOD on with .htaccess file. ;)
-
You definitely would be my hero of the day! ;)
Thanks in advance...
-
my hero of the day!
Like the song : "They're off to find the hero of the day". :mrgreen:
Posting the results in a couple of mins . . .
-
Metallica? ^^ Think I got it somewhere...
-
I play the intro often on my guitar personally. ;)
Anyway, let's focus on the issue for now.
-
Update :
I have just tested this with the .htaccess file. No 404 error message appears. Seems it is the case for you, it would seems there might be an apache configuration error from your end. Perhaps you should contact your ISP to take a look at this problem. ;)
-
Funny thing...isn't it...
Any idea WHAT config error? Just to have something to search for.. :(
Thanks for trying!
-
There are many documentations you could find on Google on this subject actually. ;)
-
Wonderful.. :(
So do you think there is another way of shortening the URL to the member profile significantly?
I thought about something like virtual subdomains but this seems to be a hundred times more difficult.. :(
-
Hum ... not sure but
change :
<Files *>
to :
<Files who.php>
in your .htaccess file. Will this work ?
-
Nope... no change. Sorry ;)
-
In that case, this is definitely a server issue. Sorry.
-
Seems you are correct. Anyway thanks for testing. If you have any idea of shortening the URLs in a different way... let me know! ;)
-
If you have any idea of shortening the URLs in a different way
I'm not quite sure what you mean by shortening the URL ... could you elaborate that ? Like - an example ? ;)
P.S : The URL structure has nothing to do with the error you're currently facing with your .htaccess file . . .
-
In this case the short URL would have been: "http://www.72px.de/001/who/christian"
And the original URL is: "http://www.72px.de/001/member.php?action=showprofile&user_id=1" which is much more difficult to remember of course.
Even better would be a subdomain like http://user.72px.de but i can't setup a subdomain for every member manually.
-
I'm starting to wonder if there aren't missing statements for <directory> from your .htaccess file since you stated that it should point to your sub-folder :
- who/christian
-
Hey;)
No, I think you got this wrong, as WHO is no subfolder but the who.php file without the .php ending! As I see it the only thing thats done by the .htaccess file is to make the browser recognize the who.php file without an ending!
Anyway its all in the same folder.. :|
-
Yes, I know. ;)
It's a routine that converts the file into a path, without the extension, and the username as a subfolder - ReWriteRule from .htaccess.
-
Mh yeah. I guess one could do this with mod_rewrite or so.. but until now I haven't found out how! ;)
I tried a different way:
If s.o. enters http://user.72px.de -which does not exist- this produces a 404 and I uploaded a 404.html which reads the referrer (in this case user.72px.de) and then redirects the user depending on the referer... but it seems I cannot change the 404 Error page of the root directory..
-
but it seems I cannot change the 404 Error page of the root directory..
Then, please, as stated above - contact your hosting party about this.
-
Yes.. ;) I just wanted to inform you... ^^
-
Hello,
just a little mod-mod...
I want to provide my users with a short URL for "Display all images added by ..." instead of the "members profile" URL.
I would like to have something like this to see all i,ages added be "username":
http://www.mysite.com/username/
Anyone who can help out with a little mod-rewirte ?
Thanks in advance
Daniel
-
<files *>
Options MultiViews
</files>
note this htaccess does not work well,
this url works with that htaccess file:
4images/profile.php/username [redirects to profile]
but this does not
4images/profile/username [shows error page]
according to my knowledge it is a htaccess fault it has wrong info i'm new to htaccess but i know that you need some other code in htaccess, i have no idea what tho.
-
Or maybe server config overides htaccess?
-
i've wondering about had some like it but on this way :
http://username.yoursite.com/
:?:
-
<files *>
Options MultiViews
</files>
note this htaccess does not work well,
this url works with that htaccess file:
4images/profile.php/username [redirects to profile]
but this does not
4images/profile/username [shows error page]
according to my knowledge it is a htaccess fault it has wrong info i'm new to htaccess but i know that you need some other code in htaccess, i have no idea what tho.
yes... i have problems with htaccess too... if i upload this file.. all my websites from my host are down :cry:
I have contacted with my server support and they said me...
Some apache commands are no longer supported in .htaccess or .htconfig due to security concerns:
Action
AddCharSet
AddEncoding
AddLanguage
AddType
BrowserMatch
BrowserMatchNoCase
CookieTracking
DefaultLanguage
DefaultType
ErrorDocument
ErrorHeader
Header
LanguagePriority
Options
PassEnv
Redirect
RedirectMatch
RedirectPermanent
RedirectTemporary
SetEnv
SetEnvIf
SetEnvIfNoCase
UnsetEnv
Is there another sentence to do the same that multiviews?
-
I know his is an old topi but looking to see if anyone has gotten this or something similar to work.
Smoothice
-
Hi.. I have tried this MOD but does not work... it says: "No input file specified. " what i can do? thanks!
-
Hi.. I have tried this MOD but does not work... it says: "No input file specified. " what i can do? thanks!
It's works fine with...
1. Open .httaccess
Insert:
RewriteRule ^who/ who.php?%{QUERY_STRING}
RewriteRule ^go$ who.php?%{QUERY_STRING}
2. Create a folder {root}/who
From first topic in the MOD:
3. Create test.php, upload and run www.yourdomain.con/test.php and remember the last array. Delete on your webspace after run.
4. Create who.php from first topic in the MOD and do modification as written (Version 1.1) .
Works fine, see http://www.ruebenberger-bilder.de/who/hikkamonster (sorry only German)
Enjoy,
CanonInk
-
Hi CanonInk! Vielen dank!
Greetings from very sunny Madrid.
It works now perfectly with some modifications:
1.- On the .htaccess file I needed to insert this code before RewriteEngine On
.
2.- It works without creating a folder called who.
3.- As I have used who.php version 1.1 I did not do the array test.php file and it works.
Hey, your website is nice! Thank you once again!! :)
-
Hi CanonInk! Vielen dank!
Greetings from very sunny Madrid.
It works now perfectly with some modifications:
1.- On the .htaccess file I needed to insert this code before RewriteEngine On
.
2.- It works without creating a folder called who.
3.- As I have used who.php version 1.1 I did not do the array test.php file and it works.
Hey, your website is nice! Thank you once again!! :)
- You are right with step 1 :thumbup:
- who needs at my server
- this is possible, but is dependent on server (Apache,...)
Thank you very much for the flowers :lol:
CanonInk
-
Hello
Maybe i click on a User on a page, the following link appears in my browsers url input bar: http://mypage.de/member.php?action=showprofile&user_id=5
Is it possible to show only the private URL in the browsers input-bar?
Im asking for that, because the users didnīt see, that they got a short-url to her own profile and they are using the long links -.-
Thanks for help
-
Da ich Google Friendly URLs installiert habe, habe ich die who.php so abgewandelt:
<?
// Settings
///////////////////////////////////////////
$url = "http://www.meineseite.de";
$table = "4images_users"; //do not edit if you have not changed table prefix
// Code
///////////////////////////////////////////
include "config.php";
$a_url = $_SERVER["REQUEST_URI"];
$i = explode("/", $a_url);
$b = count($i);
$b = $b-1;
$i = str_replace(array("%20"), " ", $i[$b]);
if (($i != "") and ($i != "guest"))
{
$db = mysql_connect("$db_host", "$db_user", "$db_password") or die ("Error");
@mysql_select_db("$db_name", $db) or die ("DB not found");
$result = mysql_query("SELECT user_id FROM `$table` WHERE user_name='$i'");
$row = mysql_fetch_array($result);
$id = $row['user_id'];
header("Location: ".$url."/profile".$id.".htm");
}
else
{
header("Location: ".$url."");
}
?>
Das klappt wunderbar. Jetzt wollte ich eine weitere Datei erstellen, namens Image:
image.php
<?
// Settings
///////////////////////////////////////////
$url = "http://www.meineseite.de";
$table = "4images_images"; //do not edit if you have not changed table prefix
// Code
///////////////////////////////////////////
include "config.php";
$a_url = $_SERVER["REQUEST_URI"];
$i = explode("/", $a_url);
$b = count($i);
$b = $b-1;
$i = str_replace(array("%20"), " ", $i[$b]);
if (($i != "") and ($i != "guest"))
{
$db = mysql_connect("$db_host", "$db_user", "$db_password") or die ("Error");
@mysql_select_db("$db_name", $db) or die ("DB not found");
$result = mysql_query("SELECT image_id FROM `$table` WHERE image_name='$i'");
$row = mysql_fetch_array($result);
$id = $row['image_id'];
header("Location: ".$url."/video".$id.".htm");
}
else
{
header("Location: ".$url."");
}
?>
Die URL zu dem Bild sieht so aus: image-fggf-3.htm
Aber wie mache ich das, dass er die Image_id und den image_name ausgibt?
Ich habe das so versucht:
<?
// Settings
///////////////////////////////////////////
$url = "http://www.anitube.de";
$table = "4images_images"; //do not edit if you have not changed table prefix
// Code
///////////////////////////////////////////
include "config.php";
$a_url = $_SERVER["REQUEST_URI"];
$i = explode("/", $a_url);
$b = count($i);
$b = $b-1;
$i = str_replace(array("%20"), " ", $i[$b]);
if (($i != "") and ($i != "guest"))
{
$db = mysql_connect("$db_host", "$db_user", "$db_password") or die ("Error");
@mysql_select_db("$db_name", $db) or die ("DB not found");
$result = mysql_query("SELECT image_id FROM `$table` WHERE image_name='$i'");
$resultname = mysql_query("SELECT image_name FROM `$table` WHERE image_id='$i'");
$row = mysql_fetch_array($result);
$id = $row['image_id'];
$name = $row['image_name'];
header("Location: ".$url."/video-".$name."-".$id.".htm");
}
else
{
header("Location: ".$url."");
}
?>
Das scheint aber nicht richtig zu sein, da es dann nun so aufgerufen wird: image--3.htm
Der name zwischen - und - fehlt, dennoch wird es aufgerufen, aber wie klappt das richtig?