collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 826
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

NEED HELP? If you're looking for support with Simple Portal, look no further than the Support Board!

Author Topic: Custom php block not showing on admin homepage only.  (Read 1940 times)

0 Members and 1 Guest are viewing this topic.

Offline thellie

  • Semi Newbie
  • *
  • Posts: 22
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Custom php block not showing on admin homepage only.
« on: October 22, 2010, 01:32:08 AM »
hi,
i've tested comprehensively (as far as my knowledge allows), and now think this is either a bug, or the mysql connection is incorrect for this page alone.

i have created a custom php block pulling records from the mysql dbase. the block/code displays perfectly except on the smf administrator's portal (smf 2.0 rc3). it displays perfectly on the portal of anyone who is not an administrator.

there are no permissions set for it anywhere (in the block it is set to ignore permissions).

the only thing i can think of, other than it being a bug, is that the portal page needs to have the admin mysql connection set differently to the other members ..?

here is the code although, as i said, it works perfectly well elsewhere... any ideas?
Code: [Select]

global $settings, $context, $modSettings, $user_info, $txt, $scripturl, $boardurl, $boarddir;

require_once('./Connections/mirrorfoundation.php');
mysql_select_db($database_mirrorfoundation, $mirrorfoundation);
$query_current_total = "SELECT DISTINCT COUNT(smf_members.id_member)  AS countthis
FROM
(smf_members LEFT JOIN volunteer_profiles
ON
smf_members.id_member=volunteer_profiles.id_member
)
LEFT JOIN volunteer_appforms
ON
volunteer_appforms.id_member=smf_members.id_member
WHERE startdate<=CURDATE() AND enddate>=CURDATE() ORDER BY M_program, M_first_name ASC";
$current_total = mysql_query($query_current_total, $mirrorfoundation) or die(mysql_error());
$row_current_total = mysql_fetch_assoc($current_total);
$totalRows_current_total = mysql_num_rows($current_total);

$query_nextmonth_total = "SELECT DISTINCT COUNT(smf_members.id_member) AS countnext
FROM
(smf_members LEFT JOIN volunteer_profiles
ON
smf_members.id_member=volunteer_profiles.id_member
)
LEFT JOIN volunteer_appforms
ON
volunteer_appforms.id_member=smf_members.id_member
WHERE startdate > CURDATE() AND (MONTH(startdate) = MONTH(DATE_ADD( CURDATE() , INTERVAL 1 MONTH ))) ORDER BY startdate, M_program, M_first_name ASC";
$nextmonth_total = mysql_query($query_nextmonth_total, $mirrorfoundation) or die(mysql_error());
$row_nextmonth_total = mysql_fetch_assoc($nextmonth_total);
$totalRows_nextmonth_total = mysql_num_rows($nextmonth_total);

mysql_select_db($database_mirrorfoundation, $mirrorfoundation);
$query_stilltocomethismonth_total = "SELECT DISTINCT COUNT(smf_members.id_member)  AS countthiswill
FROM
(smf_members LEFT JOIN volunteer_profiles
ON
smf_members.id_member=volunteer_profiles.id_member
)
LEFT JOIN volunteer_appforms
ON
volunteer_appforms.id_member=smf_members.id_member
WHERE startdate > CURDATE() AND  (MONTHNAME(startdate)=MONTHNAME(CURDATE())) AND YEAR(startdate) = YEAR(CURDATE()) ORDER BY UNIX_TIMESTAMP(startdate), M_program, M_first_name ASC";
$stilltocomethismonth_total = mysql_query($query_stilltocomethismonth_total, $mirrorfoundation) or die(mysql_error());
$row_stilltocomethismonth_total = mysql_fetch_assoc($stilltocomethismonth_total);
$totalRows_stilltocomethismonth_total = mysql_num_rows($stilltocomethismonth_total);

$query_volunteers_current = "SELECT DISTINCT smf_members.id_member, CONCAT(UPPER(SUBSTRING(M_first_name,1,1)), LOWER(SUBSTRING(M_first_name,2)), ' ', UPPER(SUBSTRING(M_last_name,1,1))) AS name, email_address, startdate AS sortdate, DATE_FORMAT(startdate,'%D') AS startdate, IF(M_program='INDOOR', UPPER(SUBSTRING(M_program,1,2)),UPPER(SUBSTRING(M_program,1,3))) AS M_program, CURDATE()
FROM
(smf_members LEFT JOIN volunteer_profiles
ON
smf_members.id_member=volunteer_profiles.id_member
)
LEFT JOIN volunteer_appforms
ON
volunteer_appforms.id_member=smf_members.id_member
WHERE startdate<=CURDATE() AND enddate>=CURDATE()
ORDER BY M_program, M_first_name ASC";
$volunteers_current = mysql_query($query_volunteers_current, $mirrorfoundation) or die(mysql_error());
$row_volunteers_current = mysql_fetch_assoc($volunteers_current);
$totalRows_volunteers_current = mysql_num_rows($volunteers_current);

