Jump to content

Mahngiel

Newly Registered
  • Posts

    1,068
  • Joined

  • Last visited

Posts posted by Mahngiel

  1. take a look at the Media library i have in my signature. it'll make uploading a snap for you.

     

    In regards to showing the last uploaded item:

     

    after you insert into the database, run $this->db->insert_id() to get the table ID number for the image.  you can use that to retrieve the image from the DB whenever you want to call it.

  2. such a strange question.  to me, JS is black. no editor i've ever used (aside from gEdit) has a coloring template for javascript vars/tags/functions.  so black... plain ol' black.  and yes, @kevin, PHP is blue...

  3. With all the users you may have and the various amount of surveys that are possible to exist, it's quite likely your mail server could get tagged as a spammer. 

     

    10 users with 10 different surveys to take = 100 emails.

     

    Something to keep in mind.

  4. I think the gears are turning now.

     

    So it's all about the server request method that a form provices, whereas a URI request will always be a GET request as far as the webserver (not the framework) is concerned.  Hence, the failed server status.  Makes a lot of sense now that you point it out. 

     

    Thanks, Req.  You're always spot on when I need it.

  5. @jazzman1, by "execute the scripts" i'm assuming you're asking if I've ever used what i described?  The answer is of course, else I would not have posted it.  I didn't test the command in PHP, but through CLI. So it might be broken - but the concept remains

     

    BuW7.png

  6. Ok, I accept that.  However, let's venture down this path so I can continue my need-based edumacations.

     

    Since the routing (and general need for this issue) revolves around Laravel and it's routing, I'll be using that code.  I'll also do my best to explain, since I don't expect anybody to research Laravel's docs to follow along.

     

    Goal: Delete a database entry

     

    Here's the route.  the static Route method can be one of the four request methods.  From there, it's the URI path and some other info, such as which controller/method to use. 

    Route::delete('admin/module.uninstall', array( 'uses'=>'modules@uninstall'));

     

    The controller method is named in a matching convention to the request method: public function delete_uninstall()

     

    Now, using a form to submit data to the method works just fine.  Problem is, now i have a form button  :-[

     

    So, instead of having a lame-duck form button (and potentially 30+ of them), i tried to use a regular html link.

    <a href="admin/module.uninstall.module_slug">Uninstall</a>

     

    And the route becomes

    Route::delete('admin/module.uninstall.(:any)', array( 'uses'=>'modules@uninstall'));

     

    Controller

    delete_uninstall( $slug )

     

    This, however, causes Laravel to shit bricks.  Converting the request method to GET for router / method produces desired effect.  But, as I'm learning something new I would like to get as best of an understanding as possible.

     

    So the questions that remain:

    [*] Should I maintain the DELETE routing with a form button because the class method is only used for deleting an entry - this is good semantics

    [*] Is it possible to access this DELETE routing through any other method besides a form post

    [*] Should I instead use a GET and act like it's all good?

  7. Sure, provided you have a *nix based server. shell_exec

     

    for reading websites

    echo shell_exec(curl -s 'http://forums.phpfreaks.com/index.php?topic=364198.0' | grep 'description' | awk -F 'content="' '{print $2}' | awk -F '"' '{print $1}');

     

    for reading files

    echo shell_exec(grep 'description' /path/to/file | awk -F 'content="' '{print $2}' | awk -F '"' '{print $1}');

  8. Must PUT and DELETE be done through a form or is it possible to communicate via other methods? 

     

    I ask because I've just begun playing with a framework that sets routing based on the request method and DELETE doesn't behave like i thought it did.  (passing the information to the method via link) :shrug:

  9. Why rename the image at all? you should instead call the thumbnail directory when you want a thumb vs full size.  It'll also save you from a query call or table overpopulation

     

    assets/

    >images/

    >>thumbs/

    >css/

    >js/

     

    define('IMAGES', '/path/to/assets/images/');
    $image = 'cool_pic.png';
    
    <img src= <?php echo IMAGES . $image;?>  />
    <img src= <?php echo IMAGES . 'thumbs/' . $image;?> />
    

  10. If anyone has any pointers for me on these scenario's, please share them with me as currently it all goes through $o->set($name, $value).

     

    My (limited) experience and reading says that's a much better plan than having individual getters/setters. Specialized setters/getters could always be drafted.

  11. get/set is newer to me as well, but I do believe having public variables is also a concern that they could be overwritten by children causing unwanted consequences down the line.  this is why i believe it's best practice to have each child / caller use gets and sets since it applies to scope only.

  12. I want a speedy ternary operator!  I don't know if any other langs have this, but it would be super cool

     

    $this->object->property['value'] ? $this->object->property['value'] : 'you suck';

     

    becomes

     

    $this->object->property['value'] ? &$$ : 'you suck';

     

    the &$$ (or any other way to reference the preceding value) simply becomes a reference to the value being conditionalized.  For instances where two PHP variables are being compared, the first var is the one who gets perpetuated over.

     

    $somevar === $othervar ? &$$ : 'no match'

     

    equates to

     

    $somevar === $othervar ? $somevar : 'no match'

  13. I am looking to modify functions in wordpress but in a way that protects my modified code from the inevitable upgrades that will be coming along.

     

    I never bothered with WP, but it would seem strange to me that a) you can't just install hooks that modify the core without having to hack the core and b)that you cannot just disable automatic updates - it would seem crazy to me to disallow THAT

×
×
  • 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.