Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - admin

Pages: [1] 2 3 ... 15
1
PHP & Perl / PHP Not Accepting Tag; Only Accepting php and Tag
« on: January 30, 2012, 02:29:09 AM »
Q. I'm using PHP along with latest version of Apache. Only <?php and <script> tags are recognized. Many of my scripts are broken. How do I allow the <? tag also?


A. You need to allow the <? tag by editing php.ini file. Using short tags should be avoided when developing applications or libraries that are meant for redistribution, or deployment on PHP servers which are not under your control, because short tags may not be supported on the target server. For portable, redistributable code, be sure not to use short tags.

Open php.ini ( /etc/php.ini or /usr/local/etc/php.ini), enter:
Code: [Select]
# vi php.iniSet short_open_tag to On:
Code: [Select]
short_open_tag = OnSave and close the file. Restart webserver:
Code: [Select]
# service httpd restartOR
Code: [Select]
# /usr/local/etc/rc.d/apache22 restart

2
Lunix & Unix / Empty Postfix Mail Queue
« on: January 25, 2012, 03:16:33 PM »
Empty Postfix Mail Queue

This command will delete one specific email from the mailq (taken from the postsuper man page)
Code: [Select]
mailq | tail -n +2 | grep -v '^ *(' | awk  'BEGIN { RS = "" } { if ($8 == "email@address.com" && $9 == "") print $1 } ' | tr -d '*!' | postsuper -d -
I use a few scripts that check the status of our servers and email/page me if they don't respond. This led to a problem when I was offline for one reason or another. I would get a ton of messages sent to the postfix queue which would all be sent out when I reconnected to the internet. Deleting the postfix mail Queue is suprisingly easy:
Code: [Select]
sudo postsuper -d ALL

This command will delete all messages in the Postfix queue. If you need more selective deleting, this can be done as well, use 'man postsuper' to find out all of the available options.


The other thing that helped with this was checking for a local network connection before doing the server checks. This is done with the following.
Code: [Select]
ifconfig | grep netmask | grep -v 127.0.0.1 | awk {'print $2'}L

3
How do I set or change Linux system password for any user account?

Both Linux and UNIX use the passwd command to change user password. The passwd is used to update a user’s authentication token (password) stored in shadow file.

The passwd changes passwords for user and group accounts. A normal user may only change the password for his/her own account, the super user (or root) may change the password for any account. The administrator of a group may change the password for the group. passwd also changes account information, such as the full name of the user, user's login shell, or password expiry date and interval.

Task: Set or Change User Password
Type passwd command as follows to change your own password:
$ passwd
Output:

Changing password for vivek
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfullyThe user is first prompted for his/her old password, if one is present. This password is then encrypted and compared against the stored password. The user has only one chance to enter the correct password. The super user is permitted to bypass this step so that forgotten passwords may be changed.

A new password is tested for complexity. As a general guideline, passwords should consist of 6 to 8 characters including one or more from each of following sets:

Lower case alphabetics
Upper case alphabetics
Digits 0 thru 9
Punctuation marks
Task: Change Password For Other User Account
You must login as root user, type the following command to change password for user vivek:
# passwd vivek
Output:

Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfullyWhere,

vivek - is username or account name.
Task: Change Group Password
When the -g option is used, the password for the named group is changed. In this example, change password for group sales:
# passwd -g sales
The current group password is not prompted for. The -r option is used with the -g option to remove the current password from the named group. This allows group access to all members. The -R option is used with the -g option to restrict the named group for all users.

4
Lunix & Unix / How to add curl support to PHP 5 in CentOS
« on: January 01, 2012, 11:55:27 PM »
How to add curl support to PHP 5 in CentOS?

Installing php-common did the trick for me
yum install php-common

 You can also specifically install the php-curl extension
yum install php-curl

Then uncomment the line
;extension=php_curl.dll

 in php.ini, and then restart the Apache service.

