Thursday, June 27, 2013

CSS: gradient background color for all browsers

Ultimate CSS Gradient Generator is a power tool can help you generate CSS code of gradient background color for all browsers.

It also supports to generate SCSS code.

Let enjoy it.

Saturday, June 22, 2013

Add custom fields to JComments 2.3

If you use JComments 2.2, you can learn how to add custom fields in this article.
Below is the modification that article for JComments 2.3. The example is adding 2 custom fields Town and Accept Terms.

1. Firstly, add 2 these fields to #__jcomments (e.g. jos_jcomments):
ALTER TABLE jos_jcomments ADD COLUMN `town` varchar (255);
ALTER TABLE jos_jcomments ADD COLUMN `acceptterms` tinyint (1) DEFAULT 0;

2. Add them to the submit form in file \components\com_jcomments\tpl\default\tpl_form.php:
+Search the text comments-form-comment to find the following code:
<p>
<span>
<textarea id="comments-form-comment" name="comment" cols="65" rows="8" tabindex="5"></textarea>
</span>
</p>
+Add the following code after the above code:
<p>
<span>
<input type="text" name="town" value="" id="comments-form-town" />
<label for="comments-form-town" >Town</label>
</span>
</p>

<p>
<span>
<input class="checkbox" type="checkbox" name="acceptterms" value="0" id="comments-form-acceptterms" />
<label for ="comments-form-acceptterms" >Accept Terms of Use</label>
</span>
</p>

3. Add these fields to ajax file to send them to DB
+In addComment function of the file \components\com_jcomments\jcomments.ajax.php, search below code:
$comment->ip = $userIP;
+Add the following code after the above code:
$comment->town = isset($values['town'] ) ? $values ['town'] : '';
$comment->acceptterms = isset($values['acceptterms']) ? $values ['acceptterms'] : 0;

4. Modify _getCommentsQuery function in file \components\com_jcomments\models\jcomments.php to query these fields:
+Search the following code:
$query = "SELECT c.id, c.parent, c.object_id, c.object_group, c.userid, c.name, c.username, c.title, c.comment"
+Replace by the following code:
$query = "SELECT c.id, c.parent, c.object_id, c.object_group, c.userid, c.name, c.username, c.title, c.comment, c.town, c.acceptterms"

5. Add these fields to file \components\com_jcomments\tpl\default\tpl_comment.php to present them in the comments list:
+Search the following code:
<div class="comment-body" id="comment-body-<?php echo $comment->id; ?>"><?php echo $comment->comment; ?></div>
+Then add the following code after the above code:
<p>
<span class="comment-town" ><?php echo $comment->town; ?></span></br>
<span class="comment-accept" ><?php echo $comment->acceptterms ? 'Accepted' : 'Not accepted'; ?></span>
</p>

6. Add these fields to file  \administrator\components\com_jcomments\admin.jcomments.html.php to view them in backend:
+Search the following code:
<tr valign="top" align="left">
<td><label for="comment_text"><?php echo JText::_('A_COMMENT_TEXT'); ?></label></td>
<td><textarea class="editbox long" cols="25" rows="10" id="comment_text" name="comment"><?php echo $row->comment; ?></textarea></td>
</tr>
+Add the following code after above code:
<tr valign="top" align="left">
<td><?php echo JText::_('Town'); ?></td>
<td><input type="text" size="35" name="town" value="<?php echo $row->town; ?>" /></td>
</tr>
<tr valign="top" align="left">
<td><?php echo JText::_('Acceptterms'); ?></td>
<td><input type="text" size="35" name="acceptterms" value="<?php echo $comment->acceptterms ? 'Accepted' : 'Not accepted'; ?>" /></td>
</tr>

That's all. Now you can add your fields in your way.

Thursday, June 20, 2013

php round to .5 or .25

To round to .5:
$value = round($value * 2, 0) / 2;

To round to .25
$value = round($value * 2, 0) / 4;

Take it easy -:)

Saturday, June 15, 2013

Windows: Change Remote Desktop Port

If you check Event Viewer of your server and see that there is many Audit Failure in Task Category Logon, you should change the port of remote desktop immediately.

Change port value (select Decimal when changing) of the registry PortNumber in:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp

PortNumber of Remote Desktop
After changing, restart your server.

To connect to your server with new port (e.g. 3333), use the following information:
Your_Server_Name:3333
OR:
Your_Server_IP:3333

Make sure the firewall of your computer doesn't lock this new port.
Subscribe to RSS Feed Follow me on Twitter!