Jump to content

JonnoTheDev

Staff Alumni
  • Posts

    3,584
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by JonnoTheDev

  1. 1. connect to your server 2. open the file in which the redirect happens 3. browse through the source code and look for any code that you did not write 4. if you find nothing then look in the directory for any unknown files (like .htaccess) 5. repeat steps 2-4 for all files and directories until you find any unknown code/file This isn't the problem. The script causing the redirect is an external file (from another url) as an include. It was included at the top of the page (advertising revenue). Look at my previous post. Just remove any includes to scripts that are not on your domain.
  2. You have external scripts included on this page. Probably a javascript redirect. I would put money on this adserver: http://ads.allvatar.com/adserver/www/delivery/fl.js
  3. You must concatonate using a period $message = "Hello, your reference number is ".$_GET['to'];
  4. Reflection class or simple method: $methods = get_class_methods(get_class($x)); print_r($methods);
  5. $wp_query is an object that is an instance of a class (not assigned). get_queried_object is a method encapsulated within the class i.e <?php class foobar { public function sayHello() { print "Hello from foobar"; } } // usage $x = new foobar(); $x->sayHello(); ?> $x is an object of foobar. The class foobar has 1 internal method: sayHello. Therefore calling this method with the instantiated object is done using the following $x->sayHello();
  6. And is not tightly coupled to a single application making it completely reusable .
  7. supply the full path to the file and make sure that permissions / ownership are avaialble to perform this action. chmod('/path/to/file.php')
  8. It is a call to a class method (usually static) class foo { static function bar() { print "hello world"; } } foo::bar();
  9. no,no,no. what you should be doing is setting a flag in a session when you authenticate the user i.e. login. You should not be setting the username in a session (not needed after login). set another flag to say that the user is logged in. i.e. <?php // login.php if($_POST['action'] == 'login') { if(strlen(trim($_POST['username'])) && strlen(trim($_POST['password']))) { // check user $result = mysql_query("SELECT userId, admin FROM users WHERE username='".mysql_real_escape_string($_POST['username'])."' AND password='".mysql_real_escape_string($_POST['password'])."' LIMIT 1"); if(mysql_num_rows($result)) { // user valid $row = mysql_fetch_assoc($result); $_SESSION['userId'] = $row['userId']; // is this an admin user $_SESSION['admin'] = ($row['admin'] == 1) ? true : false; // redirect header("Location:welcome.php"); exit(); } } } ?> Now on page that needs authentication i.e welcome.php <?php // welcome.php // check user is authenticated if(!is_numeric($_SESSION['userId'])) { header("Location:login.php"); exit(); } // is the user an admin? if($_SESSION['admin']) { print "You are an admin"; } else { print "You are a standard user"; } ?>
  10. Use whatever you want to flag a user as admin. i.e ENUM(0,1) Just use it in your condition when you check a user login from the database.
  11. Set a flag when an admin logs in. On all admin only sections check for the flag // login - check admin user $_SESSION['adminuser'] = ($row->admin == 1) ? true : false; // admin area if($_SESSION['adminuser']) { } Note you must check for admin privileges when a user logs in to set a flag.
  12. The function returns an object. Why store in an array? $xml = simplexml_load_string($response); // debug object /* print "<pre>"; print_r($xml); print "</pre>"; exit(); */ foreach($xml->system as $child) { }
  13. Exit after using header to redirect header("Location:abc.php"); exit();
  14. Sorry but I do not freelance but try posting on the freelance board and someone may help. Need to see more code really to see how the cart is put together.
  15. This is incredibly poor and messy code structure. Functions do not have access to values in the global scope (you have used several global variables in your functions). Variables required by the function should be passed as a parameter. Functions should return values i.e if a condition is not met in the function return false to the global scope. If a condition is met then return true to the global scope. Your functions do not return any value so all code will simply continue to execute. Functions are written so that duplication of code does not occur. i.e multiple pages make use of a function. Your functions are simply wrappers. Learn correct usage of functions: http://uk3.php.net/manual/en/functions.user-defined.php
  16. This file must be producing output prior to session_start(). The function must be called prior to any output. public_html/third side bar.php
  17. That is a quote from your post, not a rewrite! Learn HTML http://www.w3schools.com/TAGS/tag_Select.asp
  18. You are missing valid HTML!
  19. Use multiple file fields.
  20. Read description http://us3.php.net/manual/en/reserved.variables.server.php
  21. <?php $amount = number_format($row->total_with_tax - $row->amount_paid, 2, '.', ''); $link = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&currency_code=USD&business=".urlencode($companyInfo->primary_contact_email)."&amount=".urlencode($amount)."&item_name=".urlencode($row->name." - Invoice ".$row->invoice_number); echo "<p>Pay the balance using PayPal - <a href='".$link."'>Click Here</a></p>"; ?>
  22. Because your cart is being cleared as soon as the switch case is update. $newcart = ''; Looking at this code you would have to rebuild the cart every time an update is made. i.e. All current products must be in the post array. I cannot see how your implementation is working fine as it is fundemetally flawed logic. As I stated when you update a quantity you need to check the current quantity of the product. You must obtain its value from the cart then increase or decreas by the desired quantity, not rebuild the cart from scratch.
  23. Agree, template engines add overhead to an application. However as a previous post mentioned they make it much easier for a designer to work with when your code gets handed over. Code within templates is usually (should be) minimal consisiting of array loops. These areas are best commented for the designers benefit and the tags should be left untouched. When output is embeded in php files I usually end up with many issues when a designer takes over. IMO this is the only benefit of a template engine. They should not be written off alltogether.
  24. \r is a carraige return
  25. You need a more logical approach to your data storage. Products in the cart would be best stored as an associative array with the index being the product id. When you add/modify a product in/to the cart the initial lookup should be against its id. Add to cart 1. Check if product is in cart i. If product is in cart, increase quantity by quantity value + current quantity end 2. Add product to cart // cart array[123] = array('name' => 'red shoes', 'quantity' => 10, 'price' => 9.99); array[127] = array('name' => 'blue jeans', 'quantity' => 1, 'price' => 19.99); I would store a cart object in your session. Use member functions to modify the cart. class cart { private $cartContents; // check if a product is in the cart public function isInCart($productId) { } // add product to cart public function addToCart($productId, $quantity = 1) { } // update product quantity private function updateQty($productId, $quantity) { } // remove from cart public function removeFromCart($productId) { } // get cart total public function cartTotal() { } // empty cart public function emptyCart() { $this->cartContents = array(); } } [code]
×
×
  • 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.