Page 2 of 5
sorry
Posted: Thu 8. Sep 2005, 16:47
by msdesign
i have forgotten the foll0owing function
you must insert the following code at the end of the file include/inc_front/front.func.inc.php
function login_fe_user($fe_user_login,$fe_user_pass) {
// login frontend user
// reset all inactive users
global $phpwcms;
$sql = "UPDATE ".DB_PREPEND."phpwcms_userlog SET ";
$sql .= "logged_in = 0, logged_change = '".time()."' ";
$sql .= "WHERE logged_in = 1 AND ( ".time()." - logged_change ) > ".$phpwcms["max_time"];
mysql_query($sql, $GLOBALS['db']);
$login_passed = 0;
$fe_user_login = slweg(trim($fe_user_login));
$fe_user_pass = slweg(trim($fe_user_pass));
$sql_query = "SELECT * FROM ".DB_PREPEND."phpwcms_user WHERE usr_login='".
aporeplace($fe_user_login)."' AND (usr_pass=PASSWORD('".
aporeplace($fe_user_pass)."') OR usr_pass='".
aporeplace(md5($fe_user_pass))."') AND usr_aktiv=1 AND (usr_fe=0 OR usr_fe=2);";
if($result = mysql_query($sql_query, $GLOBALS['db'])) {
if($row = mysql_fetch_assoc($result)) {
$_SESSION['frontend_user']['login'] = $fe_user_login;
$_SESSION['frontend_user']["pass"] = $fe_user_pass;
$_SESSION['frontend_user']['name'] = ($row["usr_name"]) ? $row["usr_name"] : $fe_user_login;
$_SESSION['frontend_user']['id'] = $row["usr_id"];
$_SESSION['frontend_user']["aktiv"] = $row["usr_aktiv"];
$_SESSION['frontend_user']["rechte"] = $row["usr_rechte"];
$_SESSION['frontend_user']["email"] = $row["usr_email"];
$_SESSION['frontend_user']["avatar"] = $row["usr_avatar"];
$_SESSION['frontend_user']["logtime"] = time();
$_SESSION['frontend_user']["admin"] = $row["usr_admin"];
$_SESSION['frontend_user']["thumb"] = 1;
if($row["usr_lang"]) {
$_SESSION['frontend_user']["lang"] = $row["usr_lang"];
}
$_SESSION["structure"] = unserialize($row["usr_var_structure"]);
$_SESSION["klapp"] = unserialize($row["usr_var_privatefile"]);
$_SESSION["pklapp"] = unserialize($row["usr_var_publicfile"]);
$login_passed = 1;
}
mysql_free_result($result);
}
if($login_passed) {
//Schreiben der Login-Daten in Datenbank
$check = mysql_query( "SELECT COUNT(*) FROM ".DB_PREPEND."phpwcms_userlog WHERE logged_user='".
$fe_user_login."' AND logged_in=1;", $GLOBALS['db']);
if($row = mysql_fetch_row($check)) {
if(!$row[0]) {
//Wenn kein User geführt wird, dann neu anlegen
mysql_query("INSERT INTO ".DB_PREPEND."phpwcms_userlog ".
"(logged_user, logged_username, logged_start, logged_change, ".
"logged_in, logged_ip) VALUES ('".
$fe_user_login."', '".$_SESSION['frontend_user']['name'] ."', ".time().", ".
time().", 1, '".$_SERVER['REMOTE_ADDR']."');", $GLOBALS['db']);
}
}
mysql_free_result($check);
return true;
} else {
$err = 1;
return false;
}
}
sorry again...
Posted: Thu 8. Sep 2005, 16:52
by msdesign
dbaron wrote:I tried, but I couldn't have the login form for protected pages.
And there is a little mistake in the script:
In the file content.func.inc.php, the file fe_user_login_form.php is in ".$phpwcms["templates"]."/inc_script/fe_user_login_form.php" and msdesign said to create it in phpwcms_template/fe_user_login_form.php.
Is it a mistake ?
yes you are right the file is
phpwcms_template/inc_script/fe_user_login_form.php
Posted: Thu 8. Sep 2005, 17:08
by dbaron
Sorry but I couldn't run your hack.
Can you explain to a stupid guy how to use it?
Posted: Thu 8. Sep 2005, 17:38
by frold
msdesign wrote:dbaron wrote:I tried, but I couldn't have the login form for protected pages.
And there is a little mistake in the script:
In the file content.func.inc.php, the file fe_user_login_form.php is in ".$phpwcms["templates"]."/inc_script/fe_user_login_form.php" and msdesign said to create it in phpwcms_template/fe_user_login_form.php.
Is it a mistake ?
yes you are right the file is
phpwcms_template/inc_script/fe_user_login_form.php
what version of phpwcms do you use or do you use a cvs version? I use 1.23 and it doesnt work there...
Posted: Thu 8. Sep 2005, 20:46
by dbaron
Me, I use dev 1.2.5
Front-end Users 1.2.5-DEV
Posted: Thu 8. Sep 2005, 22:27
by Wittrock
1. Der Hack funktioniert mit dev 1.2.5 Version
Ich hatte auch das Problem das es nicht lief, der Fehler lag aber bei mir.
Ich habe den Code mit Copy and Paste übernommen, leider werden die AUSGEKLAMMERTEN Zeilen ( // ) nicht so übernommen wie hier dargestellt.
Also es wird beim einfügen nicht nur der Text AUSGEKLAMMERT, sondern auch ein wichtiger Teil des Codes.
Ich hoffe ich konnte helfen.
Ralf
Posted: Thu 8. Sep 2005, 23:18
by frold
Will someone plz spend 5 min and create a working howto install and howto use....
I think many of us would like it to work....
Front-end Users 1.2.5-DEV
Posted: Thu 8. Sep 2005, 23:45
by Wittrock
In Ordnung ich werde es versuchen.
Step1.
Find in index.php the following:
if(!isset($_SESSION['frontend_user'])) {
$_SESSION['frontend_user']['id'] = 0;
$_SESSION['frontend_user']['login'] = 'guest';
$_SESSION['frontend_user']['name'] = 'Guest';
// start frontend user login
if(isset($_POST['fe_user_submit']) || isset($_POST['fe_user_login'])) {
require_once ("include/inc_lib/general.inc.php");
require_once ("include/inc_front/front.func.inc.php");
}
}
and replace it with the following:
if(!isset($_SESSION['frontend_user']) || empty($_SESSION['frontend_user']['id'])) {
$_SESSION['frontend_user']['id'] = 0;
$_SESSION['frontend_user']['login'] = 'guest';
$_SESSION['frontend_user']['name'] = 'Guest';
// start frontend user login
if(isset($_POST['fe_user_submit']) || isset($_POST['fe_user_login'])) {
require_once ("include/inc_lib/general.inc.php");
require_once ("include/inc_front/front.func.inc.php");
$res = login_fe_user($_POST['fe_user_login'],$_POST['fe_user_pass']);
} else {
//Updaten, wenn User ausgewählt
$sql = "UPDATE ".DB_PREPEND."phpwcms_userlog SET logged_in = 0, logged_change = ". time() .
"WHERE logged_in = 1 AND (" . time() ." - logged_change ) > ".$phpwcms["max_time"].";";
mysql_query($sql, $db);
}
}
if(isset($_POST['fe_user_logout'])) {
session_destroy();
unset($_SESSION['frontend_user']);
header("Location:".$phpwcms["site"]);
}
Step 2:
Save the following as phpwcms_template in: phpwcms_template/inc_script/fe_user_login_form.php
<?php
$fe_login_form = '<form class="login_form" name="fe_login" method="post" action="'.FE_CURRENT_URL.'" style="margin:0;padding:0;"><table class="login_table" border="0" cellspacing="0" cellpadding="1">
<tr class="login_row">
<td style="font-size:10px;font-family:Verdana, Arial, Helvetica, sans-serif" class="login_data">Login: </td>
<td class="login_data"><input name="fe_user_login" type="text" id="fe_user_login" size="20" maxlength="30" style="font-size:12px;font-family:Verdana, Arial, Helvetica, sans-serif;width:130px;"></td>
</tr>
<tr class="login_row">
<td style="font-size:10px;font-family:Verdana, Arial, Helvetica, sans-serif" class="login_data">Password: </td>
<td class="login_data"><input name="fe_user_pass" type="password" id="fe_user_login" size="20" maxlength="100" style="font-size:12px;font-family:Verdana, Arial, Helvetica, sans-serif;width:130px;"></td>
</tr>
<tr class="login_row">
<td class="login_data"> </td>
<td class="login_data"><input type="submit" name="fe_user_submit" value="Anmelden" style="margin-top:2px;font-size:10px;font-family:Verdana, Arial, Helvetica, sans-serif"></td>
</tr>
</table>
</form>';
?>
Step 3:
Find the following in include/inc_front/content.func.inc.php
// put in the complete rendered content
$content["all"] = str_replace('{CONTENT}', $content["main"], $content["all"]);
and replace it with the following:
if(empty($_SESSION['frontend_user']['id']) && $content["struct"][$aktion[0]]['acat_regonly']==1) {
// put in the login form instead of complete content include(PHPWCMS_ROOT."/".$phpwcms["templates"]."/inc_script/fe_user_login_form.php");
$content["all"] = str_replace('{CONTENT}', $fe_login_form, $content["all"]);
} else
{
// put in the complete rendered content
$content["all"] = str_replace('{CONTENT}', $content["main"], $content["all"]);
}
Step 4:
Save the following as phpwcms_template/inc_script/frontend_render/logout.php
<?php
// by Tamer ERDOGAN, 2005 - returns logout submit button
$logout_form = '<form class="logout_form" name="fe_login" method="post" action="'.FE_CURRENT_URL.'" style="margin:0;padding:0;">
<input type="submit" name="fe_user_logout" id="fe_user_logout" value="Abmelden" class="logout_button"></form>';
if( ! ( strpos($content["all"],'{LOGOUT')===false ) ) {
$content["all"] = str_replace("{LOGOUT}", $logout_form, $content["all"]);
}
// LOGOUT replacement (by Tamer ERDOGAN, 2005)
// -------------------------------------------------------------
?>
Step 5:
you must insert the following code at the end of the file include/inc_front/front.func.inc.php
function login_fe_user($fe_user_login,$fe_user_pass) {
// login frontend user
// reset all inactive users
global $phpwcms;
$sql = "UPDATE ".DB_PREPEND."phpwcms_userlog SET ";
$sql .= "logged_in = 0, logged_change = '".time()."' ";
$sql .= "WHERE logged_in = 1 AND ( ".time()." - logged_change ) > ".$phpwcms["max_time"];
mysql_query($sql, $GLOBALS['db']);
$login_passed = 0;
$fe_user_login = slweg(trim($fe_user_login));
$fe_user_pass = slweg(trim($fe_user_pass));
$sql_query = "SELECT * FROM ".DB_PREPEND."phpwcms_user WHERE usr_login='".
aporeplace($fe_user_login)."' AND (usr_pass=PASSWORD('".
aporeplace($fe_user_pass)."') OR usr_pass='".
aporeplace(md5($fe_user_pass))."') AND usr_aktiv=1 AND (usr_fe=0 OR usr_fe=2);";
if($result = mysql_query($sql_query, $GLOBALS['db'])) {
if($row = mysql_fetch_assoc($result)) {
$_SESSION['frontend_user']['login'] = $fe_user_login;
$_SESSION['frontend_user']["pass"] = $fe_user_pass;
$_SESSION['frontend_user']['name'] = ($row["usr_name"]) ? $row["usr_name"] : $fe_user_login;
$_SESSION['frontend_user']['id'] = $row["usr_id"];
$_SESSION['frontend_user']["aktiv"] = $row["usr_aktiv"];
$_SESSION['frontend_user']["rechte"] = $row["usr_rechte"];
$_SESSION['frontend_user']["email"] = $row["usr_email"];
$_SESSION['frontend_user']["avatar"] = $row["usr_avatar"];
$_SESSION['frontend_user']["logtime"] = time();
$_SESSION['frontend_user']["admin"] = $row["usr_admin"];
$_SESSION['frontend_user']["thumb"] = 1;
if($row["usr_lang"]) {
$_SESSION['frontend_user']["lang"] = $row["usr_lang"];
}
$_SESSION["structure"] = unserialize($row["usr_var_structure"]);
$_SESSION["klapp"] = unserialize($row["usr_var_privatefile"]);
$_SESSION["pklapp"] = unserialize($row["usr_var_publicfile"]);
$login_passed = 1;
}
mysql_free_result($result);
}
if($login_passed) {
//Schreiben der Login-Daten in Datenbank
$check = mysql_query( "SELECT COUNT(*) FROM ".DB_PREPEND."phpwcms_userlog WHERE logged_user='".
$fe_user_login."' AND logged_in=1;", $GLOBALS['db']);
if($row = mysql_fetch_row($check)) {
if(!$row[0]) {
//Wenn kein User geführt wird, dann neu anlegen
mysql_query("INSERT INTO ".DB_PREPEND."phpwcms_userlog ".
"(logged_user, logged_username, logged_start, logged_change, ".
"logged_in, logged_ip) VALUES ('".
$fe_user_login."', '".$_SESSION['frontend_user']['name'] ."', ".time().", ".
time().", 1, '".$_SERVER['REMOTE_ADDR']."');", $GLOBALS['db']);
}
}
mysql_free_result($check);
return true;
} else {
$err = 1;
return false;
}
}
And you can use the {LOGOUT} tag to put the logout button wherever you want in the closed category.
Jetzt eine Kategorie anlegen zb. "Kundenbereich" und eine weitere Kategorie in dieser anlegen zb. "Intranet". Den Bereich "Intranet" als "Sichtbar nur für angemeldete Benutzer" markieren. Estelle nun einen Artikel in dieser Kategorie.
Jetzt in der Kategorie "Kundenbereich" einen Artikel mit Artikellink auf den Artikel in dem Bereich "Intranet" erstellen.
Das war alles.....
Wenn man jetzt in den Kundenbereich kommt, dann sollte der Artkellink zu sehen sein. Wenn man auf diesen Link klickt dann sollte das Anmeldefenster erscheinen.
Ich bin kein guter Schriftsteller, aber ich hoffe das hilft euch weiter.
Gruß
Wichtig...... auf den Code beim Copy and Paste achten!!!!!!
Posted: Fri 9. Sep 2005, 08:22
by dbaron
Jetzt eine Kategorie anlegen zb. "Kundenbereich" und eine weitere Kategorie in dieser anlegen zb. "Intranet". Den Bereich "Intranet" als "Sichtbar nur für angemeldete Benutzer" markieren. Estelle nun einen Artikel in dieser Kategorie.
Jetzt in der Kategorie "Kundenbereich" einen Artikel mit Artikellink auf den Artikel in dem Bereich "Intranet" erstellen.
Das war alles.....
Wenn man jetzt in den Kundenbereich kommt, dann sollte der Artkellink zu sehen sein. Wenn man auf diesen Link klickt dann sollte das Anmeldefenster erscheinen.
Ich bin kein guter Schriftsteller, aber ich hoffe das hilft euch weiter.
Gruß
Wichtig...... auf den Code beim Copy and Paste achten!!!!!!
Someone can translate in English please?
thanks a lot
Posted: Fri 9. Sep 2005, 10:22
by Kosse
dbaron wrote:
Someone can translate in English please?
thanks a lot
Google says:
"Now e.g. put on a category. "kundenbereich" and a further category in this e.g. put on. "Intranet". The range "Intranet" as "visible only for announced users" mark. Estelle now an article in this category. Now in the category "kundenbereich" provide an article with article left on the article within the range "Intranet". That was everything..... If one comes now into the kundenbereich, then the Artkellink should have to be seen. If one on these left clicks then should the announcing window appear. I am not a good writer, but I hope help you. Greeting important...... to the code with the CoPy and paste pay attention!!!!!!"
Not pure english but understandable enough...
Cheers
Posted: Fri 9. Sep 2005, 10:39
by dbaron
Couldn't work
If someone speak French, maybe better
Posted: Fri 9. Sep 2005, 10:41
by Kosse
dbaron wrote:If someone speak French, maybe better
Ok,
Moi, mais ça ne change rien...
Qu'est-ce qui ne va pas? La traduc ou la modif?
Me but that doesn't change, does it?
What doesn't work, the translation or the MOD?
Salut
Cheers
Posted: Fri 9. Sep 2005, 11:44
by frold
Kosse wrote:dbaron wrote:If someone speak French, maybe better
Ok,
Moi, mais ça ne change rien...
Qu'est-ce qui ne va pas? La traduc ou la modif?
Me but that doesn't change, does it?
What doesn't work, the translation or the MOD?
Salut
Cheers
Howto put in a login box? so users can login and then see the "protected" pages?
Posted: Fri 9. Sep 2005, 11:46
by dbaron
Ok,
Moi, mais ça ne change rien...
Qu'est-ce qui ne va pas? La traduc ou la modif?
Me but that doesn't change, does it?
What doesn't work, the translation or the MOD?
Salut
The problem is: both.
Maybe I misunderstood how to use it with category, etc...
Posted: Fri 9. Sep 2005, 16:10
by dbaron
Nobody use it with success?