finpingvin I have a question lets say I have a table and I have it automatically load filephp and Ialso have
get_foo(); class Class { function get_foo(){ if (somethig) return new Class else return new OtherClass; }
yes i thought of that, making a public function to return it and use an interface, thanks again f00li5h !
berry__ hello ?
wouldnt if (something) $thing = new Class; else $thing = new OtherClass; be better? +_+
no the class is a configuration class and should generate an object of QueryList itself
sure, but this factory doesn't do a lot either way
:P
return new thing ? 'Class' : 'OtherClass'; # i doubt it
my classes are pretty normal heirachy i guess, WebServer extends Server which keeps an array of ServerConnections, both have a Socket class aswell
Oh, Borland Pascal-style OOP!
where?
hi, i'm trying to create an ID (~10-15 chars long would be best) based on a file/folder path, that will always result in the same ID for the same given path, is there anything that can do this?
$server-connections[3]-socket-Blocking(false); isnt very good looking though
md5()?
bit long, aren't they around 32 chars long?
but md5 is 32 chars (16 bytes hexcode)
15 is not really much
hmm, whoever told me about spaw last night
i owe that person a beer, or 24.
that saved me like a month of work.
http://sausage.no-ip.org:88/hash?str=hash&bit=64
it's to pass into an XML file and then into HTML
although, weakest hash function i've ever seen XD
did they also tell you about security holes in it?
so ideally i don't want massive IDs on the page
such as ?
I dont know, google for it?
32chars ist not massive
substr() the md5 _
i don't read… what language is that? XD
hebrew?
nice url
il wasnt very clear
what's nice about it?
nothing at all
i'm not exceptionally concerned about vulnerabilities in spaw, the only person who will be using the control is my wife
but i'll keep it in mind in the event i port it into something more frequently used
substr(failhash('x',1024),0,16) == substr(failhash('x',2048),0,16) == substr(failhash('x',1746),0,16);
subj, yeah i have placed in some hidden forms
to solve the issue
also the first vulnerabilities i saw on google were for version 1, it's at 2.something now
finpingvin, I don't know why, but it seems pm'ing isn't working.
berry__ okey
berry__ u didnt see mine ?
finpingvin, http://pastebin.parentnode.org/20365
finpingvin, no, I didn't.
work?
Generally if they're not intended to be parsed as PHP code, you'd use file_get_contents or readfile.
thanks
finpingvin, check that pastebin. I'll be right back.
whichone is preferred?
Depends on your needs.
berry__ okay. what does the "=&" operator do ?
it's 2 operators, = and &
Just for convenience, while working with my code, I want to join all my css files into one. To reduce load-times. In production I will have them joined manually in a real file, but during development it would be easy to have php handle this.
finpingvin, php.net/references
finpingvin, I have one table and I want it to load content when the page is loaded how do I call the .php for the content?
just include_once(); without the if - statement
finpingvin, do I have to use the $_GET?
no
just include_once("members.php"); where you want to include it
finpingvin, it creates a reference to the newly created image. You can obviously change this though
I get a major error
ok
lol
berry__ oh, so when i change dst_img, newImage also changes?
finpingvin, unexpected t string
php {include_once("center.php");} ?
include_once("members.php"); ?
don't use parenthesis with include calls, it's not necessary and only confusing.
remove {}
include 'members.php';
{{{include 'foo'; }}} is possible though, only moronic but possible
haha _å
:P
check filenams etc and same directory ?
syntax error, unexpected T_STRING, expecting ',' or ';' in
php include_once"center.php"; ?
use a space
include 'center.php';
and dont use include_once unless you absolutely need it
I still get the error
why not ?
trtd align="center"php include 'center.php'; ?/td/tr
afaik opcode caches dont like *_once
That's not a good enough reason.
ok, the problem was in center.php
well, why use _once if its not needed?
Certainly, but it's needed a lot.
I'd say more often than not.
isn't it pear recommendation ?
Like, any time you include a file that defines classes or functions.
7] sn00p Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in if people would stop cutting off their error messages at "in"
__autoload?
http://www.pennergame.de/ref.php?uid=1780
__autoload screws opcode caches far more than include_once
it's not like you need the line number …
’cause you normally don't have the code anyway
it's still useful to have it sometimes
you can use __autoload to generate a loader file
which in production does not change
it's like people think posting the path to their docroot will get them hacked
well, the point is if you use __autoload the files arent loaded until execution, whereas with include theyre loaded at compile time, i think
yes, static includes are compiled into larger blobs
in apc
conditional includes arent
in most of the cases
but with autoload you usually know what youre loading (unless you do code generation)
and you can easily generate a static loader file with that
which uses include instead of include_once
which leads to better optimization (unless im completely wrong)
hmm, not sure really, i haven't ever tested it
someone told me that APC "compiles" static includes into larger blobs
berry__ enormous thanks, you are the best ;P
where conditional includes are smaller blobs
that would make sense
berry__ will compare the codes and see what i did wrong.
and naturally including larger blobs is faster (if you really need the last inches of performance)
but surely include_once is a conditional include?
finpingvin, sure, no problem.
well its static in that it can be resolved at compile time
finpingvin, I have a question. lets say I have a table and I have it automatically load file.php and Ialso have a if(isset$_GET statment going to that table as well, now when the person clicks the member link how do I get the table to clear when the person clicks the member link?
heh, just noticed my autoloader, which does create a class map, uses require_once
lets see if i get any improvement
animal sex?
if(!isset($_GET['file'])) {include_once 'file.php';}
oops, company meeting, doh
finpingvin, when the person lcicks the members link I want the table to cliear so the new text can go in there
probably not f00li5h
the topic on #perl is "off topic"…
yes, if(!isset($_GET['file'])) {include_once 'other_file.php';} only includes other_file.php if file.php is not clicked at
hmmm
or you could use javascript to clear the cell
and before i need left.php to clear
yo
php if(isset($_GET['members'])) include_once 'members.php'; else include_once 'left.php' ?
php if(isset($_GET['members'])) include_once 'members.php'; else include_once 'left.php'; ?
hi
how can I make my php script run my sql queries faster?
from another channel, someone told me to use memcached
at first i thought, to enable mod_deflate …
phpcurious, shouldn't it be your database server that runs sql queries faster?
berry__, i am thinking that as another case
the fastest query is the one you dont run
the DEFLATE output filter that allows output from your server to be compressed before being sent to the client over the network.
nothing to do with your queries
another issue is , that I am using a very popular PHP framework
Hi! May I bother you. pm? Thank you!
i would like to know if it is possible to reference others variables in a config.ini file like [section) foo=$foo/bar
oups
other=$fii/bar
wich framwork?
and fii will expand to a fii variable predifined some where
no
on the ini file.
{eXception}: okay
{eXception}, cake
i use %s in the string and than sprintf
you can do several things. use php_mysqli, then optimize your queries (joins etc), after all check mysql low queries log, after all you can think about caching
{eXception}, i am using mssql server
oh sry
{eXception}, does mssql hav persistent connections like mysql?
{eXception}, do you have an idea?
sorry no
{eXception}, ok
you should not use persistent connections with php and mysql
why not?
pconnect is buggy
They are not closed at end of script - only with timeout, mysql_connect is really fast, reusing of the connection works only in some cases
have you ever seen "To Many MySQL-Connections"?
NO NEVER _
and *btw* mysql_close has no effect on persistent connections
we see it a lot in #mysql from lusers using pconnect
"But I am calling mysql_close() at the end of my script" ;-
kewl
I am developing a routine to create two timestamps for the beginning and ending of a week. I have $weeknumber and $year; and want to return unix timestamps for first day that week, and last day that week.
any hints? In php4 there is no function that allows this, afaiks.
hey, is there a way i can make something in java but use mysql?
Is it possible to have an mssql_connect handle open in a session?
there is a plugin, but i don't think my webhost has it
Instead of closing it each time the script ends?
berkes, use the year to get a timestamp for the 1st day of the year, then add ( 86400 * 7 * $weeknumber )
here's ia mssql_pconnect - but read the section about persistent database connections in the manual
So its not good practice?
to answer your question, you can't store resources like db connections in sessions
*_pconnect should only be used if you know what your doing
Greetings again. How would you simply check if the PHP interpreter executing your script runs on Windows or Unix? Is there a more elegant way than e.g. looking for a ":" in the second place of a full path?
hi I have this problem
$thedate = 1; //date("Y-m-d H:i:s");
problem is that weeknumbers, acc to ISO start counting on the first week that has more then four days in that year.
why ask in here? go in #java
i.e. if the year starts on a friday, then week1 is the 4th of January
So it should be, berkes…
so it is
ah, ok
is there a way to have java look at mysql?
why ask in here? go in #java
i need mysql's organization
… - go to #java this has nothing to do with ##php
i thought mysql was a php thing
not at all
can you join #java?
Attempting to join #java
8] #java ##java :Forwarding to another
8] ##java :You need to be identified to join that
You said that "global" = "$x = $GLOBALS['x']". However, do any differences exist?
if I submit $thedate = 1; it works if I submit $thedate = date("Y-m-d H:i:s"); I get an error.. what could It be?
I miss your question…
IF it's the same, why should't we use "global"?
Ah.
you ned to register your nick - go to #help
logik-bomb, post some code and the error.
iam reading a blob field in db.. it s a tiff image file.. how can i display it? is there another way to do it without imagemagick or NetPBM?
Any more ideas about a simple OS detection in PHP (Win vs. *n*x is enough)?
why store an image in database/
TIFF is not natively supported by most web browsers. They are too different.
i didnt create db
Gag_H it s there anyway to hack it
Make it available for download as file.
Or convert it.
else i ll write it to a file.. than i ll convert it with imagemagick
embed width=200 height=200
src="tiffdocument.tif" type="image/tiff"
negative=yes
hello
Embedding a TIFF may result in the filler "Download a plugin to display", instead of the image being visible.
But that isa webbrowser issue, not PHP.
not matter it s my solution
Gag_H, theres various stuff in $_SERVER that might give a clue
hello
i said :p
I don't see which you mean; but I will search the docs for "Windows" and see which are differrent depending on the OS.
is there a way to identify all the users on a website at once if you use start_session()?
$_SERVER['SERVER_SOFTWARE'] i think Gag_H
I have a function in a class that need database connection. is it a good practice to just feed the function with a PDO-object as an input variable, or is there a better way to do it?
Depends on the HTTP server message, which can be faked (although unlikely).
why do you want to know anyway?
depends. if you find out that most functions in this class make use of this pdo object..then you problably pass it in the constructor. if just this one method uses it…passing is good enough
PHP_OS
real email.
PHP_OS
What happends if you start to develop on a linux box?
PHP_OS is not always defined
Unlikely… but then I will find another way.
seems like it would be better to read a configuration file Gag_H
Gag_H could please enlighten on what discussion is about?
Trying to detect the OS the PHP interpreter is running on.
php_uname("s") seems a good way.
Telling apart the development system from the public system.
I could probably as well set an environment var.
use DIRECTORY_SEPARATOR
how do I get this $thedate = date('YmdHis'); to this? $thedate = date('Y-m-d H:i:s');
logik-bomb: Are you trying to convert different TIMESTAMP formats?!
n
Looks like MySQL 4 short vs. MySQL 4.1/5 long format.
jmut:, ok great. passing it in the constructor may be a good idea for this class
well if telling apart dev from stable …DIRECTORY_SEPARATOR is not ok. DIRECTORY_SEPARATOR is used to determine OS..
where's the java plugin for php
i can't find it with google
or php's website
I use ip address of machine to detrmine if on live or test system. and just define constant to use later
logik-bomb: Imclude $thedate into single quotes.
'$thedate'
quackstar, www.php.net/java
my god
thanks
I'll check if I don't get always 127.0.0.1, but a public IP for the public server… it should.
hello friends
dumbass $vendor forgot to erase the config file. two weeks of debugging town the drain.
Thanks, H.A.N.D.
there is always 127.0.0.1
OK, I got a few ideas now. Bye!
Is there a "slick" way to perform a trim() on all the individual elements in an array? without doing elemen[0] = trim(element[0]); etc.
uptownben, php.net/array_map
uptownben, $trimmed_array = array_map ( 'trim', $array_to_be_trimmed );
ok, ill ask here
i can't find the Java Servlet SAPI
google hates me
http://www.hospedajeydominios.com/mambo/documentacion-manual_php-pagina-ref_java.html
how can i disable PHP for specific virtual hosts when i have apache installed as FastCGI under windows ?
-!- ufk [n=ufk@mail.zend.com] has joined ##php
why are you irc'ing from a mailserver
hi
Dynom, world domination.
If by world domination you mean "admin monkeys can't set up ptr properly" then yes, you are right indeed
just remove the handler
f00li5h, for specific virtual hosts ? how it can be done?
but you've guessed it.. wrong place to ask, since it's a Apache setting
ok… thanks anyways
nice fella
welcome back
btw it's not an apache question.. i understood that using the windows registry you can modify PHP directives for specific directories.. so setting the engine to off will site my needs
yeah hi again
site=suite
your question is one for #apache or #your-webserver
no idea about that, but an option is to not enable system-wide handling of .php files, and do it per vhost
and it's still a apache question, registry or not
i cannot do that for vhost because i use php as fastcgi and not as apache module with does not allow me to set php directives
and ok i found it on google
you want to make the changes to the vhost entries in apache, so as to remove the association between php and .php files
thanks
isn't that what I said.. ?
I can't run XDebug on PHP 5.2.3, Apache 2, WinXP Home
now i'm telling him that in #apache
:-|
I downloaded stable version for PHP 5.1+, added lines to php.ini and it doesn't work
third time's a charm
f00li5h:
^_^ /pat
Why may be the reason of it?
*what reason?
I think you should consult the people behind XDebug
which is the function used the truetype function used for gd in php
imagefttext or imagettftext
the first one only works in php 4 ?
imagettftext Write text to the image using TrueType fonts
what was so hard about that one
first check in database if there is any records for $access and if there is - show data from $status
select from .. where accesss=$access, _query; _result
Dynom nothing just i am intresting if they do the same thing
or the first one is in use only for php 4
read php.net lots of info at the functions
oki
thanks
anybody uses image/pict
how can i display it
how do i split a string into an array by both \n's and commas most efficiently?
i am currently using explode and foreach construct but i wonder if preg could do better
using an*
$array = preg_split("~[,\n]~", $string);
if given a list of network addresses and subnets masks, how would you determine if any in the list of say 1000 overlap?
now i wonder about the complexity of this
nopealicious, you are maybe looking for fgetcsv() ?
ekneuss, no
how is the list of 1000 saved?
it is a string that contains ,'s and might also contain several lines of , delimited data
foreach($one_list as $ip) { return true if in_array( $other_list, $ip) }