Jump to content

Brian W

Members
  • Posts

    867
  • Joined

  • Last visited

Posts posted by Brian W

  1. wow, I'm not having such a good day I guess. Nothing wants to line up with my brain...

     

    you still have my die statement in there, which should kill the app and output the array $data. There is no suggestion that it has happened in the source code you posted last (the output).

    Try this and post the source code...

    <?php
    error_reporting(E_ALL);
    require_once 'GameQ.php';
    
    // Define your servers,
    // see list.php for all supported games and identifiers.
    $servers = array(
        ' ' => array('bf2', '69.12.98.120', 29900),
    
    );
    
    
    
    // Call the class, and add your servers.
    $gq = new GameQ();
    $gq->addServers($servers);
    
        
    // You can optionally specify some settings
    $gq->setOption('timeout', 200);
    
    
    // You can optionally specify some output filters,
    // these will be applied to the results obtained.
    $gq->setFilter('normalise');
    $gq->setFilter('sortplayers', 'gq_ping');
    
    // Send requests, and parse the data
    $results = $gq->requestData();
    
    // Some functions to print the results
    function print_results($results) {
    
        foreach ($results as $id => $data) {
    
            printf("<h2>%s</h2>\n", $id);
            print_table($data);
        }
    
    }
    
    function print_table($data) {
    
        $gqs = array('gq_online', 'gq_address', 'gq_port', 'gq_prot', 'gq_type');
        
    
        if (!$data['gq_online']) {
            printf("");
            return;
        }
    
           print("<h1>$data[hostname]</h1>\n");
          print("<h1>$data[gamename]</h1>\n");
          print("<h3>$data[gq_mapname]</h3>\n");
          print("<h3>$data[gq_gametype]</h3>\n");
          print("<h3>$data[game_descr]</h3>\n");
          print("<h3>$data[gq_address]</h3>\n");
    
    $map_image= array (
    	'zatar_wetlands' => 'zatar_wetlands.jpg',
    	'Road To Jalalabad' => 'road_to_jalalabad.jpg',
    );      
    // the code i inserted
    if(array_key_exisits($data['gq_mapname'], $map_image))
    {
    	$image = $map_image[$data['gq_mapname']];
    }
    else
    {
    	$image = 'noserver.jpg';
    }
    
    echo "<img src=\"".$image."\" />\n";
    
    // End inserted code
    //die(nl2br("Give us this output:\n".print_r($data, true)));//This is for testing...
    
        foreach ($data as $key => $val) {
    
            if (is_array($val)) continue;
    
            $cls = empty($cls) ? ' class="uneven"' : '';
    
            if (substr($key, 0, 3) == 'gq_') {
                $kcls = (in_array($key, $gqs)) ? 'always' : 'normalise';
                $key = sprintf("<span class=\"key-%s\">%s</span>", $kcls, $key);
            }
    
            printf("", $cls, $key, $val);
        }
    
        print("");
       
        
    }
    
    
    ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
        <head>
            <title>GameQ - Example script</title>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
          <meta http-equiv="refresh" content="9">
            <style type="text/css">
                * {
                    font-size: 9pt;
                    font-family: Verdana, sans-serif;
                }
                h1 {
                    font-size: 9pt;
                }
                h2 {
                   
                    font-size: 10pt;
                }
             h3{
                font-size:12px;
                font-weight:normal;
                margin:0;
             }
                table {
                    border: 1px solid #000;
                    background-color: #DDD;
                    border-spacing:1px 1px;
                }
                table thead {
                    font-weight: bold;
                    background-color: #CCC;
                }
                table tr.uneven td {
                    background-color:#FFF;
                }
                table td {
                    padding: 5px 8px;
                }
                table tbody {
                    background-color: #F9F9F9;
                }
                .note {
                    color: #333;
                    font-style:italic;
                }
                .key-always {
                    color:red;
                    font-weight:bold;
                }
                .key-normalise {
                    color:red;
                }
    </style>
        </head>
        <body>
    
    <?php
        print_results($results);
       
    ?>
        </body>
    </html>
    

  2. Excuse me while I kick myself... this entire time there hasn't been any issue whatsoever besides me overwriting the incorrect file (wrong directory on in the ftp!). What tipped me off was setting error_reporting to E_ALL and not receiving any errors whatsoever.

    Thanks for your help, sorry I inconvenienced you and any one else who looked at this topic.

  3. I don't even see any output of the image tags there... so its not even getting that for or you've changed the code again.

    Repost your exact code if it has changed from the original code you posted at all even including the changes I've mentioned. I'm stumped as to why the image tags wouldn't at least show up.

     

  4. you edited it since your first post...  :-\

    any ways, in my pre-lunch glance, I told you to remove rather than adding the ' before the string...

     

    back from lunch and refreshed!

    try:

     <?php
    error_reporting(E_ALL);
    require_once 'GameQ.php';
    
    // Define your servers,
    // see list.php for all supported games and identifiers.
    $servers = array(
        ' ' => array('bf2', '69.12.98.120', 29900),
    
    );
    
    
    
    // Call the class, and add your servers.
    $gq = new GameQ();
    $gq->addServers($servers);
    
        
    // You can optionally specify some settings
    $gq->setOption('timeout', 200);
    
    
    // You can optionally specify some output filters,
    // these will be applied to the results obtained.
    $gq->setFilter('normalise');
    $gq->setFilter('sortplayers', 'gq_ping');
    
    // Send requests, and parse the data
    $results = $gq->requestData();
    
    // Some functions to print the results
    function print_results($results) {
    
        foreach ($results as $id => $data) {
    
            printf("<h2>%s</h2>\n", $id);
            print_table($data);
        }
    
    }
    
    function print_table($data) {
    
        $gqs = array('gq_online', 'gq_address', 'gq_port', 'gq_prot', 'gq_type');
        
    
        if (!$data['gq_online']) {
            printf("");
            return;
        }
    
           print("<h1>$data[hostname]</h1>");
          print("<h1>$data[gamename]</h1>");
          print("<h3>$data[gq_mapname]</h3>");
          print("<h3>$data[gq_gametype]</h3>");
          print("<h3>$data[game_descr]</h3>");
          print("<h3>$data[gq_address]</h3>");
    
    $map_plaatje = array (
        'zatar_wetlands' => 'zatar_wetlands.jpg',
        'Road To Jalalabad' => 'road_to_jalalabad.jpg',
    );      
    // the code i inserted
    if(array_key_exisits($data['gq_mapname'], $map_image))
    {
        $image = $map_image[$data['gq_mapname']];
    }
    else
    {
        $image = 'noserver.jpg';
    }
    
    echo '<img src="'.$image.'" />';
    
    // End inserted code
    die(nl2br("Give us this output:\n".print_r($data, true)));   
    
        foreach ($data as $key => $val) {
    
            if (is_array($val)) continue;
    
            $cls = empty($cls) ? ' class="uneven"' : '';
    
            if (substr($key, 0, 3) == 'gq_') {
                $kcls = (in_array($key, $gqs)) ? 'always' : 'normalise';
                $key = sprintf("<span class=\"key-%s\">%s</span>", $kcls, $key);
            }
    
            printf("", $cls, $key, $val);
        }
    
        print("");
       
        
    }
    
    
    ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
        <head>
            <title>GameQ - Example script</title>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
          <meta http-equiv="refresh" content="9">
            <style type="text/css">
                * {
                    font-size: 9pt;
                    font-family: Verdana, sans-serif;
                }
                h1 {
                    font-size: 9pt;
                }
                h2 {
                   
                    font-size: 10pt;
                }
             h3{
                font-size:12px;
                font-weight:normal;
                margin:0;
             }
                table {
                    border: 1px solid #000;
                    background-color: #DDD;
                    border-spacing:1px 1px;
                }
                table thead {
                    font-weight: bold;
                    background-color: #CCC;
                }
                table tr.uneven td {
                    background-color:#FFF;
                }
                table td {
                    padding: 5px 8px;
                }
                table tbody {
                    background-color: #F9F9F9;
                }
                .note {
                    color: #333;
                    font-style:italic;
                }
                .key-always {
                    color:red;
                    font-weight:bold;
                }
                .key-normalise {
                    color:red;
                }
    </style>
        </head>
        <body>
    
    <?php
        print_results($results);
       
    ?>
        </body>
    </html>
    

  5. not sure if this is how it is in your actual code or not, but you have an extra ' on this line:

    else

    {

        $image= noimage.jpg';<<<<get rid of the '

    }

    I'd suggest doing a print_r() on the array $data to be sure you know whats in it.... Post the results of the print_r() if your still not getting desired effect.

  6. Who and when do the new "plans" get added?

    You could have your mail script run every time a new plan is added. Lets say that someone adds a plan to category "house with garage"/cat id "5", after the code has executed to add it to the database, you run a query to get the 10 latest plans with cat id = 5 and build the email and use the mail() function to send if out to your subscribers.

  7. that is a quick fix for this issue, but this app is going to get quite deep with several classes referencing eachother repeatedly and hopefully using eachother's methods for "auth checks" and for figuring out what to show the end user.

     

    irreverent data about the app. below (only read if your bored ;-)

    Not that this is a new idea, but the app is a version 3 of a project manager I developed for my employer. Version 1 blew, version 2 works but isn't OOP and is a bit limited in functionality (plus has some bad coding style). User will sign in, setting the $_SESSION['id'], and depending on their permissions will get to view all clients or just the client they are a member of. Under clients is projects, under projects is tasks. Basic management system so far. In v3, I'm adding a PC tracking system for the hardware department to keep tabs on computer's history and whats in em.

    We now have some contract workers that we want to tighten the security on, like not showing them anything that they don't absolutely need to see, which is how I justified a rewrite of the app since previously security (as to who can see what) was never an issue and never requested.

  8. I've googles and also searched the boards here on phpfreaks and have not found any solutions that seem to fit what I'm going for. I'm new to oop, least in the since of starting from scratch (I've worked with some other apps such as pmWiki).

     

    I have 2 classes that I'm working with at the moment; class user and class auth

    class user is supposed to grab the data of the end user for referencing back to later in the application's execution.

    class auth is will reference class user for the user's id to use in verifying the user has permission to whatever they are doing. If they don't have permission, I'll be sending them to a login page or giving them an error... basic user system.

     

    So far, I've gotten as far as getting the very basics of class user working, easy. I want to get the value of $user->id into class auth during the construction of class auth rather than inputting it through some method. Here is what I have

    include.php:

    <?php
    error_reporting(E_ALL);
    if(!isset($_SESSION)){ session_start(); }
    $_SESSION['id'] = 1;//testing
    include('../../Connections/Epm.php');
    //Classes
    include('user.php');
    include('auth.php');
    include('projects.php');
    include('clients.php');
    
    if(true){ // for testing
    $epm->user = new user;
    $epm->auth = new auth;
    
    }
    ?>

    user.php:

    <?php
    if(!isset($_SESSION)){ session_start(); }
    class user {
    function user(){
    	$this->id = $_SESSION['id'];
    	if($this->id <= 0){
    		$this->login();
    	} else {
    		$query = mysql_query("SELECT * FROM bexusers WHERE ID =".$this->id) or die("Error: Could not collect data");
    		$user = mysql_fetch_assoc($query);
    		$this->email = $user['email'];
    		$this->first_name = $user['first_name'];
    		$this->last_name = $user['last_name'];
    		$this->address = trim($user['first_name']." ".$user['last_name']." <".$user['email'].">");
    	}
    }
    function login(){
    	$_SESSION['ref'] = $_SERVER['PHP_SELF'];
    	header('location: login.php'); die("Please Sign In");
    }
    function return_info(){
    	return array("id"=>$this->id, "first_name"=>$this->first_name, "last_name"=>$this->last_name, "email"=>$this->email);
    }
    }
    ?>

    auth.php:

    <?php
    class auth{
    
    function auth(){
    	if($epm->user->id <= 0){
    		die('Error: no user id found'); //will send them to sign in screen later...
    	} 
    }
    function check_project($id){
    	$sql = sprintf("SELECT p.*
    	FROM projects p
    	LEFT JOIN usergroup");//incomplete query!
    
    }
    }
    ?>

     

    the error I get is:

    PHP Notice:  Undefined variable: epm in E:\wwwroot\bexexpress\EPM v3\Classes\auth.php on line 5

    PHP Notice:  Trying to get property of non-object in E:\wwwroot\bexexpress\EPM v3\Classes\auth.php on line 5

    PHP Notice:  Trying to get property of non-object in E:\wwwroot\bexexpress\EPM v3\Classes\auth.php on line 5

     

    I understand why it doesn't work, the variable $epm isn't an object w/in the class auth, but I can't seem to figure out how to get the desired effect.

     

    Thanks for any input, suggestions, slaps to the back of the head ...

  9. I can't seem to figure out why this code won't overlay my watermark.png file over the image.

    $target_path = "images/";
    $name = date("ymd").basename($_FILES['uploadedfile']['name']);
    $target_path = $target_path . $name;
    
    if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    $o['name'] = $target_path;
    list($o['width'], $o['height']) = getimagesize($o['name']);
    if($o['width'] > $o['height']){
    $n['width'] = 400;
    $n['height'] = round(($o['height']/$o['width'])*400);
    } else {
    $n['height'] = 400;
    $n['width'] = round(($o['width']/$o['height'])*400);
    }
    $src = imagecreatefromjpeg($o['name']);//Create Handle
    
    $watermark = imagecreatefrompng('watermark.png');
    
    $tmp=imagecreatetruecolor($n['width'],$n['height']);
    imagecopyresampled($tmp,$src,0,0,0,0,$n['width'],$n['height'],$o['width'],$o['height']);
    imagecopy($tmp, $watermark, 0, 0, 0, 0, 400, 400);
    
    imagejpeg($tmp,$o['name'],100);//Output

    I found one person somewhere that said something about the version of the GD library they got (packaged with RedHat) had a bug in imagecopy(), but I'm thinking I'm just f'ing up.

  10. I'm looking for a application (IIS extension or script preferably) to parse the IIS log files for website stats. I need it to be on a per site basis, other clients shouldn't see other websites.

     

    So, if you have any ideas or links, thanks.

  11. Your switch is on $_GET['view'], correct?

    Here is a slightly modified version

    case "create":
    
    	$id_num = mysql_real_escape_string($_POST['txn_id']);
    	if($id_num > "")
    	{
    		$rs_duplicates = mysql_query("select id from photos where paypal_id='$id_num'") or die("MySql Error:<br>".mysql_error());
    		$duplicates = mysql_num_rows($rs_duplicates);
    
    		if ($duplicates > 0)
    		{
    			header("Location: index.php");
    			exit();
    		}
    	}
    
    	if(is_jpeg($_FILES['photo']['type']['file']) 
    		and is_valid_file_size($_FILES['photo']['size']['file'])
    		and is_uploaded_file($_FILES['photo']['tmp_name']['file'])
    		and is_minimum_width_height($_FILES['photo']['tmp_name']['file'])
    		and is_maximum_width_height($_FILES['photo']['tmp_name']['file'])
    	   )
    	{
    	if(is_fields_filled_out($_POST['photo']))
    		{
    			$_POST['photo']['theme_id'] = $this_weeks_theme['id'];
    			$photo_id = create_photo($_POST['photo']);
    			copy($_FILES['photo']['tmp_name']['file'], './photos/'.$photo_id.'.jpg');
    			$notice = "Successfuly created photo.";
    		}
    		else
    		{
    			$warning = "Click back and fill in all fields.";
    		}
    	}
    	else
    	{
    		$warning = "Click back, error uploading file.
    					Please make sure your file is a jpeg or gif and less than 1MB in size.";
    	}
    break;
    }

  12. if you use the code tags around your php or even html snippets, you will likely get more help

    [ code ]Like this but without the spaces in the tags[ /code ]

    would be

    Like this but without the spaces in the tags

     

    Try:

    <?php
        error_reporting(1); // Only display error messages, not warnings and notices.
       echo "UserID = " . $_REQUEST["CUserID"]; . "<br>";
    ?>

     


    Else, you could do this in java script also like the below:

    <!--if you haven't set the cookie somewhere else, this isn't going to work-->
    <head>
    <script language="javascript" type="text/javascript">
    function checkCookie() {
    if(document.getElementById("userid").value == ""){
    	cookieCASUserIDValue = getCookie("CUserID");
    	if(cookieCASUserIDValue != null){
    		document.getElementById("userid").value = getCookie("CUserID");
    		document.getElementById("aCode").value = getCookie("CUserID");
    		document.getElementById("userid_display").innerHTML = "User Id = " + getCookie("CUserID");
    	}
    }
    }
    function getCookie(c_name)
    {
    if (document.cookie.length>0)
      {
      c_start=document.cookie.indexOf(c_name + "=");
      if (c_start!=-1)
        {
        c_start=c_start + c_name.length+1;
        c_end=document.cookie.indexOf(";",c_start);
        if (c_end==-1) c_end=document.cookie.length;
        return unescape(document.cookie.substring(c_start,c_end));
        }
      }
    return "";
    }
    </script>
    </head>
    
    <body class="gradient" onLoad="checkCookie();">
    <form id="gData" name="gData" method="POST">
    <input type="text" id="userid" name="userid" size=8 >
    <input type="hidden" name="aCode" id="aCode" value="">
    </form>
    <div id="userid_display"></div>
    </body>

     

    In that example, I've cleaned up your code, fixed things A LOT . Good luck and I wish you the best in learning.

  13. Assuming that the URLs have http:// already in them, this will work.

    $query= 'SELECT Venue_Logo, Venue_Name, Venue_Show_Time, Venue_Show_Time, Host, Host_Email, Venue_Address, Venue_City, Venue_Email, Venue_Phone, Venue_Website FROM VenueUploads ORDER BY Venue_Show_Time ASC LIMIT 0, 100';
    
    $result = mysql_query($query) or die(mysql_error());
    
    while($row = mysql_fetch_array($result)) {
    
    if(empty($row['Venue_Logo']) || !file_exists("admin/venue/logos/{$row['Venue_Logoe']}"))
        {
            echo "<img src='admin/venue/logos/noimage.gif'>";  // no image
        }else{
            echo "<img src=' admin/venue/logos/{$row['Venue_Logo']}'>";  // found image
        }
        if (!empty($row['Venue_Name'])) echo $row['Venue_Name']."<br />\n";
        if (!empty($row['Venue_Show_Time'])) echo "Date: ".$row['Venue_Show_Time']."<br />\n";
        if (!empty($row['Host'])) echo "Host: ".$row['Host']."  ";
        if (!empty($row['Host_Email'])) echo "Host Email: <a href=\"mailto:".$row['Host_Email']."\">".$row['Host_Email']."</a> <br />\n";
        if (!empty($row['Venue_Address'])) echo "Address: ".$row['Venue_Address']."<br />\n";
        if (!empty($row['Venue_City'])) echo "City: ".$row['Venue_City']."<br />\n";
        if (!empty($row['Venue_Email'])) echo "Email: ".$row['Venue_Email']."<br />\n";
        if (!empty($row['Venue_Phone'])) echo "Phone: ".$row['Venue_Phone']."<br />\n";
        if (!empty($row['Venue_Website'])) echo "Website: <a href=\"".$row['Venue_Website']."\" target=\"_blank\">".$row['Venue_Website']."</a> <br />\n";
    
    
    echo "<hr>";
    }

  14. your going to need to explain what you need again, more clearly so that we all can understand your goal.

    Some things to include (not that you've missed these) is: What you want the script to do, what does it do now, and ALL applicable code which should also be the code for the submitting form in most cases.

     

    Am I correct that you are attempting to prevent double uploads?

  15. Not sure why is wouldn't save the cookie data, make sure it is even getting into your save statement...

    if (isset($_POST['savedata'])) {
            die('in')
            setcookie("testtext", $_POST['testtext'],time()+60);
           setcookie("textcolour", $_POST['textcolour'],time()+60);
           setcookie("fonttype", $_POST['fonttype'],time()+60);
           setcookie("fontsize", $_POST['fontsize'],time()+60);
        }
    die('not in');

    if when you check the box and submit it returns "not in", you have a problem and we can look further into the conditional statement.

  16. that script looks to be using register_globals wich has been depreciated for security reasons. You need to define $page... add this to the top.

    try:

    <?php
    $server = "localhost";
    $user = "user";
    $pass = "pass";
    $databasename = "table";
    $db = mysql_connect($server, $user, $pass);
    mysql_select_db($databasename,$db);
    
      $sql = "SELECT * FROM annonccom WHERE (titre LIKE '%$search%')";
      $query = mysql_query($sql,$db);
      $total_results = mysql_num_rows($query);
      $limit = "5"; //limit of archived results per page.
      $total_pages = ceil($total_results / $limit); //total number of pages
    if (empty($_GET['page']))
    {
      $page = "1"; //default page if none is selected
    } else {
      $page = $_GET['page'];//$_GET is the array of URL variables which is how the page number is passed. 
    }
    $offset = ($page - 1) * $limit; //starting number for displaying results out of DB
    
    $query = "SELECT * FROM annonccom WHERE (titre LIKE '%$search%') LIMIT $offset, $limit";
    $result = mysql_query($query);
    //This is the start of the normal results...
    
    while ($row = mysql_fetch_array($result))
      {
      
    echo "
    <table style=\"border: 1px solid #000000\" cellpadding=4 cellspacing=0 width=600>
    <tr>
    <td bgcolor=D8D8D8 width=450><b><a href=\"annonce.php?cmd=view&id=$row[id]\">$row[titre]</a></b></td>
    <td bgcolor=D8D8D8 width=150 align=right><div class=red>Prix : $row[prix] $</div></td>
    </tr>
    <tr>
    <td width=450>$row[descrp]</td>
    <td width=150 align=center><a href=\"annonce.php?cmd=view&id=$row[id]\"><IMG alt=\"\" src=\"thumbs.php?src=/uploads/$row[picture]&h=140&w=140&zc=1\" border=0> </a></td>
    </tr>
    </table><br>
    </td>
    <tr>
    </table>
            ";
    
    
      }
      mysql_close();
    
    // This is the Previous/Next Navigation
    echo "<center>";
    echo "Pages:($total_pages)  "; // total pages
    if ($page != 1)
    {
    echo "<a href=$PHP_SELF?page=1><< First</a>   "; // First Page Link
    $prevpage = $page - 1;
    echo " <a href=$PHP_SELF?page=$prevpage><<</a> "; // Previous Page Link
    }
         if ($page == $total_pages) 
       {
             $to = $total_pages;
          } 
      elseif ($page == $total_pages-1) 
       {
             $to = $page+1;
          } 
      elseif ($page == $total_pages-2) 
       {
             $to = $page+2;
          } 
      else 
       {
             $to = $page+3;
          }
         if ($page == 1 || $page == 2 || $page == 3) 
       {
             $from = 1;
          } 
      else 
       {
             $from = $page-3;
          }
       
    for ($i = $from; $i <= $to; $i++)
    
    {
    if ($i == $total_results) $to=$total_results;
    if ($i != $page)
      {
      echo "<a href=$PHP_SELF?showold=yes&page=$i>$i</a>";
      }
    else
      {
      echo "<b><font face=Verdana size=2>[$i]</font></b>";
      }
    if ($i != $total_pages)
      echo " ";
    }
    if ($page != $total_pages)
    {
    $nextpage = $page + 1;
    echo " <a href=$PHP_SELF?page=$nextpage>>></a> "; // Next Page Link
    
    }
    echo "</center>";
    
    ?>
    

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