Shared Hosting - In a pinch permission updates

After a long day working on an upgrade, I realized I needed to adjust the permissions of directories and files that were owned by nobody.nobody.

I was about to send a ticket to the hosting company, when I realized you can use PHP to change the permissions, and invoke the script through the browser.

It wasn’t graceful, or efficient, but, it did let me change permissions and continue.

The real lesson is to wait until the last minute to ask the hosting company to change ownership of the files. I hurried, because the server was hacked when I logged in.

Tweet and be heard (marketing)

If you use Twitter to keep in touch with your friends, stop reading now.

This post is for people who are using Twitter as a marketing tool.

Start on the link above - go see what others are tweeting. Check out your competition. Sit there for a few minutes and watch the words go by.

Now think about your products and services. What words describe them? Are there some key acronyms? Does your Twitter name identify your company or product in some way? If not, create a professional Twitter presence, to separate business conversations from personal. If you have the time and skill to customize your Twitter page, do it, and do a nice job.

Learn about the various URL shorteners, so you can use them when appropriate. If you have SEO friendly URLs on your site, it may be better to tweet them directly, as they may have the keywords you need and they provide direct links.

Learn about # tags, which can be used to categorize your tweets.

Business tweets aren’t about you and what you do, they should attract people to the content you’re trying to share. You don’t always have to have a link, the idea is to inform and interest, to entice people to follow.

Examples

  • I posted a video - Instead describe the video content. “Graphical view of system performance, tutorial video for VPS mgt software http://video.url
  • Going to event - Better to say what you’re bringing or looking for. “Presenting software doc tools at SWTX conference - 12 May 2010″
  • New release, upgrade done - Again, describe what is being released or upgraded. “Version 1.8.8 of VPS mgt software - installed and running. Demo at http://bit.ly/435vv
  • Free offer - Be specific, so people understand whether it’s relevant to them. “Monitor your VPS - Free trial - http://site.com/free-trial
  • RT Cool post - Only your frequent followers and friends will pick this up. To attract new people, some description is required. “RT different perspective on VPS SLAs”
  • Fun stuff - You should decide from the beginning if twitter will be fun, or serious. You could have a fun feed, and a serious feed.

Instead of considering your tweets as articles or microblog posts, think of them as headlines, or sound bites. Pack as much meaning into them as possible, if there is more information than you can tweet, blog it and announce the post in a tweet.

Debugging AJAX

  • Use the transport mechanism to send debug information. For example, if you’re sending back an array of data, add a new element (or several), and put in the SQL query so you can see exactly what’s being executed.
  • Store the returned data in global variables on the client side and use Firebug to examine them. console.debug and alert are helpful, too.
  • Use var_dump and echo if you get frustrated. They’ll probably throw an error on the client side, but you’ll get to see what you want to.
  • Use var_export($variable,true) if you want to do a var_dump to a string or to a file. file_put_contents(’/tmp/file’,$data,FILE_APPEND); is a great way to monitor script execution. Open a new SSH window and use tail -f /tmp/file to see it.
  • Cut and paste output into Notepad so you can easily verify it. Often you need several chunks of text and data to truly understand what is happening and why.
  • Develop complex pieces in a standalone environment. This is good for assembling arrays of data out of complex SQL queries. Simplifying the task so you can focus on the difficult parts will speed development.
  • Watch out for extra commas in object assignments. IE will crash.
  • If you have Visual Studio, use it. It can save you a tremendous amount of time when debugging under IE.
  • Test for the presence of variables, objects, and attributes before using them. It isn’t really right, but you can use if (variable_exists) to see if the variable has been set up. A better solution is to initialize everything, or to use if (typeof variable != ‘undefined’).
  • To remove something from a page, use style="display:none". It works, it’s simple, and it’s very low risk. If anyone is playing with your code, they’ll find it, but it shouldn’t be an issue unless it had security issues, or restricted content.
  • Add a debug setting to your code that allows you to receive more information when errors occur. You can disable it for the production release.

Advantages of Integrated Content

  • Seamless, cost-effective integration. Only one instance of the design must be maintained, and, since it is sourced from a single point, it will look better, and adjust as the content changes.
  • Unified search results. A single search function can search all elements of the site, the content, forums, blogs, images, contact opportunities.
  • Ease of navigation. Navigation through a single application is generally simpler than paging through different ones. Consistency is assured.
  • Single administrative interface. Content editors and maintainers only have to learn how to use one system.
  • Reduced cost. eZ Publish is free.
  • Effective cross-referencing tools. eZ’s editor has an excellent way to linking within the site to help a visitor find additional information. If the content changes, the link will adjust.
  • SEO. Building a single site with a robust collection of content consolidates the resources. Distributing them to other domains and subdomains may dilute the effectiveness of the content. In addition, the majority of the page rank equation is computed from external links to the site, the more links from high-ranking pages you have to your site, the higher the rank. Even if the blog is on a separate subdomain or domain, it won’t significantly increase page rank unless it becomes very popular.
  • Content is still king. The location and software running the blog is secondary to the content. Without quality posts, the blog will not attract readers or followers.
  • Visitor participation and contributions. Using a single application allows people to register and share their ideas in more than one area, commenting on a blog or post, accessing restricted content, joining a forum, or even contributing posts.
  • Corporate, brand, and product focus. A single central site ensures visitors are focused on the company, brand, and product. They won’t get lost during transitions to other sites, or frustrated by new page loads.
  • Control. Hosted applications limit the control available, for example the addition of bookmarking links.
  • Visitor trends, statistics and tracking. Distributing the tracking across different systems makes it more difficult to monitor visitors behavior.

PHP cPanel email address import .CSV file notification script

This script reads a .CSV file with a field order of email address, domain, password, and quota and issues messages to distribute the new passwords.

<?php
$sData=file_get_contents('email_accounts.txt');
$aData=explode("\n",$sData);
foreach ($aData as $k => $v)
{
        $d=trim($v);
        /* Disregard blank lines */
        if ($d!=='')
        {
                $m=explode(',',$d);
                $sMessage='Your new email account password is '.$m[2].PHP_EOL.PHP_EOL;
                $sMessage.=file_get_contents('message.txt');
                $headers = 'From: webmaster- @ -example.com' . PHP_EOL .
                        'Reply-To: webmaster- @ -example.com' . PHP_EOL .
                        'X-Mailer: PHP/' . phpversion();
                mail ($m[0],'New email access',$sMessage,$headers);
        }
}

?>

Sample message.txt

The new server is scheduled to go live at DateTime.

You will have to enter the new password to use your email after DateTime.

You may change the password, after DateTime, by logging in to http://example.com:2095, with your full email address and the
password above, and using the ‘Change Email Password’ feature.

If you have any questions, please let me know.

Your name
email
Phone