Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. Can you explain the problems you are having? Any errors? How are you testing/running the code?
  2. Try wrapping %s in strong tags instead. $message .= sprintf(__('Your username is <strong>%s</strong>'), $user_login);
  3. No sure try setting the cookie without specifying the domain. setcookie('username', $_POST['username'], time()+60*60, '/');
  4. You can only make them expire by setting their expiration date to a time in the past. Also note when using setcookie() the affects will only take place on the next page request. This is why you should also destroy the associated $_COOKIE superglobal too,e g setcookie("MLcookie_MemberID",$VMemberID,time()-3600); // expire the cookie unset($_COOKIE['MLcookie_MemberID']); // and unset the cookie superglobal too otherwise $_COOKIE['MLcookie_MemberID'] will still be set untl the next page request.
  5. You need to implement sessions. So on every page start the session ( session_start() ) Upon successfull login you set a logged in session token $_SESSION['logged_in'] = true; Now on any page the requires the user to be logged in you check for this token. If it is not set, or is not set to true then you'd redirect the user to the login page. So you'd have code like this for at the top of your restricted pages <?php session_start(); if(!isset($_SESSION['logged_in']) || (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] !== true)) { // redirect user to the login page header('Location: login.php'); exit; } // display restricted content
  6. Also while you are learning please move away from mysql_* library and instead use PDO or the newer mysqli_* library mysql_* library is deprecated and could soon be removed from future version of PHP.
  7. So what is the issue? Any errors? if so post them here. The only problem I see is you are not validating/sanitizing your users input and you left of the closing brace for the if statement } if($result) { echo "User Created Successfully."; } // <-- this is missing
  8. That path is not suitable to be used on a webpage. The path to the image should be relative from your url. ie, mysite.com maps to the document root folder (/var/www/mysite/app/webroot/ is your path document root folder), So to link to an image stored in /var/www/mysite/app/webroot/img/diagrams then $diagramPath should be set to /img/diagrams/. Note the / at the start of a url paths means the root of url (mysite.com). Also can you tell us where this code is being ran from? Is it part of a function? Variables defined in double quoted strings should be expanded and not ignored, except the $1, $2 vars, these will be expanded by preg_replace with the matches returned from your regex patterns. Does the following show the correct value for your replacement? echo $replace["diagram"];
  9. I dont understand what you are tying to do there $data=data2*0.1; //multiply each cell by 0.1 what is data2? I think you meant $data2 (dollar sign missing), in which case $data2 is an array. Doing $data2*0.1 is not possible, you cannot do an arithmetic operation on any array like that. In order to do that you need to loop through the array and apply that operation to each value in that array. The line previous is defining the values for the $data2 array. $data2[$i][$c]=$data1[$c]; So you can do multiply $data1[$c] by 0.1 here. So your for loop will be just for($c=0; $c<$count; $c++) { $data2[$i][$c] = $data1[$c] * 0.1; } $data2 array will now hold values that are 10% greater than those stored in $data1.
  10. You still can, you just need to loop through the data array foreach($data as $row) { foreach($row as $value) { echo $value; } }
  11. My bad. I didn't read your code properly I thought the foreach loop was adding each row to $data. Back to the drawing board... What is the FTP for? If the file is on the same server as the php code then there is no need for that. Try the following $data = array(); if (($handle = fopen("test.csv", "r")) !== FALSE) { while (($row = fgetcsv($handle)) !== FALSE) { $data[] = $row; } fclose($handle); } echo $data[99][4];
  12. Re-read cyberRobots reply (import bits are in bold) Either do as cyberRobot suggested. Or change your code so it outputs a new form for each row. .
  13. Your data is contained in the $data array, So if you want access column 5 and row 100 then you'd use echo $data[99][4]; // value on row 100, column 5
  14. You might want to have read this http://www.phptherightway.com/#data_filtering
  15. Preferably after you run your query You'd know that if you read the documentation for mysqli_error
  16. Your query could possibly encountering an error . Run mysqli_error to see what the error could be
  17. I have downloaded your a.php replaced your fix_files function with the code in my post here (although there was an error due to too many } in my code). Then created a few test files, some with the infected code and some without. I then ran a.php and it removed the malicious code from the infected files. So what is the issue now? I have attached the modified a.php here. a.php
  18. I dont understand? You have files which have code like this as the very first line (shortened for readability) <?php /*versio:3.02*/ $GLOBALS["ktrmpz"]="PaUlQzT...iIpKSk7at"; if (!function_exists('tjjluyoc')){function tjjluyoc($a, $b){$c=$GLOBALS['ktrmpz'];$d=pack('H*','626173653634'.'5f6465636f6465'); return $d(substr($c, $a, $b));};eval(tjjluyoc(561,3272));};?><?php and you want to remove it. My code replaces that code in the first line with a <?php. It is not meant to be used with your existing code! That is why I said to replace your code in the else statement with my code!
  19. if you are setting up the UPDATE link as cyberRobot suggested then you can retrieve the users id using $_GET['vid'] if(isset($_GET['update'])) { $id = intval($_GET['vid']); // get the user id, sanitize it before using it an SQL query $sql="select name, firstname, age from customer where id=$id"; // select name, firstname and age fields, no need to get id field again as we already have it ($id) ... }
  20. There is no need to use date() to reformat the date if your $date_time string is already in the correct format to be handled by your datetime field. The only problem you have is you are not concatenating the $testDate and $testTime variables with a space. $date_time = $testDate . ' ' . $testTime;
  21. You need to replace the code in the else statement with my three lines of code, something like function fix_files( $files ) { global $hack_str; foreach ( $files as $file ) { if ( is_array($file) ) { fix_files($file); } else { $lines = file($file, FILE_IGNORE_NEW_LINES); $lines[0] = "<?php"; // Set the first line to a <?php tag file_put_contents($file, implode(PHP_EOL, $lines)); echo "Removed first line containing <code>" . htmlentities($hack_str) ."</code>from $file...<br />"; } } } }
  22. If it is the very first line of any file you want to replace with just a <?php then use $lines = file('path/to/file.php', FILE_IGNORE_NEW_LINES); // open the file and omit new lines from end of each line, each line will be feed into an array $lines[0] = "<?php"; // Set the very first line to a <?php tag file_put_contents('path/to/file.php', implode(PHP_EOL, $lines)); // implode the array, add in the newlines and write the contents back to the file
  23. Try <table> <tr> <th>Machine Name</th> <th>Type</th> <th>Hour</th> <th>Output</th> <th>Capability</th> </tr> <?php foreach($machinesArray['Machines'] as $machines) { foreach($machines as $machine) { $name = $machine['MachineName']; $type = $machine['Type']; // Loop over the Outputs, grab the array index for each output array. // Use the index later for referecing the Capabilities array // foreach($machine['Outputs']['Output'] as $index => $output) { $hour = $output['Hour']; $outputVal = $output['Widgets']; // get the corresponding capability for current output $capability = $machine['Capabilities']['Capability'][$index]['Widgets']; echo <<<ROW <tr> <td>$name</td> <td>$type</td> <td>$hour</td> <td>$outputVal</td> <td>$capability</td> </tr> ROW; } } } ?> </tr> </table>
  24. Ok, check your browsers console (F12 > Console Tab) for any reported errors.
  25. The JavaScript code for defining cdtd function needs to go outside of the while loop. The only javascript code that should be in the while loop is when calling the cdtd function for creating the counter. <!-- Javascript cdtd function outside of loop --> <script> var cdtd = function(id,end) { var start = new Date(); var timeDiff = end.getTime() - start.getTime(); if(timeDiff <=0 ) { $(window).load(function(){$('#bidbar' + id).remove(); }); return false; } var seconds = Math.floor(timeDiff / 1000); var minutes = Math.floor(seconds / 60); var hours = Math.floor(minutes / 60); var days = Math.floor(hours / 24); hours %= 24; minutes %= 60; seconds %= 60; $( "#counter" + id + " .days").html(days); $( "#counter" + id + " .hours").html(hours); $( "#counter" + id + " .minutes").html( minutes); $( "#counter" + id + " .seconds").html( seconds ); console.log("#counter" + id + " .hoursBox",$("#counter" + id + " .hoursBox").length,id,end,hours,minutes,seconds) var timer = setTimeout(function(){cdtd(id,end)},1000); } </script> <!-- now have the while loop --> <?php $count = 1; // initialise counter while($row=mysql_fetch_array($result)) { $closedate = date_format(date_create($row['closing_date']), 'm/d/Y H:i:s'); $images_field= $row['image']; $image_show= "images/$images_field"; ?> <div id="bidbar<?php echo $count; /* append counter */ ?>"> <div id="lastsold"><strong>Last Sold : ₹ </strong><?php echo $row['lastsold']; ?> </div> <div id="title"><?php echo $row['description']; ?></div> <div id="detail"><img src="image/moredetail.jpg" height="150" alt="more detail" /> </div> <div id="image"><img src="<?php echo $image_show; ?>" width="205" height="150" alt="more detail" /></div> <div id="clock"> <table> <tr> <td style="font-size:18px;text-align:center; padding- left:30px;">Days Hr Min Sec</td> </tr> <tr> <td style="font-size:32px; font:bold; text-align:center;padding-left:30px;"> <div id="counter<?php echo $count; /* append counter */ ?>"> <div class="box days">0</div> <div class="box hours">0</div> <div class="box minutes">0</div> <div class="box seconds">0</div> </div> <script>cdtd(<?php echo $count; /* pass current count */ ?>, new Date("<?php echo $closedate; ?>"));</script> </td> </tr> </table> </div> <div id="mrp"><strong>MRP : ₹</strong><?php echo $row['mrp']; ?></div> <div id="endt"><strong>End Time: ₹</strong><?php echo $row['closing_date']; ?></div> <div id="fee"><strong>Bid Fee : ₹</strong><?php echo $row['bid fee']; ?></div> <div id="current"><strong>Current Winner</br>↓ </strong></div> <div id="buy"> <table width="271" border="0" cellpadding="0.1"> <tr> <td><img src="image/buy.png" alt="buy now" longdesc="http://buy now" /></td> <td width=110><?php echo $row['currentwinner']; ?></td> <td><img src="image/bid.png" alt="bid now" longdesc="http://bidnow " /></td> </tr> </table> </div> </div> <?php $count++; // increment counter; } ?> NB: The code is untested
×
×
  • 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.