Advertisement:

Author Topic: In a bit of trouble >_< [more]  (Read 3783 times)

Offline Ploy1886

  • Newbie
  • *
  • Posts: 8
  • Gender: Male
In a bit of trouble >_< [more]
« on: May 30, 2004, 10:34:00 PM »
I'm getting a site together @ hxxp:www.euneos.org [nonactive].. Most things are based round the SMF forums (modded slightly).

My problem is this: I'm running a divisions system, and need the ability for registered users to signup to these divisions, to do that, I need to get the user id from the cookie, to auth that user.  the Divisions script is @ hxxp:www.euneos.org/divisions.php [nonactive].

I'd be very grateful if someone could tell me how to properly split the cookie in PHP and grab the ID_MEMBER from it.

Thanks,

TheDoctor
Founder of The Euneos Foundation

Offline Oldiesmann

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,868
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • https://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: In a bit of trouble >_< [more]
« Reply #1 on: May 30, 2004, 11:39:03 PM »
Actually, if you just want to grab the ID_MEMBER, use ssi_welcome with no parameters:

just put require('../SSI.php'); at the beginning of your PHP script (right before any other code), and then when you want to get the member id, just assign some variable to ssi_welcome(); and use that variable.
« Last Edit: May 30, 2004, 11:40:36 PM by Oldiesmann »
Michael Eshom
Cincy Space - now open!

Offline Ploy1886

  • Newbie
  • *
  • Posts: 8
  • Gender: Male
Re: In a bit of trouble >_< [more]
« Reply #2 on: May 30, 2004, 11:56:59 PM »
That doesnt work... heres the two files:

divisions.php
Code: [Select]
<?php
    ob_start
