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.


Messages - admin

Pages: [1] 2 3 ... 21
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 / Re: How to edit crontab and save?
« on: November 27, 2011, 11:19:06 AM »
to edit a user crontab add: -u username

6
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.

7
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>

8
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.


9
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

10
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.

11
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

12
Lunix & Unix / Re: HowTo install PHP 5.2.17 on CentOS 5
« on: June 18, 2011, 11:41:52 AM »
If you wish to use 5.2 like 5.2.17 you will need to manually download it from the Atomic archive and install it.

For i386: http://www6.atomicorp.com/channels/atomic/centos/5EL/x86_64/RPMS/php-5.2.17-1.el5.art.i386.rpm

For x85_64: http://www6.atomicorp.com/channels/atomic/centos/5EL/x86_64/RPMS/php-5.2.17-1.el5.art.x86_64.rpm

And for 86_64 install with yum as shown below, that way yum will pull down the required deps needed for rpm:

Code: [Select]
yum localinstall php-5.2.17-1.el5.art.x86_64.rpm --nogpgcheckAnd for i386 install with:

Code: [Select]
yum localinstall php-5.2.17-1.el5.art.i386.rpm --nogpgcheckIf you are updating PHP on a system you most likely have all the deps and you could in theory use rpm to install using “rpm -Uvh php-5.2.17-1.el5.art.ARCH.rpm” obviously replace ARCH with i386 or x86_64 depending on your architecture.


13
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.



14
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.

15
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.


Pages: [1] 2 3 ... 21