Vous êtes sur la page 1sur 14

using System;

using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.NetworkInformation;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using DeadMosquito.AndroidGoodies;
//using OpenCVForUnity;
//using OpenCVForUnityExample;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class MobileCamera : MonoBehaviour


{
// Camera screenshotCamera;
public Camera camera;
private TextAsset asset;
//public Text txt;
private StreamWriter writer;

//private Texture errmsg;


[SerializeField]
Animator anim;
string ultreURL;
public MobileCamera fd;
private int ll = 0;
public string devid;
[SerializeField]

public Font f;
public GameObject neterror;
public GameObject neterror12;
public int ccv = 0;
public string Ddf;
private float k = 0;
private float k1 = 0;
private float k2 = 0;
public int cls = 0;
private float k5 = 0;
public int ta = 0;
//public int ll=0;
[SerializeField]
public string tables, tables1, tables14, tables141;
public float ratio;
public GameObject Tap;
public GameObject Wait;
string texturl;
public FileInfo theSourceFile11, theSourceFilechpl;
[SerializeField]
Animator myanim;
Renderer rend;
string ModifyURL = "0";
string lat; //Here we assign the first part t//o the name
string ddf1; //Here we assing the second part to the surname
string wid;
string ht; //Here we assing the second part to the surname
string Rota;
string[] splitArray;
string yuC;

// optical flow

public void Start()


{
//Application.OpenURL("www.google.com");

System.IO.File.WriteAllText(Application.persistentDataPath + "/" +
"Youtube.txt", null);
System.IO.File.WriteAllText(Application.persistentDataPath + "/" +
"Youtube.txt", ModifyURL);
FileInfo theSourceFile = new FileInfo(Application.persistentDataPath + "/"
+ "phnonote.txt");
//StreamReader reader = theSourceFile.OpenText();
//string texturl;
//texturl = reader.ReadToEnd();
if ((!theSourceFile.Exists) || (theSourceFile.Length == 0))
{

//if (texturl == null || texturl == " " ) {


SceneManager.LoadScene("Login", LoadSceneMode.Single);
}
theSourceFile11 = new FileInfo(Application.persistentDataPath + "/" +
"phnonote.txt");

FileInfo theSourceFilee = new FileInfo(Application.persistentDataPath + "/"


+ "ip.txt");
/*
if ((theSourceFilee.Exists) || (theSourceFilee.Length != 0)) {
//FileInfo theSourceFile = new FileInfo
(Application.persistentDataPath + "/" + "T.txt");
StreamReader reader14 = theSourceFilee.OpenText ();
string texturl14;
texturl14 = reader14.ReadToEnd ();
if (texturl14 != null) {
tables14=(texturl14.ToString());
//Debug.Log ("cc"+tables);
}
}*/
//tables14 = "9989898980";//(texturl14.ToString());
//anim.Play ("Siva");

print(Application.persistentDataPath);

public void tabclick()


{
// StartCoroutine(Fade());
StartCoroutine(CaptureCamera(camera, new Rect(Screen.width * 0f,
Screen.height * 0f, Screen.width * 1f, Screen.height * 1f)));
}

public IEnumerator mycsa()


{
yield return new WaitForSeconds(8.0f);
//Debug.Log ("SceneForwardSuccess");
//backCam.Stop();
//Caching.ClearCache ();
SceneManager.LoadScene("ScanAgain");
//Debug.Log ("MyGame");
}

public void Mycl()


{
StartCoroutine("mycsa");
Tap.SetActive(false);
Wait.SetActive(true);
myanim.Play("ScanCon");

private void Update()


{
//Screen.autorotateToLandscapeLeft = true;
//Screen.autorotateToLandscapeRight = true;

//StartCoroutine(Fade());

}
public IEnumerator CaptureCamera(Camera camera, Rect rect)
{
yield return new WaitForEndOfFrame();
Caching.ClearCache();

RenderTexture rt = new RenderTexture((int)rect.width, (int)rect.height, 0);

camera.targetTexture = rt;
camera.Render();

RenderTexture.active = rt;
Texture2D screenShot = new Texture2D((int)rect.width, (int)rect.height,
TextureFormat.RGB24, false);
//screenShot.SetPixels(Camera.GetPixels());
//screenShot.SetPixels(screenShot.GetPixels());
screenShot.ReadPixels(rect, 0, 0);
//screenShot.SetPixels(screenShot.GetPixels());
screenShot.Apply();

camera.targetTexture = null;

RenderTexture.active = null;
GameObject.Destroy(rt);
byte[] bytes = screenShot.EncodeToJPG();
string base64s = Convert.ToBase64String(bytes);
string filename = Application.persistentDataPath + "/Screenshot.jpg";
Debug.Log(Application.persistentDataPath);
System.IO.File.WriteAllBytes(filename, bytes);
string url = "http://34.231.33.25/phpcallasp/";
//string customUrl = url + "indexaspx.php";

string customUrl = url + "sample.php";

Debug.Log(tables1);

if ((theSourceFile11.Exists) || (theSourceFile11.Length != 0))


{
FileInfo theSourceFile = new FileInfo(Application.persistentDataPath +
"/" + "phnonote.txt");
StreamReader reader11 = theSourceFile11.OpenText();
string texturl11;
texturl11 = reader11.ReadToEnd();
if (texturl11 != null)
{
tables1 = (texturl11.ToString());
//Debug.Log ("cc"+tables);
}
}
//tables1 = "9899995555";// (texturl11.ToString());

//tables1 = 544445459;
//setup a form
WWWForm form = new WWWForm();
form.AddField("usd", base64s);
form.AddField("tables", "others");
form.AddField("phno", tables1);
Debug.Log("Check");

//print (bytes1);
WWW www = new WWW(customUrl, form);
Debug.Log("Wait ");
//if (Timer.Equals (10, 20)) {
yield return StartCoroutine(WaitForRequest(www));
Debug.Log("Wait for WWW");
}

public IEnumerator WaitForRequest(WWW www)


{ //Thread.Sleep (100);
yield return www;

// check for errors


if (www.error == null)
{

Ddf = www.text;
Debug.Log(Ddf);

if (Ddf != null)
{
if (Ddf.Contains("scanlimitover"))
{
Debug.Log("ScanLimit");
//backCam.Stop(); //SceneManager.UnloadScene("Game");

SceneManager.LoadScene("ScanLimit");
Debug.Log("ScanLimit");

//Debug.Log (Ddf);
}
Debug.Log("mydddf");
//StartCoroutine (Pla yStreamingVideo (Ddf));
if (Ddf.Length > 6000)
{ ///Texture video or chrome video
if (Ddf.Contains("_"))
{
//Ddf.Replace("_", "@");
int count = Ddf.Split('_').Length - 1;
if (count == 4)
{
Debug.Log("4");
splitArray = Ddf.Split(char.Parse("_")); //Here we
assing the splitted string to array by that char
//string[]
splitArray = Ddf.Split(char.Parse); //Here we assing the splitted string to array
by that char
lat = splitArray[0]; //Here we assign the first part
t//o the name
ddf1 = splitArray[1]; //Here we assing the second part
to the surname
wid = splitArray[2];
ht = splitArray[3]; //Here we assing the second part to
the surname
Rota = splitArray[4];
}
else
{
Debug.Log("5");
splitArray = Ddf.Split(char.Parse("_"));
lat = splitArray[0]; //Here we assign the first part
t//o the name//Base64
Debug.Log(lat);
ddf1 = splitArray[1]; //Here we assing the second part
to the surname
Debug.Log(ddf1);
yuC = splitArray[2];
ddf1 = ddf1 + "_" + yuC;
Debug.Log(ddf1);
wid = splitArray[3];
Debug.Log(wid);
ht = splitArray[4]; //Here we assing the second part to
the surname
Debug.Log(ht);
Rota = splitArray[5];
Debug.Log(Rota);

}
int width;
int height;
int.TryParse(wid, out width);
int.TryParse(ht, out height);
Texture2D tex = new Texture2D(width, height,
TextureFormat.RGB24, false);
byte[] sc = Convert.FromBase64String(lat);
tex.LoadImage(sc);
byte[] bytes = tex.EncodeToJPG();
Destroy(tex);

// For testing purposes, also write to a file in the


project folder
File.WriteAllBytes(Application.persistentDataPath + "/" +
"bear.jpg", bytes);
//backCam.Stop ();
Debug.Log(lat);
Debug.Log(ddf1);
Debug.Log(wid);
Debug.Log(ht);
System.IO.File.WriteAllText(Application.persistentDataPath
+ "/" + "base64.txt", null);
System.IO.File.WriteAllText(Application.persistentDataPath
+ "/" + "base64.txt", lat);
Thread.Sleep(20);

System.IO.File.WriteAllText(Application.persistentDataPath
+ "/" + "texvideowidth.txt", null);
System.IO.File.WriteAllText(Application.persistentDataPath
+ "/" + "texvideowidth.txt", wid);
System.IO.File.WriteAllText(Application.persistentDataPath
+ "/" + "texvideoht.txt", null);
System.IO.File.WriteAllText(Application.persistentDataPath
+ "/" + "texvideoht.txt", ht);

// SceneManager.LoadScene("MySelf", LoadSceneMode.Single);

if (Rota == "180")
{
if (ddf1.Contains("youtu"))
{

System.IO.File.WriteAllText(Application.persistentDataPath + "/" +
"YOUTUBETEXTURE.txt", null);

System.IO.File.WriteAllText(Application.persistentDataPath + "/" +
"YOUTUBETEXTURE.txt", ddf1);

//backCam.Stop();
//SceneManager.UnloadScene("Game");
//Caching.CleanCache();
//backCam.Stop();
SceneManager.LoadScene("MyYOUTUBE",
LoadSceneMode.Single);
}
else
{
/*

System.IO.File.WriteAllText(Application.persistentDataPath + "/" + "texvideo.txt",


null);

System.IO.File.WriteAllText(Application.persistentDataPath + "/" + "texvideo.txt",


ddf1);
//backCam.Stop();
SceneManager.LoadScene("MySelf",
LoadSceneMode.Single);*/

System.IO.File.WriteAllText(Application.persistentDataPath + "/" +
"YOUTUBETEXTURE.txt", null);

System.IO.File.WriteAllText(Application.persistentDataPath + "/" +
"YOUTUBETEXTURE.txt", ddf1);

//backCam.Stop();
//SceneManager.UnloadScene("Game");
//Caching.CleanCache();
//backCam.Stop();
SceneManager.LoadScene("MyYOUTUBE",
LoadSceneMode.Single);
}

//Application.LoadLevel (1);
Debug.Log("Texture180");
}
else
{

if (ddf1.Contains("youtu"))
{

System.IO.File.WriteAllText(Application.persistentDataPath + "/" +
"YOUTUBETEXTURE.txt", null);

System.IO.File.WriteAllText(Application.persistentDataPath + "/" +
"YOUTUBETEXTURE.txt", ddf1);

//backCam.Stop();
//SceneManager.UnloadScene("Game");
//Caching.CleanCache();
//backCam.Stop();
SceneManager.LoadScene("MyYOUTUBE00",
LoadSceneMode.Single);
}
else
{
/*

System.IO.File.WriteAllText(Application.persistentDataPath + "/" + "texvideo.txt",


null);

System.IO.File.WriteAllText(Application.persistentDataPath + "/" + "texvideo.txt",


ddf1);
// backCam.Stop();
SceneManager.LoadScene("MySelfFlat",
LoadSceneMode.Single);
Debug.Log("Texture90");*/

System.IO.File.WriteAllText(Application.persistentDataPath + "/" +
"YOUTUBETEXTURE.txt", null);
System.IO.File.WriteAllText(Application.persistentDataPath + "/" +
"YOUTUBETEXTURE.txt", ddf1);

//backCam.Stop();
//SceneManager.UnloadScene("Game");
//Caching.CleanCache();
//backCam.Stop();
SceneManager.LoadScene("MyYOUTUBE00",
LoadSceneMode.Single);
}

}
//Thread.Sleep (20);

//Application.LoadLevel (1);
}
else
{
splitArray = Ddf.Split(char.Parse("@")); //Here we assing
the splitted string to array by that char
//string[]
splitArray = Ddf.Split(char.Parse); //Here we assing the splitted string to array
by that char
int count = Ddf.Split('@').Length - 1;
if (count == 4)
{
Debug.Log("4");
splitArray = Ddf.Split(char.Parse("@")); //Here we
assing the splitted string to array by that char
//string[]
splitArray = Ddf.Split(char.Parse); //Here we assing the splitted string to array
by that char
lat = splitArray[0]; //Here we assign the first part
t//o the name
ddf1 = splitArray[1]; //Here we assing the second part
to the surname
wid = splitArray[2];
ht = splitArray[3]; //Here we assing the second part to
the surname
Rota = splitArray[4];
}
else
{
Debug.Log("5");
splitArray = Ddf.Split(char.Parse("@"));
lat = splitArray[0]; //Here we assign the first part
t//o the name//Base64
ddf1 = splitArray[1]; //Here we assing the second part
to the surname
yuC = splitArray[2];
ddf1 = ddf1 + "_" + yuC;
wid = splitArray[3];
ht = splitArray[4]; //Here we assing the second part to
the surname
Rota = splitArray[5];

}
int width;
int height;
int.TryParse(wid, out width);
int.TryParse(ht, out height);
Texture2D tex = new Texture2D(width, height,
TextureFormat.RGB24, false);
byte[] sc = Convert.FromBase64String(lat);
tex.LoadImage(sc);
byte[] bytes = tex.EncodeToJPG();
Destroy(tex);

// For testing purposes, also write to a file in the


project folder
File.WriteAllBytes(Application.persistentDataPath + "/" +
"bear.jpg", bytes);
Debug.Log(lat);
Debug.Log(ddf1);
Debug.Log(wid);
Debug.Log(ht);
System.IO.File.WriteAllText(Application.persistentDataPath
+ "/" + "base64.txt", null);
System.IO.File.WriteAllText(Application.persistentDataPath
+ "/" + "base64.txt", lat);
Thread.Sleep(20);
//
System.IO.File.WriteAllText(Application.persistentDataPath + "/" + "texvideo.txt",
null);

//System.IO.File.WriteAllText(Application.persistentDataPath + "/" +
"texvideo.txt", ddf1);
System.IO.File.WriteAllText(Application.persistentDataPath
+ "/" + "texvideowidth.txt", null);
System.IO.File.WriteAllText(Application.persistentDataPath
+ "/" + "texvideowidth.txt", wid);
System.IO.File.WriteAllText(Application.persistentDataPath
+ "/" + "texvideoht.txt", null);
System.IO.File.WriteAllText(Application.persistentDataPath
+ "/" + "texvideoht.txt", ht);

if (Rota == "180")
{
if (ddf1.Contains("youtu"))
{

System.IO.File.WriteAllText(Application.persistentDataPath + "/" +
"YOUTUBETEXTURE.txt", null);

System.IO.File.WriteAllText(Application.persistentDataPath + "/" +
"YOUTUBETEXTURE.txt", ddf1);

//backCam.Stop();
//SceneManager.UnloadScene("Game");
//Caching.CleanCache();
//backCam.Stop();
SceneManager.LoadScene("MyYOUTUBEGreen",
LoadSceneMode.Single);
}
else
{
/*
System.IO.File.WriteAllText(Application.persistentDataPath + "/" + "texvideo.txt",
null);

System.IO.File.WriteAllText(Application.persistentDataPath + "/" + "texvideo.txt",


ddf1);
// backCam.Stop();
SceneManager.LoadScene("MySelfGreen",
LoadSceneMode.Single);*/

System.IO.File.WriteAllText(Application.persistentDataPath + "/" +
"YOUTUBETEXTURE.txt", null);

System.IO.File.WriteAllText(Application.persistentDataPath + "/" +
"YOUTUBETEXTURE.txt", ddf1);

//backCam.Stop();
//SceneManager.UnloadScene("Game");
//Caching.CleanCache();
//backCam.Stop();
SceneManager.LoadScene("MyYOUTUBEGreen",
LoadSceneMode.Single);
}

//SceneManager.LoadScene("MySelfGreen",
LoadSceneMode.Single);
//Debug.Log ("Chrom180");

}
else
{
if (ddf1.Contains("youtu"))
{

System.IO.File.WriteAllText(Application.persistentDataPath + "/" +
"YOUTUBETEXTURE.txt", null);

System.IO.File.WriteAllText(Application.persistentDataPath + "/" +
"YOUTUBETEXTURE.txt", ddf1);

//backCam.Stop();
//SceneManager.UnloadScene("Game");
//Caching.CleanCache();
// backCam.Stop();
SceneManager.LoadScene("MyYOUFlatGreen",
LoadSceneMode.Single);
}
else
{
/*

System.IO.File.WriteAllText(Application.persistentDataPath + "/" + "texvideo.txt",


null);

System.IO.File.WriteAllText(Application.persistentDataPath + "/" + "texvideo.txt",


ddf1);
//backCam.Stop();
SceneManager.LoadScene("MySelfFlatGreen",
LoadSceneMode.Single);
Debug.Log("Texture90");
*/

System.IO.File.WriteAllText(Application.persistentDataPath + "/" +
"YOUTUBETEXTURE.txt", null);

System.IO.File.WriteAllText(Application.persistentDataPath + "/" +
"YOUTUBETEXTURE.txt", ddf1);

//backCam.Stop();
//SceneManager.UnloadScene("Game");
//Caching.CleanCache();
// backCam.Stop();
SceneManager.LoadScene("MyYOUFlatGreen",
LoadSceneMode.Single);
}

Debug.Log("Chrom90");

}
//Thread.Sleep (20);
//backCam.Stop();
}
//SceneManager.LoadScene("texavpro",LoadSceneMode.Single);

else if (Ddf.Contains(".mp4") || Ddf.Contains(".MP4"))


{ //open video player
string videosplit = Ddf.Replace("http", "$http");
string[] splitArray = videosplit.Split(char.Parse("$")); //Here
we assing the splitted string to array by that char

//string[] splitArray = Ddf.Split(char.Parse); //Here we assing the splitted


string to array by that char
string empty = splitArray[0]; //Here we assign the first part
t//o the name
string UrlOrig = splitArray[1];
Debug.Log(videosplit);
string ss = (AGDeviceInfo.MODEL).ToString();
string modelname = (AGDeviceInfo.MANUFACTURER).ToString();
Debug.Log("vivo" + ss);
/*
if ((ss.Contains("vivo")) || (ss.Contains("Vivo")) ||
(ss.Contains("VIVO")) || (ss.Contains("OPPO")) || (ss.Contains("Oppo")) ||
(ss.Contains("oppo")))
{

StartCoroutine(PlayStreamingVideoVIVO(UrlOrig));
//SceneManager.LoadScene ("MyGame");
}
else*/
//{
System.IO.File.WriteAllText(Application.persistentDataPath +
"/" + "YOUTUBETEXTURE.txt", null);
System.IO.File.WriteAllText(Application.persistentDataPath +
"/" + "YOUTUBETEXTURE.txt", UrlOrig);
Thread.Sleep(20);
// backCam.Stop();
SceneManager.LoadScene("NewUIExample", LoadSceneMode.Single);
// }

}
else if (Ddf.Contains("arhimaya") && Ddf.Contains("file1.php?") &&
Ddf.Contains("username") && Ddf.Contains("targetid"))
{ //open Photo Gallery
string CallYoutubeURL = Ddf;
System.IO.File.WriteAllText(Application.persistentDataPath +
"/" + "Youtube.txt", null);
System.IO.File.WriteAllText(Application.persistentDataPath +
"/" + "Youtube.txt", Ddf);
//backCam.Stop();
SceneManager.LoadScene("PhotoGallery");
//Application.OpenURL(Ddf);
}
else if (Ddf.Contains("tel:"))
{ //open Dialler
ll = 1;
//Int32 a;
//greenlaser = (Texture2D)Resources.Load ("lod");
k2 = 1; //Debug.Log (Ddf);
// backCam.Stop();

Application.OpenURL(Ddf);
Debug.Log("Tel");
if (k2 == 1)
{ //Debug.Log (Ddf);
SceneManager.LoadScene("Game");
Debug.Log("NoTel");
}
SceneManager.LoadScene("Game");
//Debug.Log (Ddf);
Debug.Log("NoTel");
}
else if (Ddf.Contains("youtu"))
{ //open youtube
ll = 1;
//Int32 a;
//greenlaser = (Texture2D)Resources.Load ("lod");
k1 = 1; //Debug.Log (Ddf);
// string[] YoutubeSplit = Ddf.Split(char.Parse("="));
//https://www.youtube.com/watch?v=dkxd7kgwiSU
//string youtubeURL = YoutubeSplit[1];
//string
CallYoutubeURL="https://www.youtube.com/embed/Qa3sHphE8LI?rel=0;autoplay=1";
// string CallYoutubeURL =
"https://www.arhimaya.com/arhimaya/youtubetest.php?youtube=" + youtubeURL;
System.IO.File.WriteAllText(Application.persistentDataPath +
"/" + "YOUTUBETEXTURE.txt", null);
System.IO.File.WriteAllText(Application.persistentDataPath +
"/" + "YOUTUBETEXTURE.txt", Ddf);
// System.IO.File.WriteAllText(Application.persistentDataPath +
"/" + "YOUTUBETEXTURE.txt", null);
// System.IO.File.WriteAllText(Application.persistentDataPath +
"/" + "YOUTUBETEXTURE.txt", Ddf);
//backCam.Stop(); //SceneManager.UnloadScene("Game");
//Caching.CleanCache();
//SceneManager.LoadScene("MyYOUTUBE", LoadSceneMode.Single);
SceneManager.LoadScene("NewUIExample");

//Application.OpenURL(Ddf);
//Debug.Log("Youtube");

// Debug.Log("Youtube");

//Debug.Log (Ddf);
}
else if (ll == 0 && Ddf.Contains("http"))
{ //open Webpage
k5 = 1;
Debug.Log("http");
// backCam.Stop();
// Application.OpenURL(Ddf);
System.IO.File.WriteAllText(Application.persistentDataPath +
"/" + "Youtube.txt", null);
System.IO.File.WriteAllText(Application.persistentDataPath +
"/" + "Youtube.txt", Ddf);
//backCam.Stop();
SceneManager.LoadScene("PhotoGallery");
//Application.OpenURL("www.google.com");

//Debug.Log ("Nohttp");

// SceneManager.LoadScene("Game");
}

}
}
else
{
Debug.Log("WWW Error: " + www.error);
}
}

private IEnumerator PlayStreamingVideo(string path)


{
k = 1;
// backCam.Stop();
Handheld.PlayFullScreenMovie(path);
Handheld.ClearShaderCache();
if (k == 1)
{
//Application.LoadLevel (1);
//Application.LoadLevel ("Game");
SceneManager.LoadScene("Game");
}
Ddf = null;
path = null;
yield return new WaitForEndOfFrame();
yield return new WaitForEndOfFrame();
Debug.Log("VideoPlaysbackCompleted");

}
private IEnumerator PlayStreamingVideoVIVO(string Videopath)
{
k = 1;
// backCam.Stop();
//Handheld.PlayFullScreenMovie(path);
Application.OpenURL(Videopath);
Handheld.ClearShaderCache();
if (k == 1)
{
Application.LoadLevel("Game");
}
Ddf = null;
Videopath = null;
yield return new WaitForEndOfFrame();
yield return new WaitForEndOfFrame();
Debug.Log("VideoPlaysbackCompleted");
Application.LoadLevel("Game");

Vous aimerez peut-être aussi