Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-web-393
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
elphel-web-393
Commits
cb6b6960
Commit
cb6b6960
authored
Dec 01, 2016
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed phpshell, added parallel requests php lib
parent
9169fb62
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
7 deletions
+92
-7
Makefile
src/php_top/Makefile
+2
-7
parallel_requests.php
src/php_top/parallel_requests.php
+90
-0
phpshell.tar.gz
src/php_top/phpshell.tar.gz
+0
-0
No files found.
src/php_top/Makefile
View file @
cb6b6960
...
@@ -10,6 +10,7 @@ SYSCONFDIR = /etc
...
@@ -10,6 +10,7 @@ SYSCONFDIR = /etc
CONFDIR
=
$(SYSCONFDIR)
/elphel393
CONFDIR
=
$(SYSCONFDIR)
/elphel393
PHP_SCRIPTS
=
i2c.php
\
PHP_SCRIPTS
=
i2c.php
\
parallel_requests.php
\
camvars.php
\
camvars.php
\
ccam.php
\
ccam.php
\
diag_utils.php
\
diag_utils.php
\
...
@@ -21,11 +22,6 @@ PHP_SCRIPTS=i2c.php \
...
@@ -21,11 +22,6 @@ PHP_SCRIPTS=i2c.php \
PHPINCLUDES
=
i2c_include.php show_source_include.php
PHPINCLUDES
=
i2c_include.php show_source_include.php
PHPSHELL
=
phpshell.php
\
phpshell.css
\
valid-xhtml10.png
\
vcss.png
all
:
all
:
@
echo
"make all in src"
@
echo
"make all in src"
@
echo
"REMOTE_IP =
$(REMOTE_IP)
"
@
echo
"REMOTE_IP =
$(REMOTE_IP)
"
...
@@ -40,8 +36,7 @@ install:
...
@@ -40,8 +36,7 @@ install:
$(INSTALL)
$(OWN)
-m
$(INSTDOCS)
$(PHPINCLUDES)
$(DESTDIR)$(INCLUDES)
$(INSTALL)
$(OWN)
-m
$(INSTDOCS)
$(PHPINCLUDES)
$(DESTDIR)$(INCLUDES)
$(INSTALL)
$(OWN)
-d
$(DESTDIR)$(SYSCONFDIR)
$(INSTALL)
$(OWN)
-d
$(DESTDIR)$(SYSCONFDIR)
$(INSTALL)
$(OWN)
-d
$(DESTDIR)$(CONFDIR)
$(INSTALL)
$(OWN)
-d
$(DESTDIR)$(CONFDIR)
tar
-xzf
phpshell.tar.gz
$(INSTALL)
$(OWN)
-m
$(INSTDOCS)
$(PHPSHELL)
$(DESTDIR)$(DOCUMENTROOT)
# $(INSTALL) $(OWN) -m $(INSTDOCS) -T autocampars.xml $(DESTDIR)$(CONFDIR)/autocampars0.xml
# $(INSTALL) $(OWN) -m $(INSTDOCS) -T autocampars.xml $(DESTDIR)$(CONFDIR)/autocampars0.xml
# $(INSTALL) $(OWN) -m $(INSTDOCS) -T autocampars.xml $(DESTDIR)$(CONFDIR)/autocampars1.xml
# $(INSTALL) $(OWN) -m $(INSTDOCS) -T autocampars.xml $(DESTDIR)$(CONFDIR)/autocampars1.xml
# $(INSTALL) $(OWN) -m $(INSTDOCS) -T autocampars.xml $(DESTDIR)$(CONFDIR)/autocampars2.xml
# $(INSTALL) $(OWN) -m $(INSTDOCS) -T autocampars.xml $(DESTDIR)$(CONFDIR)/autocampars2.xml
...
...
src/php_top/parallel_requests.php
0 → 100644
View file @
cb6b6960
<?php
/*!***************************************************************************
*! FILE NAME : parallel_requests.php
*! DESCRIPTION: send out parallel url requests and collect responses
*! Copyright (C) 2016 Elphel, Inc
*! -----------------------------------------------------------------------------**
*!
*! This program is free software: you can redistribute it and/or modify
*! it under the terms of the GNU General Public License as published by
*! the Free Software Foundation, either version 3 of the License, or
*! (at your option) any later version.
*!
*! This program is distributed in the hope that it will be useful,
*! but WITHOUT ANY WARRANTY; without even the implied warranty of
*! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*! GNU General Public License for more details.
*!
*! You should have received a copy of the GNU General Public License
*! along with this program. If not, see <http://www.gnu.org/licenses/>.
*! -----------------------------------------------------------------------------**
*/
// Using parallel requests, PHP has to be configured '--with-curl=' (and libcurl should be installed)
function
curl_multi_start
(
$urls
)
{
// numprime is needed to actually send the request and remote starts executing it
// Not really clear - what it should be
$numprime
=
4
;
// magic number, see http://lampe2e.blogspot.com/2015/03/making-stuff-faster-with-curlmultiexec.html
$curl_mh
=
curl_multi_init
();
$aCurlHandles
=
array
();
foreach
(
$urls
as
$url
)
{
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$ch
,
CURLOPT_HEADER
,
0
);
$aCurlHandles
[]
=
$ch
;
curl_multi_add_handle
(
$curl_mh
,
$ch
);
}
$curl_active
=
count
(
$urls
);
for
(
$x
=
0
;
$x
<
$numprime
&&
$curl_active
;
$x
++
)
{
curl_multi_exec
(
$curl_mh
,
$curl_active
);
// we wait for a bit to allow stuff TCP handshakes to complete and so forth...
usleep
(
10000
);
// echo ".";
}
return
array
(
"mh"
=>
$curl_mh
,
"handles"
=>
$aCurlHandles
);
}
function
curl_multi_finish
(
$data
,
$use_xml
=
true
,
$ntry
=
0
,
$echo
=
false
)
{
$curl_active
=
1
;
$curl_mrc
=
CURLM_OK
;
$nrep
=
0
;
$curl_mh
=
$data
[
'mh'
];
while
(
$curl_active
&&
$curl_mrc
==
CURLM_OK
)
{
if
(
curl_multi_select
(
$curl_mh
)
!=
-
1
)
{
do
{
$curl_mrc
=
curl_multi_exec
(
$curl_mh
,
$curl_active
);
}
while
(
$curl_mrc
==
CURLM_CALL_MULTI_PERFORM
);
}
if
(
$echo
)
echo
colorize
(
"
$curl_active
"
,
'YELLOW'
,
1
);
$nrep
++
;
if
(
$ntry
&&
(
$nrep
>
$ntry
))
{
break
;
}
}
$results
=
array
();
if
(
$use_xml
)
{
foreach
(
$data
[
'handles'
]
as
$i
=>
$ch
)
{
$xml
=
simplexml_load_string
(
curl_multi_getcontent
(
$ch
));
curl_multi_remove_handle
(
$curl_mh
,
$ch
);
$results
[
$i
]
=
array
();
foreach
(
$xml
as
$tag
=>
$value
)
{
$svalue
=
(
string
)
$value
;
if
(
strlen
(
$svalue
)
>
0
)
{
if
(
$svalue
[
0
]
==
'"'
)
$results
[
$i
][
$tag
]
=
trim
(
$svalue
,
'"'
);
else
$results
[
$i
][
$tag
]
=
(
int
)
$svalue
;
}
}
}
}
else
{
foreach
(
$data
[
'handles'
]
as
$i
=>
$ch
)
{
$r
=
curl_multi_getcontent
(
$ch
);
curl_multi_remove_handle
(
$curl_mh
,
$ch
);
$results
[]
=
$r
;
}
}
curl_multi_close
(
$curl_mh
);
return
$results
;
}
?>
src/php_top/phpshell.tar.gz
deleted
100644 → 0
View file @
9169fb62
File deleted
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment