Jump to content

CroNiX

Staff Alumni
  • Posts

    1,469
  • Joined

  • Last visited

  • Days Won

    12

Posts posted by CroNiX

  1. Problem is you are taking those methods from a class, and you don't have a "controller" to execute them.

     

    Try changing:

    curl_post_async("http://127.0.0.1/longone.php", $params); //add .php

     

    and making a longone.php file in your web root that contains ONLY the code from the longone() function definition:

    $one   = $_POST["one"];
    $two   = $_POST["two"];
    $three = $_POST["three"];
    $four  = $_POST["four"];
     
    echo uniqid("You won't see this because your PHP script isn't waiting to read any response");
     
    sleep(5);
     
    $fp = fopen("data.txt", "w");
    fwrite($fp, $one);
    fwrite($fp, $two);
    fwrite($fp, $three);
    fwrite($fp, $four);
    fclose($fp);
  2. It's simply making a custom POST request to the given url, and using the array() (2nd parameter) as the POST data. In essence, making a 2nd request to a different URL and not waiting for a response back before returning control back to your app. Then the url to the script that you called in curl_post_async() gets processed on it's own behind the scenes, as a totally separate web request (because that's what it is)

     

    All of the "we then create a string $out full of what seems to me to be random info required for some reason" you refer to is not random at all. It's a header request. All requests to your server, and the response back, contain them behind the scenes. Like if you click on a link, or request a url. It sends a header to the server, and the server sends back a response.

     

    There's a nice plugin for firefox, called "HTTP Live Headers", which allows you to easily examine all of that raw header/response data flying back and forth between your browser and a server behind the scenes. Other browsers might have a similar plugin but that's what I mainly use. It's quite helpful to learn this stuff and how it works.

  3. Because it's a full fledged working example, with a proof of concept to show you it's working. All you really need is the curl_post_async() function from that code.

     

    Then in your code, you'd just:

    curl_post_async('http://yoursite.com/path/to/pdf/processing/script.php', array(parameters needed by script.php));

    the "parameters needed by script.php" would probably just be your $_POST array.

  4. Not sure why you'd need to do that.

    if (isset($_POST["submit"]))
    {
      //use the asynchronous code I linked to to send data to the script that will create the PDF
    
      //this will immediately show since using the async method doesn't wait for the PDF generating script to be completed
      echo 'Your PDF is being generated and will be emailed to you when completed. Please check your email in about 5 minutes. Note: some PDF's will take longer to generate depending on the requested information.';
    }

    Then the user can continue on with their business, go to a different page, etc.

  5. It sounds like your login system needs to have user roles, like "admin", "user", "nurse", "doctor", etc.  One login system for them all (username/password). Once logged in check their user "role" and redirect them to their "home" page depending on what role they are. You'd also check the roles when doing actions, so a "user" can't access an admin page, or perform admin functions, etc.

  6. I just tested it and this worked fine. You'd just need to define the $source_dir at the top.

    <?php
      $source_dir = '/home/users/images/';
    ?>
    <form action="test.php" method="post">
    <select name="myDirs"> 
      <option value="" selected="selected">Select a genre</option>
      <?php
        foreach(glob($source_dir . "*", GLOB_ONLYDIR) as $val){
          echo '<option value="'.$val.'">'.$val."</option>\n";
        }
      ?>
    </select>
    <input type="submit" name="submit2">
    </form>
    <?php 
    if (isset($_POST['submit2']))
    {
      //get the dir from POST
      $selected_dir = $_POST['myDirs'];
      //now get the files from within the selected dir and echo them to the screen
      foreach(glob($selected_dir . DIRECTORY_SEPARATOR . '*') as $filename)
      {
        echo "$filename<br>";
      }
    }
    ?>
  7. I think first, you really need to document all of your business rules and come up with a plan to implement them. A diagram of all database tables needed, and of how they relate to each other. Each "page" type and what it needs to do, like "monthly calendar view, daily calendar view, sign up for time slot, doctors calendar view, nurses calendar view, admins calendar view",etc. If you just keep adding part by part without looking at the larger picture, you are probably doing yourself a disservice and will have to constantly be rewriting old parts to make new ones fit. And you might spend a lot of time getting things to work a certain way, but then have to totally redo it because you didn't consider "the next piece". You'll waste a lot of time just rewriting older stuff instead of only new stuff.

     

    We don't know your big picture. Only you do. When you ask a specific question, we can give you advice how to solve that specific question with the info given...but it may or may not be totally correct taking into everything you need to do (which we don't know). It might only be good for the generic situation in which it was posed.

  8. AFAIK, if each subdomain sets a cookie for the specific subdomain, like "subdomain.domain.com", instead of ".domain.com", and domain.com only sets cookies for "domain.com" and not ".domain.com", then the cookies would be secure and only accessible by the domain/subdomain that set them. The cookie should also be a "secure" (https) cookie and be set to HttpOnly.

    https://www.owasp.org/index.php/Testing_for_cookies_attributes_%28OTG-SESS-002%29

     

    As far as if the url starts with '/admin', you could use mod_rewrite in apache and detect that, and if it starts with that pass the request to "admin.php" or something.

    Something like:

    RewriteRule ^admin/?(.*)$ admin.php/$1

  9. Do you really need so many levels of subdomains? That's confusing and ugly and provides no real benefit that I can see.

     

    Why not just

     

    www.yoursite.com //main site

    joeq.yoursite.com //Joe Q's main site

    joeq.yoursite.com/admin (Joes admin panel)

     

    Then the cheaper *.yoursite.com can be used

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