Posts Tagged ‘PHP’

Knowledge Nuggets

Friday, January 20th, 2012 by Christian Mattix

Anyone who has done development, design, or IT knows that over the course of working on a project, you collect various “nuggets” of knowledge that you ever learn or find. Here I’m going to share some of what I’ve discovered that may be able to help you in your own projects. I have cited the original source of the information if I have that available. If there is something that I’ve left out, feel free to add it in the comments.

“Fatal error: Out of memory…” occurring when PHP and Apache memory limits seem fine

This problem drove me crazy for a little while. I did everything that I thought I needed to do, I changed the php.ini file to increase the php memory available until I ran across this link which provided the answer. We are using WiredTree as our hosting provider, for their servers, the problem was fixed by simply adding: RLimitMem 128000000 to the .htaccess file in the www root directory. After doing this, it fixed everything.

I keep getting Notice: Undefined offset: 1 in views_block_view() in Drupal 7

After doing a bunch of operations during prototyping a Drupal 7 site we kept this error. There wasn’t anything that we seemed to be able to do to eliminate it from the Drupal administrative interface. After searching the web for quite some time I came across this page: http://objitsu.com/node/29 which gave me all of the information I need. From the article:

It’s caused by stale records in the block table that then fail to resolve. There’s plenty of reading material out there and suggested fixes etc. that I am sure work but once I knew what the problem was I applied *my process* for all Drupal problems like this.

  1. Find the code that issues the message..
  2. Trap the code and drupal_set_message() the offending item
  3. Use that information to fix-up the database / code as required.

Here’s how the fix works for this particular problem. In my case I edited views.module, line 569, here’s the code that was causing the notice to be show:

list($name, $display_id) = explode('-', $delta);

and here is what I added to the code to find out what the duff delta in question was…

if (count(explode('-',$delta)) == 1) {
  drupal_set_message($delta);
}
list($name, $display_id) = explode('-', $delta);

All I did then was refresh the page, take a note of hash value that was displayed and then cutting-and-pasting it into a command line MySQL session I issued this query:

mysql> DELETE FROM block WHERE delta = 'd98a0bfa5a33e7d8bab0fc0670bdc9fd';
Query OK, 4 ROWS affected (0.01 sec)

Which took out all four problem pages at once.

What are the command line commands for git?

We use git for source control of our iOS projects. I found a great cheat sheet of git commands here:
Git Cheat Sheet.

Hide IIS7 Response Headers

Thursday, September 16th, 2010 by Force 5

What are Response Headers?

Response headers is data that gets sent from the server to the browser. The data can include date & time, content type (ex: text/html, text/javascript), and server information (ex: Microsoft-IIS/7.0).

Why is it important to hide them?

Security. At the most basic level it will not broadcast what operating system the web server is and which version it is whether it is a Microsoft IIS web server or an Apache PHP web server.

Here is an example of what information is passed back to the browser:

Notes: This was complete on a Windows 2008 web server with IIS 7. One prerequisite we noticed is that you may need to install the IIS 6 Metabase Compatibility tool.

Steps to hide Response Headers in IIS:

  1. Download & Install UrlScan
  2. Configure UrlScan.ini settings
    • Open UrlScan.ini with Notepad (run as administrator).
      • C:\%OS-Directory%\System32\inetsrv\urlscan\UrlScan.ini
    • Change RemoveServerHeader value
      • RemoveServerHeader=1
  3. Editing Machine.Config settings file
    • This next edit you will need to make on each ASP.NET Framework version that you currently run. For example, Force 5 has applications that run ASP.NET version 2.0 & 4.0.
    • You will need to add this configuration setting to each Machine.Config file inside the <system.web> section.
      <system.web>
           <httpRuntime enableVersionHeader="false" />
            .....
      </system.web>

    • An important note, if you do not access to the Machine.Config files you can make this same change to your Web.Config file inside your individual website. The only difference is that you will need to include this setting in each website. Whereas the Machine.Config file will make this change global across the web server.
    • You can find your .NET Framework versions and Machine.Config files in either of these two directories:
      • C:\%OS-Directory%\Microsoft.NET\Framework
      • C:\%OS-Directory%\Microsoft.NET\Framework64
  4. Editing php.ini configuration settings (skip this step if you do not have PHP installed)
    1. Locate and open up your php.ini file
    2. Scroll down until you locate “expose_php
    3. Set expose_php = Off
  5. Restart IIS.
    • After restarting IIS and reviewing the changes you will notice all of the Server Response Headers no longer show.

Just a quick recap of what we just did:

  • Steps 1 & 2, only removes the “Server: Microsoft- IIS/{version}“  response header.
  • Steps 3 & 4, removes the actual ASP.NET & PHP version response header (example: X-AspNet-Version: 2.0.50727) from being displayed.

If you have any questions please feel free to leave a comment below or to contact us.

From Idea to (re)Invention

Friday, April 10th, 2009 by Nevin McElwrath

There are some exciting things happening here at Force 5 Media. One of which, is exciting for me, since it involves self-discovery and insight for the purpose of solely helping our clients realize their goals. There is an old saying, “In order to see where you are going, you must know where you’ve been.” This goes for not only our clients, but ourselves. We have something in common with our clients; our need and want for success. We are on a journey; the more we realize where we have been, the more focused we can become in realizing our goals.

There’s been some reinventing going on at Force 5 Media. This journey is represented in a new page inviting clients to join us on this new journey we are embarking on. Join us on our journey. This was a fun project to work on due to the wide variety of mediums involved as well as the awesome ideas that were generated by the Force 5 team. Sure, there’s been a fair share of Willie Nelson (On the Road Again), Rascal Flatts (Life is a Highway), and B.B. King (Key to the Highway) parodies. Some humorous, some unfortunate. Over all of the tears, we enjoyed the creative brainstorming and coming up with some amazing ideas. On the “tech/creative” side of this project, we played with Flash, 3D, Photoshop, PHP, and Javascript. What’s even more exciting is the direction this project is headed. Over the next few weeks, our journey page will evolve with different messages, animations and hidden treasures – eventually revealing our new destination.

Stay tuned – it’s a wide open road ahead.