Find interesting stuff in Java, PHP and Dot Net.
Stop writing good code; Start writing Innovative code.
This site is from FUTURE. Science is powerful, but it cannot explain everything.
This site is for smart Primates & ROBOTS only (oh and A L I E N S).
Pages
- Home
- Send problem from my FaceBook Page
- Your FB bio/friends
- Auto Resume Broken File Uploader
- Screen Recorder
- Facebook App
- Screencast with Audio Capture
- Web Page Screen Capture As Image
- Add Watermark In Video
- Unique Code
- PDF Merger
- Unique Software
- Latest Posts
- Arbitrary Text in PDF
- MY ANDROID APP
- Torch in Android
Search This Blog
Top Ads
Thursday, March 11, 2010
Get number of invitations sent in Social engine 4
How to get number of invitations sent in Social engine 4.
In Social Engine you send invitation to your friends or any other person.
But you want to know that how many invitations you had beed sent.
Just use listed below my code, you will get the number of invitations which
you had sent.
<?php
if(Engine_Api::_()->user()->getViewer()->getIdentity()) {
$currentUserID=Engine_Api::_()->user()->getViewer()->getIdentity();
// or echo $viewer->getIdentity();
$sSqlInviter="select count(user_id) as totalInviterSent from engine4_inviter_invites where user_id=".$currentUserID;
$dbInviterSqli=Zend_Db_Table_Abstract::getDefaultAdapter();
$stmtInviter=$dbInviterSqli->query($sSqlInviter);
$rowInviter=$stmtInviter->fetch();
$totalInviterSent=$rowInviter['totalInviterSent'];
echo "<b> You have sent $totalInviterSent invitations yet.</b>";
} else {
echo "No, User is not login";
}
?>
Wednesday, March 10, 2010
Orbital chase paymentech gateway Mark for Capture
Orbital chase paymentech gateway Mark for Capture Request
<?php
$url = "https://orbitalvar2.paymentech.net"; // testing
//$url = "https://orbital1.paymentech.net"; // production
$post_string="
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<Request>
<MarkForCapture>
<OrbitalConnectionUsername>YOUR-USERNAME-HERE</OrbitalConnectionUsername>
<OrbitalConnectionPassword>YOUR-PASSWORD-HERE</OrbitalConnectionPassword>
<OrderID>123456789</OrderID>
<Amount>8500</Amount>
<BIN>000002</BIN>
<MerchantID>YOUR-MERCHANT-ID-HERE</MerchantID>
<TerminalID>001</TerminalID>
<TxRefNum>4F320B79F23280DAE62777C80721F838FF13548D</TxRefNum>
</MarkForCapture>
</Request>";
$header= "POST /authorize/ HTTP/1.0\r\n";
$header.= "MIME-Version: 1.0\r\n";
$header.= "Content-type: application/PTI\r\n";
$header.= "Content-length: " .strlen($post_string) . "\r\n";
$header.= "Content-transfer-encoding: text\r\n";
$header.= "Request-number: 1\r\n";
$header.= "Document-type: Request\r\n";
$header.= "Interface-Version: Test 1.4\r\n";
$header.= "Connection: close \r\n\r\n";
$header.= $post_string;
//// just initialize curl here and post the data to the orbital server.
?>
<?php
$url = "https://orbitalvar2.paymentech.net"; // testing
//$url = "https://orbital1.paymentech.net"; // production
$post_string="
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<Request>
<MarkForCapture>
<OrbitalConnectionUsername>YOUR-USERNAME-HERE</OrbitalConnectionUsername>
<OrbitalConnectionPassword>YOUR-PASSWORD-HERE</OrbitalConnectionPassword>
<OrderID>123456789</OrderID>
<Amount>8500</Amount>
<BIN>000002</BIN>
<MerchantID>YOUR-MERCHANT-ID-HERE</MerchantID>
<TerminalID>001</TerminalID>
<TxRefNum>4F320B79F23280DAE62777C80721F838FF13548D</TxRefNum>
</MarkForCapture>
</Request>";
$header= "POST /authorize/ HTTP/1.0\r\n";
$header.= "MIME-Version: 1.0\r\n";
$header.= "Content-type: application/PTI\r\n";
$header.= "Content-length: " .strlen($post_string) . "\r\n";
$header.= "Content-transfer-encoding: text\r\n";
$header.= "Request-number: 1\r\n";
$header.= "Document-type: Request\r\n";
$header.= "Interface-Version: Test 1.4\r\n";
$header.= "Connection: close \r\n\r\n";
$header.= $post_string;
//// just initialize curl here and post the data to the orbital server.
?>
Monday, February 22, 2010
Java File Upload With Broken Resume and ProgressBar
Java File Upload With Broken Resume and ProgressBar
Internet connection broken is the very common problem with of all us.
When we all upload large/small file, we need uninterrupted internet connection supply.
If net connection breaks, then need to upload files again. And if net break many times during Uploading file then need many times to upload file.
I have faced this problem many-many times, I was uploading very huge size data.
It is very time taking, frustrating to upload one file many times.
So I have created this file uploader which having resume facility, it will upload file from the position, where net connection was broken. I have created it in three very popular web languages.
1) JSP/SERVLET
2) PHP
3) ASP.NET (CS, VB)
===================
How to Test?
===================
You can test it, just setup this uploader in you server,
I have given the code in the three languages which are widely used in computer world.
1) JSP/SERVLET,
2) PHP
3) ASP.NET (VB/CS) and made each directory for that.
When uploader upload the file, it will show the progress bar and percentage of data for ex: 1%, 10% etc.
Now this is the time for test, just unplugged you internet cable, then you can see after 4 or 10 second one button's text will be changed in this text "Resume" and a message will be appeared" net connection is broken click on resume button to process".
Now plugged in the internet cable and click on “Resume Button”.
Uploader will start from the position from where net connection was disconnected.
=============================
What we need for this Uploader?
=============================
Only Latest JRE, you can find/download it from Sun Site.
=================================
Where is Other Instruction?
=================================
I have made each instruction readme.txt in the JSP, SERVELT, DOTNET, CS, VB, PHP directory. Just read that file.
-Amit
Internet connection broken is the very common problem with of all us.
When we all upload large/small file, we need uninterrupted internet connection supply.
If net connection breaks, then need to upload files again. And if net break many times during Uploading file then need many times to upload file.
I have faced this problem many-many times, I was uploading very huge size data.
It is very time taking, frustrating to upload one file many times.
So I have created this file uploader which having resume facility, it will upload file from the position, where net connection was broken. I have created it in three very popular web languages.
1) JSP/SERVLET
2) PHP
3) ASP.NET (CS, VB)
===================
How to Test?
===================
You can test it, just setup this uploader in you server,
I have given the code in the three languages which are widely used in computer world.
1) JSP/SERVLET,
2) PHP
3) ASP.NET (VB/CS) and made each directory for that.
When uploader upload the file, it will show the progress bar and percentage of data for ex: 1%, 10% etc.
Now this is the time for test, just unplugged you internet cable, then you can see after 4 or 10 second one button's text will be changed in this text "Resume" and a message will be appeared" net connection is broken click on resume button to process".
Now plugged in the internet cable and click on “Resume Button”.
Uploader will start from the position from where net connection was disconnected.
=============================
What we need for this Uploader?
=============================
Only Latest JRE, you can find/download it from Sun Site.
=================================
Where is Other Instruction?
=================================
I have made each instruction readme.txt in the JSP, SERVELT, DOTNET, CS, VB, PHP directory. Just read that file.
-Amit
Wednesday, February 17, 2010
Convert an EPS file in to JPEG in ASP.net
Convert an EPS file in to JPEG in ASP.net
Here is the asp.net code, which convert .eps file to .jpeg file.
Just download here
Here is the asp.net code, which convert .eps file to .jpeg file.
Just download here
Friday, January 29, 2010
Post all values with variables in data section of jquery ajax
Post all values with variables in data section of jQuery ajax
HTML PART
<script type="text/javascript" src="../js/jquery-1.6.js"></script>
<input type="button" name="postButton" id="postButton" value="Do Add" onclick="doAddAction();"/>
<script language="javascript">
function doAddAction() {
var a1,a2,a3;
var a1Val,a2Val,a3Val;
var urlStr="xmlPost.php";
var postOrGet="POST";
var ans;
a1Val="This is a1 val";
a2Val="This is a2 val";
a3Val="This is a3 val";
var variableAndValue={a1:a1Val,a2:a2Val,a3:a3Val};
ans=doAdd(urlStr,postOrGet,variableAndValue);
alert(ans);
}
function doAdd(urlStr,POSTorGET,variableAndValue) {
var ans="";
$.ajax( {
type: POSTorGET,
async: false,
url: urlStr,
data: variableAndValue,
timeout: 9999,
cache:false,
success: function(msg){ans=msg;},
error: function(xhr) {
if (xhr.responseText)
ans=xhr.responseText;
else
ans="I don't know! My Processor Has Been HACKED!";
}
}
);
return ans;
}
Php or any other language part:
<?php
$a1=$_POST['a1'];
$a2=$_POST['a2'];
$a3=$_POST['a3'];
$val=$a1."=".$a2."=".$a3;
if($a1!="" && $a2!="" && $a3!="")
echo "<br/>Hi ".$val;
else
echo "Hi There are no any value";
?>
HTML PART
<script type="text/javascript" src="../js/jquery-1.6.js"></script>
<input type="button" name="postButton" id="postButton" value="Do Add" onclick="doAddAction();"/>
<script language="javascript">
function doAddAction() {
var a1,a2,a3;
var a1Val,a2Val,a3Val;
var urlStr="xmlPost.php";
var postOrGet="POST";
var ans;
a1Val="This is a1 val";
a2Val="This is a2 val";
a3Val="This is a3 val";
var variableAndValue={a1:a1Val,a2:a2Val,a3:a3Val};
ans=doAdd(urlStr,postOrGet,variableAndValue);
alert(ans);
}
function doAdd(urlStr,POSTorGET,variableAndValue) {
var ans="";
$.ajax( {
type: POSTorGET,
async: false,
url: urlStr,
data: variableAndValue,
timeout: 9999,
cache:false,
success: function(msg){ans=msg;},
error: function(xhr) {
if (xhr.responseText)
ans=xhr.responseText;
else
ans="I don't know! My Processor Has Been HACKED!";
}
}
);
return ans;
}
Php or any other language part:
<?php
$a1=$_POST['a1'];
$a2=$_POST['a2'];
$a3=$_POST['a3'];
$val=$a1."=".$a2."=".$a3;
if($a1!="" && $a2!="" && $a3!="")
echo "<br/>Hi ".$val;
else
echo "Hi There are no any value";
?>
Wednesday, January 13, 2010
encrypt and decrypt in mysql
First you need to create the fields and that fields must be varbinary or blob type and length also must be at least 128 characters long.
aes_encrypt(VALUE,'mykey')
aes_decrypt(COLUMN NAME, 'mykey')
INSERT INTO userinfo(add1) VALUES (aes_encrypt('my address','mykey'))
SELECT aes_decrypt(add1, 'mykey') FROM userinfo
aes_encrypt(VALUE,'mykey')
aes_decrypt(COLUMN NAME, 'mykey')
INSERT INTO userinfo(add1) VALUES (aes_encrypt('my address','mykey'))
SELECT aes_decrypt(add1, 'mykey') FROM userinfo
Wednesday, December 30, 2009
Post Xml data without form in JSP and receive
How to post xml data in JSP page without form field and get it's data
in the next JSP page.
The first file post-data.jsp is just taking xml data form xml file and
sending xml data as a post to the get-post.jsp page.
Find Full Solution Here:
http://agalaxycode.blogspot.in/2014/07/post-xml-data-without-form-in-jsp-and.html
in the next JSP page.
The first file post-data.jsp is just taking xml data form xml file and
sending xml data as a post to the get-post.jsp page.
Find Full Solution Here:
http://agalaxycode.blogspot.in/2014/07/post-xml-data-without-form-in-jsp-and.html
first file is:
post-data.jsp
--------------
< %@ page import="java.net.*" % >
< %@ page import="java.io.*" % >
< %@ page import="java.util.*" % >
< %@ page import="java.text.*" % >
< %
try
{
URL u;
u = new URL("http://localhost:9292/post/get-post.jsp");
// get the xml data from xml file which you want to post
String inputFileName="C:\\temp1.xml";
FileReader filereader =new FileReader(inputFileName);
BufferedReader bufferedreader=new BufferedReader(filereader);
String initial=bufferedreader.readLine();
String finalData=new String();
while(initial!=null)
{
finalData=finalData+initial;
initial=bufferedreader.readLine();
}
String s=(finalData.toString());
HttpURLConnection uc = (HttpURLConnection)u.openConnection();
uc.setRequestMethod("POST");
uc.setDoOutput(true);
uc.setDoInput(true);
uc.setRequestProperty("Content-Type", "text/xml; charset=\"utf-8\"");
uc.setAllowUserInteraction(false);
DataOutputStream dstream = new DataOutputStream(uc.getOutputStream());
dstream.writeBytes(s);
dstream.close();
InputStream in = uc.getInputStream();
BufferedReader r = new BufferedReader(new InputStreamReader(in));
StringBuffer buf = new StringBuffer();
String line;
while ((line = r.readLine())!=null) {
buf.append(line);
}
in.close();
out.println(buf.toString());
}
catch (IOException e)
{
out.println(e.toString());
}
% >
Second file is:
get-post.jsp
-----------------
< %@ page import="java.util.*" % >
< %
String postedData = request.getReader().readLine();
///// perform here your operation for postedData
out.println("Posted Data is ");
out.println(postedData);
% >
post-data.jsp
--------------
< %@ page import="java.net.*" % >
< %@ page import="java.io.*" % >
< %@ page import="java.util.*" % >
< %@ page import="java.text.*" % >
< %
try
{
URL u;
u = new URL("http://localhost:9292/post/get-post.jsp");
// get the xml data from xml file which you want to post
String inputFileName="C:\\temp1.xml";
FileReader filereader =new FileReader(inputFileName);
BufferedReader bufferedreader=new BufferedReader(filereader);
String initial=bufferedreader.readLine();
String finalData=new String();
while(initial!=null)
{
finalData=finalData+initial;
initial=bufferedreader.readLine();
}
String s=(finalData.toString());
HttpURLConnection uc = (HttpURLConnection)u.openConnection();
uc.setRequestMethod("POST");
uc.setDoOutput(true);
uc.setDoInput(true);
uc.setRequestProperty("Content-Type", "text/xml; charset=\"utf-8\"");
uc.setAllowUserInteraction(false);
DataOutputStream dstream = new DataOutputStream(uc.getOutputStream());
dstream.writeBytes(s);
dstream.close();
InputStream in = uc.getInputStream();
BufferedReader r = new BufferedReader(new InputStreamReader(in));
StringBuffer buf = new StringBuffer();
String line;
while ((line = r.readLine())!=null) {
buf.append(line);
}
in.close();
out.println(buf.toString());
}
catch (IOException e)
{
out.println(e.toString());
}
% >
Second file is:
get-post.jsp
-----------------
< %@ page import="java.util.*" % >
< %
String postedData = request.getReader().readLine();
///// perform here your operation for postedData
out.println("Posted Data is ");
out.println(postedData);
% >
Tuesday, December 29, 2009
Post Xml data without form in PHP and receive
How to post Xml data without form in PHP and receive
=====================================================
If it is not working in localhost/localsystem, try to run it in from live server.
here is the first file which will send xml data
vp-post4.php
-------------
< ? php
#get the xml data from xml file which you want to post
$xml = file_get_contents("temp1.xml");
$context = stream_context_create(array('http' => array(
'method' => "POST",
'header' => "Content-Type: text/xml",
'content' => $xml
)));
// put here host name with page name.
// if it is not working in local try to run it in live server.
$file = file_get_contents("http://localhost:90/post/vp-postget4.php", false, $context);
echo $file;
?>
here is the second file which will receive xml data
vp-postget4.php
-------------------
< ? php
$xml = file_get_contents("php://input");
// perform here your operation for received xml data
/////// .....
/////// .....
echo "received data is : ".$xml;
?>
=====================================================
If it is not working in localhost/localsystem, try to run it in from live server.
here is the first file which will send xml data
vp-post4.php
-------------
< ? php
#get the xml data from xml file which you want to post
$xml = file_get_contents("temp1.xml");
$context = stream_context_create(array('http' => array(
'method' => "POST",
'header' => "Content-Type: text/xml",
'content' => $xml
)));
// put here host name with page name.
// if it is not working in local try to run it in live server.
$file = file_get_contents("http://localhost:90/post/vp-postget4.php", false, $context);
echo $file;
?>
here is the second file which will receive xml data
vp-postget4.php
-------------------
< ? php
$xml = file_get_contents("php://input");
// perform here your operation for received xml data
/////// .....
/////// .....
echo "received data is : ".$xml;
?>
Wednesday, December 16, 2009
Get current logged user user_id in Social Engine 4
How to get current logged user user_id in Social Engine 4
As you know that Social engine used Zend framework.
In any page if you need current logged in user's user_id then you can find it via this
one piece of line code:
$currentUserID=Engine_Api::_()->user()->getViewer()->getIdentity();
echo $currentUserID;
now current logged in user's id stored in the variable $currentUserID,
you can use it in your code as you want.
Info tab is not working in Social Engine 4
Member Info tab is not working in Social Engine
4
I was working fix bugs in social engine 4. There were lot of bugs, but the one bug was very strange. When any user logon and see own profile by clicking on “My Profile” link.
I have solved it. If you are facing the same problem then make the listed below changes:
I was working fix bugs in social engine 4. There were lot of bugs, but the one bug was very strange. When any user logon and see own profile by clicking on “My Profile” link.
A sub menu tab is show with “Updated”, “Notes”, “My Contacts
Groups” etc.
The sub menu tab “Updated”, “Notes”, “My Contacts Groups”
are working but after the rest all sub tabs for ex: “Info”, “Contacts”,
“Albums” and in “More+” dropdown tabs links were not working.
The same problem was occurring when any logged in user see his/her
friend’s or other user’s profile, that’s information were not coming.
I have solved it. If you are facing the same problem then make the listed below changes:
1) Open the file container-tabs's Controller.php file
2) Goto line number 56 and search the listed below code:
$childrenContent .= $child->render() . PHP_EOL;
3) Make it comment:
//$childrenContent .= $child->render() . PHP_EOL;
4) and paste listed below code:
if($child->getIdentity()=="945")
{
$cntDivStart=count(explode("<div",
$child->render()))-1;
$cntDivEnd=count(explode("</div",
$child->render()))-1;
if($cntDivEnd<$cntDivStart)
{
$childrenContent .=
$child->render() ."</div>". PHP_EOL;
} else {
$childrenContent .=
$child->render() . PHP_EOL;
}
} else {
$childrenContent
.= $child->render() . PHP_EOL;
}
Sunday, November 22, 2009
Java file upload applet.
I have created a Two java file upload applet, in one applet just select one directory and all the files in that directory will be uploaded in the server.
And in the other Applet you can upload large file size (GBs) to the server.
And in the other Applet you can upload large file size (GBs) to the server.
How to connect Sql Server 2005 in Java
import java.sql.*;
///////////////////////////////////////////////////////////////////////////
//1) download sel server 2005 driver from :
//http://msdn.microsoft.com/en-us/data/aa937724.aspx
//OR
//http://www.microsoft.com/downloads/details.aspx?FamilyID=99b21b65-e98f-4a61-b811-19912601fdc9&displaylang=en
//2) set sqljdbc4.jar in your class path.
//3) and run the code.
// By: Amit
//////////////////////////////////////////////////////////////////////////
public class SqlSvrConn
{
public static void main(String[] srg)
{
String driverName= "com.microsoft.sqlserver.jdbc.SQLServerDriver";
//String dbURL = "jdbc:sqlserver://PUT-SQLSERVER-IP-HERE:1433;DatabaseName=PUTDATABASENAMEHERE";
String dbURL = "jdbc:sqlserver://230.100.100.100:1433;DatabaseName=TestDB";
String userName="myusername";
String userPwd="mypassword";
Connection dbConn;
try
{
Class.forName(driverName);
dbConn = DriverManager.getConnection(dbURL,userName,userPwd);
System.out.println("Connection Successful!");
Statement sta = dbConn.createStatement();
ResultSet res = sta.executeQuery("SELECT TOP 10 * FROM emp");
System.out.println("Customers");
while (res.next()) {
String firstName = res.getString("nName");
String emailName = res.getString("Emailid");
System.out.println(" "+firstName+" "+emailName);
}
dbConn.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
///////////////////////////////////////////////////////////////////////////
//1) download sel server 2005 driver from :
//http://msdn.microsoft.com/en-us/data/aa937724.aspx
//OR
//http://www.microsoft.com/downloads/details.aspx?FamilyID=99b21b65-e98f-4a61-b811-19912601fdc9&displaylang=en
//2) set sqljdbc4.jar in your class path.
//3) and run the code.
// By: Amit
//////////////////////////////////////////////////////////////////////////
public class SqlSvrConn
{
public static void main(String[] srg)
{
String driverName= "com.microsoft.sqlserver.jdbc.SQLServerDriver";
//String dbURL = "jdbc:sqlserver://PUT-SQLSERVER-IP-HERE:1433;DatabaseName=PUTDATABASENAMEHERE";
String dbURL = "jdbc:sqlserver://230.100.100.100:1433;DatabaseName=TestDB";
String userName="myusername";
String userPwd="mypassword";
Connection dbConn;
try
{
Class.forName(driverName);
dbConn = DriverManager.getConnection(dbURL,userName,userPwd);
System.out.println("Connection Successful!");
Statement sta = dbConn.createStatement();
ResultSet res = sta.executeQuery("SELECT TOP 10 * FROM emp");
System.out.println("Customers");
while (res.next()) {
String firstName = res.getString("nName");
String emailName = res.getString("Emailid");
System.out.println(" "+firstName+" "+emailName);
}
dbConn.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Wednesday, November 11, 2009
get name of module, controller and method/action in Zend Framework
// How to get name of module, controller and method/action in Zend Framework.
<?php
// How to get name of module, controller and method/action in Zend Framework.
$front1 = Zend_Controller_Front::
getInstance();
$module1 = $front1->getRequest()-> getModuleName();
$controller1 = $front1->getRequest()-> getControllerName();
$action1 = $front1->getRequest()-> getActionName();
echo "<br/><br/>".$module1;
echo "<br/><br/>".$controller1;
echo "<br/><br/>".$action1;
?>
<?php
// How to get name of module, controller and method/action in Zend Framework.
$front1 = Zend_Controller_Front::
$module1 = $front1->getRequest()->
$controller1 = $front1->getRequest()->
$action1 = $front1->getRequest()->
echo "<br/><br/>".$module1;
echo "<br/><br/>".$controller1;
echo "<br/><br/>".$action1;
?>
Friday, October 23, 2009
Password secure MD5 in JSP
Password secure as MD5 in JSP
<%@page import="java.security.MessageDigest"%>
<%!
public String inc(String passwd) {
StringBuffer sb = new StringBuffer();
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.reset();
md.update(passwd.getBytes());
byte[] digest = md.digest();
String hex;
for (int i=0;i<digest.length;i++){
hex = Integer.toHexString(0xFF & digest[i]);
if(hex.length() == 1){hex = "0" + hex;}
sb.append(hex);
}
} catch(Exception ee) {
}
return sb.toString();
}
%>
<%
String passwd = "superadmin",inc_pass="";
inc_pass=inc(passwd);
out.print(inc_pass);
%>
<%@page import="java.security.MessageDigest"%>
<%!
public String inc(String passwd) {
StringBuffer sb = new StringBuffer();
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.reset();
md.update(passwd.getBytes());
byte[] digest = md.digest();
String hex;
for (int i=0;i<digest.length;i++){
hex = Integer.toHexString(0xFF & digest[i]);
if(hex.length() == 1){hex = "0" + hex;}
sb.append(hex);
}
} catch(Exception ee) {
}
return sb.toString();
}
%>
<%
String passwd = "superadmin",inc_pass="";
inc_pass=inc(passwd);
out.print(inc_pass);
%>
Subscribe to:
Posts (Atom)
