Connecting PHP with Oracle

September 6, 2012 Leave a comment

Reblogged from அறிவுச் சுடரேந்து:

PHP provides two extension modules with which we can connect to Oracle:

  • The normal Oracle functions (ORA); and
  • the Oracle Call-Interface functions (OCI).

OCI is frequently used. ORA doesn’t include support for CLOBs, BLOBs, BFILEs, ROWIDs, etc.

Here is a sample PHP script that uses OCI Extension module to connect Oracle.

<?php

$dbuser = “username”;
$dbpass = “password”;
$dbserver = “server”;

Read more… 82 more words

Categories: Uncategorized

scary Facebook ...

September 6, 2012 Leave a comment

Reblogged from pindanpost:

Click to visit the original post

Wolfram Alpha: The Facebook app that knows you better than you do

  • by: Claire Connelly
  • From: News Limited Network
  • September 05, 2012 8:39AM

New app crunches the numbers on your Facebook page. Picture: File

A FACEBOOK app known as "Wolfram Alpha" knows more about your social media use than you do.

In fact it's a little bit scary.

Read more… 67 more words

.
Categories: Uncategorized

PHP codes to tell browsers to open the download dialog box for users to download a file instead of open into the Browsers

September 4, 2012 Leave a comment

A fairly common question is, “How can I force a file to download to the user?” The answer is, you really cannot. You will need something on the server to send a Content-Disposition header to set the file as an attachment instead of being inline. You could do this with plain Apache configuration though.

<a href="download.php?file=path/<?=$row['file_name']?>">Download</a>

download.php:

<?php

$file = $_GET['file'];

download_file($file);

function download_file( $fullPath ){

  // Must be fresh start
  if( headers_sent() )
    die('Headers Sent');

  // Required for some browsers
  if(ini_get('zlib.output_compression'))
    ini_set('zlib.output_compression', 'Off');

  // File Exists?
  if( file_exists($fullPath) ){

    // Parse Info / Get Extension
    $fsize = filesize($fullPath);
    $path_parts = pathinfo($fullPath);
    $ext = strtolower($path_parts["extension"]);

    // Determine Content Type
    switch ($ext) {
      case "pdf": $ctype="application/pdf"; break;
      case "exe": $ctype="application/octet-stream"; break;
      case "zip": $ctype="application/zip"; break;
      case "doc": $ctype="application/msword"; break;
      case "xls": $ctype="application/vnd.ms-excel"; break;
      case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
      case "gif": $ctype="image/gif"; break;
      case "png": $ctype="image/png"; break;
      case "jpeg":
      case "jpg": $ctype="image/jpg"; break;
      default: $ctype="application/force-download";
    }

    header("Pragma: public"); // required
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: private",false); // required for certain browsers
    header("Content-Type: $ctype");
    header("Content-Disposition: attachment; filename=\"".basename($fullPath)."\";" );
    header("Content-Transfer-Encoding: binary");
    header("Content-Length: ".$fsize);
    ob_clean();
    flush();
    readfile( $fullPath );

  } else
    die('File Not Found');

}
?>

The way to force the browser not to handle the file internally is to change the headers (content-disposition prefereably, or content-type) so the browser will not try to handle the file internally. You can either do this by writing a script on the webserver that dynamically sets the headers (i.e. download.php) or by configuring the webserver to return different headers for the file you want to download.

Categories: Programming

Creating a HTTP Web Server Using NodeJs

August 12, 2012 Leave a comment

Here I am gonna show you how to create a HTTP Web Server .Node.js is an evented system,.

To create an application using NodeJs you simply make sure that you have installed NodeJs in your system .

Write this code on your textfile

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');

To run the server, put the code into a file app.js and execute it with thenode program:

Go to command Prompt

go to NodeJs Directory and Type

C:\ NodeJs>node app.js
Server running at http://127.0.0.1:1337/

Then go to your browser and type above address :) :) Enjoy

Categories: Programming

Implement Cache using PHP

July 23, 2012 Leave a comment

Cache is a very simple concept that can be used in a various web applications . A cache can be used for storing database queries for later use, to store rendered pages to be served again without generating them again, or to save indexed pages in a crawler application to be processed by multiple modules.

here will see how to implement Cache into your website

First of all, if you’re using sessions, you must disable session_cache_limiter (by setting it to noneor public). Headers it sends are the worst case of voodoo programming I’ve ever seen.

session_cache_limiter('none');

Then send Cache-Control: max-age=number_of_seconds and optionally equivalent Expires:header.

header('Cache-control: max-age='.(60*60*24*365));
header('Expires: '.gmdate(DATE_RFC1123,time()+60*60*24*365));

To get best cacheability, send Last-Modified header and reply with status 304 and empty body if browser sends If-Modified-Since header.

This is cheating a bit (doesn’t verify the date), but is valid as long as you don’t mind browsers keeping cached file forever:

if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
   header('HTTP/1.1 304 Not Modified');
   die();
}
Categories: Uncategorized

Upload image Using PHP and store name into MySQL Database

June 1, 2012 2 comments

Here I will show you how to upload the image using PHP . and  store that image into Specific folder and store the name of image intp Mysql database as well 