$query_volunteers_stilltocomethismonth = "SELECT DISTINCT smf_members.id_member,  CONCAT(UPPER(SUBSTRING(M_first_name,1,1)), LOWER(SUBSTRING(M_first_name,2)), ' ', UPPER(SUBSTRING(M_last_name,1,1))) AS name, email_address, startdate AS sortdate, DATE_FORMAT(startdate,'%D') AS startdate, IF(M_program='INDOOR', UPPER(SUBSTRING(M_program,1,2)),UPPER(SUBSTRING(M_program,1,3))) AS M_program
FROM
(smf_members LEFT JOIN volunteer_profiles
ON
smf_members.id_member=volunteer_profiles.id_member
)
LEFT JOIN volunteer_appforms
ON
volunteer_appforms.id_member=smf_members.id_member
WHERE
startdate > CURDATE() 
AND
(MONTHNAME(startdate)=MONTHNAME(CURDATE()))
AND
YEAR(startdate) = YEAR(CURDATE( ))
ORDER BY sortdate ASC, M_program, M_first_name";
$volunteers_stilltocomethismonth = mysql_query($query_volunteers_stilltocomethismonth, $mirrorfoundation) or die(mysql_error());
$row_volunteers_stilltocomethismonth = mysql_fetch_assoc($volunteers_stilltocomethismonth);
$totalRows_volunteers_stilltocomethismonth = mysql_num_rows($volunteers_stilltocomethismonth);

mysql_select_db($database_mirrorfoundation, $mirrorfoundation);
$query_volunteers_nextmonth = "SELECT DISTINCT smf_members.id_member,  CONCAT(UPPER(SUBSTRING(M_first_name,1,1)), LOWER(SUBSTRING(M_first_name,2)), ' ', UPPER(SUBSTRING(M_last_name,1,1))) AS name, email_address, startdate AS sortdate, DATE_FORMAT(startdate,'%D') AS startdate, MONTHNAME( DATE_ADD( CURDATE( ) , INTERVAL 1
MONTH ) ) AS monthname, IF(M_program='INDOOR', UPPER(SUBSTRING(M_program,1,2)),UPPER(SUBSTRING(M_program,1,3))) AS M_program
FROM
(smf_members LEFT JOIN volunteer_profiles
ON
smf_members.id_member=volunteer_profiles.id_member
)
LEFT JOIN volunteer_appforms
ON
volunteer_appforms.id_member=smf_members.id_member
WHERE startdate > CURDATE( )
AND (
MONTH( startdate ) = MONTH( DATE_ADD( CURDATE( ) , INTERVAL 1
MONTH ) )
)
ORDER BY sortdate ASC, M_program, M_first_name";
$volunteers_nextmonth = mysql_query($query_volunteers_nextmonth, $mirrorfoundation) or die(mysql_error());
$row_volunteers_nextmonth = mysql_fetch_assoc($volunteers_nextmonth);
$totalRows_volunteers_nextmonth = mysql_num_rows($volunteers_nextmonth);

$query_users = "SELECT DISTINCT smf_members.id_member, CONCAT(UPPER(SUBSTRING(M_first_name,1,1)), LOWER(SUBSTRING(M_first_name,2)), ' ', SUBSTRING(M_last_name, 1,1)) AS name, enddate, DATEDIFF(enddate,CURDATE()) AS daysleft
FROM
(smf_members LEFT JOIN volunteer_profiles
ON
smf_members.id_member=volunteer_profiles.id_member
)
LEFT JOIN volunteer_appforms
ON
volunteer_appforms.id_member=smf_members.id_member
WHERE DATEDIFF(enddate,CURDATE()) BETWEEN 1 AND 10
ORDER BY enddate, M_first_name DESC";
$users = mysql_query($query_users, $mirrorfoundation) or die(mysql_error());
$row_users = mysql_fetch_assoc($users);
$totalRows_users = mysql_num_rows($users);

echo '
<table class="table" width="100%">
<tr class="catbg3" width="100%">
    <td colspan="2" class="windowbg3" width="100%">
Leaving soon
</td>
</tr>