5
Lunix & Unix / How to edit crontab and save?
« on: October 22, 2011, 10:45:19 AM »
To edit crontab write:
crontab -e

The default editor is for crontab is vi.
 
Make your edit..
 
Then hit "ESC" once. Then :wq

That should drop you back to the command line.

6
Java Script / jQuery: How to check if button is disabled
« on: October 19, 2011, 10:47:47 PM »
jQuery: How to check if button is disabled

You can use jQuery to trigger a button click from the client.  In this certain situation, I needed to make sure the button was not disabled prior to clicking.  In jQuery you can use the “is” function to check if the button is disabled like this:
Code: [Select]
<script type="text/javascript">
    $(document).ready(function() {
    if ($('#StartButton').is(':disabled') == false) {
            $('#StartButton').click();
        }
    });
</script>

7
Java Script / How to get and set form element values with jQuery
« on: October 13, 2011, 11:12:00 PM »
Getting a value with jQuery
 
To get a form value with jQuery use the val() function. Let's say we have a form like this, using an id for each form element:
 
Code: [Select]
<input name="foo" id="foo" type="text">
<select name="foo" id="bar">
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select>

We can display an alert for the values of "foo" and "bar" as easily this:
 
Code: [Select]
window.alert( $('#foo').val() );
window.alert( $('#bar').val() );

If we're using the name only and not specifying an id, the jQuery to get the form values would be this:
 
Code: [Select]
window.alert( $('[name=foo]').val() );
window.alert( $('[name=bar]').val() );

If you have a group of radio buttons and want to get the selected button, the code is slightly different because they all have the same name. Using the above code examples will show the value for the first radio button on the form with that name. To find out the value of the checked one, do this instead:
 
HTML:
Code: [Select]
<input type="radio" name="baz" value="x">
<input type="radio" name="baz" value="y">
<input type="radio" name="baz" value="z">


jQuery:
Code: [Select]
window.alert($('input[name=baz]:checked').val());
Setting a form value with jQuery
 
You can set the form values with jQuery using the same val() function but passing it a new value instead. Using the same example forms above, you'd do this for the text input and select box:
Code: [Select]
$('#foo').val('this is some example text');
$('#bar').val('3');

OR
Code: [Select]
$('[name=foo]').val('this is some example text');
$('[name=bar]').val('3');

Using the above for a radio button will change the actual value of the radio button rather than changing the one that is selected. To change the radio button that is selected you'd do this:
 
Code: [Select]
$('input[name="baz"]')[0].checked = true;
  • would set the first one checked, [1] would set the second one checked and so on.


8
If you got this error:
The install location for prerequisites has not been set to 'component vendor's web site' and the file 'Crystal Reports for .NET Framework 4.0\CRRuntime_32bit_13_0_1.msi' in item 'SAP Crystal Reports Runtime Engine for .NET Framework 4.0' can not be located on disk
you will need to add this file to:
C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\Crystal Reports for .NET Framework 4.0

9
ASP.NET / Read Post Data submitted to ASP.Net Form
« on: August 20, 2011, 06:47:21 PM »
Read the Request.Form NameValueCollection and process your logic accordingly:
Code: [Select]
NameValueCollection nvc = Request.Form;string userName, password;
if (!string.IsNullOrEmpty(nvc["txtUserName"]))
{
 userName = nvc["txtUserName"];
}
if (!string.IsNullOrEmpty(nvc["txtPassword"]))
{
  password = nvc["txtPassword"];
}
//Process login
CheckLogin(userName, password);

... where "txtUserName" and "txtPassword" are the Names of the controls on the posting page.

10
Lunix & Unix / Moving domain between user accounts with DirectAdmin
« on: June 18, 2011, 11:51:10 AM »
If you want to move a domain to another user and you have DirectAdmin control panel installed on your server you can do that as following:
Code: [Select]
cd /usr/local/directadmin/scripts
./move_domain.sh domain olduser newuser