Before Start you need to create a database in your MySql Database . and you need to configure

1) Create a HTML Form and Copy this Code

<form method=”post” action=”addMember.php” >

<p>
Please Upload a Photo of the Member in gif or jpeg format. The file name should be named after the Members name. If the same file name is uploaded twice it will be overwritten! Maxium size of File is 35kb.
</p>
<p>
Photo:
</p>
<input type=”hidden” name=”size” value=”350000″>
<input type=”file” name=”photo”>

<input TYPE=”submit” name=”upload” title=”Add data to the Database” value=”Add Member”/>
</form>

2) You need to create another file = addMember.php and then copy below code

<?php

//This is the directory where images will be saved
$target = “your directory”;
$target = $target . basename( $_FILES['photo']['name']);

$pic=($_FILES['photo']['name']);

// Connects to your Database
mysql_connect(“yourhost”, “username”, “password”) or die(mysql_error()) ;
mysql_select_db(“dbName”) or die(mysql_error()) ;

//Writes the information to the database
mysql_query(“INSERT INTO tableName (photo)
VALUES (‘$pic’)”) ;

//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{

//Tells you if its all ok
echo “The file “. basename( $_FILES['uploadedfile']['name']). ” has been uploaded, and your information has been added to the directory”;
}
else {

//Gives and error if its not
echo “Sorry, there was a problem uploading your file.”;
}
?>

Enjoyyyyyyyyy

Categories: Uncategorized

One Page scrolling with Jquery

March 17, 2012 2 comments

nowadays vertically and horizontly scrolling websites are scattered around the net.
In this tutorial we will create a simple smooth scrolling effect with jQuery.We will be using the jQuery Easing Plugin and just a few lines of jQuery. So, let’s start!

HTML5

The html is actually pretty simple. You’ve seen the FAQ pages that have a list of questions at the top, and then you click one and it takes you to the middle of the page
<html>

<head>

<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.js”></script&gt;

<script src=”scroll.js” language=”javascript” type=”text/javascript”></script>
<link rel=”stylesheet” type=”text/css” href=”style.css” />

</head>
<body bgcolor=”#999999″>

<div id = “menubar”>
<ul style=” list-style: none;” id=”list-nav”>
<li> <a> <div class=”home-title”> Home </div> </a> </li>
<li> <a> <div class=”about-title”> About Me </div> </a> </li>
<li> <a> <div class=”contact-title”> Contact </div> </a> </li>
<li> <a> <div class=”blog-title”> Blog </div> </a> </li>
</ul>
</div>
<div id=”container”>
<div class=”home”>
<div class= “innerdiv” >Home</div>
</div>

<div class=”aboutme”>
<div class= “innerdiv”>About Me </div>
</div>

<div class=”contact”>
<div class= “innerdiv”>Contact</div>
</div>

<div class=”blog”>
<div class= “innerdiv”>Blog</div>
</div>
</div>

</body>

</html>

CSS

The CSS is also quite basic. First, we define the page colors and positioning for the header and paragraphs.

/******************** Main DIV****************/
.home, .aboutme, .contact, .blog{
padding:30px;
}

.home{
height:100%;
background-color:#999999;
margin-bottom:30px;
}

.aboutme{
height:100%;
background-color:#999999;
margin-bottom:30px;
}

.contact{
height:100%;
background-color:#999999;
margin-bottom:30px;
}

.blog{
height:100%;
background-color:#999999;
margin-bottom:30px;
}

.innerdiv{
height:96%;
border:2px solid;
border-radius: 10px;
background-color:#EEEEEE;
}
.home-title, .about-title, .contact-title, .blog-title{
cursor:pointer;
}

/**************** MENUBAR***********************/
#menubar{
text-align:center;
position: fixed;
margin-top: -28px;
margin-left: 280px;}

ul#list-nav {
margin:20px;
padding:0;
list-style:none;
width:525px;}

ul#list-nav li {
display:inline
}

ul#list-nav li a {
text-decoration:none;
padding:5px 0;
width:100px;
background:#abaaac;
color:#eee;
float:left;
}

Jquery

In order to make your page scroll up and down smoothly using jquery, just paste the following code into your html file.When you click a link in your site that takes you somewhere else within the same page it will slide smoothly.
The function for the horizontal scrolling effect is the following:

$(“document”).ready(function() {

$(‘.home-title’).click(function(){

$(‘html, body’).animate({
scrollTop: $(“.home”).offset().top
}, 1000);

});

$(‘.about-title’).click(function(){

$(‘html, body’).animate({
scrollTop: $(“.aboutme”).offset().top
}, 1000);

});

$(‘.contact-title’).click(function(){

$(‘html, body’).animate({
scrollTop: $(“.contact”).offset().top
}, 1000);

});

$(‘.blog-title’).click(function(){

$(‘html, body’).animate({
scrollTop: $(“.blog”).offset().top
}, 1000);

});

});
If you want to change the speed, go to the line that reads

“.animate({scrollTop: $(“.contact”).offset().top}, 1000); ”

and change the 1000 to whatever you want. (1000 = 1 seconds).

Categories: Programming
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: