-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathudpf.html
More file actions
2084 lines (1857 loc) · 61.6 KB
/
udpf.html
File metadata and controls
2084 lines (1857 loc) · 61.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en-US">
<head>
<title> UDPF :Custome Php and Java script Function </title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="Keywords" content="Custom function,Php function, Js function, Site Tamplets">
<meta name="Description" content=" Some personilized user define function of Php Java Script which we can use
to make our php progaming experience easy and better. As example function are scan_fiels(),
curl_browser(), querry_data(), path_url(), header_respoance_arry(),querry_arry() and sub_string()">
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="css.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<meta name="google-site-verification" content="BXMRPVIqBc6klGm5IRLJPPBuroKX8olXUWH0DOMg4so" />
<link rel="stylesheet" href="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.12.0/build/styles/default.min.css">
<script src="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.12.0/build/highlight.min.js"></script>
<script src="tools.js" ></script>
<script>
/////////// syntex hylighter
hljs.initHighlightingOnLoad();
/////////// syntex hylighter end
///////// vav top
window.onscroll = function() {hederbar()};
function hederbar() {
if ( document.documentElement.scrollTop > 120) {
document.getElementById("hb").className = "w3-top nav-top w3-bar w3-center w3-black";
} if (document.documentElement.scrollTop <76 ) {
document.getElementById("hb").className = "nav w3-bar w3-center w3-black";
}
}
///////// vav top end
//////tablink
function tabswitcher(evt, cityName) {
var i, x, tablinks;
x = document.getElementsByClassName("tab");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablink");
for (i = 0; i < x.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" w3-green", "");
}
document.getElementById(cityName).style.display = "block";
evt.currentTarget.className += " w3-green";
}
//////tablink end
//random image
window.onload = function()
{
randombg("home",home);
randombg("hb",hb);
randombg("hhhhh",header);
randombg("footer",footer);
}
//////////
</script>
<style>
.nav-top
{
max-width:100%;
margin: auto;
height:auto;
overflow:hidden;
margin-top:0px;
margin-bottom:0px
}
.nav
{
max-width:95%;
margin: auto;
height:auto;
overflow:hidden;
margin-top:1px;
margin-bottom:0px
}
</style>
</head>
<body id="body" class="mycss-bg">
<!-- header-->
<header id="hhhhh" class="mycss-big-container" style="max-width:95%; height:120px;margin-top:0px; margin-bottom:0px; background-color:rgba(10, 11, 11, 0.24);">
<img src="logo.png" width="75px" height="76px">
<p class="mycss-cloud-text" >UDPF: User Define Presonal Functions</p>
</header>
<!-- header End -->
<!-- header-->
<div id="hb" class=" w3-bar nav w3-center w3-black">
<button class="w3-bar-item w3-button tablink w3-green" onclick="tabswitcher(event,'home')">Home</button>
<button class="w3-bar-item w3-button tablink" onclick="tabswitcher(event,'php')">PHP</button>
<button class="w3-bar-item w3-button tablink" onclick="tabswitcher(event,'js')">JS</button>
<button class="w3-bar-item w3-button tablink" onclick="tabswitcher(event,'youtube')">Youtube</button>
<button class="w3-bar-item w3-button tablink" onclick="tabswitcher(event,'jiosaavanpro')">JIOSaavan-Pro</button>
<button class="w3-bar-item w3-button tablink" onclick="tabswitcher(event,'hungamapro')">Hungama-Pro</button>
</div>
<!-- home tab -->
<!-- content -->
<div id="home" class="mycss-big-container tab w3-gray w3-text-white" style="max-width:95%; height:auto; margin-top:5px; margin-bottom:05px;">
<!-- content Start-->
<!-- about us-->
<h4><i><b>About Us</b></i></h4>
<p>
<b>UDPF</b> stand for " <b>User Defined Personal Functions</b> " . On this portal there are some Php and Java Script function . In the future we will also make to avalable some more cool user define function(s) . Really I make sure you will love this functions.
</p>
<!-- about us end -->
<!-- download-->
<h4><i><b>Download</b></i></h4>
<p><i><b>Php</b></i></p>
<b >Github:</b><a href="https://github.com/udpf/php_function_tools">Download</a><br>
<b >Inserver</b><a href="http://wbut.co.nf/php_function/tools">Download</a><br>
<br>
<p><i><b>Js:</b></i></p>
<b >Github:</b><a href="https://github.com/udpf/js_function_tools">Download</a><br>
<b >Inserver</b><a href="http://wbut.co.nf/js_function/tools.js">Download</a><br>
<br>
<p><i><b>Youtube:</b></i></p>
<b >Github:</b><a href="https://github.com/udpf/youtube_function">Download</a><br>
<b >Inserver</b><a href="http://wbut.co.nf/js_function/youtube.js">Download</a><br>
<!-- php function list-->
<h4><i><b>List of Php Function(s)</b></i></h4>
<div class="w3-container">
<div class="w3-half" >
<li>php_browser()</li>
<li>scan_files()</li>
<li>query_data()</li>
<li>path_url()</li>
<li>header_responce_arry()</li>
<li>query_arry()</li>
<li> sub_string()</li>
</div>
</div>
<!-- php function list end -->
<!-- js function list-->
<h4><i><b>List of Js Function(s)</b></i></h4>
<div class="w3-container">
<div class="w3-half" >
<li>js_browser()</li>
<li>auto_refresh()</li>
<li>var_dum()</li>
<li>print_r()</li>
<li>echo()</li>
<li>json_encode()</li>
<li>json_decode()</li>
<li>query_data()</li>
</div>
<div class="w3-half" >
<li>count()</li>
<li>sub_string()</li>
<li>isset()</li>
<li>urlencode()</li>
<li>urldecode()</li>
<li>parse_str()</li>
<li>explode()</li>
</div>
</div>
<!-- js function list end -->
<!-- Contact -->
<h4><i><b>Contact Us</b></i></h4>
<p>
For any kind of help related to progaming (php and js only) and Queary related to this function(s) you can contact me by- <br>
<b>Email :</b> admin@udpf.dx.am <br>
</p>
<!-- Contact end -->
<!-- content start End-->
</div>
<!-- content End -->
<!-- home tab end -->
<!-- php tab -->
<!-- content -->
<div id="php" class="mycss-big-container tab" style="max-width:95%; height:auto; margin-top:0px; margin-bottom:05px;display:none;">
<!-- content Start-->
<div>
<h4><i><b>How To Use</b></i></h4>
<p>There are three methods to use it.</p>
<p><i><b>First method</b></i></p>
<p>If you have acess to "php.ini" file.<br>
Then enable url file include. if it ebabled then ok.<br>
By default it is off.<br>
Enable it by adding "allow_url_include=1;" text to "php.ini" page.<br>
After that include "include "http://wbut.co.nf/php_function/tools";" in script(s) page.</p>
<pre>
<code>
<? php
include "http://wbut.co.nf/php_function/tools";
/*
Rest Of Code
*/
?>
</code>
</pre>
<p><i><b>Second Method</b></i></p>
<p> Download script from "https://github.com/udpf/php_function_tools" .<br>
Upload to your server.<br>
After that include "include "/location/tools.php";" in script(s) page.<br>
Use is as local function.</p>
<pre>
<code>
<? php
include "/php_function/tools";
?>
</code>
</pre>
<p><i><b>Third Method</b></i></p>
<p>This is simple method to use .<br>
Copy the required functon and paste it in your script and use it as we use user define function.
</p>
<pre>
<code>
<? php
function sub_string($op,$top,$top_no,$botom,$botom_no)
{
$Sp1=strpos($op,$top)+$top_no;
$ss1=substr($op,$Sp1);
///
$Sp2=strpos($ss1,$botom)-$botom_no;
return substr($ss1,0,$Sp2);
}
echo sub_string($op,$top,$top_no,$botom,$botom_no);
?>
</code>
</pre>
</div>
<h4><i><b>Function(s)</b></i></h4>
<div>
<p><i><b>1. scan_files($rootDir)</b></i></p>
<p> Return - Array </p>
<p>$rootDir -string- Name of the directory from where we want to scan folder. Only its subfolder will we scaned. </p>
<pre>
<code>
<? php
function scan_files($rootDir, $allData=array())
{
// set filenames invisible if you want
$invisibleFileNames = array(".", "..","bhuv.mp4", ".htaccess", ".htpasswd");
// run through content of root directory
$dirContent = scandir($rootDir);
foreach($dirContent as $key => $content)
{
// filter all files not accessible
$path = $rootDir.'/'.$content;
if(!in_array($content, $invisibleFileNames))
{
// if content is file & readable, add to array
if(is_file($path) && is_readable($path))
{
// save file name with path
$allData[]["name"] = $content;
$allData[]["url"] = $path;
// if content is a directory and readable, add path and name
}
elseif(is_dir($path) && is_readable($path))
{
// recursive callback to open new directory
$allData[$content]= scan_files($path, $allData[$content]);
}
}
}
return $allData;
}
?>
</code>
</pre>
<p>Example</p>
<pre>
<code>
<? php
include "/php_function/tools";
print_r( scan_files("./")); //same folder in which function is run in page.
//print_r( scan_files("../")); // one step back folder function cantain in script.
//print_r(scan_files("/storage/emulated/0/www/")); // it will scan leaving "www" folder.
//print_r(scan_files("/storage/emulated/0/www")); // it will scan including "www" folder.
Array
(
[0] => Array
(
[name] => ajktv
)
[1] => Array
(
[url] => .//ajktv
)
[cookies] => Array
(
[0] => Array
(
[name] => cookie.txt
)
[1] => Array
(
[url] => .//cookies/cookie.txt
)
)
[2] => Array
(
[name] => newfile.php
)
[3] => Array
(
[url] => .//newfile.php
)
)
?>
</code>
</pre>
</div>
<div>
<p><i><b>2. curl_browser($url, "post", $postdata, $header, "proxy", "IN", "cookies")</b></i></p>
<p> curl_browser($url, "$request_method", $postdata, $header, "proxy", "IN", "cookies", "data_type")</p>
<p> Return - Array, string </p>
<p>$url -string- url (full url for external url relative url for local url)</p>
<p>$request_method - string-get, post (presently only two method get and post are supported). for get we can leave blank. </p>
<p>$postdata -string- In post request provide post data value
in get request live it blank</p>
<p>$header -Array-To use default header leave it blank. or to use customized header provide header</p>
<p>proxy -string_constant- use woed "proxy" to make connection throught proxy server. leve it blank to to not use proxy server</p>
<p>"In" -string_constant- if we thave enable proxy than only it is valid aotrher wise it is invalid to use. if it is blank by default proxy server is india. else we can use didfferent resion as UK,US/NP etc. </p>
<p>cookies -string_constant or array- this last is optional parameter</p>
<p>$return -string_constant-
errorno- return error no.
errormsg- error message
info- give request info
conteny_info- content + info
header_responce- responce header
unknown- we can use it in future for other function if requered.
</p>
<pre>
<code>
<? php
function browser($data_arry)
{
if(!empty($data_arry['proxy_region']))
{
$proxy_arry=proxy($data_arry['proxy_region']);
$data_arry['ip']=$proxy_arry[0]['ip'];
$data_arry['port']=$proxy_arry[0]['port'];
}
else
{
$data_arry['ip']="";
$data_arry['port']="";
}
// cookies folder create
if(!is_dir("cookies"))
mkdir("cookies");
$cookies_file= "cookies/cookie.txt";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_arry['url']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_PROXY, $data_arry['ip']);
curl_setopt($ch, CURLOPT_PROXYPORT, $data_arry['port']);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies_file);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies_file);
$post=(isset($data_arry['post'])) ? 1: 0;
if(!empty($post))
{
curl_setopt($ch, CURLOPT_POST,$post);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_arry['postdata']);
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $data_arry['headers']);
if($data_arry['return']=="errorno")
{
$err = curl_errno( $ch );
$output=$err ;
}
else if($data_arry['return']=="errormsg")
{
$errmsg = curl_error( $ch );
$output=$errmsg;
}
else if($data_arry['return']=="info")
{
$info = curl_getinfo( $ch );
$output=$info;
}
else if($data_arry['return']=="conteny_info")
{
$body= curl_exec ($ch);
$info = curl_getinfo( $ch );
$output=$info;
}
else if($data_arry['return']=="header_responce")
{
curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_NOBODY, true);
$header= curl_exec ($ch);
$output=$header;
}
else
{
$server_output = curl_exec ($ch);
$output=$server_output;
}
curl_close ($ch);
return $output;
}
//curl_browser
function curl_browser($url,$methodtype=null,$postdata=null,$headers=null,$proxy=null,$proxy_region=null,$cookie=null,$return="webpage")
{
$z['url']=$url;
if($methodtype=='post')
{$z['postdata']=$postdata;
$z['post']=1;}
else
$z['postdata']=null;
if($proxy=='proxy')
{
if($proxy_region==null)
$z['proxy_region']="IN";
else
$z['proxy_region']=$proxy_region;
}
if($cookie=='cookie')
$z['cookiefile']=$cookie;
if($headers==null)
{
$z['headers']=[
'User-Agent: Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36',
'Accept-Encoding: identity',
'Connection: close',
];
}
else
{$z['headers']=$headers;}
//return
$z['return']=$return;
return browser($z);
}
#proxy
function proxy($region='IN')
{
$url="https://kingproxies.com/api/v2/proxies.json?alive=1&t;country_code=".$region."&t;key=freesample&t;limit=5&t;protocols=&t;type=elite" ;
$json=curl_browser($url,"","","","","","cookie");
$arry=json_decode($json,1);
return $arry=$arry['data']['proxies'];
}
#curl_browser($url,"","","","","","", "");
#curl_browser($url,"post","postdata","headers arry ","proxy","IN","cookie",returntype(string) optional);
?>
</code>
</pre>
</div>
<div>
<p><i><b>3. query_data($id)</b></i></p>
<p> Return - string </p>
<p>$id -string-pass string to get "get" data from url. </p>
<pre>
<code>
<? php
function query_data($id)
{
return urldecode($_GET[$id]);
}
?>
</code>
</pre>
<p>Example</p>
<pre>
<code>
<? php
include "/php_function/tools";
url="http://ecample.com/hfghgfd/hfghd.php?ram=13&t;shyam=25";
echo query_data("ram");
// ans-13
echo query_data("shyam");
// ans-13
?>
</code>
</pre>
</div>
<div>
<p><i><b>4. path_url($url)</b></i></p>
<p> Return -string </p>
<p>$url -string-pass url as string. </p>
<p> return url path only</p>
<pre>
<code>
<? php
include "/php_function/tools";
function path_url($url)
{
$arry=parse_url($url);
$url=$arry['scheme']."://".$arry['host'].$arry['path'];
$basename=basename($url);
return str_replace($basename,'',$url);
}
?>
</code>
</pre>
<p>Example</p>
<pre>
<code>
<? php
include "/php_function/tools";
$url="http://ecample.com/hfghgfd/hfghd.php?ram=13&amp";
echo path_url($url);
// Ans- "http://ecample.com/hfghgfd/"
?>
</code>
</pre>
</div>
<div>
<p><i><b>5. header_responce_arry($output)</b></i></p>
<p> Return -Array</p>
<p>$return - -string- pass responce header as string. </p>
<p>pure plane responce data top arry conmversion</p>
<pre>
<code>
<? php
function header_responce_arry($output)
{
$headers=array();
$data=explode("\n",$output);
$headers['status']=$data[0];
array_shift($data);
foreach($data as $part){
$middle=explode(":",$part);
$headers[trim($middle[0])] = trim($middle[1]);
}
return $headers;
}
//$headers=header_responce_arry($output);
//print_r($headers);
//var_dump($headers);
?>
</code>
</pre>
<p>Example</p>
<pre>
<code>
<? php
include "/php_function/tools";
$output=curl_browser("http://google.com","","","","","","","header_responce");
print_r(header_responce_arry($output));
/* Ans-
Array
(
[status] => HTTP/1.1 302 Found
[Cache-Control] => private, max-age=0
[Content-Type] => text/html; charset=UTF-8
[Referrer-Policy] => no-referrer
[Location] => https
[Content-Length] => 285
[Date] => Wed, 21 Feb 2018 09
[Connection] => close
[] =>
[HTTP/1.1 302 Found] =>
[Server] => gws
[X-XSS-Protection] => 1; mode=block
[X-Frame-Options] => SAMEORIGIN
[Set-Cookie] => NID=124=fY8BrgiLnGzB7MAEe2bVYTeK7Rdgrdp66kOxnGjCbG9AltuY_v9nhJ0rweidKuqrUrnUOsHGHSCwWc6RsFLOurRixfG8SpZwS2M3KFrieVA8DahgvogWwSTdt5R2yY1TgINCiW8; expires=Thu, 23-Aug-2018 09
[HTTP/1.1 200 OK] =>
[Expires] => -1
[Strict-Transport-Security] => max-age=3600
[P3P] => CP="This is not a P3P policy! See g.co/p3phelp for more info."
[Alt-Svc] => hq="
[Accept-Ranges] => none
[Vary] => Accept-Encoding
)
*/
?>
</code>
</pre>
</div>
<div>
<p><i><b>6. query_arry($query)</b></i></p>
<p> Return -Array</p>
<p>$querry - string- query as string. </p>
<p> it will give arry of querry </p>
<pre>
<code>
function query_arry($query)
{
$data=explode("&",$query);
foreach($data as $part){
$arry=explode("=",$part);
$arryf[$arry[0]]=$arry[1];
}
return $arryf;
}
</code>
</pre>
<p>Example</p>
<pre>
<code>
<?php
include "/php_function/tools";
print_r(query_arry("ram=13&shyam=25"));
Ans-
Array
(
[ram] => 13
[shyam] => 25
)
?>
</code>
</pre>
</div>
<div>
<p><i>7. sub_string($op,$top,$top_no,$botom,$botom_no)<b></b></i></p>
<p> Return -string</p>
<p>$op -string- pass string data from u want sub string. </p>
<p>$top -string- pass string data from where u want to string. </p>
<p>$top_no-string- number to correct the string. </p>
<p>$bottom -string- pass string data from upto u want to string. </p>
<p>$bottom_no-string- number to correct the string. </p>
<p></p>
<pre>
<code>
<?php
function sub_string($op,$top,$top_no,$botom,$botom_no)
{
$Sp1=strpos($op,$top)+$top_no;
$ss1=substr($op,$Sp1);
///
$Sp2=strpos($ss1,$botom)-$botom_no;
return substr($ss1,0,$Sp2);
}
?>
</code>
</pre>
<p>Example</p>
<pre>
<code>
<?php
include "/php_function/tools";
$op='string- number to correct the string';
echo sub_string($op,'ing',3,'the',0);
/* Ans-
- number to correct
*/
?>
</code>
</pre>
</div>
<!-- content start End-->
</div>
<!-- content End -->
<!-- php tab end -->
<!-- js tab -->
<!-- content -->
<div id="js" class="mycss-big-container tab" style="max-width:95%; height:auto; margin-top:0px; margin-bottom:05px;display:none;">
<!-- content Start-->
<div>
<h4><i><b>How To Use</b></i></h4>
<p>There are three methods to use it.</p>
<p><i><b>First method</b></i></p>
<p> Add following code in your head of the page </p>
<pre><code>
<script src="http://wbut.co.nf/js_function/tools.js" ></script>
</code></pre>
<p><i><b> Second Method</b></i></p>
<p>
Download script from "https://github.com/udpf/js_function_tools" . <br>
Upload to your server.<br>
After that add following code in your head of the page.<br>
Use function(s) as local function.<br>
</p>
<pre><code>
<script src="/your_file_location/tools.js" ></script>
</code></pre>
<p><i><b>Third Method</b></i></p>
<p>
This is simple method to use .<br>
Copy the required functon and paste it in your script page and use it as we use user define function.
</p>
<p>Example</p>
<pre>
<code>
<script>
function sub_string (ot,topstring,topno,bottomstring,bottomno)
{
var pos1=ot.indexOf(topstring)+topno;
var ot1=ot.substr(pos1);
var pos2=ot1.indexOf(bottomstring)-bottomno;
var json= ot1.substr(0,pos2);
return json;
}
</script>
</code>
</pre>
</div>
<h4><i><b>Function(s)</b></i></h4>
<div>
<p><i><b>1.js_browser("url(string)" , "get(method)"," postdata(string)", "header(string)", "datatype(string)")</b></i></p>
<p> <b>Return - </b> String</p>
<p> datatype- webpage(default)- return body of page(string)<br>
header - return all header (array)
</p>
<pre>
<code>
<script>
function browser(arry)
{
var xhr, i;
if (window.XMLHttpRequest)
{
xhr= new XMLHttpRequest();
}
else
{
// code for older browsers
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
// for get request
if(arry['method']=='get')
{
xhr.open('GET',arry['url'], false);
}
// for post request
if(arry['method']=='post')
{
xhr.open('POST',arry['url'],false);
}
if(arry['method']=='options')
{
xhr.open('OPTIONS',arry['url'], false);
}
// set header
var aHeaders=arry['header'],ram,ramm;
for(var i in aHeaders )
{
ram= i;
ramm= aHeaders[i];
xhr.setRequestHeader(ram, ramm );
}
if(arry['method']=='get')
xhr.send();
if(arry['method']=='post')
xhr.send(arry['postdata']);
if(arry['method']=='options')
xhr.send();
if(xhr.readyState ===4)
{
if(arry['datatype']=="webpage")
{
return xhr.response;
}
if(arry['datatype']=="header")
{
return xhr.getAllResponseHeaders();
}
}
}
function js_browser(url,method="get",postdata,header="",datatype="webpage")
{
var arryy=Array;
arryy['url']=url;
arryy['method']=method;
arryy['postdata']=postdata;
arryy['datatype']=datatype;
if(header=="")
{
arryy['header']={
};
}
else
{
arryy['header']=header;
}
return browser(arryy);
}
</script>
</code>
</pre>
<p>Example</p>
<pre>
<code>
<script>
var url,;
url="http://www.youtube.com/get_video_info?video_id=DRYcz5pt5oc"";
header={
'Key': '12345678'
};
postdata="vdevid=5&vtenantId=3&vstreamname=Yupp ";
echo (js_browser(url)); // output webcontent . //echo () in another user define to output the text.
// js_browser(url,"get","","",""); // output webcontent.
// js_browser(url,"get","","header",""); // output webcontent.
// js_browser(url,"get","","header","header"); // output responce header as text.
// post request
// js_browser(url,"post",postdata,"",""); // output webcontent .
// js_browser(url,"post",postdata,"header",""); // output webcontent.
// js_browser(url,"post",postdata,"header","header"); // output webcontent.
////////////output
/*
hi bhuvan.
*/
</script>
</code>
</pre>
</div>
<div>
<p><i><b>2.auto_refresh()</b></i></p>
<p> <b>Return - </b> No return</p>
<p> The page will be reloded in which it it called</p>
<pre>
<code>
<script>
function auto_refresh()
{
location.reload(true);
}
</script>
</code>
</pre>
</div>
<div>
<p><i><b>3.echo(string,display="write",idname)</b></i></p>
<p> <b>Return - </b> No return</p>
<p> The page output direct to the document</p>
<pre>
<code>
<script>
function echo(string,display="write",idname)
{
if(display==="write")
document.write(string);
if(display==="id")
document.getElementById(idname).innerHTML =string;
if(display==="class")
document.getElementsByClassName(idname).innerHTML =string;
}
</script>
</code>
</pre>
</div>
<div>
<p><i><b>4. var_dump(v, howDisplay, recursionLevel)</b></i></p>
<p> <b>Return - </b> No return</p>
<p> howDisplay-optional </p>
<p> recursionLevel-optional </p>
<p> The page will directly output to document the help of echo function </p>
<pre>
<code>
<script>
function repeatString(str, num) {
out = '';
for (var i = 0; i < num; i++) {
out += str;
}
return out;
}
function var_dump(v, howDisplay, recursionLevel) {
howDisplay = (typeof howDisplay === 'undefined') ? "body" : howDisplay;
recursionLevel = (typeof recursionLevel !== 'number') ? 0 : recursionLevel;
var vType = typeof v;
var out = vType;
switch (vType) {
case "number":
/* there is absolutely no way in JS to distinguish 2 from 2.0
so 'number' is the best that you can do. The following doesn't work:
var er = /^[0-9]+$/;
if (!isNaN(v) && v % 1 === 0 && er.test(3.0))
out = 'int';*/
case "boolean":
out += ": " + v;
break;
case "string":
out += "(" + v.length + '): "' + v + '"';
break;
case "object":
//check if null
if (v === null) {
out = "null";
}
//If using jQuery: if ($.isArray(v))
//If using IE: if (isArray(v))
//this should work for all browsers according to the ECMAScript standard:
else if (Object.prototype.toString.call(v) === '[object Array]') {
out = 'array(' + v.length + '): {\n';
for (var i = 0; i < v.length; i++) {
out += repeatString(' ', recursionLevel) + " [" + i + "]: " +
var_dump(v[i], "none", recursionLevel + 1) + "\n";
}
out += repeatString(' ', recursionLevel) + "}";
}
else { //if object
sContents = "{\n";
cnt = 0;
for (var member in v) {
//No way to know the original data type of member, since JS
//always converts it to a string and no other way to parse objects.
sContents += repeatString(' ', recursionLevel) + " " + member +
": " + var_dump(v[member], "none", recursionLevel + 1) + "\n";
cnt++;
}
sContents += repeatString(' ', recursionLevel) + "}";
out += "(" + cnt + "): " + sContents;
}
break;
}
if (howDisplay == 'body') {
// var pre = document.createElement('pre');
// pre.innerHTML = out;
// document.body.appendChild(pre)
echo (out);
}
else if (howDisplay == 'alert') {
alert(out);
}
return out;
}
</script>