Jump to content

Bisa

Members
  • Posts

    76
  • Joined

  • Last visited

    Never

About Bisa

  • Birthday 07/04/1988

Profile Information

  • Gender
    Male
  • Location
    Sweden

Bisa's Achievements

Member

Member (2/5)

0

Reputation

  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
×
×
  • 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.