php-general Digest 25 May 2006 18:33:49 -0000 Issue 4148
Topics (messages 236872 through 236899):
Re: calling JS function from php
236872 by: Ryan Creaser
236873 by: David Tulloh
236874 by: Rabin Vincent
236882 by: Mindaugas L
Re: captcha or other recommendations
236875 by: Angelo Zanetti
Re: preg_replace learning resources? Regex tuts? Tips? (and yes, I have been
rtfm)
236876 by: Kevin Waterson
236899 by: Micky Hulse
Slow query-building function
236877 by: George Pitcher
Re: Generating thumbnails from tiff images
236878 by: mbneto
236879 by: mbneto
236883 by: Jay Blanchard
Re: storing single and double quote in MySQL
236880 by: Mindaugas L
236884 by: afan.afan.net
help needed with pager
236881 by: Ross
236885 by: Rabin Vincent
Monitoring Remote Server Services using php !!!
236886 by: Phil Martin
236888 by: chris smith
236890 by: Rabin Vincent
Õý¹æ´ó¹«Ë¾£¬Ãâ·Ñ°ïÄú°ìÐÅÓÿ¨
236887 by: zfe
PHP halts after calling non-existing socket
236889 by: Artzi, Yoav \(Yoav\)
Re: Upload File (binary files?)
236891 by: Michelle Konzack
236892 by: Michelle Konzack
syntax highlighting for Shell scripts and C?
236893 by: Michelle Konzack
str_replace(), and correctly positioned HTML tags
236894 by: Dave M G
236896 by: Adam Zey
236897 by: tedd
Can the pic include be based on a variable?
236895 by: Tristan
236898 by: tedd
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
php-general@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
suresh kumar wrote:
I am facing one problem in my project.I am trying to call a javascript function
from php.but it not executing.this is my code.
function clientTime() {
var cNow = new Date();
var cHour = cNow.getHours();
var cMin = cNow.getMinutes();
var hour= cHour + ":" + cMin;
return hour;
} //End function clientTime
function clientDate() {
var cDate = new Date();
var clientYear = cDate.getFullYear();
var clientMonth = cDate.getMonth();
var clientDay = cDate.getDate();
var year= clientYear + "-" + clientMonth + "-" + clientDay;
return year;
} //End function clientDate
<? print "<span style=padding-left:14.2cm><font size=2 face=Arial color=#555555><script type=\"text/javascript\">";
print "clientTime()";
print "clientDate()</script></font></span>"; ?>
i need help from u.
---------------------------------
Yahoo! India Answers Share what your know-how and wisdom
Send free SMS to your Friends on Mobile from your Yahoo! Messenger Download now
Hi Suresh
Unfortunately you cannot call a javascript function from directly within
php. What you are doing is generating a web page that has invalid
javascript. Try looking at your output with "view source" for clues.
Ryan
--- End Message ---
--- Begin Message ---
suresh kumar wrote:
> I am facing one problem in my project.I am trying to call a javascript
> function from php.but it not executing.this is my code.
>
This is not a php problem, php produces a text file which is interpreted
by the browser as html and javascript. Have a look at your
html/javascript (view source) and figure out the problem. The use of
php is completely incidental.
David
--- End Message ---
--- Begin Message ---
On 5/25/06, suresh kumar <[EMAIL PROTECTED]> wrote:
I am facing one problem in my project.I am trying to call a javascript function
from php.but it not executing.this is my code.
You can't "call" a javascript function from php. What you can
do is output javascript code that calls a javascript function.
function clientTime() {
var cNow = new Date();
var cHour = cNow.getHours();
var cMin = cNow.getMinutes();
var hour= cHour + ":" + cMin;
return hour;
} //End function clientTime
function clientDate() {
var cDate = new Date();
var clientYear = cDate.getFullYear();
var clientMonth = cDate.getMonth();
var clientDay = cDate.getDate();
var year= clientYear + "-" + clientMonth + "-" + clientDay;
return year;
} //End function clientDate
<? print "<span style=padding-left:14.2cm><font size=2 face=Arial color=#555555><script
type=\"text/javascript\">";
print "clientTime()";
print "clientDate()</script></font></span>"; ?>
Your functions are returning values, but you aren't printing out
those values. Try:
print "document.write(clientTime());";
Rabin
--- End Message ---
--- Begin Message ---
Hi,
print needs escaping, so fix style=\"\". Read XHTML requirements.
"<span style=padding-left:14.2cm><font size=2 face=Arial
color=#555555><script type=\"text/javascript\">";
I see you are missing semicolon when calling clientDate(); The same for
clientTime(); Javascripts need semicolons at the end of statement.
in the beginning style must be
On 5/25/06, Rabin Vincent <[EMAIL PROTECTED]> wrote:
On 5/25/06, suresh kumar <[EMAIL PROTECTED]> wrote:
> I am facing one problem in my project.I am trying to call a javascript
function from php.but it not executing.this is my code.
You can't "call" a javascript function from php. What you can
do is output javascript code that calls a javascript function.
> function clientTime() {
>
> var cNow = new Date();
> var cHour = cNow.getHours();
> var cMin = cNow.getMinutes();
> var hour= cHour + ":" + cMin;
> return hour;
> } //End function clientTime
> function clientDate() {
> var cDate = new Date();
> var clientYear = cDate.getFullYear();
> var clientMonth = cDate.getMonth();
> var clientDay = cDate.getDate();
> var year= clientYear + "-" + clientMonth + "-" + clientDay;
> return year;
> } //End function clientDate
>
>
> <? print "<span style=padding-left:14.2cm><font size=2 face=Arial
color=#555555><script type=\"text/javascript\">";
> print "clientTime()";
> print "clientDate()</script></font></span>"; ?>
Your functions are returning values, but you aren't printing out
those values. Try:
print "document.write(clientTime());";
Rabin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
Mindaugas
--- End Message ---
--- Begin Message ---
tedd wrote:
Hi all.
I've been playing with captcha for one of my sites. It works well but
have had a few issues integrating it into the site and sometimes it
appears not to work/show the textfield and graphic.
Anyway are there any other suggestions for something with similiar
functionality as captcha and what are your experiences with these code
bases?
TIA
--
Angelo Zanetti
Z Logic
Angelo:
Read this:
http://www.access-matters.com/2005/05/22/quiz-115-did-a-captcha-catch-ya/
While not prefect by any means (i.e., blind can't see it), you may want
to review my "click the circle" solution:
http://xn--ovg.com/captcha
If you want the code, I'll provide -- BUT -- try to find another way.
tedd
thank Tedd, very interesting, and I agree its not nice to eliminate the
visually impaired. However my client is getting bombed with posts so I need to
put something in place to prevent this.
Is it possible for me to get the captcha code for that link you sent me?
preferabbly off list.
thanks in advance
--- End Message ---
--- Begin Message ---
This one time, at band camp, Micky Hulse <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I have been rtfm on preg_replace, and I am a bit turned-off by how
> complex reg-exing appears to be.... anyway, I would like to spend some
> time learning how I would convert a file full of links that look like:
Try this quicky
http://phpro.org/tutorials/Introduction-to-PHP-Regular-Expressions.html
Kevin
--
"Democracy is two wolves and a lamb voting on what to have for lunch.
Liberty is a well-armed lamb contesting the vote."
--- End Message ---
--- Begin Message ---
Koen Martens wrote:
You might be better off then by parsing the html file with DOM:
http://nl2.php.net/manual/en/ref.dom.php
Whoa, that is cool, I had no idea this was something PHP could do!
Thanks for the links. :D
Cheers,
Micky
--- End Message ---
--- Begin Message ---
Hi,
Last year I switched from using FileMaker Pro to MySQL. One of FileMaker's
quirks was that if, in a text field, you searched for say, 'free ass boo',
it would find any records with those three substrings in that field (in this
example, its 'Free Association Books').
I want to have this quirkiness on my site, along with the option of adding +
or ! before substrings.
I've got it working using the following function:
function sql_fltr($sql,$field,$input){
$input = addslashes($input);
if(strlen($input)>0){
if(substr_count($input,"*")>0 || substr_count($input,"!")>0 ||
substr_count($input,"^")>0 || substr_count($input,"+")>0){
$output="";
/* search for substring conditions */
$tempy = str_replace(" +","|+",str_replace(" !","|!",str_replace("
*","|*",str_replace(" ^","|^",($input)))));
$temp = explode("|",$tempy);
$i=0;
while($i < sizeof($temp)){
if(substr($temp[$i],0,1)=="*"){
$temp[$i]=" and ".$field." LIKE
'%".strim(str_replace("*","",$temp[$i]))."%'";
$output.= $temp[$i]."|";
}elseif(substr($temp[$i],0,1)=="!"){
$temp[$i]=" and ".$field." NOT LIKE
'%".strim(str_replace("!","",$temp[$i]))."%'";
$output.= $temp[$i]."|";
}elseif(substr($temp[$i],0,1)=="+"){
$temp[$i]=" and ".$field." LIKE
'%".strim(str_replace("+","",$temp[$i]))."%'";
$output.= $temp[$i]."|";
}else{
$temp[$i]="and ".$field." LIKE '%".strim($temp[$i])."%'";
$output.= $temp[$i]."|";
}
$i++;
}
$output = strim(substr($output,0,strlen($output)-1));
if(substr(strtolower(strim($output)),0,3)=='and'){
$output = str_replace("|"," ",$output);
} else {
$output = substr($output,4,strlen($output)-1);
}
/* search for whole string conditions */
} elseif(substr($input,0,1)=="*"){
$output=$field." LIKE '%".strim(str_replace("*","",$input))."%'";
} elseif(substr($input,0,1)=="!"){
$output=$field." NOT LIKE '%".strim(str_replace("!","",$input))."%'";
} elseif(substr($input,0,1)=="="){
$output=$field."='".strim(str_replace("=","",$input))."'";
} else {
$input = str_replace(" ","|",$input);
$output ="";
/* search for all substrings */
if(substr_count($input,"|")>0){
$temp = explode("|",$input);
$d=0;
while($d < sizeof($temp)){
$temp[$d]=" and ".$field." LIKE '%".rtrim($temp[$d])."%'";
$output.= $temp[$d]."|";
$d++;
}
} else {
$output=$field." LIKE '%".rtrim(str_replace("|", " ",$temp))."%'";
}
}
} else {
$output="";
}
if(substr(strtolower(strim($output)),0,3)=='and'){
$query = str_replace("|"," ",$output);
} else {
$query = substr($output,4,strlen($output)-1);
}
$output = str_replace("|"," ",$query);
return str_replace("and and","and",$output);
}
For info the strim() function combines ltrim() and rtrim().
My usage example is:
$sqlp = "select supplier_id from suppliers where (supplier_id>0 ";
$sqlp.= sql_fltr($sqlp, 'imprint', $pubname);
$sqlp.=")";
echo "<br><br><br>".$sqlp."<br><br><br>";
I just add extra sql_fltr() lines for additional fields.
The main problem with this function is that takes 12 seconds on my XP
laptop, to build the query (I'm not even hitting the DB, but pasting that
into my DB front end gives a quick result.
I'm running PHP5.1RC on the laptop (PHP5.0.2 on my server) - both with
Apache 2.
Can anyone suggest a solution that will improve performance while retaining
the functionality?
George
--- End Message ---
--- Begin Message ---
Jay,
I am not quite sure if you've made sarcastic comments but to make things
more clear...
I'd like to use GD instead of ImageMagick beacuse I would not want to
install extra packages if I can.
When I mentioned that I use convert I said 'when GD is not available...' So
I have alternatives: if there is no GD support go with ImageMagick. If
there is support use GD.
On 5/22/06, Jay Blanchard <[EMAIL PROTECTED]> wrote:
[snip]
I know the imagemagick tools. I use convert when I need to perform
operations on images and gd is not available.
I'd like an alternative without having to install any extra packages
specially that in this case the scripts will be hosted in a win32 machine
(windows xp).
[/snip]
Ah. Well. You could have saved me the effort by being more descriptive in
your first post.
1. Doesn't want to use GD. Check.
2. Doesn't want to use Imagemagick. Check.
3. Doesn't want to install extra packages. Check.
4. SOL. Check.
--- End Message ---
--- Begin Message ---
Hi,
Is this a non documented api?
http://www.php.net/manual/en/ref.image.php does not show this.
On 5/23/06, Richard Lynch <[EMAIL PROTECTED]> wrote:
On Mon, May 22, 2006 5:10 pm, mbneto wrote:
> I am looking for sample code/class that can generate a thumbnail (can
> be a
> png/jpeg) image from a tiff image. So far I've only found examples
> using
> png/jpg/gif as input.
In those examples, change the line that reads:
imagecreatefromjpeg(...)
to
imagecreatefromtiff(...)
That's pretty much it...
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
[snip]
I'd like to use GD instead of ImageMagick beacuse I would not want to
install extra packages if I can.
[/snip]
GD is an extra package.
--- End Message ---
--- Begin Message ---
Yesterday I read this discussion and looked at php manual for
mysql_real_escape... There is good example with extra function to check php
magic quotes status. I like the idea, because the code is more portable. You
don't have to add .htaccess files nor configre php..
Beginner Mindaugas
On 5/24/06, tedd <[EMAIL PROTECTED]> wrote:
At 8:14 PM +0200 5/24/06, [EMAIL PROTECTED] wrote:
>if magic_quotes_gpc is On, does it add slashes in front of quotes when
>submit through form?
>Mean, if I submit in input form (text) afan's "crazy" web, after
>echo $_POST['record'];
>I'll get afan\'s \"crazy\" web. Is this because of magic_quote_gps is On?
>
>-afan
afan:
You're getting the idea. Whatever is in your mysql dB should look
just like it would in print with quotes and all -- and without any
escape characters preceding them.
So, if your records in mysql (when viewed via something like
myphpadmin) have something like this "O\'Mally", then the data is
wrong. It should be "O'Mally" and thus somewhere you, or
magic_quotes, have added slashes.
So, backup to your original data, turn magic_quotes OFF, use
mysql_real_escape_string to prepare the data and then add that data
to your mysql.
Upon retrieval of the data from mysql -- if -- you want to show it to
a browser, then use htmlentities. Remember mysql_real_escape_string
IN and htmlentities OUT and the world will be well.
I don't know if you are working in the same type of environment as
me, but I fixed mine by adding a ".htacess" file to my root. The code
is simply a text file like so:
php_value magic_quotes_gpc 0
php_value magic_quotes_sybase 0
php_value magic_quotes_runtime 0
That might work for you -- others on this list may have more detailed
information.
In any event, IMO do everything you can to turn magic_quotes OFF
because after that, then everything will be easier and you'll never
have to worry about when, or if, you should add_lashes, strip_lashes,
and other such confusing stuff.
hth's
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
Mindaugas
--- End Message ---
--- Begin Message ---
I have an access as root user to the server and it shouldn't be a problem
to turn Off magic quote, but I really CANNOT do it right now because, as I
said earlier, just put live our new (pretty big) web site and there is no
chance to put it again "under construction" for a next couple of weekls
(redo site and test it again). As far as I can see, the only "solution" is
make on extra server whole thing and then, once it's finished and tested,
replace the old one? Also, there is a lot of info with slashes i DB - that
has to be cleaned too, right?
But, as sombody mentioned earlier, the whole php development goes in that
direction (like global's Off/On before) and one day I will have to do it
anyway. But, at least I can "wait" for version 2.0 of the web site :).
Thanks.
-afan
> At 8:14 PM +0200 5/24/06, [EMAIL PROTECTED] wrote:
>>if magic_quotes_gpc is On, does it add slashes in front of quotes when
>>submit through form?
>>Mean, if I submit in input form (text) afan's "crazy" web, after
>>echo $_POST['record'];
>>I'll get afan\'s \"crazy\" web. Is this because of magic_quote_gps is On?
>>
>>-afan
>
> afan:
>
> You're getting the idea. Whatever is in your mysql dB should look
> just like it would in print with quotes and all -- and without any
> escape characters preceding them.
>
> So, if your records in mysql (when viewed via something like
> myphpadmin) have something like this "O\'Mally", then the data is
> wrong. It should be "O'Mally" and thus somewhere you, or
> magic_quotes, have added slashes.
>
> So, backup to your original data, turn magic_quotes OFF, use
> mysql_real_escape_string to prepare the data and then add that data
> to your mysql.
>
> Upon retrieval of the data from mysql -- if -- you want to show it to
> a browser, then use htmlentities. Remember mysql_real_escape_string
> IN and htmlentities OUT and the world will be well.
>
> I don't know if you are working in the same type of environment as
> me, but I fixed mine by adding a ".htacess" file to my root. The code
> is simply a text file like so:
>
> php_value magic_quotes_gpc 0
> php_value magic_quotes_sybase 0
> php_value magic_quotes_runtime 0
>
> That might work for you -- others on this list may have more detailed
> information.
>
> In any event, IMO do everything you can to turn magic_quotes OFF
> because after that, then everything will be easier and you'll never
> have to worry about when, or if, you should add_lashes, strip_lashes,
> and other such confusing stuff.
>
> hth's
>
> tedd
> --
> ------------------------------------------------------------------------------------
> http://sperling.com http://ancientstones.com http://earthstones.com
>
--- End Message ---
--- Begin Message ---
http://scottishsocialnetworks.org/editor.php
http://scottishsocialnetworks.org/editor.phps
the pager in this page works except try and choose aberdeen from the area
dropdown. You should get 18 answers which is fine except when page 2 is
pressed at the bottom the query seems to be scrubbed and it returns the full
database.
any ideas how I can 'save' the query and not create a new blank query every
time the page is slef submitted?
--- End Message ---
--- Begin Message ---
On 5/25/06, Ross <[EMAIL PROTECTED]> wrote:
http://scottishsocialnetworks.org/editor.php
http://scottishsocialnetworks.org/editor.phps
the pager in this page works except try and choose aberdeen from the area
dropdown. You should get 18 answers which is fine except when page 2 is
pressed at the bottom the query seems to be scrubbed and it returns the full
database.
any ideas how I can 'save' the query and not create a new blank query every
time the page is slef submitted?
Get your variables, like 'area', from $_GET if they're not in $_POST.
And then you can change your page navigation links to something
like:
echo $pager->get_prev('<a href="{LINK_HREF}&area=' . $area . '"
title="Previous">«</a>');
Rabin
--- End Message ---
--- Begin Message ---
Hi everybody,
I'm new to the list and also new to php, I hope I can learn many
things from here.
My first doubt is the following: I'm trying to create a small monitor
system, just to suit my needs in monitoring some services in my application.
I've found some functions that return to me the service by port, name and so
on (getservbyport, getservbyname). What I need is to monitor remote server
services, I mean, lets suppose I have a server 192.168.0.2 with a ssh server
running. I'd like to see the status (up/down) of that server from another
machine, like 192.168.0.1. I don't want to use some monitoring softwares out
there in the web, i know they exist and in fact I use many of them like
nagios, cacti and so on, but I'm planning to do my own small solution.
What I need is some function that asks me a remote IP, port and
protocol as input data and results TRUE/FALSE (any boolean value), just to
see if the service is up. I did that making a function using nmap, but i
don't want to hold that solution to linux, I'd like to use it at other OS.
My function's syntax is like this
<?php
$ssh_status=service_status (192.168.0.2, 22, tcp);
if ($ssh_status==TRUE); {
echo "Service UP";
} else {
echo "Service DOWN";
}
?>
Does anyone know if there is a similar function in PHP ? I'd be very
happy if somebody knows about a function like that.
Thanks in advance
att.
Felipe Martins
--- End Message ---
--- Begin Message ---
On 5/25/06, Phil Martin <[EMAIL PROTECTED]> wrote:
Hi everybody,
I'm new to the list and also new to php, I hope I can learn many
things from here.
My first doubt is the following: I'm trying to create a small monitor
system, just to suit my needs in monitoring some services in my application.
I've found some functions that return to me the service by port, name and so
on (getservbyport, getservbyname). What I need is to monitor remote server
services, I mean, lets suppose I have a server 192.168.0.2 with a ssh server
running. I'd like to see the status (up/down) of that server from another
machine, like 192.168.0.1. I don't want to use some monitoring softwares out
there in the web, i know they exist and in fact I use many of them like
nagios, cacti and so on, but I'm planning to do my own small solution.
What I need is some function that asks me a remote IP, port and
protocol as input data and results TRUE/FALSE (any boolean value), just to
see if the service is up. I did that making a function using nmap, but i
don't want to hold that solution to linux, I'd like to use it at other OS.
My function's syntax is like this
<?php
$ssh_status=service_status (192.168.0.2, 22, tcp);
if ($ssh_status==TRUE); {
echo "Service UP";
} else {
echo "Service DOWN";
}
?>
Does anyone know if there is a similar function in PHP ? I'd be very
happy if somebody knows about a function like that.
No such function exists.
You should check out http://www.nagios.org - it's not php but it does
what you want.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
On 5/25/06, Phil Martin <[EMAIL PROTECTED]> wrote:
Hi everybody,
I'm new to the list and also new to php, I hope I can learn many
things from here.
My first doubt is the following: I'm trying to create a small monitor
system, just to suit my needs in monitoring some services in my application.
I've found some functions that return to me the service by port, name and so
on (getservbyport, getservbyname). What I need is to monitor remote server
services, I mean, lets suppose I have a server 192.168.0.2 with a ssh server
running. I'd like to see the status (up/down) of that server from another
machine, like 192.168.0.1. I don't want to use some monitoring softwares out
there in the web, i know they exist and in fact I use many of them like
nagios, cacti and so on, but I'm planning to do my own small solution.
What I need is some function that asks me a remote IP, port and
protocol as input data and results TRUE/FALSE (any boolean value), just to
see if the service is up. I did that making a function using nmap, but i
don't want to hold that solution to linux, I'd like to use it at other OS.
My function's syntax is like this
<?php
$ssh_status=service_status (192.168.0.2, 22, tcp);
if ($ssh_status==TRUE); {
echo "Service UP";
} else {
echo "Service DOWN";
}
?>
Does anyone know if there is a similar function in PHP ? I'd be very
happy if somebody knows about a function like that.
You can use php.net/fsockopen.
Rabin
--- End Message ---
--- Begin Message ---
如果此mail无法正常显示,请点击 http://www.51credit.com/minisite/cardjoin/index.php
我爱卡首页 | 关于我们 | 联系方式
热门信用卡推荐
中信STAR卡详情 立即申请中信魔力卡详情 立即申请
加菲猫卡详情 立即申请
兴业信用卡详情 立即申请
据最新统计显示,我国内地信用卡累计发行数量达到已超过 1000
万张,可见国人对信用卡的接受程度之强,如果皮夹里还没有一张信用卡,是否有点落伍了呢!办理信用卡不需要担保,既不需要担保人也不需要质押,方便快捷,现在通过信用卡门户网站――我爱卡网站(www.51credit.com)即可方便快捷的申请信用卡。
我爱卡网上申请信用卡步骤:
模拟评审→在线填写申请表→上门服务→银行审核发卡
客服热线:010-51778989
富有创意的设计,精美的图案,原来信用卡也可以这样酷! 你心动了吗,快快来预约申请吧!
银行卡对比查询
商户优惠查询
中信STAR卡特色服务介绍
安全 挂失卡 零风险
方便 预借现金 全球通行
轻松 先消费 后还款
简易 免担保人 免保证金
精彩 刷卡回馈 积分礼遇
周全 灵活缴款 轻松省力
特色服务
・ 24 小时全球免费旅游交通意外保险
・ 24 小时免费意外入院医疗保险
・ 24 小时手机短信通知服务
・ 24 小时全球免费客服热线
立即申请
关于我们 联系我们 加入我们 服务条款 隐私条款 友情链接
Copyright 2005 Sino Credit Technologies Inc. All Rights Reserved
京ICP证050596号
--- End Message ---
--- Begin Message ---
After calling a non existing socket PHP halts and doesn't return. It
happens when we do it through our web server (AppWeb) or through the
command line. The problem is with socket_recvfrom. (see code below)
Is this a known bug? a mistake I make in accessing sockets? installation
error on my side?
Thanks.
Code:
<?php
unlink ("/tmp/local_domain");
$addr = "/tmp/main_adaptor_sock";
$socket = socket_create(AF_UNIX, SOCK_DGRAM, 0);
if (!$socket)
echo "problem in creating socket";
if (!socket_bind($socket, "/tmp/local_domain"))
echo "problem in binding socket";
$buffer = "Update";
socket_sendto($socket, $buffer, strlen($buffer), 0, $addr);
socket_recvfrom($socket, $buffer, 100, 0, $from);
echo "message recv $buffer \n";
?>
--- End Message ---
--- Begin Message ---
Am 2006-05-15 20:06:06, schrieb Richard Lynch:
> After you start working for the CIA and actually write a function that
> *DOES* something with the blob data to search for common facial
> features or something, you can use this argument...
>
> Until then, it's really rather empty.
>
> :-) :-):-)
I do not work for the CIA because I live in FR and working
for the concurence :-) We have very big servers serving
the binaries (pics, docs and more but only the biometric
datas are stored in the databases... (the guys there have
nothing to do as spidering the internet for PIC's...)
Maybe around 400.000.000 peoples allready indexed...
The CIA is maybe a little bit more crazy since they are
createing a 12-page file of each people of the world...
Which IS allready enough to make HDD sellers happy...
Oh yes, at the DGSE (where I am PMC) we are using Debian
and PostgreSQL 7.4.
My little database of 370 GByte + 1,8 TByte binaries has
only 83.000 peoples indexed.
Greetings
Michelle Konzack
--
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack Apt. 917 ICQ #328449886
50, rue de Soultz MSM LinuxMichi
0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)
--- End Message ---
--- Begin Message ---
Am 2006-05-15 17:25:05, schrieb Rory Browne:
> Bullshit. there are multiple tools for copying files from host to host,
> including ftp, scp, sftp, rsync, nfs, etc. Planning ahead, is a better way
> to avoid breaking links than using MySQL to store your images.
Right, currently I am using a php5 script which generate temporary
tables and references where to find the binaries and the I dump the
temporary table. After this I put the dump plus the images into a
tar-ball and transfer it.
The receiver has an equivalent script which can import the table dump
and install the "binaries correctly.
> I notice you've misspelt the most important word there. He says the lookup
> _MAY_ become slow. This behavour is dependent on the filesystem you are
> using. You will encounter this problem with ext3 if you have too many files
> in the same dir. You're less likely to encounter it with reiser. This comes
> down to the competance of the administrator. An incompetantly setup mysql
> table ( without indexes ) would have the same problem.
Right, I have had to create a filesystem with directory structure
where I use the md5sum of the binary and split the 32 Bytes it up
into several subdirectories (e.g. 4 Byte wise)
Now this has speed up my binary-server over the factor 3-5
Oh yes, one thing:
For some years as I begun to use PostgreSQL (I think it was 6.5)
I have stored *.doc, *.xls and such stuff into the PostgreSQL which
gaved me a performance as the hell...
Since I do not realy like the hell and found many usefull *NIX-Tools
I have extracted the Data into text/plain of for the *.xls stuff into
XLM-Tables which can very good stored into the Database and searching
is working perfectly...
The original are always stored on my binary-server.
Having infos about JPEG's? I extract teh EXIF data and store it in
the Database...
Greetings
Michelle Konzack
--
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack Apt. 917 ICQ #328449886
50, rue de Soultz MSM LinuxMichi
0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)
--- End Message ---
--- Begin Message ---
Hello,
since I include source sniplets into some of my webpages I like
this syntax highlighting for php scripts... because it make
scripts more readable.
My question is: Does such thing exist for Shell scripts and C?
(It would be realy nice)
Thanks
Michelle Konzack
--
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack Apt. 917 ICQ #328449886
50, rue de Soultz MSM LinuxMichi
0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)
--- End Message ---
--- Begin Message ---
PHP list,
This may be a simple matter. Please feel free to tell me to RTFM if you
can direct me to exactly where in the FM to R. Or, alternately, please
use simple explanations, as I'm not an experienced PHP coder.
I'm building a simple content management system, where users can enter
text into a web form. The text is stored in a MySQL database. The text
should be plain text.
When the text is retrieved from the database for display, I want to add
some HTML tags so I can control the format with an external CSS.
I'm assuming the best way to do this is with str_replace(). But there
are some complications which make me unsure of its usage.
First, here is the code I initially made:
$content = "<p>" . str_replace("\r\n", "</p>\n<p>", $text) . "</p>\n";
echo $content;
The problem is that I want to give the users the ability to add text
that will be converted to <h3> tags. I figure the best and easiest way
to do this is give them some text markers, like "--++" and "++--" that
can be converted to <h3> and </h3> respectively.
So I guess I do:
$content = str_replace("--++", "<h3>", $text);
$content1 = str_replace("++--", "</h3>", $content);
$content2 = "<p>" . str_replace("\r\n", "</p>\n<p>", $content1) . "</p>\n";
echo $content2;
But of course a user is likely to put their <h3> heading at the
beginning of their text. Which would generate:
<p><h3>Heading</h3>text text text</p>
That's not good. What I need is:
<h3>Heading</h3><p>text text text</p>
And figuring out how to do that was where my brain stopped.
I need to be able to account for circumstances where it may not be
appropriate to arbitrarily put a <p> tag at the beginning.
As well as <h3> tags, there may also be things such as images and <hr>
lines, but they are all similar in that they will take some text code
and convert into an HTML entity.
I need to be able to separate those out and then be able to place
opening and closing <p> tags at the right place before and after paragraphs.
Is there a way to do this? Is there a good tutorial available?
Any advice appreciated. Thank you for taking the time to read this.
--
Dave M G
--- End Message ---
--- Begin Message ---
Dave M G wrote:
PHP list,
This may be a simple matter. Please feel free to tell me to RTFM if you
can direct me to exactly where in the FM to R. Or, alternately, please
use simple explanations, as I'm not an experienced PHP coder.
I'm building a simple content management system, where users can enter
text into a web form. The text is stored in a MySQL database. The text
should be plain text.
When the text is retrieved from the database for display, I want to add
some HTML tags so I can control the format with an external CSS.
I'm assuming the best way to do this is with str_replace(). But there
are some complications which make me unsure of its usage.
First, here is the code I initially made:
$content = "<p>" . str_replace("\r\n", "</p>\n<p>", $text) . "</p>\n";
echo $content;
The problem is that I want to give the users the ability to add text
that will be converted to <h3> tags. I figure the best and easiest way
to do this is give them some text markers, like "--++" and "++--" that
can be converted to <h3> and </h3> respectively.
So I guess I do:
$content = str_replace("--++", "<h3>", $text);
$content1 = str_replace("++--", "</h3>", $content);
$content2 = "<p>" . str_replace("\r\n", "</p>\n<p>", $content1) . "</p>\n";
echo $content2;
But of course a user is likely to put their <h3> heading at the
beginning of their text. Which would generate:
<p><h3>Heading</h3>text text text</p>
That's not good. What I need is:
<h3>Heading</h3><p>text text text</p>
And figuring out how to do that was where my brain stopped.
I need to be able to account for circumstances where it may not be
appropriate to arbitrarily put a <p> tag at the beginning.
As well as <h3> tags, there may also be things such as images and <hr>
lines, but they are all similar in that they will take some text code
and convert into an HTML entity.
I need to be able to separate those out and then be able to place
opening and closing <p> tags at the right place before and after
paragraphs.
Is there a way to do this? Is there a good tutorial available?
Any advice appreciated. Thank you for taking the time to read this.
--
Dave M G
It seems like your life would be a lot easier with break takes instead
of paragraph tags. Break tags behave like newlines, so work rather well
for a 1 to 1 correspondance when turning \r\n into <br />. This way, you
don't have to worry about the opening tags.
The fastest way to do this may be the function nl2br(), which takes only
one parameter, your string, and returns your string with the newlines
replaced by break tags.
Another piece of advice is that you are creating a lot of strings. Do
you need the string $text to be unmodified? Why don't you do this:
$text = str_replace("--++", "<h3>", $text);
$text = str_replace("++--", "</h3>", $text);
$text = "<p>" . str_replace("\r\n", "</p>\n<p>", $text) . "</p>\n";
echo $text;
Remember that PHP works by value, not by reference. So what happens in
that first line is that it makes a copy of $text, does the replacement
on that copy, and then overwrites $text with that copy. With your method
you are creating a bunch of strings that I would imagine go unused later
in your script.
Since you seem to want to maintain a newline in the HTML source, nl2br
might not be exactly perfect for you. Here is your original code
modified to work with break tags:
$text = str_replace("--++", "<h3>", $text);
$text = str_replace("++--", "</h3>", $text);
$text = str_replace("\r\n", "<br />\n", $text);
echo $text;
And here is the same code using arrays and one single replace
instruction to do it, since replacement order doesn't matter:
$text = str_replace(array("--++", "++--", "\r\n"), array("<h3>",
"</h3>", "<br />\n"), $text);
echo $text;
And of course, if you never do anything with your formatted string
except echoing it out, don't store it, just echo it:
echo str_replace(array("--++", "++--", "\r\n"), array("<h3>", "</h3>",
"<br />\n"), $text);
So, to sum up my advice:
1) Don't create extra variables that you will never use
2) Consider using break tags instead of paragraph tags, they're easier
to deal with in your situation.
3) Use arrays for replacement when appropriate
4) Don't store data if you're only ever going to echo it out right away
and never use it again.
I think that's it, unless I missed something.
Regards, Adam Zey.
--- End Message ---
--- Begin Message ---
At 12:53 AM +0900 5/26/06, Dave M G wrote:
PHP list,
This may be a simple matter. Please feel free to tell me to RTFM if
you can direct me to exactly where in the FM to R. Or, alternately,
please use simple explanations, as I'm not an experienced PHP coder.
I'm building a simple content management system, where users can
enter text into a web form. The text is stored in a MySQL database.
The text should be plain text.
When the text is retrieved from the database for display, I want to
add some HTML tags so I can control the format with an external CSS.
I'm assuming the best way to do this is with str_replace(). But
there are some complications which make me unsure of its usage.
Dave:
RTFM -- yeah, unfortunately, there's a lot of that going around --
most justified, some not.
In any event, I think this is where you're going wrong -- don't use
str_replace() to alter the *content* at all !
If you know css, then keep the content separate from presentation.
Content comes from your mysql and you should be able to place it
within html markup where its presentation is controlled by css.
For example, if I have a text paragraph ($my_paragraph) that's been
pulled from mysql and I want to show that paragraph in html, then I
would do something like this:
<div="content">
<p>
<?php echo($my_paragraph); ?>
</p>
</div>
That way I use use css to control how that paragraph will look with
those <div> and <p> tags and, at the same time, make the content easy
to handle.
If you want to allow users to enter html tags themselves, then you're
asking for a bit of trouble IMO because you are relying upon them to
do the mark-up correctly.
For example, if someone entered "<h1>This is what I want to say</h1"
-- how would you handle it? Also note that if that was entered
"as-is" your page would not longer be well formed and would probably
cause problems with the rest of your page, not to mention not
validating.
If you think you can write code to fix their mistakes, then I think
that's a mistake for users can screw up code even more than
programmers can. :-)
Additionally, if you don't handle the input right, then there's a
security concern, such as mysql injection.
If you want to give your users the option of having "headlines" and
"body of work", then provide a Headline box and Body of Work box and
then manage those entries in your markup.
I think you get the idea.
I'm sure there are other ways to do this, but this is the way I've done it.
hth's
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
Can the pic include be based on a variable?
my client asked me this question. I have a movie that is the header to
the site and it pulls in a swf that calls a picture from pic00.jpg.
I'm not sure exactly what he means by this. I'm assuming he wants to
pass flash a variable name instead of a hardcoded file name but, I'm
not sure exactly how to do this. Am I on the right track? Can someone
show me an example or point me in the right direction?
Thanks,
T
--- End Message ---
--- Begin Message ---
At 9:54 AM -0600 5/25/06, Tristan wrote:
Can the pic include be based on a variable?
my client asked me this question. I have a movie that is the header to
the site and it pulls in a swf that calls a picture from pic00.jpg.
I'm not sure exactly what he means by this. I'm assuming he wants to
pass flash a variable name instead of a hardcoded file name but, I'm
not sure exactly how to do this. Am I on the right track? Can someone
show me an example or point me in the right direction?
Thanks,
T
T:
If I understand you correctly, you just create a variable for the
first part of the image and then add on ".jpg" or whatever and then
place it in your html <img> tag.
The following is an example taken from my: http://xn--ovg.com/location
php
$flag = "flags/".strtolower($country_code).".png";
html
<fieldset class="bgblue">
<legend>Your location</legend>
<?php echo ("Country: $country_name - $country_code <img
src=\"$flag\" >");?>
</fieldset>
What this does is pull in a flag image of the county and show it to
the user. I have no idea who the user is, but their IP gives me an
indication that I then lookup in a dB. From there, I pull out the
corresponding flag and assemble the <img src"<whatever>" call.
Get the idea?
hth's
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---