Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

Including the output for one dedicated group_id on custom page

Hi all!

I got a quite simple question/problem, which will be easy and a 5 minutes work for a php-pro, but for me who is not so familar with php it is hard :(

Issue:
I want to put the output for group_id=2 from profile.php as "code snippet" on a custom page. Who could customize this code for me? I would really appreciate it!

I could do it on my own and try 2-3 hours until it would work, but as i am not a pro i do not know if my own solution would be "safe/secure/clean" then.

Here is the original code from the profile.php which of i need the output for group_id=2 from as code:

CodeDownload  
<?php
require_once "maincore.php";
require_once THEMES."templates/header.php";
require_once CLASSES."UserFields.class.php";
include LOCALE.LOCALESET."user_fields.php";

if (!iMEMBER && $settings['hide_userprofiles'] == 1) { redirect(BASEDIR."login.php"); }

if (isset($_GET['lookup']) && isnum($_GET['lookup'])) {
   $user_status = " AND (user_status='0' OR user_status='3' OR user_status='7')";
   if (iADMIN) {
      $user_status = "";
   }
   $result = dbquery(
      "SELECT u.*, s.suspend_reason
      FROM ".DB_USERS." u
      LEFT JOIN ".DB_SUSPENDS." s ON u.user_id=s.suspended_user
      WHERE user_id='".$_GET['lookup']."'".$user_status."
      ORDER BY suspend_date DESC
      LIMIT 1"
   );

   if (dbrows($result)) { $user_data = dbarray($result); } else { redirect("index.php"); }
   add_to_title($locale['global_200'].$locale['u103'].$locale['global_201'].$user_data['user_name']);

   if (iADMIN && checkrights("UG") && $_GET['lookup'] != $userdata['user_id']) {
      if ((isset($_POST['add_to_group'])) && (isset($_POST['user_group']) && isnum($_POST['user_group']))) {
         if (!preg_match("(^\.{$_POST['user_group']}$|\.{$_POST['user_group']}\.|\.{$_POST['user_group']}$)", $user_data['user_groups'])) {
            $result = dbquery("UPDATE ".DB_USERS." SET user_groups='".$user_data['user_groups'].".".$_POST['user_group']."' WHERE user_id='".$_GET['lookup']."'");
         }
         redirect(FUSION_SELF."?lookup=".$user_data['user_id']);
      }
   }

   opentable($locale['u104']." ".$user_data['user_name']);
   $userFields                = new UserFields();
   $userFields->userData          = $user_data;
   $userFields->showAdminOptions    = true;
   $userFields->displayOutput();
} elseif (isset($_GET['group_id']) && isnum($_GET['group_id'])) {
   $result = dbquery("SELECT group_id, group_name FROM ".DB_USER_GROUPS." WHERE group_id='".$_GET['group_id']."'");
   if (dbrows($result)) {
      $data = dbarray($result);
      $result = dbquery(
         "SELECT user_id, user_name, user_level, user_status
         FROM ".DB_USERS."
         WHERE user_groups REGEXP('^\\\.{$_GET['group_id']}$|\\\.{$_GET['group_id']}\\\.|\\\.{$_GET['group_id']}$')
         ORDER BY user_level DESC, user_name"
      );

      opentable($locale['u110']);
      echo "<table cellpadding='0' cellspacing='0' width='100%'>\n<tr>\n";
      echo "<td align='center' colspan='2' class='tbl1'><strong>".$data['group_name']."</strong>\n";
      echo "(".sprintf((dbrows($result) == 1 ? $locale['u111'] : $locale['u112']), dbrows($result)).")";
      echo "</td>\n</tr>\n<tr>\n";
      if (dbrows($result)) {
         echo "<td class='tbl2'><strong>".$locale['u113']."</strong></td>\n";
         echo "<td align='center' width='1%' class='tbl2' style='white-space:nowrap'><strong>".$locale['u114']."</strong></td>\n";
         echo "</tr>\n";
         while ($data = dbarray($result)) {
            $cell_color = ($i % 2 == 0 ? "tbl1" : "tbl2"); $i++;
            echo "<tr>\n<td class='".$cell_color."'>\n".profile_link($data['user_id'], $data['user_name'], $data['user_status'])."</td>\n";
            echo "<td align='center' width='1%' class='$cell_color' style='white-space:nowrap'>".getuserlevel($data['user_level'])."</td>\n</tr>";
         }
      }
      echo "</table>\n";
   } else {
      redirect("index.php");
   }
} else {
   redirect(BASEDIR."index.php");
}
closetable();

require_once THEMES."templates/footer.php";
?>



Could a php-pro delete all uneccesary (like header, footer, userprofile stuff) and simply recode this code for me so it outputs only the result for group_id=2 ?

This would be so nice and i would be very thankful!

Thanks a lot, very much appreciated to help a php-noob :G

Tom
try this:
CodeDownload  
<?php

require_once CLASSES."UserFields.class.php";
include LOCALE.LOCALESET."user_fields.php";


$_GET['group_id'] = 2;
   $result = dbquery("SELECT group_id, group_name FROM ".DB_USER_GROUPS." WHERE group_id='2'");
   if (dbrows($result)) {
      $data = dbarray($result);
      $result = dbquery(
         "SELECT user_id, user_name, user_level, user_status
         FROM ".DB_USERS."
         WHERE user_groups REGEXP('^\\\.{$_GET['group_id']}$|\\\.{$_GET['group_id']}\\\.|\\\.{$_GET['group_id']}$')
         ORDER BY user_level DESC, user_name"
      );

      opentable($locale['u110']);
      echo "<table cellpadding='0' cellspacing='0' width='100%'>\n<tr>\n";
      echo "<td align='center' colspan='2' class='tbl1'><strong>".$data['group_name']."</strong>\n";
      echo "(".sprintf((dbrows($result) == 1 ? $locale['u111'] : $locale['u112']), dbrows($result)).")";
      echo "</td>\n</tr>\n<tr>\n";
      if (dbrows($result)) {
         echo "<td class='tbl2'><strong>".$locale['u113']."</strong></td>\n";
         echo "<td align='center' width='1%' class='tbl2' style='white-space:nowrap'><strong>".$locale['u114']."</strong></td>\n";
         echo "</tr>\n";
         while ($data = dbarray($result)) {
            $cell_color = ($i % 2 == 0 ? "tbl1" : "tbl2"); $i++;
            echo "<tr>\n<td class='".$cell_color."'>\n".profile_link($data['user_id'], $data['user_name'], $data['user_status'])."</td>\n";
            echo "<td align='center' width='1%' class='$cell_color' style='white-space:nowrap'>".getuserlevel($data['user_level'])."</td>\n</tr>";
         }
      }
      echo "</table>\n";
      closetable();
   }


?>

Basti ... works perfectly ... you are my hero ;)
Very nice from you! Thank you very much!

But this causes following error in the log now:
SoftException in Application.cpp:629: Directory "/home/whatever/public_html/images/avatars" is writeable by group, referer: http://www.whatev...page_id=28

Is this serious? Can we (you) fix this?

Thanks!

--------------------------

Update:

Seems that this error/warning has nothing to do with your/my change, maybe i just have made notice of this warning the first time right after i made you change ;)

I habe "fixed" this by changing chmod from 777 to 755 even if the php-fusion installation says that the image and image/avatar folder should be chmoded 777 (!) ... :|

If someone has an idea why this happens and why installations tells to chmod 777 while cpanel error log warns about it and asks for 755 ... please write ;)

thanks
Thread Information
Author
Replies
3 posts
Views
2,858 times
Last Post
Last updated on 6 years ago
You can view all discussion threads in this forum.
You cannot set up a bounty in this discussion thread.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
You cannot up or down-vote on the post in this discussion thread.
Users who participated in discussion: Basti, tom-fusion