<tr class="catbg3" width="100%">
<td class="smalltext">';
echo date('D jS', strtotime($row_users['enddate'])); ?>: <?php echo '

<a href="'
$scripturl '?action=profile;u='$row_users['id_member'] ,'">'$row_users['name'] ,'</a>
</td>
</tr>'
;
echo 
'<tr class="catbg3" width="100%">
    <td colspan="2" class="windowbg3" width="100%"><hr />
    Current ('
$row_current_total['countthis'] ,')</td>
  </tr>'
;
  do { 
echo 
'<tr class="catbg3" width="100%">
      <td class="smalltext">'
;
echo 
'<a href="'$scripturl '?action=profile;u='$row_volunteers_current['id_member'] ,'">'$row_volunteers_current['name'] ,'</a></td>
      <td class="smalltext">'
$row_volunteers_current['M_program'] ,'</td>
    </tr>'
;
} while ($row_volunteers_current mysql_fetch_assoc($volunteers_current));
    echo 
'<tr class="catbg3" width="100%">
    <td colspan="2" class="windowbg3"><hr />
    Due later this month ('
$row_stilltocomethismonth_total['countthiswill'],')</td>
  </tr>'

  do { 
  echo 
'<tr class="catbg3" width="100%">
      <td class="smalltext">'
;
      echo 
'<a href="'$scripturl '?action=profile;u='$row_volunteers_stilltocomethismonth['id_member'] ,'">'$row_volunteers_stilltocomethismonth['name'] ,'</a></td>
      <td class="smalltext">'
$row_volunteers_stilltocomethismonth['M_program'] ,' ',$row_volunteers_stilltocomethismonth['startdate'] ,'</td>
    </tr>'
;
} while ($row_volunteers_stilltocomethismonth mysql_fetch_assoc($volunteers_stilltocomethismonth));
    echo 
'<tr class="catbg3" width="100%">
    <td colspan="2" class="windowbg3" width="100%"><hr />
    Due next month ('
$row_nextmonth_total['countnext'] ,')</td>
  </tr>'
;
  do {
      echo 
'<tr class="catbg3" width="100%">
      <td class="smalltext">'
;
          echo 
'<a href="'$scripturl '?action=profile;u='$row_volunteers_nextmonth['id_member'] ,'">'$row_volunteers_nextmonth['name'] ,'</a></td>
      <td class="smalltext">'
$row_volunteers_nextmonth['M_program'],' '$row_volunteers_nextmonth['startdate'] ,'</td>
    </tr>'
;
} while ($row_volunteers_nextmonth mysql_fetch_assoc($volunteers_nextmonth));
    echo 
'
<tr>
<td height="20" colspan="2" align="center" class="windowbg3" width="100%">Key to programmes<br>
COL = Colleague<br>
IN  = Indoor<br>
OUT = Outdoor<br>
JAP = Japanese</td>
  </tr></table>
</body></html>'
;
mysql_free_result($current_total);
mysql_free_result($nextmonth_total);
mysql_free_result($stilltocomethismonth_total);
mysql_free_result($volunteers_current);
mysql_free_result($volunteers_stilltocomethismonth);
mysql_free_result($volunteers_nextmonth);
mysql_free_result($users);

EDIT: forgot to say - the block itself shows as a header with the title in it, and the top section of the main box (with the curved corners)
« Last Edit: October 22, 2010, 04:53:11 AM by thellie »

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Custom php block not showing on admin homepage only.
« Reply #1 on: October 28, 2010, 10:16:20 AM »
My guess is this problem is not really a SimplePortal problem, and may not even be an SMF problem, though I could be wrong.
 
In general, I don't think you want the "die" statement in your production block -- it is designed to write its error message and kill the entire rest of the page. It could be helpful in narrowing things down while you are debugging.
 
I would first look for a problem with this php code.
Here's how I would start, no matter what code I was working on.
1) What clues do I have to start with?
   + Something messes up so badly that the bottom of the block is not showing up
   + Check the error log when this happens, to see if there are any error messages
   + Look at the HTML for the page, to see what happens. How far through the block's echo statements does the code get?  Is the bottom of the block really missing, or is it more like the formatting is messed up? Did a mysql error cause you to "die" and stop right there without doing the rest of the plage?
 
2) Do I have any idea how far the code gets before it starts to go wrong? (see above)
 
3) Start with an empty php block that is only visible on a test page.  Add in all the lines you know FOR SURE (see step 2) really work.  Test to make sure you get the bottom of the block and no error messages on your log.
 
4) One by one, add in more lines, testing each time to see when things start to go haywire.  Pretty soon, you'll know which line is causing your problem.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?