Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About mouseywings

  • Rank
  1. Well right now in my method, I'm grabbing ALL results (from a cache) and then paginating those results. If I cache during the pull, wouldn't I have to do like Page 1 cache, Page 2 cache and end up storing like 50 cache results per topic if it were to hit 50 pages? That would be an insane amount of caches per topic when I could just do one. That's why I was trying to keep it that way. I just dislike how I have to flush the entire cache and recache the entire topic posts if just one post was edited or liked.
  2. I'm using Laravel for the get_posts() so I'm not sure if you could follow along. I'm storing all of these in a cache file (.txt), not a session.
  3. Ok so this is how my collection looks when pulling from the database: http://pastebin.com/xrdGr4bU array (size=43) 0 => array (size= 'id' => int 1 'topic_id' => int 1 'user_id' => int 3 'body' => string '<p>Right after this I will change my permissions and see if I can only reply and not create!</p>' (length=96) 'hidden' => int 0 'likes' => int 1 'created_at' => string '2015-04-08 13:00:34' (length=19) 'updated_at' => string '2015-04-19 16:34:06' (length=19) 1 => array (size= 'id' => int 2 'topic_id' => int 1 'user_id' => int 3 'body' => string '<p>Seeing if I can reply!</p>' (length=29) 'hidden' => int 0 'likes' => int 0 'created_at' => string '2015-04-08 14:08:40' (length=19) 'updated_at' => string '2015-04-19 16:34:08' (length=19) 2 => array (size= 'id' => int 3 'topic_id' => int 1 'user_id' => int 3 'body' => string '<p></p> <p>Testing reply as an artist! <br /></p>' (length=53) 'hidden' => int 0 'likes' => int 1 'created_at' => string '2015-04-09 14:06:46' (length=19) 'updated_at' => string '2015-04-19 16:34:13' (length=19) 3 => array (size= 'id' => int 4 'topic_id' => int 1 'user_id' => int 3 'body' => string '<p>Testing a new comment!</p>' (length=29) 'hidden' => int 0 'likes' => int 0 'created_at' => string '2015-04-15 14:53:05' (length=19) 'updated_at' => string '2015-04-15 14:53:05' (length=19) ................. However when it gets to be over 100 items long.. I'm trying to make it so if I make an edit to ID 5, I can JUST make an edit to that one and re-cache it without having to flush all those items out of the cache and then regrab them.. because that will get pretty hectic I think especially if they are edited like every 2 minutes or whatever. Is there a way to make the array INDEX the value of the post ID? Or would I have to loop through them after grabbing them to do so? I just want to be able to make it like: $data = $this->getPosts( $id ); // This will grab that array that you see above $data[$id]->body = $newBody; // And then code to recache the data (overwrite the cache key with the new data) Thanks for any help!
  4. I'm trying to do my research, but I can't see if cURL allows you to access that domain without them changing their headers and accepting our domain to talk to theirs. I didn't know if you knew if you could do it without them having to issue something.. or if there was a nice tutorial on how to go about doing this.
  5. Will CURL allow me to hit their webpage without them having to set out any headers?
  6. Don't you have to add that to the domain you are trying to reach? It's apart of their domain. I would never be able to get them to look into the code or whatever because it's a huge company.
  7. The thing is is that they aren't going to add headers on their side just for our website.. I looked into that, but both parties need to be in communication.
  8. I want to know how to hit a webpage that is not on your domain. I am doing an AJAX request right now, but receiving the following error in my console: The site I'm trying to hit does this weird cookie thing. I already spoke with their web administrator and he said the first time they access that site, it sets the cookie so they have to refresh in order to see if they can bypass a webpage they are trying to access.. I'm not sure if there is anyway to go about doing this since I can't go the AJAX route. But I don't have the capability of refreshing the user once they go on that page since it's not under my server or whatever. The only thing I could think of was AJAX which is not an option now. <?php include('scripts/config.php'); //Declare Variables $filter = new Filter(); $byPasscode = $filter->getBypassCode(); $openDns = "https://bpb.opendns.com/a/" . $_GET['url']; echo 'Redirecting...'; ?> <html> <head></head> <body> <form method="post" name="bypassForm" id="bypassForm" action="<?php echo $openDns ?>" style="display:none"> <input type="text" size="15" name="textBypassCode" id="textBypassCode" autocomplete="off" value="<?php echo $byPasscode; ?>" /> <input type="password" size="15" name="passwordBypassCode" id="passwordBypassCode" style="display:none;" value="<?php echo $byPasscode; ?>" /> <input type="hidden" name="code" id="bypassCode" value="<?php echo $byPasscode; ?>" /> <input type="submit" value="Continue" /> </form> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script type="text/javascript"> //setTimeout(function(){ var textBypassCode = $('#textBypassCode').val(); var passwordBypassCode = $('#passwordBypassCode').val(); var bypassCode = $('#bypassCode').val(); $.ajax({ type: 'POST', url: $('#bypassForm').attr('action'), data: { textBypassCode: textBypassCode, passwordBypassCode: passwordBypassCode, bypassCode: bypassCode } }) .done(function(data) { //$('#bypassForm').submit(); }); //}, 3000); </script> </body> </html> Up above you can see my code. Thanks for any other options that you may think of.
  9. Thanks for your reply! Cleared it up a bit for me =) This is what I had so far in my head for the Item Factory: <?php interface IItemRepo { public function use( $id ); } class ItemFactory { public function make( $id ) { $item = $this->model->getById( $id ); if($item->type == 1) { return new FoodItemRepo( $item ); } } } abstract class ItemRepo implements IItemRepo { protected $type; protected $model; public function __construct(Item $item) { $this->model = $item; } public function setType( IItemRepo $type ) { $this->type = $type; } abstract function use( array $attributes ); public function remove( $id ) { $this->model->whereId( $id )->delete(); } public function removeAll( $id ) { $this->model->whereItemId( $id )->delete(); } } class FoodItemRepo extends ItemRepo { public function __construct(Item $item) { $this->model = $item; $this->setPet( new Pet ); } public function setPet( IPetRepo $pet ) { $this->pet = $pet; } public function use( array $attributes ) { // Raise health $this->pet->raiseHunger( $attributes->pet ); // Remove item from inventory $this->remove( $attributes->item ); } } // www.sitename.com/inventory/item/remove/29 // www.sitename.com/inventory/item/use/29 class Item { public function setItem( $item ) { $this->item = ItemFactory::make( $item ); } public function getUse( $id ) { $this->data['item'] = $this->item->get(); $this->render('content', 'inventory.item.index', $this->data); } public function postUse( $id ) { $this->item->use( Input::all() ); } } Am I going about the Factory::make() the right way? Passing the Item Model to it so it grabs it's type by there?
  10. So I was stumbling around with Repositories and Interfaces and got a decent grasp on it. However, I started running into abstraction and started to implement a little bit of the Factory design. How often is this typically used? It seems like I should be using Factory with 90% of my Repositories since there are different types of Items, Tutorials, Random Events, etc. Items - Food - Weapon - Toy Tutorials - Newbie - Farming Random Events - Coin Giving - Item Giving - Item Draining Things like this... so all of them have similar methods involved. So they each have a base method, for example.. an Item child class would always have the use() method and a factory would determine which kind of object to initiate from your controller just from the item model being passed through. So therefore you can call use() on the repository instance it returns. Then I was moving onto my tutorials and random events and it just seemed very similar. So in most cases, will factories be a huge plus? Just wanted some general opinions from the PHP developers =) Thanks!
  11. I got it working like this: public function findKey( $doc, $key ) { $doc = preg_match("/<body[^>]*>(.*?)<\/body>/is", $doc, $matches); $list = explode('<BR>', $matches[1]); foreach($list as $l) { $pair = explode('=', $l); if(trim($pair[0]) == $key) { return $pair[1]; } } return null; } Thanks
  12. It's not letting me edit my post for some odd reason. But after a little digging around, I got this to display so far: string ' REC INFO[p!]=p EXP DATE[p43]=03-20-15 PCODE1[p44]=1 PCODE2[p45]=u'... $doc = file_get_contents('http://IPADDRESSTOPIN/PATRONAPI/21333008706699/dump'); $doc = trim(str_replace("<BR>", "", $doc)); $doc = preg_match("/<body[^>]*>(.*?)<\/body>/is", $doc, $matches); die(var_dump($matches[1])); I tried exploding that file, but it still did the same thing with mild changes in the results. So far that's what I have. The code is on the bottom of the result. Not sure how to get what I want after that =/
  13. The problem is is that it's taking the break lines into consideration... This is what it returns: die(var_dump($k)) returns this: string '<HTML><BODY> REC INFO[p!]' (length=25) And die(var_dump($v)) returns this: string 'p<BR> EXP DATE[p43]' (length=19) I have no idea what it's even doing. I just have 4 lines. And sometimes it could be more. I just want to get the value of a key. Sometimes I'll get the p45 one, sometimes I'll need the p44. Or whatever other key I'll need in the list. When I put the returned api string in a die() method, it returns this: <body> REC INFO[p!]=p<br> EXP DATE[p43]=03-20-15<br> PCODE1[p44]=1<br> PCODE2[p45]=u<br> </body> That's the HTML at least..
  14. So this is how the data is returned for the API I'm using: REC INFO[p!]=p EXP DATE[p43]=03-20-15 PCODE1[p44]=1 PCODE2[p45]=u So I'm trying to filter on either of the keys like 'PCODE2[p45]' or 'PCODE1[p44]'.. I'm trying to get the value after the equal sign, but still remain on the same line. So if I were searching by the p45 key, I would get 'u'. If I was searching by the p44 key I would get 1.. Is there a simple regex or something that would allow me to achieve these results? Thank you for any help!
  15. I don't want the user to be able to control the shading strengths though..? I was using GD as well, but ImageMagick seems to offer so much more control so I switched over to that. Your screenshot is just a screenshot of phpfreaks..
  • 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.