Jump to content

sen5241b

Members
  • Posts

    19
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by sen5241b

  1.  I have questions but I also have some good info to share about putting your software in the cloud.  

    The situation:

    Some of you may have read about the nightmare stories. A developer had a infinite loop in his code that ran all night. This code did things inefficiently that devoured CPU in each iteration. This developer, greatly skilled,  opened his email the next morning and saw a email bill from his cloud provider totaling for $75K. True story. 

    Most cloud providers let you define CPU usage thresholds that, when breached, send you a warning but these thresholds, if I understand them, are per account. 

    It would seem the claim that cloud resources are available in whatever amounts you need, CPU, disk space, enough RAM to never have to wait on a page faults, etc... the claim that the cloud provides you with infinitely elastic  resources in an "all you can eat for one price" contract smells just a like a little like 💩

    I did cloud development for many years with ServiceNow starting when it was a help desk and I watched it evolve into one of the best cloud development platforms out there. At one customer site I installed and managed it it out of the cloud and saw its insides and I can tell you its core code is not so terribly efficient. IMHO the cloud DOES take away 90% of a developer's worries about app performance..

    If you call ServiceNow tech support and your problem is diagnosed as a performance issue with your code the first thing they will ask you is "did you follow the developer best practices"? They will politely say "sorry. Here's a link to them implying "fix your code". 

    Questions: 

    PHP Functions that devour CPU and where there is a better way?

    What PHP functions or code techniques waste CPU? I am using similar_text and it does the job but it is slow. Better way?

    What is the best way to measure CPU used by a PHP script or by a particular code module, defined as a set of related functions that fulfill a common purpose or by a single line of code? The purpose being to identify inefficient modules of code and improve them and even if the code is damn near perfect then at least can know what code modules are the most expensive.

    CPU killin users (and developers too), how can they be identified?

    I need to store data on cumulative CPU usage for any of the above and compare it with the free amount they give you and warn CPU hogs before they breach a threshold and generate $75K bills that were not in the plan.

    Any info you have on avoiding surprise $75K CPU bills from a cloud provider are welcome

     

     

     

     

    It would seem the 

  2. I am trying to develop a UI using PHP., html,  css and javascript.  I have an app with a lot of HTML tables. I'd like to be able to reduce the size of the HTML tables and have one table come into focus at larger size when selected the same way windows task view works. Have you seen a web UI like this? Is there a template for it?

  3.  

    I have come to the conclusion that nothing works perfectly to do this. This surprises me. How many servers and for how many years has this problem been around? 

    OPTIONS

    PHP provides filters. The filters are pretty generic.

    Strip tag seems useless. One greater than symbol in the input and most of the good data is stripped out

    Clean-html seems better than the rest but I'll be damned if I can get it to work on  my system

    https://github.com/dave-kennedy/clean-html

     

    • Like 1
  4. I have never coded on a WAMP. I experimented with them over 10 years ago and was not impressed. It appears WAMPs have improved much since then. I don't know much about XAMPPs. Three questions:

    What is your preference and why?

    What are the pros and cons of each? 

    How portable is code back and forth between the various -AMPs?

  5. Yep. I use foreaches all the time. I enhanced your code a bit.  Foreach prints the key value  and but not the key name.

    <?php
    $myArray = array();
    $myArray[0] = 'fred';
    $myArray[1] = 'Joe';
    
    foreach ($myArray as $key => $value):
      echo '<br> '  . $myArray[$key];
    endforeach;
    
    $myArray = array();
    $myArray[0]['Name'] = 'fred';
    $myArray[0]['Age'] = 55;
    $myArray[1]['Name'] = 'Joe';
    $myArray[1]['Age']= 765;
    print_r($myArray);
    foreach ($myArray as $key => $value):
      echo '<br> ';
      echo '<br> '  . $myArray[1]['Age'];
    endforeach;
    ?> 

     

  6. More detail and context as requested:

    I use the following lines of code a lot because I use deal with a lot of multi-dimensional associative arrays:

    $headerNames = implode('‖', array_keys(current($AnyArray)));
    $ColumnNameLookup = explode('‖', $headerNames);  

    $ColumnNameLookup is a lil array to lookup column names in an associative array. I call them 'column names' but in  proper PHP terminology they're called "key names".  As you can see its fairly easy to extract the key names  and put them in a little array. Those two lines of code has made it easy to write some data manipulation functions that can perform all sorts of operations on a specific column name in any generic array I pass to it. E.g.  such as concatenate a string to a string already in the array or highlight a string within a string:

    HighlightColumnsWithBadData($AnyArray, $ColumnName)

    My current problem:  I have a  func that validates a long list of data elements in a multi-dimensional associative array.  If a particular element, like  'Age' in $MyArray[$i]['Age'] has bad data, then I need to pass the key name 'Age' to a func that reports the data problem. That is why I need the  'Age' in $MyArray[$i]['Age'] or the 'Name' in  $MyArray[$i]['Name'].

    Why not:

    if ($MyArray[$i]['Age'] >  700) then pass 'Age' to reporting func? 

    Key names for the numerous arrays I deal with are not hard coded anywhere in the generic data manipulation funcs and that makes these funcs immune to key renames and flexible enough  to process any array.

     

     

     

  7. I have been protecting directories with .htaccess files for a while now. However, as you get a lot of users that need to authenticate to a directory you can start to have performance issues on the server. I then started to stream all content through PHP to the user, but if you have large files, and lots of hits to the server, you will also begin to experience performance issues. Not to mention you have issues with some web hosts not giving you control over the execution time limits of a PHP script, which will halt all php initiated streams.

     

    I got to thinking. Instead of authenticating each user through a .htaccess file I could have a .htaccess file that would only allow one user to authenticate to the directory and all files inside from outside the server. This one user would be operated by the PHP script. The user visiting the site would have no idea of this authentication mechanism. Essentially if they wanted to download a file from directory x, the only way they would be able to do so would be through the php script. If they visited the directory directly without being passed through the PHP script, they would be denied access. This would allow normal PHP authentication and access mechanisms for protected directory and file access.

     

    I have seen various sites employ a theory like this, at least that is how I perceive it. I, the visiting user, would not have to log in to access the sites download section. However if I navigate to the web directory without the aid of the sites PHP scripts, I get an access denied message. My problem is, I don't know quite how to make this happen. I am not sure how to give PHP the ability to authenticate the users browser session with a set of user credentials unknown to the visiting user so that they can have access to the protected directory or file. Does anyone know how to point me in the right direction to make this happen?

     

    Thanks in advance.

     

    This is very similar to my recent post entitled: "When .htaccess can't protect a file". I' convinced apache or Unix/Linux security is the best way to protect files from direct access.

  8. And you have a question? You can quite easily write a php script which acts as an image. Serving up whatever images are passed to it via $_GET[].

     

    I was hoping someone would prove me wrong but your workaround might do the job. Do you have an example?

     

    I'm actually trying to protect a data file from direct access. This is similar to but not exactly the same as the bandwidth-image stealing issue.

  9. Based on everything I've read and tried you can't do it. You can deny a directory listing, you can completely deny access to the files in a directory based on many things like IP, user etc. and you can allow access too.

     

    ... but you cannot both allow a web visitor to access an image or data file through html and php and simultaneously deny them direct access to that same file through a browser. For individual files, .htaccess allows access or it doesn't. Web visitors can do a "view source" to see the image or data file and then just type the URL to it.

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