Jump to content

Bisa

Members
  • Posts

    76
  • Joined

  • Last visited

    Never

Everything posted by Bisa

  1. Actually, yes, the loop logic was kinda flawed, what I realized due to your input was the following: Since the {PAGE_TITLE} had already been handled in the first circulation it couldn't be replaced magically in some way once the files had been included which also contained {PAGE_TITLE}. What I did to solve this was, as u suggested, simply to include the pages first and then loop through the tags that had only replacements in it for them Thnx
  2. $tags print_r results in this: Array ( [PAGE_TITLE] => Index [PAGE_HEAD] => ./templates/page_head.html [PAGE_FOOT] => ./templates/page_foot.html ) 1 and by that you might figure that I cannot simply parse the file before the loop as I would need to parse both head and foot thus making the buffer consist of only head and foot, or am I thinking wrong there?
  3. If you wonder how to get values from the url into the php script (and subsequently into the db query) you might just be looking for $_GET[]
  4. I see. And yes, I use {PAGE_TITLE} two times for example. One time in the header.html that I am including (the html gets printed out just fine) and a second time in the body. The only time I actually get the title printed is in the body where it's preg_replaced based on a tag associative array " Title" => "My Page Title" what seems to be the issue here is that whenever Ive included a file such as my header.html the preg_replace won't replace my {PAGE_TITLE} which should be located in the buffer output string - instead it just skips it and I'm left with the place holder being echoed rather then my desired title.
  5. I'm working on a basic structure for websites containing user management and a template engine. I've run into troubles with the template engine when I try to allow for including scripted pages. This function is supposed to include and buffer the scripted page: function parse_file($file) { ob_start(); include($file); $buffer = ob_get_clean(); return $buffer; } In my template class I check to see if the data entered is a file or not, if it is then I run these lines to replace place holder-tags with the output buffer of the file included: foreach ($tags as $tag => $data) { if (file_exists($data)){ $data = $this->parse_file($data); } $this->page = preg_replace('/{' . $tag . '}|<!-- '.$tag.' -->/', $data, $this->page); } now here is the hitch, it seems the preg_replace is only replacing one of several identical place holder-tags and I am puzzled as of why this happens, could it be the buffer or what?
  6. This could be what you are looking for perhaps: http://www.webcheatsheet.com/PHP/multidimensional_arrays.php
  7. cheers, well I am able to understand/write php but I never got my head around sessions (and classes, but that is not relevant) so if you could "jot" me just a little sample code (provided you feel like it and have the time of course) I will most likely be able to build on it to suit my needs on a side not, this will be my last entry for tonight so if you do not hear from me it will not be because I am not grateful for your help but rather that I am sleeping or working
  8. As the topic suggests I'd like to know how to check a user remotely (in this particular example if they are logged in to our phpBB3 forum) and then, if they are, redirect them back to the page they were trying to access. This is an attempt to bridge two frameworks, phpBB and Eqdkp. What I know so far is this code would help me restrict access to custom pages based on my phpBB sessions: define('IN_PHPBB', true); $phpbb_root_path = './../forum/'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); // Start session management $user->session_begin(); $auth->acl($user->data); $user->setup(); if(!$user->data['is_registered']){ if ($user->data['user_id'] != ANONYMOUS){ trigger_error('NOT_AUTHORISED'); } login_box('', $user->lang['NOT_AUTHORISED']); } (btw, I've got the eqdkp and forum on the same server in separate sub-directories so perhaps "remotely" is an incorrect word) however, simply adding this to my EqDKP session.php results in to many conflicts as they both use the same names for functions etcetera. Hence why I want to first send the user to some code checking if they are forum users and logged in, if they are send them back to eqdkp and allow them access. I suspect this approach might be riddled with security issues or that it is possibly even messier then solving it some other way, well, that's why I reach out for help here
  9. ah, thank you, mysql_set_charset('utf8',$db_connect) in my configuration file did the trick =)
  10. My guess is you would need a cron job (something repeatedly executed by the server with a user specified time interval, in your case once every 60min) Can't help you with crons thou =/
  11. I've tried to make my website international (that is making it possible to post any character such as åäö) but all I am getting is cryptic symbols... Here is the deal, I thought utf-8 was the way to go so my meta tag reads as follows: <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" /> The default char set in my database reads " DEFAULT CHARACTER SET utf8 COLLATE utf8_swedish_ci" (side note, is there a choise without the collate so I only have utf8?). What I am doing is using php to fetch data from the db and store a variable that is to be printed on my page as content. If I type anything in the html using åäö they show up fine due to the meta tag BUT anything I echo such as the content variable the åäö shows up pretty screwed... --- Basically, whats "standard procedure" when storing international text into a db?
  12. cheers, but I worked around it by adding $raid_count = $raid_count['count(*)']; and $individual_raid_count = $individual_raid_count['count(*)']; before putting those into the calculation $percent_of_raids = ( $raid_count > 0 ) ? round(($individual_raid_count / $raid_count) * 100) : 0; Now the calculation is correct, the data is fetched from the db correctly BUT The data is not inserted into the db at all... any hints? I guess I'm doing something wrong here: mysql_query("UPDATE eqdkp_members SET member_attendance = " . $percent_of_raids . " WHERE member_name = " . $row['member_name'] . ""); (perhaps using some $vbulletin->db-> update? could do the trick.... be right back ^^ ) Edit* $vbulletin->db->query_write(); is working and as a result this is how my finished code looks like, thanks to them who helped me <?php $result = mysql_query("SELECT member_name FROM eqdkp_members"); while($row = mysql_fetch_array($result)) { // Find the percent of raids they've attended in the last 30 days $percent_of_raids = raid_count(mktime(0, 0, 0, date('m'), date('d')-30, date('Y')), time(), $row['member_name']); $vbulletin->db->query_write("UPDATE eqdkp_members SET member_attendance = " . $percent_of_raids . " WHERE member_name = '" . $row['member_name'] . "'"); echo "%<br /><br />(In While Loop) Member Name: " . $row['member_name'] . " " . $percent_of_raids . "%"; } function raid_count($start_date, $end_date, $member_name) { global $vbulletin; $raid_count = $vbulletin->db->query_first("SELECT count(*) FROM eqdkp_raids WHERE (raid_date BETWEEN '" . $start_date . "' AND '" . $end_date . "')"); $raid_count = $raid_count['count(*)']; $sql = "SELECT count(*) FROM eqdkp_raids AS r, eqdkp_raid_attendees AS ra WHERE (ra.raid_id = r.raid_id) AND (ra.member_name='" . $member_name . "') AND (r.raid_date BETWEEN '" . $start_date . "' AND '" . $end_date . "')"; $individual_raid_count = $vbulletin->db->query_first($sql); $individual_raid_count = $individual_raid_count['count(*)']; echo "<br />(In Function) Member Name: " . $row['member_name'] . " Raid Count: " . $raid_count . " Ind. Raid Count: " . $individual_raid_count . "<br />"; $percent_of_raids = ( $raid_count > 0 ) ? round(($individual_raid_count / $raid_count) * 100) : 0; $raid_count_stats = array( 'percent' => $percent_of_raids, 'total_count' => $raid_count, 'indiv_count' => $individual_raid_count); return $raid_count_stats['percent']; // Only thing needed ATM } ?>
  13. Cheers, but now I'm getting: Fatal error: Unsupported operand types in /includes/cron/custom/member_attendance.php on line 32 What I did was echoing $raid_count to discover it's an array ??? I then proceeded with print_r($raid_count); and get the following output: Array ( [count(*)] => 2 ) Fatal error: Unsupported operand types in /includes/cron/custom/member_attendance.php on line 34
  14. I hate to bring up old problems but here goes... In my previous post I praise the lord for having things working my way however, that is not the case any more :-\ The code: <?php $result = mysql_query("SELECT member_name FROM eqdkp_members"); while($row = mysql_fetch_array($result)) { // Find the percent of raids they've attended in the last 30 days $percent_of_raids = raid_count(mktime(0, 0, 0, date('m'), date('d')-30, date('Y')), time(), $row['member_name']); mysql_query("UPDATE eqdkp_members SET member_attendance = " . $percent_of_raids . " WHERE member_name = " . $row['member_name'] . ""); echo "Member Name: " . $percent_of_raids . "%<br /><br />"; } //Attendance Function function raid_count($start_date, $end_date, $member_name) { $result = mysql_query('SELECT count(*) FROM eqdkp_raids WHERE raid_date BETWEEN ' . $start_date . ' AND ' . $end_date . ''); if(mysql_num_rows($result) > 0) list($raid_count) = mysql_fetch_row($result); $result = mysql_query('SELECT count(*) FROM eqdkp_raids AS r, eqdkp_raid_attendees AS ra WHERE ra.raid_id = r.raid_id AND ra.member_name=' . $member_name . ' AND r.raid_date BETWEEN ' . $start_date . ' AND ' . $end_date . ''); if(mysql_num_rows($result) > 0) list($individual_raid_count) = mysql_fetch_row($result); if(isset($raid_count, $individual_raid_count) && is_numeric($raid_count) && is_numeric($individual_raid_count)) { $percent_of_raids = ( $raid_count > 0 ) ? round(($individual_raid_count / $raid_count) * 100) : 0; $raid_count_stats = array( 'percent' => $percent_of_raids, 'total_count' => $raid_count, 'indiv_count' => $individual_raid_count); return $raid_count_stats['percent']; // Only thing needed ATM } return false; } ?> Presents me with the following error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in [path]/includes/cron/custom/member_attendance.php on line 23 Member Name: % Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in [path]/includes/cron/custom/member_attendance.php on line 23 Member Name: % note that if things would work as I'd like them to you would see the two only members printed as: Member Name: Aa 100% Member Name: Bb 50% Also note that adding echo "<br />" . $result; as the second line of the raid_count function echos "Resource id #20" and "Resource id #19"... No idea as of why this is really, any help would be appreciated =/
  15. Cheers, works as intended
  16. I'm trying to update some rows in my db using this query in a while-loop mysql_query('UPDATE eqdkp_members SET member_attendance = ' . $percent_of_raids . ' WHERE member_name = ' . $row['member_name'] . ''); To make sure I'm having variables n' stuff sorted I entered this echo: echo $row['member_name'] . ' - ' . $percent_of_raids . '<br />'; which gives me the following output: User1 - 60 User2 - 40 User3 - 8 User4 - 99 As you can see the $row['member_name'] and $percent_of_raids change accordingly throughout the while-loop but if I check my database the same old default values are still there, no updates have been made (and Mind you I do get the $row['member_name'] from the same database ) Any help would be appreciated :-\
  17. I was under the impression that using count(*) on this line $raid_count_result = mysql_query('SELECT count(*) FROM eqdkp_raids AS r, eqdkp_raid_attendees AS ra WHERE ra.raid_id = r.raid_id AND ra.member_name=' . $member_name . ' AND r.raid_date BETWEEN ' . $start_date . ' AND ' . $end_date . ''); would give me the number of rows where the same member name shows up in both tables in the same raid_id between now and 30 days ago, albeit this seems wrong in some way as when I run $percent_of_raids = ( $raid_count > 0 ) ? round(($individual_raid_count / $raid_count) * 100) : 0; I'm presented with the error Fatal error: Unsupported operand types in /dkp_attendance.php on line 32 I suspect that the warning mysql_fetch_row(): supplied argument is not a valid MySQL result resource for this line list($individual_raid_count) = mysql_fetch_row($raid_count_result); is what's causing the trouble...
  18. hmm, thnx for trying to help me but I'm generating yet another set of erros and now the function looks like this with wildteens additions function raid_count($start_date, $end_date, $member_name) { $raid_count = mysql_query('SELECT count(*) FROM eqdkp_raids WHERE raid_date BETWEEN ' . $start_date . ' AND ' . $end_date . ''); $raid_count = mysql_fetch_row($raid_count); echo $raid_count . ' - '; //$individual_raid_count = mysql_query('SELECT count(*) FROM eqdkp_raids AS r, eqdkp_raid_attendees AS ra WHERE ra.raid_id = r.raid_id AND ra.member_name=' . $member_name . ' AND r.raid_date BETWEEN ' . $start_date . ' AND ' . $end_date . ''); //$individual_raid_count = mysql_fetch_row($individual_raid_count); //echo $individual_raid_count . ' - '; $raid_count_result = mysql_query('SELECT count(*) FROM eqdkp_raids AS r, eqdkp_raid_attendees AS ra WHERE ra.raid_id = r.raid_id AND ra.member_name=' . $member_name . ' AND r.raid_date BETWEEN ' . $start_date . ' AND ' . $end_date . ''); list($individual_raid_count) = mysql_fetch_row($raid_count_result); echo $individual_raid_count . ' - '; $percent_of_raids = ( $raid_count > 0 ) ? round(($individual_raid_count / $raid_count) * 100) : 0; $raid_count_stats = array( 'percent' => $percent_of_raids, 'total_count' => $raid_count, 'indiv_count' => $individual_raid_count); return $raid_count_stats['percent']; // Only thing needed ATM } Getting the following echo output: Array - Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /dkp_attendance.php on line 29 - Fatal error: Unsupported operand types in /dkp_attendance.php on line 32 where line 29 is: list($individual_raid_count) = mysql_fetch_row($raid_count_result); and line 32 is: $percent_of_raids = ( $raid_count > 0 ) ? round(($individual_raid_count / $raid_count) * 100) : 0;
  19. Modifying to fetch row and the code looks like this function raid_count($start_date, $end_date, $member_name) { $raid_count = mysql_query('SELECT count(*) FROM eqdkp_raids WHERE raid_date BETWEEN ' . $start_date . ' AND ' . $end_date . ''); $raid_count = mysql_fetch_row($raid_count); echo $raid_count . ' - '; $individual_raid_count = mysql_query('SELECT count(*) FROM eqdkp_raids AS r, eqdkp_raid_attendees AS ra WHERE ra.raid_id = r.raid_id AND ra.member_name=' . $member_name . ' AND r.raid_date BETWEEN ' . $start_date . ' AND ' . $end_date . ''); //$individual_raid_count = mysql_fetch_row($individual_raid_count); echo $individual_raid_count . ' - '; $percent_of_raids = ( $raid_count > 0 ) ? round(($individual_raid_count / $raid_count) * 100) : 0; $raid_count_stats = array( 'percent' => $percent_of_raids, 'total_count' => $raid_count, 'indiv_count' => $individual_raid_count); return $raid_count_stats['percent']; // Only thing needed ATM } While running this I'm getting this printed on my screen: Array - - Fatal error: Unsupported operand types in /dkp_attendance.php on line 28 Line 28 is: $percent_of_raids = ( $raid_count > 0 ) ? round(($individual_raid_count / $raid_count) * 100) : 0;
  20. Cheers, but changing this and running the code again gives me the same echo output =/
  21. This function is supposed to grab data from my database and calculate how many times out of a total that members have been participating in events the past 30 days. The function itself is a rip off from eqdkp 1.3.2 viewmember.php with slight modifications to match my database. The code looks like this function raid_count($start_date, $end_date, $member_name) { $raid_count = mysql_query('SELECT count(*) FROM eqdkp_raids WHERE raid_date BETWEEN ' . $start_date . ' AND ' . $end_date . ''); //$raid_count = mysql_fetch_array($raid_count); echo $raid_count . ' - '; $sql = 'SELECT count(*) FROM eqdkp_raids AS r, eqdkp_raid_attendees AS ra WHERE ra.raid_id = r.raid_id AND ra.member_name=' . $member_name . ' AND r.raid_date BETWEEN ' . $start_date . ' AND ' . $end_date . ''; $individual_raid_count = mysql_query($sql); echo $individual_raid_count . ' - '; $percent_of_raids = ( $raid_count > 0 ) ? round(($individual_raid_count / $raid_count) * 100) : 0; $raid_count_stats = array( 'percent' => $percent_of_raids, 'total_count' => $raid_count, 'indiv_count' => $individual_raid_count); return $raid_count_stats['percent']; // Only thing needed ATM } $result = mysql_query('SELECT member_name FROM eqdkp_members'); while($row = mysql_fetch_array($result)) { // Find the percent of raids they've attended in the last 30, 60 and 90 days $percent_of_raids = array( '30' => raid_count(mktime(0, 0, 0, date('m'), date('d')-30, date('Y')), time(), $row['member_name']) ); echo $percent_of_raids['30'] . ' - ' . $row['member_name'] . '<br />'; //mysql_query('UPDATE eqdkp_members SET member_attendance = ' . $attendance . ' WHERE member_name = ' . $row['member_name'] . ''); } While running this (It's supposed to be a cron job when I'm done) I get the following output via my echos: Resource id #3 - - 0 - UserName1 Resource id #4 - - 0 - UserName2 Resource id #5 - - 0 - UserName3 Resource id #6 - - 0 - UserName4 As you can see the $percent_of_raids['30'] is always 0 and I get no errors whatsoever =/ The date data from eqdkp_raid_attendees and eqdkp_raids uses the same format "1228086789" to store dates (something which works in the original function but not for mine) Ideally feeding the function with this data would where this is the only event that has taken place the past 30 days all users should have a 100% attendance as they are all listed in the eqdkp_raid_attendees table... I suppose I'm tired and such but banging my head long enough against the screen isnt helping me much here any help or pointers are greatly appreciated
  22. Lovely, you saved my back, the moderators were starting to whine about having to do to many small repetitive tasks already
  23. ah! Cheers, this worked like a charm thank you =) another thing, if I aso wanted to include the groups 10 and 11 in addition to 15 can I use fu.usergroupid = 10 OR fu.usergroupid = 11 or will this break the check and simply change the rank on all members in grp 11 without checking the usernames?
  24. Well, instead of trying to make general examples I'll go with the full story I'm using eqdkp and vBulletin, I've managed to bridge the two applications to allow users to log in with one acc on them both. In eqdkp users are able to create characters/toons and by default these toons do not get a rank, this rank is needed for eqdkp to do various automated tasks and I would like to check whether or not the forum_users(username) is a member of the user group "15", if they are the eqdkp_members(member_name) that is identical to (username) should have there (rank_id) edited into "2". dunno if that made things clearer? :-\ Edit* This might fit better into the php help section seeing the real problem might be getting the "while"/"ifs" and "elses" to work properly?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.