Good morning Im running gentoomod_php4 and php5-cgi to aid in discovering migration issues of some archaic code
it wont quite work that way
cant give users an irc client
why not?
php_flag magic_quotes_gpc off in a .htaccess file in your webroot
well, now its fixed
in the code
yeah, until the next time you use $_(GET|POST|COOKIE)
thanks anyway for teh advice bbryant
f00li5h yep, now works, so no mre changes for now
if it works… don’t touch it
they need ot be connected to an operator not enter an IRC room
why not fix it now?
read my last line
and the operator doesn’t have an IRC client?
it is not fixed, that’s what i’m– who cares, do what you want
what do you mean
the httaccess file
or the code itself
I deleted strip slasghes yet
you’ve got code to work arround magic quotes, which you can just turn off
well, it’s a shared server, how can I turn it off?
httaccess?
what is everyone going ot enter the same room ?
yes
i think IRC supports PMs
well, I have to recognize that I’m a bit lots there
(/In fact I’m a java/nj2ee developer that got a good php work)
sessions are for persisting information between requests. Depending on what that one page is doing, you may or may not need them.
Hay peeps
anyone need file sharing my site went live today boostshare.com
again users enter an irc room then i PM them ?
sorta ghetoto
well, it’s well tested
fyrestrtr i need to use a flag variable to know when to display certain html after the page has been refreshed from submitting a form pointed at PHP_SELF
you don’t need sessions for that.
you could tamper with the irc client, and have it do a PM to one of the ops in #support or similar
and present the user with that
yeah i can see that now, im tired been goin at this all day and for some reason i can’t think of the obvious right now heh
i would feel mucn more secure using a different protocol but yea
well, thus far my solution is the best (only) one you have, no?
re
meow
how do I get php to execute an exe file on a windows server?
exec(“file.exe”); ?
where does that file have to be?
you should give it the full path
if you provide the absolute path or chdir() first it could be anywhere
anywhere you have permission to execute that is
i’ve been trying to do this for 2 hours.. i’ve tried this
linuxtk10, you could also have people join a room, and automatically set the services to only allow operators to join after it’s created
i’ve googled it a million times too
then have a bot inform people that there’s somebody waiting in a room
exec( ‘C\path\\to\\your\\binary.exe’ ); # that’s it
you have to use 2 \’s because \ is the escape character in php strings
]
which bit?
yes.. let me try this.. again
The \\.
exec(“\”c\program files\\winamp\\winamp.exe\”");
does not work
nor does it without the quotes
what?
check that it doesn’t want progra~1 or something
nope..
i’ve been able to execute cmd, but not any commands through cmd
I’m trying to create a web application so I can control winamp from my iphone
lol
and if I can get this thing to execute a command line program that controls winamp..
the sky is the limit
but I’ve been stuck on this first step for 2 hours
hrm
test2 php } ?
cant think of how else to do it
isset($_POST['bla']) ???
that’ll work, but i’d suggest using a template of some sort
thats shorter
i must learn PHP
and MySQL
i guess isset would be safe , before i was using GET which could have issues with null’s if i did isset someone said
f00li5h a template in what sense?
i dont wanna have to do this with asp
that sounds desparate sedai| … is it a matter of life and death?
how many senses are there?
im the all-your-html-in-another-file sense
hmm i know how I can do it with cold fusion.. but that’s overkill
how would i get the html host ?
well, in most of my uses I want null GET variables to trigger my conditional
someone said there was a security exploit goin around about that
Hal, paths are case sensitive
you really do want to wrap arround the get/post variable behaviour with a class of some kind
to do isset($_GET['bla'])? I want myphpfile.php?bla to cause the conditional to evaluate true
‘; echo implode(‘br /’,$_POST); } else { echo ‘form method=”post” action=”‘.basename($_SERVER['PHP_SELF']).’”input type=”text” name=”name” value=”value” /input type=”submit” //form’; }
if you are expecting a possible null value and check the value before using it then I don’t see how it could pose any sort of risk
$_POST won’t do what you want there
examancer, when a variable is assigned NULL, it evaluates as not set
var_export($_POST)
oh, hmm
I am redirecting from within an iframe to a page on the site that contains the iframe.. using header() – the issue is of course, its loading the site into the iframe. Is there a way to load the page into the viewport thats the parent? or can I get header to open into a new window?
f00li5h if i put all the html in a separate file how would i load it into my php script?
examancer, but if it’s set to anything but null, it’ll be set
with header, no.
include
fyrestrtr is there a better way?
you can do include(“bla.html”) on a pure html file?
yesterday i was askin for the exact opposite saying it woudl be nice if i could keep my html and php separate by putting include(“bla.php”) in my .html and someone said i should just throw all my html and php hosting together and name it a
..php file so that’s what i did heh
ChrisC35, HTML, meta http-equiv=”refresh” content=”0;URL=whatever.html” target=”_top” /
when the script is done what its doing, I need to redirect to another page – is there another way besides header?
you cannot redirect and expect html functionality; unless the url you are redirecting to has the functionality you want. In other words, the page that you are redicting to can check to see if it is included in a frame or not; then ‘break out’ of the frame; but this is a HTML issue, not PHP.
meta, javascript or a plain ol’ link that a user can click.
f00li5h i just looked at the docs and it says If you want to include a file that has no PHP in it (such as a template), it is more efficient to use file_get_contents()
Or readfile.
ok thanks i’ll try the meta thingy
just faster i guess
anyway sweet templates ftw
but it’s likely to have php in it
bbryant is URL= supposed to have http:// or not?
since you’ll want to have your navigation built from a list etc
depends, it doesn’t have to
f00li5h ah
it’s like the href attribute for links
same principle
does look a lot cleaner
graywhite, no, $_POST is always set, so that if will always be true
i’m not sure if $_POST will ever be unset though
I think you want, php if (count($_POST)) readfile(“template.html”); ?
that’s still meaningless
right i didnt paste im just tired and tried to type it out heh
no it’s not
there being items in $_POST doesn’t mean your form was postsed, someone could have just made a post request
bbryant it is redirecting ok, but it is still in the iframe
fopen() [function.fopen]: php_network_getaddresses: getaddrinfo failed: Name or service not known
Anyone have experience with this error?
sounds like the thing you’re GET’ing isn’t there
most likely due to a DNS resolution failure
f00li5h, yes, but it does what he was trying to do
i didn’t say it did any form validation :-p
ChrisC35, one sec
should it maybe be _parent?
in your case, both should do the same thing
_top just make sure it loads in the full browser window
do I even need to go through the motions of explaining why not validating/cleaning data is a terrible terrible plan?
_parent makes sure it loads in the frame right above it
f00li5h … i’m not getting anything though
try buying her a couple of drinks
i’ll try parent
f00li5h heh
f00li5h, I assume form validation would go somewhere else
sometimes I _do_ want to know if something has just been posted
and then give any error reports if i find any
then you need if ($_SERVER['REQUEST_METHOD'] == ‘POST’)
this works but when i refresh the page the unset() doesn’t get the html host that was loaded to unload php if (isset($_POST['answer'])) { readfile(“template.html”); unset($_POST['answer']); } ?
$form = new Form_ThisSetOfQuestions(); if ( $form-validate() ){ process }; $form-render()
fyrestrtr, not necessarily, you can send an HTTP POST request with a content-length of 0
i prefer to just check if there’s anything parsed into the $_POST array
besides, it’s shorter too
what does content-length 0 have to do with anything?
nope, _parent didnt work either
Do you know any other things that would cause the error?
you can post without sending any values
if the length is 0 then no data is sent with the POST request, it acts like GET would
no
so what does that have to with what request method was used?
its not like it magically morphs from POST to GET
just because content-length is 0
my point is, post data being sent is not necessarily true when the method is POST
so there’s no need to do any validation, or anything later by using that method
yes, but why are you arguing with me on that? $_SERVER['REQUEST_METHOD'] has nothing to do with the payload of a request, just the *method* of the request.
because starting form validation on a request with no data doesn’t make any sense, count($_POST) is a better way of doing things
I wasn’t talking about form validation, I was posting a way to check if something has been posted — which I understand to mean, is there a post request to the server? Nevermind what $_POST has or not.
what’s a good way to do broken nested ifs in PHP?
if (condition) {
if (condition2) {
endif(condition)
hey zackattack, sup?
sup shesek
can’t be switch/case?
fyrestrtr, well then i misunderstood you
there is no good way to do that, since that is not supported in php
i didn’t really understand the question
zackattack, you’d have to do something dirty, like, if (condition) { if (condition2) { $break = true; break; } if ($break) break; …
Eww.
Yeah,
I ended up sovling the problem by just copying/pasting a bunch of code.
“it’s not fixed unless you fixed it”
I didn’t need the ugly nested if hack
what is a broken nested if?
Are there anything close to structures in php?
a class with no methods is a struct
struct myStruct { $name, $som, $new }; etch?
I figured as much, was just wondering if there was anything specific to it.
Thanks.
class myStruct{ public $name, $som, $new };
Thanks.
hi all
how can i run php webhosting from cli if it was built with –enable-cgi by default ?
php -C ?
why don’t you run php-cli?
f00li5h, i dont have it
why not?
shared host … get a better host
so there is no alternate to this ?
well, what’s wrong with using the CGI binary?
the only difference is that it throws out a couple of headers at the start
actually, that’s wrong, it as a bundle of idiot proofing doesn’t it
f00li5h, i have a php script that likes to run in cli mode
goodnight everyone
Can anyone help me with a SimpleXML issue real quick?
givertex dont ask to ask just ask
rd
Hi, I’d like to be able to click a button on a web interface, and have an audio file play locally on the server. I’m trying to do so just by using php’s system() and mplayer. When I’m doing so mplayer returns this error “Terminal type `unknown’ is not defined.”. I have googled this error, but I
can’t seem to find a solution. How can I make this work? Thanks…
var_dump(json_decode(‘{access_token: “8ce03ddd51f16b367cae398c4744ced2d5466c69″, user_id: 9984}’)); Returns NULL on 5.2.2
any clue why this might be hapening?
i’m guessing that running the same mplayer command plays the mp3 without errors?
Yep, no error.. it is as if the web/apache user doesn’t have access to the soundcard or something like that.
hi, can anyone tell me, where can i get some idea about i18n of php web application?
su to the web user and try running mplayer?
and I’m guessing that terminal type ‘unknown’ relates to your $TERM environment setting.
givertex, try putting access_token and user_id in quotes
Do you by any chance know the default password of the apache user? (the user is called www-data on my ubuntu installationen)
It doesn’t have a password, because the account isn’t intended to be used. You can su to it from root, however.
There is no default password
Don’t give the account a password.
And don’t feed it after midnight
su root ; su www-data
Wait… that’s a Mogwi
I tried playing an audio file from the apache users – There is several errors where it says it does not have access to things, fx “[AO OSS] audio_setup: Can’t open audio device /dev/dsp: Permission denied”
Yeah, that’s normal
Typically apache doesn’t do a lot of rocking out
so give the apache permission to use /dev/dsp
Hah
Is it possible to run the mplayer command from another user via php? Security is not an issue as this is a local server…
asns the
erp, sans the
Sure, setup sudo
thanks, too bad it’s an API response…. :[ Worked by copy&paste
I'm not so strong in user access administration in linux... could you please tell me how to grant that access?
man chmod
chmod 777 /dev/dsp might work.
otherwise you can google for a sudo tutorial and grant access to /dev/dsp; i don't remember the syntax off the top of my head
morning all
Wooaav ! - I think it works! hang on
9984 )
Now I only need to find a way to make the previous audio file stop, before starten the next one ...
killall -9 mplayer
Thank you guys...
Now I own my own personal network based jukebox
bonus
Good morning. I'm running gentoo+mod_php4 and php5-cgi to aid in discovering migration issues of some archaic code. Fairly obviously the cgi doesn't get passed some per directory (either through httpd.conf includes or .htaccess) settings. Does anybody know a decent 'trick' to allow me some
form of emulation ?
On last thing ... I run the mplayer command via the backticks operators. Unfortunately the web request "hangs" until the audio file has ended, because mplayer keeps sending return vales throughout the song. Can I avoid this somehow?
are you sure its because of the output, or because of the fact mplayer takes the song length to run
hm. good question
try "mplayer foo&"
so it forks into the background
Could always revert back to using the good ol' iframe so the rest of the page is free'd up
Presuming your not playing it through headers or such
Mace[work]: Actually I am using iframe – but I don’t want that to keep loading either
http://www.phpfreaks.com/tutorials/71/1.php
that might come in handy, too–quick little tutorial on forking processes with php
could use xmlhttprequest then for the asycronous transfer so you don’t get the loading bar
Mace[work]: True.. good idea
Hi I have a stupid problem here.
thanks, I’ll look into that
I got three variables, two with numbers in it and one with a operator
ah, there’s a better writeup of forking processes with php http://www.electrictoolbox.com/article/php/process-forking/
like “1+1″?
yes
how can i check what version of php i have in my machine?
I cannot get it to calculate it
It just prints it instead
make a test.php file and write the following php phpinfo(); ?
kashei, ok
taking a look
kashei, thanks
great, thanks.
php -v gives you the version from the command line, a bit simpler
line 15 builds a string not a math operator.
garret_ I know, thats my problem, cannot figure out how to do it.
mornin
/dev/null &’; did the trick Thanks for your help
I thought you could use eval, but you can’t.. soo..
Hi, I am working on some code and the author has used what appears to be odd syntax (to me!) for the control structures, there’s no curly braces and they are not using the ternary operator – I’ve looked at the docs on alternative syntax and not found anything – any ideas where I can find some
info on this?
maybe something like swithc(rand(1,3)) { case 1: $result = $val1 + $val2; break; case 2: $result = $val1 – $val2 …… }
It’s possible somehow
you might already do so; but make sure you validate the $_GET['play'] …. don’t want any shell injection
return $var
arh
I knew someone was gonna say that – I AM aware
But thanks anyway
I think I got it
tried that and i kept getting syntax errors.
ow k
good cannot read your mind unfortunately
Ronald:
$str=”1+1″; echo eval($str); “unexpected $ in foo.php”
ello ello. im wondering if some people in here could tell me their favourite php editors? does anything have decent ftp/scp support? code completion or code hinting? syntax highlighting too. currently using adobe dreamweaver as I work with a bunch of designers. thanks heaps !
Got it working this way http://pastebin.com/m147328e4
Thank you
cool
what might make a php page time out?
Server faeries.
What’s your script doing?
if I want to send a news letter but not have the person recieving it send a read recipte can one do this?
how do i get the raw version of what is in $_POST ?
“Raw version”?
I’m using Cacti, but the people in #cacti aren’t in the numbers that there are here, and I suspect it has something to do with PHP itself. My phpinfo() works, but the script doesn’t.
what the browser sent…
huh. ok.
Then it goes through the webserver, so PHP may not know.
eval’s pretty picky
“1+1″ is valid code. eval(“1+1″) is a parse error.
huh
1+1 is invalid code.
doesn’t cause a parse error.
eval just exec the code
if u want it to return sth
– tell me this parses.
$var = eval(“return 1+1;”);
hello
ahh. late night, i guess.
will parse.
yup
im using ZEND_SESSION from ZF framework – http://paste2.org/p/5908 – can someone take a look at this ?
it won’t do anything, but it’ll parse.
that’s true
strange
but it is not proper code for eval
yeah, which i just figured out a second ago
_Ergo_, that’s because foreach is modifying the internal array position, and it can’t do that
but when you copy it to a local variable, you can
but there is array inside it, the funny thing is with php 5.2.3 on my local machine it doesnt have problems
umm.. php puts it into $_POST
which is a multidimensional array. i just need the raw data php worked on
But then, as per definition, it is no longer “raw”.
ah…. “Due to the implementation history of PHP magic methods, modifying an array inside a namespace may not work under PHP versions before 5.2.1″ ok found it…..
fine i’ll keep looking myself :p
Looking randomly through the manual I pick out http_build_str and http_get_request_body_stream.
Your mileage may vary.
requires extension – i’m pretty confident an extension shouldn’t be needed
out of curiosity, ‘why’ would you want to do that?
hello
where can i locate the latest php rpm ?
couldn’t you just stich it back together and use it as a string?
php.net/download
first question still stands though, why’d you want to do that o.O
hi all. can you suggest some resourses with full and cleany explanations of ACL?
Mace[work] : cant seem to see any rpm files there?
http://www.google.co.uk/search?q=PHP+5.2.3+rpm&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
it’s not rocket science really
lol
ta
Jafet / Mace[work]: file_get_contents(‘php://input‘) does it
Mace[work]: i found a bug and needed to verify it
i see
Mace[work]: i see that the bug is pretty much unfixable though
presumably you know where to take that then
Mace[work]: that what where?
bugs.php.net
Mace[work]: it’s unfixable :
they work magic
$_POST
it certainly needs reporting then
doubt it actually *is* a bug though
Mace[work]: input type=”image” name=”Image[0]“
php can handle diminsional name/id tags?
Mace[work]: Id is html, Name yes it can
Mace[work]: but image inputs append “.x” and “.y” to names, it doesn’t work with arrays
not meaning to be picky but that’s a html problem not php
Mace[work]: since Image[0].x turns into Image[0]_x which doesn’t make sense
That’s a feature. Deal with it.
It’s not a feature
the end result is that both gets written in Image[0]
so the .x is lost
..y is in Image[0]
it’s the price you pay for having x /y co-ordinate support
if I want to send a news letter but not have the person recieving it send a read recipte can one do this so that I still know that the user has opened the email, download a dynamic picture but… how do I flag a database column?
Mace[work]: i don’t even need the x/y’s, i just happened to come across the bug :p
Liquid-Silence: Gmail blocks images in emails.
so does outlook
Liquid-Silence: And I mark all newsletters as spam.
I have used them before for image cropping – it’s worth the price
but when they force download the images it will work
Mace[work]: it is definitely a php bug, it should be placed as [x] [y] instead of _x _y
Liquid-Silence: use mod_rewrite to change .jpg to .php then execute a script that updates your database
Mace[work]: would break a lot of backward compatibility though
Mace[work]: for all i know this could be fixed in php 5.0/1 ?
it’s probably been brought to their attention before now anyway
Mace[work]: ok I will read up on this thanks
HAH i said it was unfixable :p
that’s what bug list says anyway :p
why can’t you just use Image[0]_x?
Mace[work]: so foreach client I include something like this
Mace[work]: it doesn’t exist
because this is not python
img src=image.php?emailaddress…. then when the images pulls down
the image.php updates the db?
so it ends in Image[0][0] and Image[0][1]
Liquid-Silence: not quite that would be detected and prevented
hmmm
I can not find any info on google about this
Liquid-Silence: Obviously mail clients should block anything that has the remotest potential to load a request, like a frame or image or script or whatever.
But that’s the general idea.
Then send the appropriate content-type header.
it’s not even close to the idea
yeah
Mace[work]: Fine.
it would be prevented and hence doesn’t work
Mace[work]: Prevented?
in .htaccess do RewriteRule ^newsletter-image/(.*).jpg$ /update_database.php?email_id=$1 [QSA]
then use a simple image in the email where the name of the image relates to the users email address
Google “mod_rewrite”
most people have images off in emails…
it’s useless to use images unless they are embedded, which defeats your purpose
hmmm
afaik Hotmail etc attach the image that’s sent inside an email hence it does work as the image gets downloaded
if the image gets downloaded in any form, whether displayed or not, it still works
sweet mother of god this was a huge channel
and to be honest gmail, hotmail etc are all a waste of time sending useful information to because they are used by people who never spend any money anyway
I know of not one business that promotes the use of “gmail” or “hotmail” for their staff, everyone uses Outlook or Thunderbird
I know of not one business that should promote to use Outlook.
outlaw is probably the no 1 way of getting viruses
i know of at least one major telecoms company that uses yahoo to manage it’s sales appointments
yahoo calendar and email that is
A telecoms company using a 3rd party to communicate with it’s employees? that _has_ to be a British company, it defines irony
how to get the row id of the last insert?
php.net/mysql_insert_id
thanks
hi i dont know if im doing right dont know much about mysql i have a block on my site that pull member name and date joined this member have a personal photo that is in another table how i can call it together example in the table Photo,name,joined this is the code http://www.pastebin.ca/656647
wow i cant believe you posted an unfathomable three line long irc post without at all showing a single scrap of capitalization or basic punctuation
yet another person coming to ##php for a #mysql question
Jafet my english is not good
i ask on mysql and they send me here
gar type /join #mysql
AlexC_ usual stuff that always happen in this irc server
aha
sorry gar
So i made a script for downloading files, but when i choose “Open” the file doesn’t exist to the program trying to open it – is this cache settings or what? anyone know what i can do server side to fix this?
gar, just do a left join, for example SELECT m.id, m.members_display_name, m.joined, m.pp_thumb_photo FROM members m LEFT JOIN profile_portal pp ON (pp.pp_member_id = m.id) ORDER BY m.id DESC LIMIT 10
ugar, just do a left join, for example SELECT m.id, m.members_display_name, m.joined, m.pp_thumb_photo FROM members m LEFT JOIN profile_portal pp ON (pp.pp_member_id = m.id) ORDER BY m.id DESC LIMIT 10/u
Your English is perfect. It is your attitude that may need slight adjustment.
nah it was my mistake, I sent him to ##php by mistake
instead of actually reading the pastebin
Hello, I’d like to ask, why I can’t see PHP.net in english. http://animesivu.com/upload/view/6C6AEEDB.png
it doesn’t matter that do I use us.php.net, fi.php.net ..
I still see the same crap. Sigh.
incd, that is because php.net correctly identified you as finnish-chinese.
http://fi.php.net/my.php
choose ur fav language
german
follow my link ^_^
wtf… finish chinese!
i once got php.net in italian or something for about half an hour before i could find the right link. then the header with the nav disappeared
Thanks a lot
the finish chinese have an ancient history. they’re actually credited with writing the first limrick.
this is of course not true
for ( $kio = 0 , $kio 1000 , $kio++ ) {
$kelly = rand(1,98898);
echo $kelly;
}
hi, would someone know how to calculate age through date of birth ?
Oliss, nothing, besides the fact that you’ve pasted it into the channel.
berry_ is it wrong to paste it here ?
I shouldn’t ?
Oliss, yes, it is. No, you shouldn’t.
I didn’t know you could seperate them with a comma?
berry_ how would you know the prb then
use ; instead of , ?
should it not be $kio = 0; $kio 100 …. etc
Oliss, ever heard of pastebin?
ohhh !! yes
(time()-$timestamp_of_date_of_birth) / 3600*24*365 ?
AlexC_, Oliss, omg, can’t believe I didn’t see that!
thanks garrett , berry_
and ceil( the result )
make sure you have error reporting enabled. you’d get something like “unexpcted ‘)’, expecting ‘;’
Thomvaill, 3600*24*365 ?
AlexC_ thx also
the number of seconds in a year ?
86400 * 365
it’s the same ..
Thomvaill, oh, hmm, sounds like an idea
http://snippets.dzone.com/posts/show/1310
but I am trying it out now
so theres always 365 days in a year huh?
1 year = 365.242199 days according to google.
so $age = ceil((time()-$timestamp_of_date_of_birth) / 3600*24*365.242199);
Shrike|work, when we’re calculating age, that quarter day won’t make that much of a difference
why this get’s the entire line fgets ($user_file, 4096)
fgets ($user_file, 4096) … what is 4096 ?
well, over the course of 4 years you’re actually aging one day secretly.
MindSpark, depends if you need to be actually correct or just nearly correct
Shrike|work, in this case nearly correct IS actually correct
also you won’t be taking into account daylight savings tyime
time*
hmm, good point
( leap year discussion …….. ) “The years that are divisible by 100 but not 400 are known as “exceptional common years”. By this rule, the average number of days per year will be 365 + 1/4 – 1/100 + 1/400 = 365.2425.”
if you can work the function strtotime() in somehow it will figure out these things for you
and daylight savings doesn’t do anything since the hour is zero’d over the course of the year
it doesn’t add or subtract an hour so much as adjust the schedule ahead or behind
well if you are accurate to the hour it might cause an issue
Shrike|work, I am not even accurate to the month
??
fgets ($user_file, 4096) … what is 4096 ?
it’s the maximum of bytes
yes , but it get’s the entire line
is the line max bytes is 4096 or..
because the line is than 4096
ohh a new piece of info
thx
it reads 4096bytes the first 4096bytes of information from where the cursor in the file is. 4096bytes=4k. if the file is 4k, it’ll read the entire file.
oh, lag.
garrette__ THX ,,
garrette__ ,
hello, does anyone know dotproject?
I’ve USED it before
like once or twice :;/
never set it up
hum.. I think fgets only returns line per line
lol at fget
at the oposite of fread
obnauticus, i need to save a field input in the database of dotproject but i dont know how, i can pay someone that help me
now i’ve learned something new
thanks for clearing that up
I have this file full of functions without actual execution code in it. But I want all functions to include another php file. Do I have to explicitly include it in in every function ?
or is there a way to just include it once in that file ?
No idea thehcdreamer
obnauticus, ok thanks
I want to say there’s a way to do that, but I don’t remember if I’m thinking about something in C++ or PHP. A possible solution would be to wrap all the functions in a class and then, if you can, make that class inherit from the other include file (assuming you wrap the other file as a
class)
garrett__, I don’t want to make that object oriented, should be compatible with php4
I am just wondering if require_once would make a difference
i.e. instead of using include at the beginning of the file
“should be compatible with php4″ – php 4 has enough oop features for basic oop
subj, ok, thanks
and look at include_once(), require_once()
-()s
*btw* require_once() should be used only outside functions/classes at the start of files
use include_once() inside functions/classes
subj, yes, that’s why I am asking
subj, I want to remove all the includes in the functions and just put it in the head of the file
then they’ll have to be in a global scope, i think
which gets sort of annoying if your program gets big
garrett__, and how do I put them in the global scope ?
subj, why is that? require once should be used when a file is required, like when it contains function/class definition, it doesn’t make much difference if it’s used inside a class or in the global scope
it does
if foo1.php has $var=”foo”; and foo2.php includes foo1.php such that include(“foo1.php”) function foo(){echo $var}), var will be null.
require_once() is “executed” at parse time – so the required file is parsed all time
garrett__, thanks for that meaningful input, we’re not talking about that.
subj, that’s not true
heh, i agree
hmm?
I believe require_once checks if a file is already included to avoid redeclaration of functions
include() doesn’t cause a fatal when the file doesn’t exist. thats the only difference afaik
if i dont want to use iframes, what is it called in php? sorry if i dont explain good enough.
aye
subj, the only difference between include and require is the way it handles errors, require will issue a Fatal while include will issue a Warning.
hence the semantic meaning….
s/meaning/naming
hmmm
anyway, most of the time, usage of include_once doesn’t make sense
and yes, it was meaningful, as it pertained to why include/require wouldn’t work in his case unless he rescoped the content of the include
i’d say use of include() doesn’t really make much sense
What are these “signs” like || && ?? called so I can look up on the on php site?
Matic`Makovec: logical or and logical and
www.php.net/operators or something similar
Thanks
garrett__, we’re talking about “require_once should be used outside functions while include_once should be used inside functions”
“Note: Prior to PHP 4.0.2, the following applies: require() will always attempt to read the target file, even if the line it’s on never executes.” – i still had this in my mind
*grmpf*
huh.. i guess i don’t know why i addressed that to you–probably been up too late. sorry
s/late/long
blah
subj, that’s old, indeed
it is
so include_once() only if you have an error handling for it
one is a [six]:[ok], i want to click [six] as many times as i can and when i click the [ok] it shows me how many times ive clicked [six]. How do i accumulate the number of times ive clicked six?
javascript.
javascript or www.php.net/sessions
you could write an onClick event that triggered a function to increment a counter, and another onClick for the “ok” button that will print the value of the incrementing variable
the javascript one is the one id want. Anyone got some sample code? I’m not all that good with JS
google for “javascript onclick tutorial” or something….
first hit on google http://www.intranetjournal.com/corner/hoque/eh-1.shtml
and a general tutorial for intro js on the second hit http://www.cs.brown.edu/courses/bridge/1998/res/javascript/javascript-tutorial.html
checking those out
and a link to almost exactly what you want.. http://www.pageresource.com/jscript/jlinktut.htm
i really hate flash
for some reason, every time i go to fark my cpu spikes and sits at like 99% while gobbling ram
there’s something goofy with their lame dell flash ads
I am doing this “edit news” thing and I am deciding between ways of getting id of the news. One is that I just $_GET and the other one I’m thinking also about is with exploding the URL and taking the id out of that. What is better, safer in your opinion?
not sure which is better, $_GET is probably safer as it’s parsed by the server. strange things can happen when you mess with URLs
i assume you’d use some mod_rewrite rule to get parameters from a URL
how do i test is ssl is enabled in my php?
make an ssl conenction
how?
i am a php noob
congratulations.
?
you could just use file_get_contents() on an https URL
if (!fsockopen(‘ssl://www.google.com‘, 443)) { echo ‘SSL No Worko!!’; } else { echo ‘SSL Worko!’; }
or check extension_loaded( ‘SSL’ )
hey
I have never used php sessions, I have always used cookies to store data in the user side, but for what I have read is better to use sessions. Is it better to use php sessions o idenify an user or to store and remember the user language?
Shrike|work, is not this shown in phpinfo() too ?
it should be yes
Aquaman –
Aquaman, the disadvantage of session variables is that they expire at the end of the session
you are crazy
so if you want to remember a language forever, use cookies
hahaha ok
or remember the session with a cookie
what about when they’re logged in?
even then?
sure you know what you’re doing but gee..!
thanks, it works
good efuzzyone
when i do a echo $tal1 $tal2; seems to give error
its two strings.. one in each
echo $tal1 . $tal2;
ahh ok thanks
so what are really sessions used for? I mean in real examples. If they are not to keep data “forever” it must be useful for something
how can I send a POST request to some URL?
or printf(“%s %s”, $tal1, $tal2);
I use session’s to store information forever
I couldn’t imagine having to implement security fixes for every piece of preference info gathered from their computer, it would be a nightmare
I prefer to validate their cookie information against what’s in the database then i know who they are for certain
cookie’s are sooo dangerous..
[Mace[work]] so just remembering the session id, is enough?
nop
they must have a cookie with their username, which matches 5 unique cookie id’s stored in the database
their ip address can never be too far off what it was the last time they logged in
sure it can,
there are a few other little things that can cause them to be logged out but other than that, once they pass that verification their session data is loaded from an AES_ENCRYPTED data field into their $_SESSION
I use cookies to identify users and log them automatically
but you just said that you use sessions to keep data forever
they don’t _have_ to have an account to have a session
I know
so i assign each new user a “random username” then use that to perform the same security checks
Aquaman, typically session variables hold data for the duration of the session
but the cookie which holds the session ID can be changed to make it expire later than the end of the session
that is dangerous though as it is more likely to be “hacked”
they must have a cookie with their username, which matches 5 unique cookie id’s stored in the database
setting unique codes each time (note the plural) the user is detected makes your applications much less prone to specific hack attempts on individuals
why do you do that? can’t quite see why it’s better than a session ID
I have a php bot, and run it off of a shell, how do i make it use one of their other ips?
it’s simple – an md5 is never enough for checking the contents of a file on it’s own right? well the chances of someone setting a cookie with the username “admin” then successfully guessing the next “id1″ “id2″ and “id3″ .. etc cookie’s is well, impossible in my book
s/is/as
but thats the whole point of the session id, isn’t it?
(Mace[work]) setting unique codes each time (note the plural) the user is detected makes your applications much less prone to specific hack attempts on
well you could just call session_regenerate_id() on every request
I prefer to be paranoid
1 ID
depends how you create your own ID’s really
Im becoming a little bit crazy ahahaha each of you say a different thing lol. I dont really know what to use sessions for right now. Phil4 said it must be to hold data for the duration of the session, and what kind of data is just wanted in a session longing time? I’m just trying to understand
this session thing.
I’m sorry if I sound stupid
Aquaman, read www.php.net/session
I read
the thing I’ve found with this channel is, everyone has a different way of doing things which is always “the best”
just do what you find the easiest and safest
$_SESSION is very similar to $_COOKIE except $_SESSION’s data is stored on the server side, not the users computer
[Phil4] hahaha right
what Mace[work] says is basically the extent of it
ok
thanks
i’m paranoid though
ok, so storing the name of the layout and the language of an user or web visitor would be better in a $_SESSION variable or inside a cookie ?
a cookie right?
that is trivial information Aquaman
nothing that could compromise your system
so I’d personally say a cookie would be great for it
It’s up to you, you never know what infiormation a hacker could find useful.
information*
and what if I encript the password of the user with md5() and I keep it in a cookie to identify him, that would be secure aswell?
never store a password in cookie,
just remember, if it’s held in a cookie it needs to be sanitised before it goes into any queries etc. to prevent injection
Personally I start each site with a script that automatically detects users and “starts the session”. It can actually track users which don’t have cookie’s but that’s another story
[Phil4] yeah I know that I had problems with that along time ago
Although those users who don’t have cookie’s can’t store data for longer than a session.
effectively got ranted at by a bunch of people but not actually educated as to why you shouldn’t store it in a cookie
well i suppose you can somwhat identify a user but as long as you dont trust that person to actually BE that person..
they’d have issues storing it even for a session, Mace[work]
trust is one thing that you should never consider when coding
I don’t use cookies
what do you use?
hi, how can i do something like $xxx = include(‘file.php’); ??? but something what works ;]
php.net/output_add_rewrite_var
(as i said,you can’t track them when they return)
do you want the page to be executed, w0jtas?
I should drink less coffee.
hi
and now i want to execute this file and add it to $content string
nice function Mace[work]
something like exec or sth.
rza, moo
here
does anyone know how could I preven Kanji characters from being entered in my database since this is in utf8 and I can guess they will be stored?
I’d say you’re going to wrong way about it w0jtas
whats up?
I got my SQLite stuff working
btw imagick was mentioned in php|architect
i heard
http://public.office.vbulletin.com/sqlite/
I’d have split the file into function(s), include the file and call the functions
ooh
rza, what month?
i need to talk to preinheim to write a full article about it
this issue
one paragraph
hi, how would i find a “tab space” with strpos?
but its in the section that talks about new framework news and ext news
so what’s better way ??
figured if you didnt already know you would find that quite interesting
I’d have split the file into function(s), include the file and call the functions
nothing from olivia purvis yet
propably summer holidays or something
rza, I’ll give a whirl at home later but I think it should be fine
looks good
the sqlite stuff
took a quick view
rza, there isn’t a result set yet
you can however create databases, tables and prepare the queries
it’s not too speed i think ;d
too fast*
hm w0jtas?
pretty solid code
rza, if you’re looking for another task I’ll probably need a hand later this week
the scottmac + rza combo attack
if i have to take all file content from array then add function { before it would take long time if content is long
personally i like WRONG_PARAM_COUNT if wrong number of args is passed
some people dont do that
like if theres a foo(void) passing args is no error
but i prefer more strict approach
hi
I’ve not type hinted anything
all the zend function entries for that are are NULL
you should make argument hinting
its good for reflection
I’m more interested in just getting the base objects implemented first
i’ll go back and type hint and probably refactor large chunks
how do i search a string in a buffer for the “tab” char? \t or whatever it is? with strpos?
minor detail:
strpos(“\t”, $foo) !== false
take a look at PHP_METHOD(sqlite3, prepare)
whoops other wy about
dont use zend_object_store_get_object before youve parsed args
minor detail thou
strpos($foo, “\t”)
mem leak?
no
if sql_len is 0
you call function for nothing
minor detail then
yeah
I seriously expect half of this to be re-written once done
or at least re-engineered
i had an error in imagick where i called zend_object_store_get_object in a loop
where i couldve just called it once before the loop
but i rewrote most of that stuff anyway
so if i can’t reproduce the imagick problems on WIndows later we good for a stable release?
i would say lets go with a release candidate
if no bugs reported in lets say 10 days
then go stable
is there a way to make strpos return the char on a certain place ? like having it return the letter L in the word Hello by having it return char2 ( the third char in the string )
rza, what do we do after its stable then? Find a new extension
use []
keep up with imagemagick guys breaking the api
yeah
new extension would be nice
i wrote a small taglib extension a while back
thats a task in a half they break things so often
mp3 idv tags
i might or might not release that
personal use?
not really
i was bored
took me like one night to write it
this sqlite thing has taken be 2 nights so far
I’m up until like 4am
what about a new ffmpeg extension?
ffmpeg has a compatible license
and we could do some syndication between imagick and ffmpeg
rza like echo strpos[2]; ?
like no
$pos = strpos( $string “a” ); if ( $pos !== false ) { echo $string[$pos]; }
missing a comma
rza, ooh sounds fun
you’ll need to let me finish the sqlite3 one first
like returning an preloaded imagick object from a movie keyframes
and so on
thanks
people use ffmpeg heavily from the command line currently
just like they use(d) imagemagick
2,476 downloads in less than a month
and its still beta
Hi
anyone know an article that covers all angles of using exec in a windows environment?
Call to undefined function mysql_connect() in Fwww_root\arma\connect.php on line 8 when i got mysql section in phpinfo()?
P4, var_dump(get_loaded_extensions());
mysqlI not mysql
guys, quick question…
im creatin a small website for a company, but one of their requirements is to be able to upload images themselves and for these images to be reduced in size and also for a small copyright logo to be placed on them. Has any one any suggestions as to how this can be achieved?
if I have a class that declares an instance of another class, can the declared instance access the class that declared it?
Uploading and resizing is easy wanderingii
Phil4, pass the object of the class to the class you instanciate
yah ekneuss
no way to access it directly?
there is no link, no
ok, thanks