Skip to main content

Posts

Showing posts from January, 2012

SFTP and File Upload in SFTP using C# and Tamir. SShSharp

The right choice of SFTP Server for Windows OS Follow the following steps, 1. Download the server version from here . The application is here 2. Provide the Username, password and root path, i.e. the ftp destination. 3. The screen shot is given below for reference. 4. Now download the CoreFTP client from this link 5. The client settings will be as in this screen shot: 6. Now the code to upload files via SFTP will be as follows. //ip of the local machine and the username and password along with the file to be uploaded via SFTP. FileUploadUsingSftp("172.24.120.87", "ftpserveruser", "123456", @"D:\", @"Web.config"); private static void FileUploadUsingSftp(string FtpAddress, string FtpUserName, string FtpPassword, string FilePath, string FileName) { Sftp sftp = null; try { // Create instance for Sftp to upload given files using given credentials sf

using the Id property in JSON objects

When using the `Id` as a property in the Javascript Objects, and sending them using JSON.stringify, they are not model bound as `Id`, instead, they are skipped and inserted as null in the bound model in the controller. Hence, Never Use `Id` as a property for a JSON object.

Credits Deducted for Any Reply to Dirty Dozen Topic

We would like to charge credits for ANY reply to a Dirty Dozen topic regardless of whether an avatar is used or not.  We would like to charge two (2) credits per reply, but if they would like an avatar it will still cost them an additional four (4) credits. to indicate the user that he has insufficient credits to make a post, we use the following code in the file : /home/webmaster/public_html/mod/groups/actions/forums/addpost.php [code] /* ds start - 11.02.2010 -> to check for the user credits */ $avid = intval(get_input('cavid')); $user = get_loggedin_user(); if($user["credits"] < $avCost) {     register_error(elgg_echo("You have insufficient Credits to make a post. Please purchase Credits"),"errors");     forward("http://dirtdisser.com/mod/cubet_membership/upgradecredits.php"); } else if($user["credits"] > $avCost) {     if($avid > 0)     {         $avCost = $avCost * 6;     }     else     {

admin manageable Front Page Message

On the frontpage there is a chat box with text in it (divider id #frontpage-message).  We would like to make this dynamic so any admin can change that text on a page in the Administration section.  Please be sure to limit the amount of characters a user can input so it does not allow enough text to overflow from the chatbox. to write the page title and set the url [code] else if($type=='CHM') {     $external_page_title = elgg_echo('expages:CHM'); } [/code] code to generate the form for handling the messages [code] /* ds start - CHM */ if($type=="CHM") {     $msg = "Edit the Frontpage welcome Message here. <br /><br />";         $chatMessageForm = <<<EOT         <form method="post" action="">             <label for="chatMsg">                 Customize the Front Page Chat Message Here. [Max : 50 characters]             </label>             <textarea id="

hide the reply option for all the commented wireposts in the "thewire posts"

This option is implemented by checking whether the comment text has a @ and if so, we just indent it and hide the reply link from the user so that this comment cannot be commented. /home/webmaster/public_html/mod/thewire/views/default/object/thewire.php 1. check for the @ in the text [code]     $haystack= $vars['entity']->description;     $needle = "@";     if($haystack[0] == $needle)         $shallIndent = TRUE;     else         $shallIndent = FALSE; [/code] 2. use the indentation for the div which is a comment or a reply to a post made earlier. [code]  if($shallIndent)     {         ?> <!-- style="margin-left:50px"--> <div class="thewire-singlepage"  style="margin-left:50px"> <?php } else { ?> <div class="thewire-singlepage">     <?php } ?> [/code] 3. code to display the link only when the user is logged in and when this post is not indented. [code] <

creating a facebook messaging system using php and facebook access tokens

Here is the procedure that was used to write posts in facebook by allowing the user to signin using their facebook id and then writing a post in their facebook profile page. 1. use the following url with your own application id created in facebook facebook login     Then after the page is reloading, get the access token returned by facebook for the logged in user     3. use the following lines of code to get the facebook access token from the set cookie above and use it to send the post data via curl to facebook if(isset($_COOKIE['access_token_fb'])) {     /* NEVER DELETE THIS LINE. THIS IS THE MOST IMPORTANT LINE IN USING FACEBOOK */     json_decode(file_get_contents('https://graph.facebook.com/me?access_token=' .$_COOKIE['access_token_fb']));         /* new testing code */         $url = "https://graph.facebook.com/me/feed";     $ch = curl_init();     $attachment =  array(   'access_token'  => $_COOKIE['access

HTML to C# Color Conversion

To convert a System.Drawing.Color to the HTML color format (Hex value or HTML color name value) and back. System.Drawing.Color c = System.Drawing.ColorTranslator.FromHtml("#F5F7F8"); String strHtmlColor = System.Drawing.ColorTranslator.ToHtml(c);

Client Script for GUID Generator

To create GUID's or Pseudo-Random numbers in Javascript, use the following function guidGenerator() { var S4 = function() { return (((1+Math.random())*0x10000)|0).toString(16).substring(1); }; return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4()); } This was adapted from the Original Work