Jump to content

castis

Members
  • Posts

    23
  • Joined

  • Last visited

Everything posted by castis

  1. I cant really make too much sense of whats going on in there. What did you want to happen? Also, you don't have to specify byref on objects passed as arguments. Objects in PHP are always passed by reference. You've got a lot of stuff commented out... What were you attempting to do?
  2. btherl, you're the man. the code that works is as follows if you have ?apples=oranges at the end of your page, this will filterGet() will return 'oranges' ZEND_FUNCTION(filterGet) { zval **data; HashTable *arr_hash; HashPosition pointer; int array_count; zval *arr = PG(http_globals)[TRACK_VARS_GET]; arr_hash = Z_ARRVAL_P(arr); array_count = zend_hash_num_elements(arr_hash); for( zend_hash_internal_pointer_reset_ex(arr_hash, &pointer); zend_hash_get_current_data_ex(arr_hash, (void**) &data, &pointer) == SUCCESS; zend_hash_move_forward_ex(arr_hash, &pointer)) { if (Z_TYPE_PP(data) == IS_STRING) { PHPWRITE(Z_STRVAL_PP(data), Z_STRLEN_PP(data)); } return; } RETURN_NULL(); return; }
  3. I'm looking for anything documenting such php_strlcat(), PHPWRITE() and such. Im trying to find out what all the supplied functions do but I have yet to find anything. thanks!
  4. use $_POST['a'.$counterx.$counter] you only want to quote the literal string, not the variables
  5. if you're manually refreshing the page (via F5 and/or the refresh button) its going to keep doing that. thats how browsers work.
  6. put unset($_POST) after the point you no longer need the variable. edit: unless you're manually refreshing the page, in which case... thats kinda the way it works...
  7. you can render an iframe if you want the users browser to access the website but cookies arent transferrable across domains.
  8. what are the contents of your index.php file? also, users dont really like the waiting periods. if you use the header relocation, they're automatically sent to where you want them to go. public function verifyuser() { $this->user = mysql_num_rows($this->query); if ($this->user == 1) { $username = $_SESSION['username']; $_SESSION['user_agent'] = 1; header('location:index.php'); } else { display_denied_login(); } }
  9. move the connection piece above where you get your username and password from $_POST edit: when using mysql_real_escape_string, the mysql extension automatically checks for an open connection, since procedural code goes top to bottom, you're trying to use the function and THEN connect. You need to be connected and THEN use the function. elseif(isset($_POST['submit'])) { $connection = new mysql(); $connection->connect('localhost', 'root', ''); $connection->select('cms'); $username = mysql_real_escape_string($_POST['username']); $password = md5($_POST['password']); $query = "SELECT Username, Password FROM admin WHERE Username = '".mysql_real_escape_string($username)."' AND Password = '".md5($password)."'"; $connection->query($query); $connection->verifyuser(); }
  10. if you have them, check your error logs. Im not sure where they're located on a godaddy setup but your error should definitely be in there. the code you posted doesnt seem to have anything that would cause a server error. what about your other two pages?
  11. I'm doing this in c the code I currently am fiddling with is ZEND_FUNCTION(autopage){ long threadCount = 0; int perPage = 0; int currentPage = 0; /* get and assign arguments */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lii", &threadCount, &perPage, &currentPage) == FAILURE){ RETURN_STRING("Bad parameters!", true); } long totalPagesDecimal = threadCount/perPage; double totalPages = ceil(totalPagesDecimal); RETURN_DOUBLE(totalPages); } i want to know how to get $_GET directly from the engine while inside an extension.
  12. you want automated? $page = 'Home'; $menu['Home'] = 'index'; $menu['Login'] = 'login'; $menu['Register'] = 'register'; echo "<ul>\n"; foreach ($menu as $key => $value) { echo ($page == $key) ? "\t".'<li><a href="'. $value .'.php" title="'. $key .'" class="current">'. $key .'</a></li>'."\n" : "\t".'<li><a href="'. $value .'.php" title="'. $key .'">'. $key .'</a></li>'."\n"; } echo "</ul>\n";
  13. I have posted my question in the forum you linked to. Thank you. http://www.phpfreaks.com/forums/index.php/topic,232726.0.html
  14. I have an extension that gives you filterGet(), it's being called via filterGet($_GET, [arg, ...]); and i'd like to eliminate the first argument and grab $_GET straight from the engine. How would I go about doing that? Thanks!
  15. for that specific instance right there, do this. try { @$Connection = new Mysqli( $location, $username, $password, $database); if (mysqli_connect_errno()) { throw new Exception("Could not connect to ". $database); } } catch (Exception $e) { exit($e->GetMessage()); } that should disable anything else from happening if the database connection fails. edit: the error suppression operator is expensive to use but theres no other way around that one.
  16. the way I've done this is to have a variable that is set at the top of every page. a little tedious but works absolute best. Have something like $thisPage = 'login'; or something. then use that in your generated menu and check for the flag in $thisPage to decided whether or not to output something like {class="active"} in your li tag or whatever you're using.
  17. put var_dump($_POST); before your if statement and see if it outputs anything.
  18. make sure that the submit button in your form is as such. <button type="submit" name="submit" value="1">Click Here</button> $_POST['submit'] reads off the name attribute, and will contain "1". As long as your submit button has a name and a value, isset($_POST['submit']); will always work.
  19. i wrote this a while back for encrypting credit card numbers. this does everything you need it to do. <?php /* use as such // this line creates a new class for you. $Enc = new Encryption(); // this line encrypts data $var = $Enc->Encrypt("Hello World!!!"); // this line decrypts it echo $Enc->Decrypt($var); */ class Encryption { private $Iv; /** * __construct() * * Checks for a cookie on the users computer for the iv. * If none exists, create a new one and go with that * * @access public * @param object * @return void */ function __construct() { $this->Configuration = array(); $this->Configuration['Algorithm'] = 'rijndael-256'; $this->Configuration['Cookie'] = 'mcc'; $this->Configuration['Cookie_Timeout'] = 900; $this->Configuration['Key'] = 'çwmƒj0rþb@nk9£¥ph§v€x7qµ¡2'; $this->Configuration['Mode'] = 'cbc'; if (empty($_COOKIE[$this->Configuration['Cookie']])) { // if the cookie for the IV is not present srand(); // make sure the seed is random $this->Iv = mcrypt_create_iv( mcrypt_get_iv_size( $this->Configuration['Algorithm'], $this->Configuration['Mode']), MCRYPT_RAND // this value is a shitty random value if srand isnt run on some machines ); // create an initialization vector setcookie( $this->Configuration['Cookie'], base64_encode($this->Iv), time() + $this->Configuration['Cookie_Timeout'], '/' ); // store the iv on the users computer } else { // if the cookie with the iv is on the users computer $this->Iv = base64_decode($_COOKIE[$this->Configuration['Cookie']]); // fetch the cookie from the users computer and decode it } } /** * Decrypt() * * @access public * @param string * @return mixed */ function Decrypt($data) { return trim(mcrypt_decrypt( $this->Configuration['Algorithm'], $this->Configuration['Key'], base64_decode($data), $this->Configuration['Mode'], $this->Iv )); } /** * Encrypt() * * @access public * @param mixed * @return string */ function Encrypt($data) { return base64_encode( mcrypt_encrypt( $this->Configuration['Algorithm'], $this->Configuration['Key'], $data, $this->Configuration['Mode'], $this->Iv ) ); } } ?>
  20. What I mean by extension is... a php extension...? A bit of compiled code that is loaded in after the Zend engines initialization by means of a .dll or .so file. I'm already pretty handy with both php and c and have an extension that gives you filterGet(), it's being called via filterGet($_GET, [arg, ...]); and i'd like to eliminate the first argument and grab $_GET straight from the engine. thanks!
  21. I've been using PHP for a long time now. And I've decided to get into creating my own extension. I'd like to know if theres a way to get access to PHP internal variables from inside the extension. Id like to be able to use $_GET in a certain extension but I'd rather not pass it in by reference if I don't have to. Anyone have a clue?
  22. This isnt going to be any ecommerce action here. This is just an application for me to keep track of items we have available for my band. As of right now I have two tables: `items` and `variants` `items` consists of: `id`, `name`, and `color. `variants` consists of: `id`, `variant_of`, `size`, `price`, and `in_stock` Then I have this query to get everything out. $query = "SELECT * FROM `items` AS i LEFT JOIN `variants` AS v ON v.variant_of = i.id ORDER BY i.id ASC"; Everything is working according to plan up to this point. And then I realized I have absolutely no idea how to display the information the way I want it. I have one entry in `item` which is: id: 1 name: Unisex Cotton Tee color: black and two entries in `variants` which are: id: 1 variant_of: 1 size: SM price: 10.00 in_stock: 13 and id: 2 variant_of: 1 size: MD price: 10.00 in_stock: 13 Just to give me a place holder. Now I'd like for it to display one item, but have a dropdown form to select the size. And thats where I lost it. Any ideas? EDIT: I thought about putting another loop inside while($row = mysql_fetch_assoc($results)) to go through and add sizes to a class and then when the item id changes, display the item... You think that'll 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.