();
    include(&
#39;/home/euneos.org/www/web/global.php&#39;);
    
PrintHeader();

    if(
$_REQUEST["id"] OR $_REQUEST["name"]) { 
        
$query mysql_query("SELECT * FROM divisions WHERE id=&#39;".$_REQUEST["id"]."&#39; OR shortname=&#39;".$_REQUEST["name"]."&#39;");
        if(
mysql_num_rows($query) == 1) { 
            
$row mysql_fetch_array($query);
            if(
$_REQUEST["task"] == "Signup") { 
                include(&
#39;/home/euneos.org/www/web/divisions/signup.php&#39;);
            
}
            elseif(
$_REQUEST["task"] == "ControlPanel") { 
                include(&
#39;/home/euneos.org/www/web/divisions/index.php&#39;);
            
}
            else { 
                
ShowDiv($row["id"]);
            }
        }
        else { 
            
PrintError(&#39;Invalid Division ID or Name&#39;);
        
}
    }
    else { 
        
ShowDiv(&#39;1&#39;);
    
}

    function 
ShowDiv($id) { 
        
$div_query mysql_query("SELECT * FROM divisions WHERE id=&#39;".$id."&#39;");
        
$div_row mysql_fetch_array($div_query);

        echo 
"<h2 align=\"center\"><font color=\"".$div_row["color"]."\">".$div_row["name"]."</font></h2>\n\n";

        echo 
"<center><b>".$div_row["description"]."</b></center>\n";

        echo 
"<ul type=\"disc\">\n";
        echo 
"  <li><b>Division Information</b></li>\n";
        echo 
"  <ul type=\"circle\">\n";
        echo 
"    <li><b>Join Rank:</b> ".GetRank($div_row["joinrank"])."</li>\n";
        if(
$div_row["website"] != null) { 
            echo 
"    <li><b>Website:</b> <a href=\"".$div_row["website"]."\">".$div_row["name"]."</a></li>\n";
        }
        if(
$div_row["joinstatus"] == 1) { 
            echo 
"    <li><b>Join Status:</b> Closed for recruiting</li>\n";
        }
        elseif(
$div_row["joinstatus"] == 2) { 
            echo 
"    <li><b>Join Status:</b> <a href=\"/divisions.php?id=".$div_row["id"]."&task=Signup\">Apply for this Division</a></li>\n";
        }
        elseif(
$div_row["joinstatus"] == 3) { 
            echo 
"    <li><b>Join Status:</b> <a href=\"/divisions.php?id=".$div_row["id"]."&task=Signup\">Open for recruiting</a></li>\n";
        }
        if(
$div_row["parent"] > 0) { 
            
$p_query mysql_query("SELECT * FROM divisions WHERE id=&#39;".$div_row["parent"]."&#39;");
            
$p_row mysql_fetch_array($p_query);
            echo 
"    <li><b>Up:</b> <a href=\"/divisions.php?id=".$div_row["parent"]."\"><font color=\"".$p_row["color"]."\">".$p_row["name"]."</font></a></li>\n";
        }
        echo 
"  </ul>\n";
        echo 
"</ul>\n";

        echo 
"<ul type=\"disc\">\n";
        echo 
"  <li><b>Division Management</b></li>\n";
        echo 
"  <ul type=\"circle\">\n";
        if(
$div_row["leader1"] > 0) { 
            echo 
"    <li><b>Leader:</b> ".GetNameRank($div_row["leader1"])."</li>\n";
            if(
$div_row["leader2"]) { 
                echo 
"    <li><b>Leader:</b> ".GetNameRank($div_row["leader2"])."</li>\n";
            }
            if(
$div_row["deputyleader1"]) { 
                echo 
"    <li><b>Deputy Leader:</b> ".GetNameRank($div_row["deputyleader1"])."</li>\n";
            }
            if(
$div_row["deputyleader2"]) { 
                echo 
"    <li><b>Deputy Leader:</b> ".GetNameRank($div_row["deputyleader2"])."</li>\n";
            }
            if(
$div_row["deputyleader2"]) { 
                echo 
"    <li><b>Deputy Leader:</b> ".GetNameRank($div_row["deputyleader3"])."</li>\n";
            }
        }
        else { 
            echo 
"    <li><b>Leader:</b> Open</li>\n";
        }
        echo 
"  </ul>\n";
        echo 
"</ul>\n\n";

        
$nm_query mysql_query("SELECT * FROM smf_members WHERE divisionID=&#39;".$id."&#39;");
        if(
mysql_num_rows($nm_query) > 0) { 
            
$nm_row mysql_fetch_array($nm_query);

            if(
$nm_row["ID_MEMBER"] == $div_row["leader1"]) { 

            }
            elseif(
$nm_row["ID_MEMBER"] == $div_row["leader2"]) { 

            }
            elseif(
$nm_row["ID_MEMBER"] == $div_row["deputyleader1"]) { 

            }
            elseif(
$nm_row["ID_MEMBER"] == $div_row["deputyleader2"]) { 

            }
            elseif(
$nm_row["ID_MEMBER"] == $div_row["deputyleader3"]) { 

            }
            else { 
                echo 
"<ul type=\"disc\">\n";
                echo 
"  <li><b>Members</b></li>\n";
                echo 
"  <ul type=\"circle\">\n";
                
Members($div_row["id"]);
                echo 
"  </ul>\n";
                echo 
"</ul>\n\n";
            }

            
$sub_query mysql_query("SELECT * FROM divisions WHERE parent=&#39;".$id."&#39;");
            if(
mysql_num_rows($sub_query) > 0) { 
                echo 
"<ul type=\"disc\">\n";
                echo 
"  <li><b>Sub Divisions</b></li>\n";
                echo 
"  <ul type=\"circle\">\n";
                
SubDivs($div_row["id"]);
                echo 
"  </ul>\n";
                echo 
"</ul>\n\n";
            }
        }
    }

    function 
Members($id) { 
        
$mbr_query mysql_query("SELECT * FROM smf_members WHERE divisionID=&#39;".$id."&#39;");
        while(
$mbr_row mysql_fetch_array($mbr_query)) { 
            echo 
"    <li>".GetNameRank($mbr_row["ID_MEMBER"])."</li>\n";
        }
    }

    function 
SubDivs($id) { 
        
$sub_query mysql_query("SELECT * FROM divisions WHERE parent=&#39;".$id."&#39;");
        while(
$sub_row mysql_fetch_array($sub_query)) { 
            if(
$sub_row["leader1"] > 0) { 
                
$ldr GetNameRank($sub_row["leader1"]);
            }
            else { 
                
$ldr "<i>Open</i>";
            }
            echo 
"    <li><a href=\"/divisions.php?id=".$sub_row["id"]."\"><font color=\"".$sub_row["color"]."\">".$sub_row["name"]."</font></a><font color=\"".$sub_row["color"]."\"> - ".$ldr."</font></li>\n";
        }
    }

    
PrintFooter();
    
ob_flush();
?>


divisions/signup.php
Code: [Select]
<?php
    ob_start
();

    if(
$_REQUEST["id"]) { 
        
ShowOpts($_REQUEST["id"]);
    }
    else { 
        
PrintError(&#39;No Division ID Specified&#39;);
    
}

    function 
ShowOpts($id) { 
        
$id_query mysql_query("SELECT * FROM divisions WHERE id=&#39;".$id."&#39;");
        
$id_row mysql_fetch_array($id_query);

        
$u_query mysql_query("SELECT * FROM smf_members WHERE ID_MEMBER=&#39;".<need id bit here>."&#39;");

        if(
$id_row["joinstatus"] == OR $id_row["joinstatus"] == 1) { 
            
PrintError(&#39;This Division is not currently recruiting&#39;);
        
}
        else { 

        }
    }

    
ob_flush();
?>


the divisions script is fine, the SSI.php file is included in global.php, the prob is where the <need id bit here>  i need to split the cookie, get the userid as sommat like $id = $_COOKIE['TEF'] for instance.  Its so that it sees if theyre logged in, and if that division requires an application, it adds the userid and division id to table divwishlist, from there the Division leader can view that wishlist in divisions/wishlist.php and select who they will admit, and who they will reject, etc.

Hope that sheds a little more light on the problem.

Thanks,

TheDoctor
Founder of The Euneos Foundation

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: In a bit of trouble >_< [more]
« Reply #3 on: May 31, 2004, 12:04:00 AM »
SSI.php fills a global variable - namely, $ID_MEMBER.  This is what you want, I expect.

Using the cookie directly is messy imho, because the session could be used for login.

-[Unknown]

Offline Ploy1886

  • Newbie
  • *
  • Posts: 8
  • Gender: Male
Re: In a bit of trouble >_< [more]
« Reply #4 on: May 31, 2004, 12:57:19 AM »
Yup, it works now.

i put global $ID_MEMBER; in ShowOpts() and in the query, and it runs fine :)

Thanks guys, very much appreciated.

Thanks,

TheDoctor
Founder of hxxp:www.euneos.org/ [nonactive]