Jump to content
MakeWebGames

I broked it again


boionfire81

Recommended Posts

Adding this Mod Advanced Property System & I had issues with 2 of the install instructions

First a mysql issue with

 

ALTER TABLE  `properties_mod_user` ADD  `upgrades` VARCHAR( 200 ) NOT NULL COMMENT  '

 

returned invalid syntactic.

My second issue is with this step:

4) Open ‘globals.php’ and find the following snippet of code

$ir=$db->fetch_row($is);

Now, directly under it, add the following;

/* Properties mod - sniko */ include_once('property_mod_globals.php'); if(array_key_exists('hNAME', $ir)) {  $ir['hNAME'] = ($ir['houseid_row'] > 0) ? get_house_name_by_row($ir['houseid_row']) : $ir['hNAME']; }   

 

My code prior

 

global $jobquery, $housequery;
if (isset($jobquery) && $jobquery)
{
   $is =
           $db->query(
                   "SELECT `u`.*, `us`.*, `j`.*, `jr`.*
                    FROM `users` AS `u`
                    INNER JOIN `userstats` AS `us`
                    ON `u`.`userid`=`us`.`userid`
                    LEFT JOIN `jobs` AS `j` ON `j`.`jID` = `u`.`job`
                    LEFT JOIN `jobranks` AS `jr`
                    ON `jr`.`jrID` = `u`.`jobrank`
                    WHERE `u`.`userid` = {$userid}
                    LIMIT 1");
}
else if($housequery)  
{   $is=$db->query(
                 "SELECT u.*,us.*,h.*
                 FROM users u
                 LEFT JOIN userstats us
                 ON u.userid=us.userid
                 LEFT JOIN houses h
                 ON h.hWILL=100
                 WHERE u.userid=$userid");  
}  
else
{
   $is =
           $db->query(
                   "SELECT `u`.*, `us`.*
                    FROM `users` AS `u`
                    INNER JOIN `userstats` AS `us`
                    ON `u`.`userid`=`us`.`userid`
                    WHERE `u`.`userid` = {$userid}
                    LIMIT 1");
}
$ir = $db->fetch_row($is);

if ($ir['force_logout'] != '0')
{
   $db->query(
           "UPDATE `users`
               SET `force_logout` = 0
               WHERE `userid` = {$userid}");
   session_unset();
   session_destroy();
   $login_url = "http://{$domain}/login.php";
   header("Location: {$login_url}");
   exit;
}

 

Error on property_mod_staff.php

 

PHP Warning: array_key_exists() expects parameter 2 to be array, null given (2)

Action taken: Line executed: /home/public_html/property_mod_staff.php:24

Link to comment
Share on other sites

So far my solution is populating the data into the standard users and house tables. I have no clue how to make one form disperse the same info into 2 tables.

So adding houses seems to be fine. But I'm getting an error at editing. I can select the house, but then on loading next step I get

A critical error has occurred, and page execution has stopped. Below are the details:

1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3

Action taken: Attempted to execute query: SELECT `hWILL`, `hPRICE`, `hNAME`

FROM `houses`

WHERE `hID` =

 

Here is the add & edit php code.

 

function addhouse()
{
   global $db, $ir, $c, $h, $userid;
   $price =
           (isset($_POST['price']) && is_numeric($_POST['price']))
                   ? abs(intval($_POST['price'])) : '';
   $will =
           (isset($_POST['will']) && is_numeric($_POST['will']))
                   ? abs(intval($_POST['will'])) : '';
   $name =
           (isset($_POST['name'])
                   && preg_match(
                           "/^[a-z0-9_]+([\\s]{1}[a-z0-9_]|[a-z0-9_])+$/i",
                           $_POST['name']))
                   ? $db->escape(strip_tags(stripslashes($_POST['name'])))
                   : '';
   if ($price && $will && $name)
   {
       staff_csrf_stdverify('staff_addhouse',
               'staff_houses.php?action=addhouse');
       $q =
               $db->query(
                       "SELECT COUNT(`hID`)
                        FROM `houses`
                        WHERE `hWILL` = {$will}");
       if ($db->fetch_single($q) > 0)
       {
           $db->free_result($q);
           echo 'Sorry, you cannot have two houses with the same conscience.<br />
           > <a href="staff_houses.php?action=addhouse">Go Back</a>';
           die($h->endpage());
       }
       $db->free_result($q);
       $db->query(
               "INSERT INTO `houses`
                VALUES(NULL, '$name', '$price', '$will', '$picture', '$description')");
       stafflog_add('Created House ' . $name);
       echo 'House ' . $name
               . ' added to the game.<br />
               > <a href="staff.php">Go Back</a>';
       die($h->endpage());
   }
   else
   {
       $csrf = request_csrf_html('staff_addhouse');
       echo "
       <h3>Add House</h3>
       <hr />
       <form action='staff_houses.php?action=addhouse' method='post'>
           Name: <input type='text' name='name' /><br />
           Price: <input type='text' name='price' /><br />
           Conscience: <input type='text' name='will' /><br />
           Picture: <input type='text' name='picture'><br />
           Description:<br /> <textarea name='description'></textarea> <br />         
           {$csrf}
           <input type='submit' value='Add House' />
       </form>
          ";
   }
}

function edithouse()
{
   global $db, $ir, $c, $h, $userid;
   if (!isset($_POST['step']))
   {
       $_POST['step'] = '0';
   }
   switch ($_POST['step'])
   {
   case "2":
       $price =
               (isset($_POST['price']) && is_numeric($_POST['price']))
                       ? abs(intval($_POST['price'])) : 0;
       $will =
               (isset($_POST['will']) && is_numeric($_POST['will']))
                       ? abs(intval($_POST['will'])) : 0;
       $_POST['id'] =
               (isset($_POST['id']) && is_numeric($_POST['id']))
                       ? abs(intval($_POST['id'])) : 0;
       if (!$price || !$will || !$_POST['id'])
       {
           echo 'Sorry, invalid input.
           <br />> <a href="staff_houses.php?action=edithouse">Go Back</a>';
           die($h->endpage());
       }
       staff_csrf_stdverify('staff_edithouse2',
               'staff_houses.php?action=edithouse');
       $q =
               $db->query(
                       "SELECT `hID`
                        FROM `houses`
                        WHERE `hWILL` = {$will} AND `hID` != {$_POST['id']}");
       if ($db->num_rows($q))
       {
           echo 'Sorry, you cannot have two houses with the same conscience.
           <br />> <a href="staff_houses.php?action=edithouse">Go Back</a>';
           die($h->endpage());
       }
       $q =
               $db->query(
                       'SELECT `hWILL`
                        FROM `houses`
                        WHERE `hID` = ' . $_POST['ID']);
       if ($db->num_rows($q) == 0)
       {
           $db->free_result($q);
           echo 'Invalid house.<br />
           > <a href="staff_houses.php?action=edithouse">Go Back</a>';
           die($h->endpage());
       }
       $oldwill = $db->fetch_single($q);
       $name =
               (isset($_POST['name'])
                       && preg_match(
                               "/^[a-z0-9_]+([\\s]{1}[a-z0-9_]|[a-z0-9_])+$/i",
                               $_POST['name']))
                       ? $db->escape(strip_tags(stripslashes($_POST['name'])))
                       : '';
       if ($oldwill == 100 && $oldwill != $will)
       {
           echo 'Sorry, this house\'s conscience bar cannot be edited.<br />
           > <a href="staff_houses.php?action=edithouse">Go Back</a>';
           die($h->endpage());
       }
       $db->query(
               "UPDATE `houses`
                SET `hWILL` = $will, `hPRICE` = $price, `hNAME` = '$name'
                WHERE `hID` = {$_POST['id']}");
       $db->query(
               "UPDATE `users`
                SET `maxwill` = $will, `will` = LEAST(`will`, $will)
                WHERE `maxwill` = {$old['hWILL']}");
       stafflog_add('Edited house ' . $name);
       echo 'House ' . $name
               . ' was edited successfully.<br />
               > <a href="staff_houses.php?action=edithouse">Go Back</a>';
       die($h->endpage());
       break;
   case "1":
       $_POST['house'] =
               (isset($_POST['house']) && is_numeric($_POST['house']))
                       ? abs(intval($_POST['house'])) : 0;
       staff_csrf_stdverify('staff_edithouse1',
               'staff_houses.php?action=edithouse');
       $q =
               $db->query(
                       "SELECT `hWILL`, `hPRICE`, `hNAME`
                        FROM `houses`
                        WHERE `hID` = {$_POST['id']}");
       if ($db->num_rows($q) == 0)
       {
           $db->free_result($q);
           echo 'Invalid house.<br />
           > <a href="staff_houses.php?action=edithouse">Go Back</a>';
           die($h->endpage());
       }
       $old = $db->fetch_row($q);
       $db->free_result($q);
       $csrf = request_csrf_html('staff_edithouse2');
       echo "
       <h3>Editing a House</h3>
       <hr />
       <form action='staff_houses.php?action=edithouse' method='post'>
           <input type='hidden' name='step' value='2' />
           <input type='hidden' name='id' value='{$_POST['id']}' />
           Name: <input type='text' name='name' value='{$old['hNAME']}' />
           <br />
           Price: <input type='text' name='price' value='{$old['hPRICE']}' />
           <br />
           Conscience: <input type='text' name='will' value='{$old['hWILL']}' />
           <br />
           Picture: <input type='text' name='picture' value='{$old['hWILL']}' />
           <br />
           Description:<br />
           <textarea name='description'>{$old['hWILL']}</textarea>
           <br />
           {$csrf}
           <input type='submit' value='Edit House' />
       </form>
          ";
       break;
   default:
       $csrf = request_csrf_html('staff_edithouse1');
       echo "
       <h3>Editing a House</h3>
       <hr />
       <form action='staff_houses.php?action=edithouse' method='post'>
           <input type='hidden' name='step' value='1' />
           House: " . house_dropdown(NULL, "house")
               . "
           <br />
           {$csrf}
           <input type='submit' value='Edit House' />
       </form>
          ";
       break;
   }
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...