"Switch" werkt niet
Ik probeer gebruik te maken van de login functie van phpbb3 in combinatie met een stuk radio automatiserings software (SAM), de bedoeling is dat mensen die in phpbb3 ingelogd zijn een aanvraag kunnen doen in keuze lijst van muziek.
Het aanroepen vanuit SAM doe ik met de volgende code:
Code (php)
Hier wordt dus de database van phpbb geraadpleegd of iemand is ingelogd, dit werkt goed want dat kan ik met de volgende code (verwerkt in de pagina) controleren:
Code (php)
Dan komt mijn probleem pas echt want als er niemand is ingelogd wil ik de volgende regel uitgeschakeld hebben en dacht daarvoor de functie "switch" te gebruiken, echter dat wil niet lukken, zowel met de oude functie:
Code (php)
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
<?
<!-- BEGIN switch_user_logged_out -->
<td nowrap width="1%">
<p align="center"><font size="2" color="#003366"><a href="<? echo $song["request"]; ?>"><img
src="images/request.gif" alt="Request this song now!" border="0"></a></font>
</td>
<!-- END switch_user_logged_out -->
?>
<!-- BEGIN switch_user_logged_out -->
<td nowrap width="1%">
<p align="center"><font size="2" color="#003366"><a href="<? echo $song["request"]; ?>"><img
src="images/request.gif" alt="Request this song now!" border="0"></a></font>
</td>
<!-- END switch_user_logged_out -->
?>
als met de nieuwe functie:
Code (php)
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
<?
<!-- IF not S_USER_LOGGED_IN -->
<td nowrap width="1%">
<p align="center"><font size="2" color="#003366"><a href="<? echo $song["request"]; ?>"><img
src="images/request.gif" alt="Request this song now!" border="0"></a></font>
</td>
<!-- ENDIF -->
?>
<!-- IF not S_USER_LOGGED_IN -->
<td nowrap width="1%">
<p align="center"><font size="2" color="#003366"><a href="<? echo $song["request"]; ?>"><img
src="images/request.gif" alt="Request this song now!" border="0"></a></font>
</td>
<!-- ENDIF -->
?>
In beide gevallen blijf ik deze regel zien waarin de aanvraag mogelijk is, zowel ingelogd als niet ingelogd.
**********************************************************************
Zal hier nog even de totale code van die betreffende pagina plaatsen zodat het misschien wat duidelijker wordt wat er gedaan wordt.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?
define('IN_PHPBB', true);
$phpbb_root_path = '../phpbb/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
require("config.php");
$where = " WHERE (songtype='S') AND (status=0) ";
Def($start,0);
Def($limit,50);
Def($search,"");
//########## BUILD SEARCH STRING ################
if(!empty($search))
{
$words = Array();
$temp = explode(' ',$search);
reset($temp);
while(list($key,$val) = each($temp))
{
$val = trim($val);
if(!empty($val))
$words[] = $val;
}
$where2 = "";
reset($words);
while(list($key,$val) = each($words))
{
if(!empty($where2)) $where2 .= " OR ";
$val = "%$val%";
$db->AddStr($val); $db->AddStr($val); $db->AddStr($val);
$where2 .= " (title like :val1) OR (artist like :val2) OR (album like :val3) ";
}
$where .= "AND ($where2) ";
}
if((isset($letter)) && (!$letter==""))
{
$nextletter = chr(ord($letter)+1);
if($letter=='0')
$where .= " AND NOT((artist>='A') AND (artist<'ZZZZZZZZZZZ')) ";
else
{
$db->AddStr($letter); $db->AddStr($nextletter);
$where .= " AND ((artist>=:letter) AND (artist<:nextletter)) ";
}
}
else
{
$letter="";
}
//########## =================== ################
//Calculate total
$tmp = $db->params; //Save params for second query
$db->open("SELECT count(*) as cnt FROM songlist $where ");
$row = $db->row();
$cnt = $row["cnt"];
//Now grab a section of that
$db->params = $tmp; //Restore params
$db->open("SELECT * FROM songlist $where ORDER BY artist ASC, title ASC", $limit, $start);
$first = $start+1;
$last = min($cnt,$start+$limit);
$rc = $start;
$prevlnk = "";
$nextlnk = "";
if($cnt>0)
{
if(!isset($search))
{ $search=""; }
$searchstr = urlencode($search);
$prev = max(0,$start-$limit);
if($start>0)
$prevlnk = "<a href='?start=$prev&limit=$limit&letter=$letter&search=$searchstr'><< Previous</a>";
$tmp = ($start+$limit);
if($tmp<$cnt)
$nextlnk = "<a href='?start=$tmp&limit=$limit&letter=$letter&search=$searchstr'>Next >></a>";
}
function PutSongRow($song)
{
global $rc, $start, $darkrow, $lightrow;
$rc++;
$bgcolor = $darkrow;
if(($rc % 2)==0) $bgcolor = $lightrow;
PrepareSong($song);
?>
<tr bgcolor="<? echo $bgcolor; ?>">
<td nowrap align="right" width="1%"><font size="2" color="#003366"><small><? echo "$rc"; ?></small></font></td>
<td nowrap><font size="2" color="#003366"> <small><? echo $song["combine"]; ?></small></font></td>
//om de volgende regel zou het gaan
<td nowrap width="1%">
<p align="center"><font size="2" color="#003366"><a href="<? echo $song["request"]; ?>"><img
src="images/request.gif" alt="Request this song now!" border="0"></a></font>
</td>
// tot hier dus
<td nowrap width="1%">
<p align="center"><font size="2" color="#003366"><a href="<? echo $song["buycd"]; ?>" target="_blank"><img
src="images/buy.gif" alt="Buy this CD now!" border="0"></a></font>
</td>
<td nowrap width="1%">
<p align="center"><font size="2" color="#003366"><a href="<? echo $song["website"]; ?>" target="_blank"><img
src="images/home.gif" alt="Artist homepage" border="0"></a></font>
</td>
<td nowrap align="center" width="1%">
<font size="2" color="#003366"><a href="javascript:songinfo(<? echo $song["songid"]; ?>)"><img
src="images/info.gif" alt="Song information" border="0"></a></font>
</td>
<td nowrap><font color="#003366" size="2"><small><? echo $song["album"]; ?></small></font></td>
<td nowrap>
<p align="right"><font color="#003366" size="2"><small><strong><? echo $song["mmss"]; ?></strong></small></font>
</td>
</tr>
<?
}//PutSongRow
/* ## ===================================================================== ## */
?>
<? require("header.php"); ?>
<? if ($user->data['user_id'] != ANONYMOUS)
echo("Hallo en welkom, " . $user->data['username'] . "!");
else
{
echo("Wil je een nummer aanvragen dan moet je eerst <a href='../phpbb/ucp.php?mode=login' >inloggen.</a>");
}
?>
<? require("search.php"); ?>
<br>
<table border="0" width="98%" cellspacing="0" cellpadding="4">
<tr bgcolor="#002E5B">
<td colspan="8" nowrap align="left">
<b><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF">Playlist results</font></b>
</td>
</tr>
<?
while($song = $db->row())
PutSongRow($song);
?>
<tr bgcolor="#E0E0E0">
<td colspan="8" nowrap align="center">
<? echo "$prevlnk"; ?>
( Showing <? echo "$first to $last of $cnt"; ?> )
<? echo "$nextlnk"; ?></td>
</tr>
</table>
<br>
<? require("search.php"); ?>
<? require("footer.php"); ?>
define('IN_PHPBB', true);
$phpbb_root_path = '../phpbb/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
require("config.php");
$where = " WHERE (songtype='S') AND (status=0) ";
Def($start,0);
Def($limit,50);
Def($search,"");
//########## BUILD SEARCH STRING ################
if(!empty($search))
{
$words = Array();
$temp = explode(' ',$search);
reset($temp);
while(list($key,$val) = each($temp))
{
$val = trim($val);
if(!empty($val))
$words[] = $val;
}
$where2 = "";
reset($words);
while(list($key,$val) = each($words))
{
if(!empty($where2)) $where2 .= " OR ";
$val = "%$val%";
$db->AddStr($val); $db->AddStr($val); $db->AddStr($val);
$where2 .= " (title like :val1) OR (artist like :val2) OR (album like :val3) ";
}
$where .= "AND ($where2) ";
}
if((isset($letter)) && (!$letter==""))
{
$nextletter = chr(ord($letter)+1);
if($letter=='0')
$where .= " AND NOT((artist>='A') AND (artist<'ZZZZZZZZZZZ')) ";
else
{
$db->AddStr($letter); $db->AddStr($nextletter);
$where .= " AND ((artist>=:letter) AND (artist<:nextletter)) ";
}
}
else
{
$letter="";
}
//########## =================== ################
//Calculate total
$tmp = $db->params; //Save params for second query
$db->open("SELECT count(*) as cnt FROM songlist $where ");
$row = $db->row();
$cnt = $row["cnt"];
//Now grab a section of that
$db->params = $tmp; //Restore params
$db->open("SELECT * FROM songlist $where ORDER BY artist ASC, title ASC", $limit, $start);
$first = $start+1;
$last = min($cnt,$start+$limit);
$rc = $start;
$prevlnk = "";
$nextlnk = "";
if($cnt>0)
{
if(!isset($search))
{ $search=""; }
$searchstr = urlencode($search);
$prev = max(0,$start-$limit);
if($start>0)
$prevlnk = "<a href='?start=$prev&limit=$limit&letter=$letter&search=$searchstr'><< Previous</a>";
$tmp = ($start+$limit);
if($tmp<$cnt)
$nextlnk = "<a href='?start=$tmp&limit=$limit&letter=$letter&search=$searchstr'>Next >></a>";
}
function PutSongRow($song)
{
global $rc, $start, $darkrow, $lightrow;
$rc++;
$bgcolor = $darkrow;
if(($rc % 2)==0) $bgcolor = $lightrow;
PrepareSong($song);
?>
<tr bgcolor="<? echo $bgcolor; ?>">
<td nowrap align="right" width="1%"><font size="2" color="#003366"><small><? echo "$rc"; ?></small></font></td>
<td nowrap><font size="2" color="#003366"> <small><? echo $song["combine"]; ?></small></font></td>
//om de volgende regel zou het gaan
<td nowrap width="1%">
<p align="center"><font size="2" color="#003366"><a href="<? echo $song["request"]; ?>"><img
src="images/request.gif" alt="Request this song now!" border="0"></a></font>
</td>
// tot hier dus
<td nowrap width="1%">
<p align="center"><font size="2" color="#003366"><a href="<? echo $song["buycd"]; ?>" target="_blank"><img
src="images/buy.gif" alt="Buy this CD now!" border="0"></a></font>
</td>
<td nowrap width="1%">
<p align="center"><font size="2" color="#003366"><a href="<? echo $song["website"]; ?>" target="_blank"><img
src="images/home.gif" alt="Artist homepage" border="0"></a></font>
</td>
<td nowrap align="center" width="1%">
<font size="2" color="#003366"><a href="javascript:songinfo(<? echo $song["songid"]; ?>)"><img
src="images/info.gif" alt="Song information" border="0"></a></font>
</td>
<td nowrap><font color="#003366" size="2"><small><? echo $song["album"]; ?></small></font></td>
<td nowrap>
<p align="right"><font color="#003366" size="2"><small><strong><? echo $song["mmss"]; ?></strong></small></font>
</td>
</tr>
<?
}//PutSongRow
/* ## ===================================================================== ## */
?>
<? require("header.php"); ?>
<? if ($user->data['user_id'] != ANONYMOUS)
echo("Hallo en welkom, " . $user->data['username'] . "!");
else
{
echo("Wil je een nummer aanvragen dan moet je eerst <a href='../phpbb/ucp.php?mode=login' >inloggen.</a>");
}
?>
<? require("search.php"); ?>
<br>
<table border="0" width="98%" cellspacing="0" cellpadding="4">
<tr bgcolor="#002E5B">
<td colspan="8" nowrap align="left">
<b><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF">Playlist results</font></b>
</td>
</tr>
<?
while($song = $db->row())
PutSongRow($song);
?>
<tr bgcolor="#E0E0E0">
<td colspan="8" nowrap align="center">
<? echo "$prevlnk"; ?>
( Showing <? echo "$first to $last of $cnt"; ?> )
<? echo "$nextlnk"; ?></td>
</tr>
</table>
<br>
<? require("search.php"); ?>
<? require("footer.php"); ?>
Iemand die me een stapje verder kan helpen misschien?
groeten Arthur
Er zijn nog geen reacties op dit bericht.