Tuesday, 31 March 2015

Create a Random String In PHP

$characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$randstring = '';
for ($i = 0; $i < 10; $i++) {
$randstring .= $characters[rand(0, strlen($characters))];
}
echo $randstring;

Generating a Log File In PHP

$log = "-----------Chinnayya Naidu Nalla's Application Accesed on".date("Y-m-d H:i:s"). "--------------".PHP_EOL.
"User: ".$_SERVER['REMOTE_ADDR'].' - '.date("F j, Y, g:i a").PHP_EOL.
"-------------------------".PHP_EOL;
file_put_contents('./log_'.date("j.n.Y").'.txt', $log, FILE_APPEND);





Place this code in your Php code it will generate a log file in your application. to achieve polymorphic nature place this in a function in a separate php file and include it. remember to create a function with a parameter to pass the log message to it Logging Code in a function with a parameter


function WriteLog($logmessage){
file_put_contents('./log_'.date("j.n.Y").'.txt', $logmessage, FILE_APPEND); }

Thursday, 22 January 2015

Get the Parameters From the Form URL in JavaScript

function getSearchParameters() {
      var parameterstring = window.location.search.substr(1);
      return parameterstring != null && parameterstring != "" ? transformToAssocArray(parameterstring) : {};
}

function transformToAssocArray( parameterstring ) {
    var params = {};
    var prmarr = parameterstring.split("&");
    for ( var i = 0; i < prmarr.length; i++) {
        var tmparr = prmarr[i].split("=");
        params[tmparr[0]] = tmparr[1];
    }
    return params;
}

var params = getSearchParameters();
alert(params.code);


Test with any url having the Parameter

abc.html?code=adslkfjlaksjflsadfsadfsadfsaddfsafsdfasdf&abc=akjdha


Tuesday, 13 January 2015

Blinking Your HTML Title

<script>
    function titlebar(val)
    {
    var speed = 1000;
    var position = val;
    var message1 = "Chinnayya Naidu Nalla - Software Developer ";

    var message2 = "Software Developer - Chinnayya Naidu Nalla"; 
    if(position == 0)    {
           message = message1;
           position = 1;
      } else if(pos == 1) {
          message = message2;
          position = 0;
      }
    document.title = message;
    timer = window.setTimeout("titlebar("+position +")",speed); }
    titlebar(0);

</script>

Sunday, 11 January 2015

Animating Typography In HTML Pages

Css Code:

body{
  background: #000;
  padding-top: 10px;
}

p{
  color: lime;
  font-family: "Courier";
  font-size: 20px;
  margin: 10px 0 0 10px;
  white-space: nowrap;
  overflow: hidden;
  width: 30em;
  animation: type 4s steps(60, end);
}

p:nth-child(2){
  animation: type2 8s steps(60, end);
}

p a{
  color: lime;
  text-decoration: none;
}

span{
  animation: blink 1s infinite;
}

@keyframes type{
  from { width: 0; }
}

@keyframes type2{
  0%{width: 0;}
  50%{width: 0;}
  100%{ width: 100; }
}

@keyframes blink{
  to{opacity: .0;}
}

::selection{
  background: black;
}

HTML:


Develop a simple html page with content in a <p></p>  Paragraph tag