11
Lunix & Unix / HowTo install PHP 5.3.6 on CentOS 5
« on: June 18, 2011, 11:38:20 AM »
This small guide shows you how to install PHP 5.3.6 on CentOS 5 64bit 32 bit, this will work with any control panel like Virtualmin and no need to upgrade apache web server ( httpd ), Using a PHP 5.3.6 RPM for CentOS / RHEL. This guide assumes you have shell access with a super user (root) account to your server.

Install Atomic YUM repository on CentOS
Code: [Select]
wget -q -O atomic http://www.atomicorp.com/installers/atomic |sh

chmod 655 atomic
./atomic


Update / Upgrade PHP
If you already have PHP installed and wish to upgrade to 5.3.6 then run the following:

Code: [Select]
yum update php
Check what packages are going to be updated and proceed if it looks sane.

If you don’t currently have PHP installed then run the following:

Code: [Select]
yum install php
Check what other deps are going to be pulled and proceed if you are happy.

Restart Apache and verify the new version is working using phpinfo.php

Code: [Select]
/etc/init.d/httpd restart
 

For this create a file in a directory served up by Apache containing the following information:

Code: [Select]
<?php phpinfo(); ?>Call the file phpinfo.php and browse to the file in a web browser e.g http://yourdomain.com/phpinfo.php

At the top of the page it should display the PHP version Apache is using.

 

Note you will need to update ionCube Loader to the same version, guide for this coming soon…


If you got error then you may need to update Mysql
Code: [Select]
yum update mysql and then try again.



12
Lunix & Unix / How to change a unix user password
« on: June 09, 2011, 10:05:45 AM »
"A user forgot their password. Can I change it?"
Yes you can. The step-by-step solution to this problem is shown below.

Changing a User's Password

Step #1: Log in to the system as the "root" user.

Step #2: Assume the user's login account was "fred". At the command-line prompt, type "passwd fred".

Step #3: The system gives you the option of (1) Picking a password or (2) Having a password generated for you.

In this case you will probably want to select "1" to pick your own password. Enter "1".

Step #4: Enter the password two times (the second time is for verification).

The user's password has been changed.

13
Lunix & Unix / Linux or UNIX - Find and remove file
« on: June 09, 2011, 01:11:11 AM »
Linux or UNIX - Find and remove file syntax
To remove multiple files such as *.jpg or *.sh with one command find, use

Code: [Select]
find . -name "FILE-TO-FIND"-exec rm -rf {} \;OR

Code: [Select]
find . -type f -name "FILE-TO-FIND" -exec rm -f {} \;The only difference between above two syntax is that first command can remove directories as well where second command only removes files.

More Examples of find command
(a) Find all files having .bak (*.bak) extension in current directory and remove them:
Code: [Select]
$ find . -type f -name "*.bak" -exec rm -f {} \;(b) Find all core files and remove them:
Code: [Select]
# find / -name core -exec rm -f {} \;(c) Find all *.bak files in current directory and removes them with confirmation from user:
Code: [Select]
$ find . -type f -name "*.bak" -exec rm -i {} \;Output:

rm: remove regular empty file `./data0002.bak'? y
rm: remove regular empty file `./d234234234fsdf.bak'? y
rm: remove regular empty file `./backup-20-10-2005.bak'? nCaution: Before removing file makes sure, you have backup of all-important files. Do not use rm command as root user it can do critical damage to Linux/Unix system.

Above examples are specific to this topic only.


14
Host Talk / 55 SEO tips
« on: June 05, 2011, 07:44:13 PM »

SEO Tips

1. If you absolutely MUST use Java script drop down menus, image maps or image links, be sure to put text links somewhere on the page for the spiders to follow.

2. Content is king, so be sure to have good, well-written and unique content that will focus on your primary keyword or keyword phrase.

3. If content is king, then links are queen. Build a network of quality backlinks using your keyword phrase as the link. Remember, if there is no good, logical reason for that site to link to you, you don’t want the link.

4. Don’t be obsessed with PageRank. It is just one isty bitsy part of the ranking algorithm. A site with lower PR can actually outrank one with a higher PR.

5. Be sure you have a unique, keyword focused Title tag on every page of your site. And, if you MUST have the name of your company in it, put it at the end. Unless you are a major brand name that is a household name, your business name will probably get few searches.

6. Fresh content can help improve your rankings. Add new, useful content to your pages on a regular basis. Content freshness adds relevancy to your site in the eyes of the search engines.

7. Be sure links to your site and within your site use your keyword phrase. In other words, if your target is “blue widgets” then link to “blue widgets” instead of a “Click here” link.

8. Focus on search phrases, not single keywords, and put your location in your text (“our Palm Springs store” not “our store”) to help you get found in local searches.

9. Don’t design your web site without considering SEO. Make sure your web designer understands your expectations for organic SEO. Doing a retrofit on your shiny new Flash-based site after it is built won’t cut it. Spiders can crawl text, not Flash or images.

10. Use keywords and keyword phrases appropriately in text links, image ALT attributes and even your domain name.

11. Check for canonicalization issues – www and non-www domains. Decide which you want to use and 301 redirect the other to it. In other words, if http://www.domain.com is your preference, then http://domain.com should redirect to it.

12. Check the link to your home page throughout your site. Is index.html appended to your domain name? If so, you’re splitting your links. Outside links go to http://www.domain.com and internal links go to http://www.domain.com/index.html.

Ditch the index.html or default.php or whatever the page is and always link back to your domain.

13. Frames, Flash and AJAX all share a common problem – you can’t link to a single page. It’s either all or nothing. Don’t use Frames at all and use Flash and AJAX sparingly for best SEO results.

14. Your URL file extension doesn’t matter. You can use .html, .htm, .asp, .php, etc. and it won’t make a difference as far as your SEO is concerned.

15. Got a new web site you want spidered? Submitting through Google’s regular submission form can take weeks. The quickest way to get your site spidered is by getting a link to it through another quality site.

16. If your site content doesn’t change often, your site needs a blog because search spiders like fresh text. Blog at least three time a week with good, fresh content to feed those little crawlers.

17. When link building, think quality, not quantity. One single, good, authoritative link can do a lot more for you than a dozen poor quality links, which can actually hurt you.

18. Search engines want natural language content. Don’t try to stuff your text with keywords. It won’t work. Search engines look at how many times a term is in your content and if it is abnormally high, will count this against you rather than for you.

19. Not only should your links use keyword anchor text, but the text around the links should also be related to your keywords. In other words, surround the link with descriptive text.

20. If you are on a shared server, do a blacklist check to be sure you’re not on a proxy with a spammer or banned site. Their negative notoriety could affect your own rankings.

21. Be aware that by using services that block domain ownership information when you register a domain, Google might see you as a potential spammer.

22. When optimizing your blog posts, optimize your post title tag independently from your blog title.

23. The bottom line in SEO is Text, Links, Popularity and Reputation.

24. Make sure your site is easy to use. This can influence your link building ability and popularity and, thus, your ranking.

25. Give link love, Get link love. Don’t be stingy with linking out. That will encourage others to link to you.

26. Search engines like unique content that is also quality content. There can be a difference between unique content and quality content. Make sure your content is both.

27. If you absolutely MUST have your main page as a splash page that is all Flash or one big image, place text and navigation links below the fold.

28. Some of your most valuable links might not appear in web sites at all but be in the form of e-mail communications such as newletters and zines.

29. You get NOTHING from paid links except a few clicks unless the links are embedded in body text and NOT obvious sponsored links.

30. Links from .edu domains are given nice weight by the search engines. Run a search for possible non-profit .edu sites that are looking for sponsors.

31. Give them something to talk about. Linkbaiting is simply good content.

32. Give each page a focus on a single keyword phrase. Don’t try to optimize the page for several keywords at once.

33. SEO is useless if you have a weak or non-existent call to action. Make sure your call to action is clear and present.

34. SEO is not a one-shot process. The search landscape changes daily, so expect to work on your optimization daily.

35. Cater to influential bloggers and authority sites who might link to you, your images, videos, podcasts, etc. or ask to reprint your content.

36. Get the owner or CEO blogging. It’s priceless! CEO influence on a blog is incredible as this is the VOICE of the company. Response from the owner to reader comments will cause your credibility to skyrocket!

37. Optimize the text in your RSS feed just like you should with your posts and web pages. Use descriptive, keyword rich text in your title and description.

38. Use captions with your images. As with newspaper photos, place keyword rich captions with your images.

39. Pay attention to the context surrounding your images. Images can rank based on text that surrounds them on the page. Pay attention to keyword text, headings, etc.

40. You’re better off letting your site pages be found naturally by the crawler. Good global navigation and linking will serve you much better than relying only on an XML Sitemap.

41. There are two ways to NOT see Google’s Personalized Search results:

(1) Log out of Google

(2) Append &pws=0 to the end of your search URL in the search bar

42. Links (especially deep links) from a high PageRank site are golden. High PR indicates high trust, so the back links will carry more weight.

43. Use absolute links. Not only will it make your on-site link navigation less prone to problems (like links to and from https pages), but if someone scrapes your content, you’ll get backlink juice out of it.

44. See if your hosting company offers “Sticky” forwarding when moving to a new domain. This allows temporary forwarding to the new domain from the old, retaining the new URL in the address bar so that users can gradually get used to the new URL.

45. Understand social marketing. It IS part of SEO. The more you understand about sites like Digg, Yelp, del.icio.us, Facebook, etc., the better you will be able to compete in search.

46. To get the best chance for your videos to be found by the crawlers, create a video sitemap and list it in your Google Webmaster Central account.

47. Videos that show up in Google blended search results don’t just come from YouTube. Be sure to submit your videos to other quality video sites like Metacafe, AOL, MSN and Yahoo to name a few.

48. Surround video content on your pages with keyword rich text. The search engines look at surrounding content to define the usefulness of the video for the query.

49. Use the words “image” or “picture” in your photo ALT descriptions and captions. A lot of searches are for a keyword plus one of those words.

50. Enable “Enhanced image search” in your Google Webmaster Central account. Images are a big part of the new blended search results, so allowing Google to find your photos will help your SEO efforts.

51. Add viral components to your web site or blog – reviews, sharing functions, ratings, visitor comments, etc.

52. Broaden your range of services to include video, podcasts, news, social content and so forth. SEO is not about 10 blue links anymore.

53. When considering a link purchase or exchange, check the cache date of the page where your link will be located in Google. Search for “cache:URL” where you substitute “URL” for the actual page. The newer the cache date the better. If the page isn’t there or the cache date is more than an month old, the page isn’t worth much.

54. If you have pages on your site that are very similar (you are concerned about duplicate content issues) and you want to be sure the correct one is included in the search engines, place the URL of your preferred page in your sitemaps.

55. Check your server headers. Search for “check server header” to find free online tools for this. You want to be sure your URLs report a “200 OK” status or “301 Moved Permanently ” for redirects. If the status shows anything else, check to be sure your URLs are set up properly and used consistently throughout your site.



15
MySQL / mysql: Got a packet bigger than 'max_allowed_packet' bytes
« on: May 12, 2011, 01:40:22 AM »
If you got this error:
Code: [Select]
Got a packet bigger than 'max_allowed_packet' bytesThis means you need to increase the max_allowed_packet. You can do that by changing the my.cnf or my.ini file under the mysqld section and set max_allowed_packet=100M or you could run these commands in a mysql console connected to that same server:

Code: [Select]
set global net_buffer_length=1000000;
set global max_allowed_packet=1000000000;

(Use a very large value for the packet size.)

Pages: [1] 2 3 ... 15