Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. After you have logged in, the sensitive information is now the session id that you are sending from the client to the server on every http request. If someone 'was' monitoring the data packets (which is why you would be using SSL in the first place), such as over an unencrypted wifi connection, they would have the session id and can visit the site as you and do anything you can do after you have logged in (which is why you typically re-authenticate when doing critical things, such as modifying profile information, making purchases,...). Since they already have access to the same network you are using, they will also have the same IP that you have when they visit the site.
  2. http://dev.mysql.com/doc/refman/5.5/en/example-maximum-column-group-row.html
  3. Php serializes and unserializes the session data automatically when it writes and reads the session data file, you don't have to. To store or reference an object in a session variable, all you need to do is have the class definition before the session_start() statement (so that php can recreate the object properly) and then either directly use a $_SESSION variable to hold the instance of the class (i.e. $_SESSION['an_object'] = new class_name();) or you make an instance in a scaler variable and assign that to a session variable (i.e. $object = new class_name(); $_SESSION['an_object']=$object;). To reference the object, you can either directly use the session variable $_SESSION['an_object']->method(); or $_SESSION['an_object']->property; or you can assign the object back to a scaler variable $object = $_SESSION['an_object']; and reference the methods and properties as $object->method(); or $object->property; The browser's session and the session id cookie you are propagating when using curl to access a page(s) don't have anything to do with each other. There would be no need to do any of the things you suggest. ^^^ Hiding errors messages doesn't fix the problem. The error is still occurring and your code still doesn't work, but you have hidden the message that is telling you what error is preventing your code form working. You need to rework your code taking into account the information I have supplied.
  4. Sample code that would force a single class at a time. Any other tabs or windows open in the same browser will just get the current step, even if the request is link indicating to start a class - <?php // assuming one class at a time // define data structure for demo purposes $classes[1] = array('name'=>'Class 1','steps'=>4); $classes[2] = array('name'=>'Class 2','steps'=>5); $classes[3] = array('name'=>'Class 3','steps'=>3); $classes[4] = array('name'=>'Class 4','steps'=>2); session_start(); // process any 'end class' get request $endclass = isset($_GET['endclass']) ? true : false; if($endclass){ unset($_SESSION['class_id']); // clear class id (no class in progress) header("Location: {$_SERVER['SCRIPT_NAME']}"); // clear get (or post) variables exit; } // if no class in progress or the current one is done, display class menu and process any 'start class' get request if(!isset($_SESSION['class_id']) || (isset($_SESSION['step']) && $_SESSION['step'] == 'done')){ // check if starting a class (can be done using $_POST as well) $startclass = isset($_GET['startclass']) ? intval($_GET['startclass']) : false; if(isset($classes[$startclass])){ $_SESSION['step'] = 1; // start at 1 $_SESSION['class_id'] = $startclass; // remember the class id header("Location: {$_SERVER['SCRIPT_NAME']}"); // clear get (or post) variables exit; } // class menu (can be done using a form and $_POST instead of links) echo "<h4>You may start a class, click on a choice -</h4>"; echo "<ul>"; foreach($classes as $id=>$class){ echo "<li><a href='?startclass=$id'>{$class['name']}</a></li>"; } echo "</ul>"; } // a class is in progress if(isset($_SESSION['class_id'])){ // check if done if($_SESSION['step'] == 'done'){ echo "You have completed: {$classes[$_SESSION['class_id']]['name']}"; } else { // not done echo "Thank you for picking: {$classes[$_SESSION['class_id']]['name']}, you are at step: {$_SESSION['step']} out of {$classes[$_SESSION['class_id']]['steps']}."; // code to detect and operate on each step would go here... // for demo, just a form that submits echo "<form method='post' action=''><input type='submit'></form>"; // when you have successfully completed a step, go onto the next step $_SESSION['step']++; // in real code, this would be inside some logic that tests if the step is successfully completed // detect the end of the current class if($_SESSION['step'] > $classes[$_SESSION['class_id']]['steps']){$_SESSION['step'] = 'done';} // menu echo "<ul>"; echo "<li><a href='?endclass'>Drop this class (your progress in the class will be deleted.)</a></li>"; echo "</ul>"; } }
  5. You are thinking too literally. You just need logic that tests when they can start at step 1. If you want to limit them to one class at a time, you would require that they finish a class in progress (the step number is equal to the end value) before being able to start a different one or you would have a link that would cancel the current class in progress, which would clear the session information and permit them to start a new class. If you wanted to permit concurrent different classes, you would use $_SESSION[some_class_id]['step'], $_SESSION[some_other_class_id]['step'], ... to keep track of what step they are in each class. To prevent them from re-starting the current class, you would check if the class_id already existed in the session array.
  6. Without the code for the whole query statement, it's not possible to tell you exactly why mysql found a syntax error at that point. The only thing I can tell from what you posted is that php couldn't find a valid php variable since it didn't replace it with its value and left the name of the variable in the resulting string.
  7. Example code to accomplish the above suggestion - <?php session_start(); if(isset($_SESSION['step'])){ // you have already started this process echo "You are now at step: {$_SESSION['step']}"; // code to detect and operate on steps 2,3,4,... // successfully completed a step, go onto the next step. $_SESSION['step']++; } else { // this is the first time during the current browser session that you have started step 1 echo "Thank you for starting this process, you are at step 1."; // code for step 1 // successfully complete step 1, go onto the next step $_SESSION['step'] = 2; }
  8. Array variables that are inside of strings need to be surrounded with {} to tell php where they start and where they end (php cannot tell if $some_var['index'] means a scaler variable $some_var with the string ['index'] after it or you you meant an array variable $some_var['index'].)
  9. +1 It sounds like your code is unconditionally clearing/initializing session variable(s) at some point or step in the process and the problem can be fixed by testing if the session variable(s) already exist when someone arrives at the first step in the process and skip over the first step or skip to the correct step they were actually on.
  10. ^^^ Is that information in the error messages accurate? Are there two different paths (sitedir and dploy) , implying two different domain's and are there two different file names? ^^^ Programming and troubleshooting programming is an EXACT science. When you do more than xxxyyy out sensitive information in your posts, you change the meaning of the information. You cannot paraphrase, interpret, or alter the meaning of the information you supply about what you did, what your code is, and what result or error you got (unless you want it to take forever to find what is actually causing the problem.) If you didn't get any errors in the thankyou.php page, that means the $_SESSION variables you are referencing on that page DO exist (or you are doing something on that page that is hiding errors and hiding the expected results.) What exact symptom are you getting on the thankyou.php page that leads you to believe the session variables don't exist or don't have any value? What does adding the following to the thankyou.php page, after the session_start() statement, show - echo "<pre>"; echo "SESSION:"; print_r($_SESSION); echo "</pre>"; If the above doesn't pin down what is occurring in your code, you will need to post ALL the code that makes up your index.php and thankyou.php pages (less things like database credentials, payment gateway credentials, actual domain names, but if you have more than one domain involved, indicate where they are being used - xxxxxxx for one, yyyyyy for another) that would be needed to reproduce the problem.
  11. Well the host-name and paths are the same before/after, so that is not the problem. I'll assume that you modified the index.php file and re-uploaded it to the server, in going from the working version (processing the form on your site) to the non-working version. Add the following two lines of code, immediately after your first opening <?php tag and before the session_start() statement in your index.php file, and post any errors you get when you visit the index.php page (xxxyyy out any portion of the errors you don't want to post) - ini_set("display_errors", "1"); error_reporting(-1); Do the same if you modified the thankyou.php page.
  12. The redirect back to your site is probably changing the host-name/sub-domain (a www vs no www.) or the path after the domain AND your session id cookie is not setup to match all variations of host-name/sub-domain or paths for your site. What's the complete starting URL on your site (xxxxx out the domain name part if you don't want to post it, but keep everything else as is) and what is the complete URL the redirect goes back to?
  13. Yes, you either have a problem in your query or in your php code. What does your error checking and error reporting logic you (should already) have in your code say as to why and where the query failed? In any case we cannot possibly help you without seeing your code from where the actual query is being formed up through the point where the mysql_fetch_assoc error is occurring at and if there's a loop involved, you need to post all the code inside the loop too since it could be overwriting the result resource.
  14. That's not an answer to the question that was asked. The reason we ask specific questions is because we are not standing right next to you and don't know how you got to this point or what you observed in front of you. When you don't supply the information that is asked for, there's little chance of anyone helping you.
  15. Concerning converting your code - 1) The specific sqlsrv_ functions that you still have in your main code should be replaced will calls to class methods that perform the same function. This will allow you to more simply convert your code by replacing your existing class with the one you write that uses ODBC functions. 2) I would also rename all the $mssql references to just $db to make the code generic. 3) You need to eliminate the use of the GLOBAL keyword in your class and instead define a constructor and pass the server specific "\SQLEXPRESS" value into the class as a call time parameter when you create an instance of your class - i.e. $db = new sqlsrv_db_class("\SQLEXPRESS"); I also have a number of comments about your actual code that have nothing to do with converting it. Most of these 'fixes' will improve the performance of your code, make your code easier to read, write, modify, and maintain, reduce the amount of code you have, and in one case make your code work the way you think - 1) You should not close and open a database connection just to change databases. It takes a significant amount of time to open a connection. You should instead issue a "USE dbname" query. 2) You should have all the related tables that make up your application in ONE database. This would eliminate the need to keep switching between database and keep track of the which database you are currently using. 3) You should store the user's 'JID' in a session variable when he logs in so that you don't need to specifically query for it every time a page gets requested. 4) The SELECT queries in your code expect to match only one row. There's no point in using a where(){} loop to retrieve that one row of data. Just fetch the row. 5) Your form should list the available character names either using a select menu or radio buttons so that all you need to do is pick the character you want. Your form should also submit the CharID of the character, not the character name. Passing less data around and using an integer, that would also be an index in your tables, will make your queries execute faster. 6) The following code only has one = sign and does not work like you expect (it is always true) - if ($_User_Row = 1) {. You need two == signs to test if $_User_Row == 1. 7) Assuming that your form submits the CharID instead of the CharName, the query to get the character data in _Char should be inside the logic that has tested if the user actually has the character. This query is also referencing some column values that are not used in the posted code. Excess lines of code should be removed or commented out so as to avoid confusion later when you or someone else tries to read your code. You should consistently use the CharID through out the code and queries. You need to make your application "data driven". What this means is you define a data structure (array, query from a database table) that determines what your code does and you write general purpose code. Your blocks of repetitive code that has 'Strength' and 'Intellect' values hard-coded into them, should be replaced with one set of that code that uses a data structure to define what values get used. 9) If a multi-value INSERT query is available, you should use that instead of your list of 13 separate insert queries. The data for those insert queries should also be defined in a data structure (see item #8 above.) 10) Your database class is including a config file that it does not use and is assigning to $this->mssql_server where there is no class property with that name. 11) You also have no validation of external data and little or no logic in your code to test for errors or to test if a query matched any row(s). The following incomplete and untested code SHOWS many of the things I suggested in the list above - <?php $db = new sqlsrv_db_class("\SQLEXPRESS"); if (isset($_POST['submitchange'])) { $user = $_SESSION['username']; $JID = $_SESSION['JID']; $CharID = $_POST['CharID']; // assumes your form actually submits the CharID from a select menu or radio buttons $db->dbQuery("USE {$conf->shardDbName}"); // select the correct database. If you only have one database, no need to do this at all. // test if this user has the requested character $_User = $db->dbQuery("SELECT COUNT(*) FROM _User WHERE UserJID = '$JID' and CharID = '$CharID'"); if( sqlsrv_fetch( $_User ) === false) { die( print_r( sqlsrv_errors(), true)); } $_User_Row = sqlsrv_get_field( $_User, 0); // get the query count value if ($_User_Row == 1) { // note: == equal signs for a comparison // get the character information $_Char = $db->dbQuery("select * FROM _Char where CharID = '$CharID'"); $row = sqlsrv_fetch_array($_Char, SQLSRV_FETCH_ASSOC); $Reborns = $row['Reborns']; // used $CurLevel = $row['CurLevel']; // used // define values to use when a character is reborn, the index 0...6 is the current $Reborns value // you would normally define this data in an included configuration file (or get it from a database table) $reborn[0] = array('Strength' => 30, 'Intellect' => 30); $reborn[1] = array('Strength' => 40, 'Intellect' => 40); $reborn[2] = array('Strength' => 50, 'Intellect' => 50); $reborn[3] = array('Strength' => 60, 'Intellect' => 60); $reborn[4] = array('Strength' => 70, 'Intellect' => 70); $reborn[5] = array('Strength' => 80, 'Intellect' => 80); $reborn[6] = array('Strength' => 90, 'Intellect' => 90); // test if the current level should cause character to be reborn if(isset($reborn[$Reborns]) && $CurLevel == 120) { // update the _Char to the next level $db->dbQuery("UPDATE _Char set CurLevel = 1, MaxLevel = 1, Strength = {$reborn[$Reborns]['Strength']}, Intellect = {$reborn[$Reborns]['Intellect']}, RemainSkillPoint = 0, ExpOffset = 0, RemainStatPoint = 0, Reborns = Reborns + 1 WHERE CharID = '$CharID'"); // delete existing _CharSkill data and populate with starting values $db->dbQuery("DELETE FROM _CharSkill WHERE CharID = '$CharID'"); // you should actually have an array that defines the data to use in the following // and then either make one multi-value insert query or if that is not available, // use a loop to loop over the array of data $db->dbQuery("INSERT INTO _CharSkill (CharID, SkillID, Enable) VALUES ('$CharID', 1, 1)"); $db->dbQuery("INSERT INTO _CharSkill (CharID, SkillID, Enable) VALUES ('$CharID', 2, 1)"); $db->dbQuery("INSERT INTO _CharSkill (CharID, SkillID, Enable) VALUES ('$CharID', 40, 1)"); $db->dbQuery("INSERT INTO _CharSkill (CharID, SkillID, Enable) VALUES ('$CharID', 70, 1)"); $db->dbQuery("INSERT INTO _CharSkill (CharID, SkillID, Enable) VALUES ('$CharID', 8419, 1)"); $db->dbQuery("INSERT INTO _CharSkill (CharID, SkillID, Enable) VALUES ('$CharID', 8420, 1)"); $db->dbQuery("INSERT INTO _CharSkill (CharID, SkillID, Enable) VALUES ('$CharID', 8421, 1)"); $db->dbQuery("INSERT INTO _CharSkill (CharID, SkillID, Enable) VALUES ('$CharID', 9354, 1)"); $db->dbQuery("INSERT INTO _CharSkill (CharID, SkillID, Enable) VALUES ('$CharID', 9355, 1)"); $db->dbQuery("INSERT INTO _CharSkill (CharID, SkillID, Enable) VALUES ('$CharID', 9944, 1)"); $db->dbQuery("INSERT INTO _CharSkill (CharID, SkillID, Enable) VALUES ('$CharID', 10625, 1)"); $db->dbQuery("INSERT INTO _CharSkill (CharID, SkillID, Enable) VALUES ('$CharID', 11162, 1)"); $db->dbQuery("INSERT INTO _CharSkill (CharID, SkillID, Enable) VALUES ('$CharID', 11526, 1)"); $db->dbQuery("UPDATE _CharSkillmMstery set Level = 0 WHERE CharID = '$CharID'"); } elseif($Reborns == 7) { echo "Du hast bereits 7 Reborns ! "; } if ( $CurLevel !== 120) { echo 'Du bist nicht level 120 ! '; } }else{ echo "Das ist nicht dein Character!"; } } else { echo '<div class="page-body newsblock">'; echo '<div class="news-title">'; echo 'Reborn ur Char:'; echo '</div>'; echo '<div class="news-content">'; echo '<form method="post">'; echo 'Charactername:<br />'; // you should output a select menu or radio buttons that let the user select which character he wants echo '<input onfocus="clearText(this);" style="background: rgba(0,0,0,0.5);width:220px;border-radius: 6px 6px 6px 6px;" type="text" maxlength="16" name="charname" value="charactername" /><br />'; echo '<br />'; echo '<input style="height:32px;vertical-align:middle;" class="button" type="submit" value="Submit" name="submitchange" />'; echo '</form>'; echo '</div>'; echo '</div>'; } ?>
  16. What exactly is the relationship between the correct logged in user and this other user you get switched to when you go to a specific page? Is this other user one that you have previously logged in as or is it something like the first or last user stored in your database table?
  17. I'm not exactly sure what you mean in reply #7, but if it seems like you have more than set of session values and navigating between different pages, perhaps some with and some without the www. on the URL or with different paths, switches back and forth between logged in users, check what a phpinfo statement shows for the session.cookie_path and session.cookie_domain settings on both systems.
  18. The error will be emitted if the magic_quotes_gpc setting is ON for any reason. Sadly, the default is on for a lot of the php versions, when there is nothing specifically setting it to an off value. Start my checking which php.ini is being used. It is the Loaded Configuration File value in the phpinfo output. You should set magic_quotes_gpc to off magic_quotes_gpc = Off and then restart your web server to get any changes made to the php.ini to take effect. Next, make sure there are no local php.ini files (when php is running as a cgi application) or .htaccess files (when php is running as an Apache server module) that is setting it to an on value. Did your phpinfo output for the magic_quotes_gpc setting show both a master and local value? What exactly did they show? A syntax error in the setting will display what the setting is, but the setting doesn't actually take effect. If all else fails, you can factor out the depreciated error setting from the error_reporting setting.
  19. Relying on htmlspecialchars to prevent sql injection won't stop actual hackers, because they can inject sql that contains no quotes and they can use quotes that have meaning to the character set your database is using for which htmlspecialchars could care less about. As already stated, you must filter/validate/cast/escape data as appropriate for the type of data it is.
  20. <?php $num_col = 3; $col = 0; echo '<div class="resultados_sub_cat">'; echo "<table>"; foreach($this->subcats as $key => $subcat) { // start a new row if($col == 0){ echo "<tr>"; } $subcat->link = JRoute::_('index.php?option=classcliff&view=list&catid='.$subcat->id."&Itemid=".$this->Itemid); //if ($key != 0) //echo ' - '; echo '<td><a href="'.$subcat->link.'">'.$subcat->name.'</a></td>'; $col++; // count the column you just output if($col >= $num_col){ echo "</tr>\n"; // end the row $col = 0; // reset counter } } // finish any partial last row if($col !== 0){ while($col < $num_col){ echo "<td> </td>"; $col++; } echo "</tr>"; } echo "</table>"; ?>
  21. Posting your current code would help. Edit: BTW - you need logic after the end of your loop that completes any partial last row.
  22. You do realize that the sobi2Id value from the URL will be available as $_GET['sobi2Id'] ? What exactly are you trying to accomplish and what is the actual data you are trying to do it for?
  23. You forgot to tell us exactly what it is about that URL that caused a problem. Is it the fact that there is an &cat value present at all or is the &cat=0 supposed to be present and the problem is that there is an ' OR download_parent = '1 following the expected zero value? htmlspecialchars doesn't remove anything. It only converts '&', '"' (double quote), "'" (single quote), '<', and '>' to their html entity. Double and single quotes are only converted when you specify the correct second parameter values when you call htmlspecialchars. I'm guessing you aren't using any of the second parameter values. If your cat= value is expected to be a number, you need validate or cast it as a number because it is possible to inject sql that contains no quotes as part of it and escaping it doesn't do anything because there's nothing to escape and if you happen to be treating it as a string in the query (it is being put between single-quotes in the query statement), you need to use the mysqll_real_escape_string function on it. All external data cannot be trusted, can be anything, and must be filtered/validated/cast/escaped as needed, depending on how you are using that data. The above is based on your description. To get the best help, post the relevant code so that any other problems with it can be found.
  24. What's $GLOBALS['DEBUG_MODE'] set to?
  25. You are going to need to troubleshoot exactly at what point the code and data are doing what you expect and at what point they are not in order to pin down what is causing the problem. In any case, we cannot help you without seeing the code needed to reproduce the problem (less any database credentials) and a description or picture of the error or symptom you are getting that makes you believe that the code does not work.
×
×
  • 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.