php-general Digest 21 Nov 2010 17:03:07 -0000 Issue 7047

2010-11-21 Thread php-general-digest-help

php-general Digest 21 Nov 2010 17:03:07 - Issue 7047

Topics (messages 309590 through 309594):

Re: MySQL Query Help
309590 by: Richard West
309591 by: admin.buskirkgraphics.com
309593 by: Simcha Younger
309594 by: PW

Problem with functions and arrays...
309592 by: Jason Pruim

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
I'm going to jump in and throw in my 2 cents...

Have you used dreamweaver?
I would suggest Dreamweaver to any new programmer beginning php/mysql.
It helped me out tremendously in the beginning. I'm not an advanced programmer 
with hand coding classes yet, but I can get any job completed for clients with 
dreamweaver. Custom content management systems, image galleries from mysql 
etc...

Give it a try, It lets you add the the prewritten code and then you can switch 
to code view and see whats its doing.
RD

On Nov 20, 2010, at 3:54 PM, Ben Miller wrote:

 Hi,
 
 I'm building a website for a client in which I need to compare their
 products, side-by-side, but only include criteria for which all selected
 products have a value for that criteria.
 
 In my database (MySQL), I have a tables named products,criteria and
 criteria_values
 
 If I have something like
 
 $selected_product = array(1=Product 1,2=Product 2...)  //  All
 products selected for comparison by the user
 
 I need to get only rows from criteria where there is a row in
 criteria_values matching criteria.criteria_id for each $selected_product
 - in other words, if any of the $selected_product does not have a row in
 criteria_values that matches criteria.criteria_id, that criteria would
 not be returned.  I hope that makes sense.
 
 I've played around with a few join queries, but none have given the desired
 results.  Best I've been able to come up with so far is to query criteria
 for each DISTINCT(criteria_id) and then run through each $selected_product
 to make sure each has a criteria_value with a matching criteria_id,
 eliminating any criteria where the number of criteria_values 
 count($selected_product), but this seems pretty inefficient.
 
 Thanks in advance for any help.
 
 Ben Miller
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

---End Message---
---BeginMessage---
Since we are just tossing out development environments.

We moved to Aptana in conjunction with TortoiseSVN for a team environment
development timelines dropped.  
Personally I do not feel any gui editor makes you a better programmer, maybe
you understand the fundamentals a little less.


Not that anything so far has been an answer to your question.

Developing mysql statements that not only require minimum resources but that
are highly effective. Take a lot of trial and error.
I feel there is no better tool in my mind to test query concepts than
NaviCat.

Not only is the product very user friendly but as a senior developer it
gives me more insight into the impact the query has on my servers.
Always think longevity of the product you are producing. 
Imagine one day you have 650,000 products how will the query impact the
service you have written.

I feel as a certified MySQL DBA you should understand that what works today
may NOT be the best choice in query statements for the future.
Always analyze your query statements for query length and system resources
requirements.

Depending on the structure of your database/tables/fields your query may be
achieved many different ways.

I might suggest you try an extended select statement.

 SELECT product from sometable WHERE product='$array1' AND product=(SELECT
product_name from sometable where other matching critera); 

By extending or what some may call concating the statement the return is
more effective.



Richard L. Buskirk



-Original Message-
From: Ben Miller [mailto:biprel...@gmail.com] 
Sent: Saturday, November 20, 2010 3:54 PM
To: 'php-general'
Subject: [PHP] MySQL Query Help

Hi,

I'm building a website for a client in which I need to compare their
products, side-by-side, but only include criteria for which all selected
products have a value for that criteria.

In my database (MySQL), I have a tables named products,criteria and
criteria_values

If I have something like

$selected_product = array(1=Product 1,2=Product 2...)  //  All
products selected for comparison by the user

I need to get only rows from criteria where there is a row in
criteria_values matching criteria.criteria_id for each $selected_product
- in other words, if any of the $selected_product does not have a row in
criteria_values that matches criteria.criteria_id, that criteria would
not be returned.  I hope that 

php-general Digest 22 Nov 2010 06:45:05 -0000 Issue 7048

2010-11-21 Thread php-general-digest-help

php-general Digest 22 Nov 2010 06:45:05 - Issue 7048

Topics (messages 309595 through 309605):

E-mail injection question
309595 by: Gary
309596 by: Adam Richardson

Re: MySQL Query Help
309597 by: Ben Miller

Re: Problem with functions and arrays...
309598 by: Tamara Temple

How to install ext/intl on Mac OSX (NumberFormatter and so on)
309599 by: cimodev

range header in curl?
309600 by: Tontonq Tontonq
309601 by: Michael Shadle
309602 by: shiplu

Wordpress Page: How to add pagination?
309603 by: vince samoy

Re: PHP Sockets, problem with remote execution (exec/system)
309604 by: 惠新宸
309605 by: Ronny Tiebel

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
I have been testing various scripts to kill email injection attacks.  I 
adapted this script and it seems to work well.  Does anyone see any issues 
with this?

?php
$newlinecounter = 0;
foreach($_POST as $key = $val_newline){
if(stristr($val_newline, '\r')){$newlinecounter++;}
if(stristr($val_newline, '\n')){$newlinecounter++;}
if(stristr($val_newline, '\\r')){$newlinecounter++;}
if(stristr($val_newline, '\\n')){$newlinecounter++;}
if(stristr($val_newline, '\r\n')){$newlinecounter++;}
if(stristr($val_newline, '\\r\\n')){$newlinecounter++;}
if(stristr($val_newline, 'Bcc')){$newlinecounter++;}
}
if ($newlinecounter = 1){ die('die scum die');
}

?

Thank you,
Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5636 (20101121) __

The message was checked by ESET Smart Security.

http://www.eset.com




---End Message---
---BeginMessage---
On Sun, Nov 21, 2010 at 12:02 PM, Gary gp...@paulgdesigns.com wrote:

 I have been testing various scripts to kill email injection attacks.  I
 adapted this script and it seems to work well.  Does anyone see any issues
 with this?

 ?php
 $newlinecounter = 0;
 foreach($_POST as $key = $val_newline){
 if(stristr($val_newline, '\r')){$newlinecounter++;}
 if(stristr($val_newline, '\n')){$newlinecounter++;}
 if(stristr($val_newline, '\\r')){$newlinecounter++;}
 if(stristr($val_newline, '\\n')){$newlinecounter++;}
 if(stristr($val_newline, '\r\n')){$newlinecounter++;}
 if(stristr($val_newline, '\\r\\n')){$newlinecounter++;}
 if(stristr($val_newline, 'Bcc')){$newlinecounter++;}
 }
 if ($newlinecounter = 1){ die('die scum die');
 }

 ?

 Thank you,
 Gary


Hi Gary,

There are issues with this approach (one being that checking all POST fields
non-discriminately will lead to false positives, as the body/message of an
email can contain new line characters without issue.)

I'd suggest using Zend's Email capabilities.  You just upload the framework
to your site, add it to your include path, and then you can even use SMTP
email capabilities through an account such as gmail or another email
provider, which is much better than using the general mail() function,
anyway.  And, you have all the security benefits.

Here's a link to Zend's Mail class documentation:
http://framework.zend.com/manual/en/zend.mail.html

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com
---End Message---
---BeginMessage---


SELECT * FROM products p LEFT JOIN criteria_values cv ON p.key=cv.key LEFT
JOIN criteria c ON cv.key=c.key WHERE c.value IS NOT NULL

Hard to answer without more detail, but I am guessing the answer will be
something like the above. Your question makes it hard to understand whether
c or cv is joined to p. So swap em around if I misunderstood. 

iPhone 4. It rocks!

On Nov 21, 2010, at 1:37 AM, Simcha Younger sim...@syounger.com wrote:

 On Sat, 20 Nov 2010 13:54:29 -0700
 Ben Miller biprel...@gmail.com wrote:
 
 Hi,
 
 I'm building a website for a client in which I need to compare their 
 products, side-by-side, but only include criteria for which all 
 selected products have a value for that criteria.
 
 In my database (MySQL), I have a tables named products,criteria 
 and criteria_values
 
 If I have something like
 
 $selected_product = array(1=Product 1,2=Product 2...)  //  
 All products selected for comparison by the user
 
 I need to get only rows from criteria where there is a row in 
 criteria_values matching criteria.criteria_id for each 
 $selected_product
 - in other words, if any of the $selected_product does not have a row 
 in criteria_values that matches criteria.criteria_id, that 
 criteria would not be returned.  I hope that makes sense.
 
 It would be a lot easier to think about this if you could provide the
table structure or create table statements.
 
 If I understood correctly, you have products which reference a criteria ID
which

[PHP] E-mail injection question

2010-11-21 Thread Gary
I have been testing various scripts to kill email injection attacks.  I 
adapted this script and it seems to work well.  Does anyone see any issues 
with this?

?php
$newlinecounter = 0;
foreach($_POST as $key = $val_newline){
if(stristr($val_newline, '\r')){$newlinecounter++;}
if(stristr($val_newline, '\n')){$newlinecounter++;}
if(stristr($val_newline, '\\r')){$newlinecounter++;}
if(stristr($val_newline, '\\n')){$newlinecounter++;}
if(stristr($val_newline, '\r\n')){$newlinecounter++;}
if(stristr($val_newline, '\\r\\n')){$newlinecounter++;}
if(stristr($val_newline, 'Bcc')){$newlinecounter++;}
}
if ($newlinecounter = 1){ die('die scum die');
}

?

Thank you,
Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5636 (20101121) __

The message was checked by ESET Smart Security.

http://www.eset.com





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] MySQL Query Help

2010-11-21 Thread PW
SELECT * FROM products p LEFT JOIN criteria_values cv ON p.key=cv.key LEFT JOIN 
criteria c ON cv.key=c.key WHERE c.value IS NOT NULL

Hard to answer without more detail, but I am guessing the answer will be 
something like the above. Your question makes it hard to understand whether c 
or cv is joined to p. So swap em around if I misunderstood. 

iPhone 4. It rocks!

On Nov 21, 2010, at 1:37 AM, Simcha Younger sim...@syounger.com wrote:

 On Sat, 20 Nov 2010 13:54:29 -0700
 Ben Miller biprel...@gmail.com wrote:
 
 Hi,
 
 I'm building a website for a client in which I need to compare their
 products, side-by-side, but only include criteria for which all selected
 products have a value for that criteria.
 
 In my database (MySQL), I have a tables named products,criteria and
 criteria_values
 
 If I have something like
 
 $selected_product = array(1=Product 1,2=Product 2...)  //  All
 products selected for comparison by the user
 
 I need to get only rows from criteria where there is a row in
 criteria_values matching criteria.criteria_id for each $selected_product
 - in other words, if any of the $selected_product does not have a row in
 criteria_values that matches criteria.criteria_id, that criteria would
 not be returned.  I hope that makes sense.
 
 It would be a lot easier to think about this if you could provide the table 
 structure or create table statements.
 
 If I understood correctly, you have products which reference a criteria ID 
 which has no matching value. If this is the problem you have a to first take 
 care of the integrity of your data, as this should never happen. 
 
 
 -- 
 Simcha Younger sim...@syounger.com
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] E-mail injection question

2010-11-21 Thread Adam Richardson
On Sun, Nov 21, 2010 at 12:02 PM, Gary gp...@paulgdesigns.com wrote:

 I have been testing various scripts to kill email injection attacks.  I
 adapted this script and it seems to work well.  Does anyone see any issues
 with this?

 ?php
 $newlinecounter = 0;
 foreach($_POST as $key = $val_newline){
 if(stristr($val_newline, '\r')){$newlinecounter++;}
 if(stristr($val_newline, '\n')){$newlinecounter++;}
 if(stristr($val_newline, '\\r')){$newlinecounter++;}
 if(stristr($val_newline, '\\n')){$newlinecounter++;}
 if(stristr($val_newline, '\r\n')){$newlinecounter++;}
 if(stristr($val_newline, '\\r\\n')){$newlinecounter++;}
 if(stristr($val_newline, 'Bcc')){$newlinecounter++;}
 }
 if ($newlinecounter = 1){ die('die scum die');
 }

 ?

 Thank you,
 Gary


Hi Gary,

There are issues with this approach (one being that checking all POST fields
non-discriminately will lead to false positives, as the body/message of an
email can contain new line characters without issue.)

I'd suggest using Zend's Email capabilities.  You just upload the framework
to your site, add it to your include path, and then you can even use SMTP
email capabilities through an account such as gmail or another email
provider, which is much better than using the general mail() function,
anyway.  And, you have all the security benefits.

Here's a link to Zend's Mail class documentation:
http://framework.zend.com/manual/en/zend.mail.html

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


RE: [PHP] MySQL Query Help

2010-11-21 Thread Ben Miller


SELECT * FROM products p LEFT JOIN criteria_values cv ON p.key=cv.key LEFT
JOIN criteria c ON cv.key=c.key WHERE c.value IS NOT NULL

Hard to answer without more detail, but I am guessing the answer will be
something like the above. Your question makes it hard to understand whether
c or cv is joined to p. So swap em around if I misunderstood. 

iPhone 4. It rocks!

On Nov 21, 2010, at 1:37 AM, Simcha Younger sim...@syounger.com wrote:

 On Sat, 20 Nov 2010 13:54:29 -0700
 Ben Miller biprel...@gmail.com wrote:
 
 Hi,
 
 I'm building a website for a client in which I need to compare their 
 products, side-by-side, but only include criteria for which all 
 selected products have a value for that criteria.
 
 In my database (MySQL), I have a tables named products,criteria 
 and criteria_values
 
 If I have something like
 
 $selected_product = array(1=Product 1,2=Product 2...)  //  
 All products selected for comparison by the user
 
 I need to get only rows from criteria where there is a row in 
 criteria_values matching criteria.criteria_id for each 
 $selected_product
 - in other words, if any of the $selected_product does not have a row 
 in criteria_values that matches criteria.criteria_id, that 
 criteria would not be returned.  I hope that makes sense.
 
 It would be a lot easier to think about this if you could provide the
table structure or create table statements.
 
 If I understood correctly, you have products which reference a criteria ID
which has no matching value. If this is the problem you have a to first take
care of the integrity of your data, as this should never happen. 
 

To help clarify - the 3 tables look something like the following (tableName
= column,column,column...):

Products = product_id,product_name,product_description...  (key =
product_id)
Criteria = criteria_id,criteria_title,criteria_text,...  (key =
criteria_id)
Criteria_values = product_id,criteria_id,criteria_value,... (key =
product_id  criteria_id)

The user selects up to X product_id's to compare, stored in
$selected_products.

I then need to get each criteria_title and criteria_text from
table(criteria) where there is a matching criteria_id in
table(criteria_values) for each/all $selected_products, also returning the
criteria_value for each $selected_products, ultimately ending up with an
array or object that looks something like:

(Assuming the user selected Product A (product_id=1), Product B
(product_id=2) and Product C (product_id=3)

criteria = Array  (
[$criteria_id] = Array (
[title] = query_row[criteria_title]
[text] = query_row[criteria_text]
[values] = Array (
[1] = Product A's value for this criteria
[2] = Product B's value for this criteria
[3] = Product C's value for this criteria
)
)
[$criteria_id] = Array (
.
)
)

Again, displaying only/all criteria where there is a matching value for
each/all $selected_products

Thanks again,
Ben



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Problem with functions and arrays...

2010-11-21 Thread Tamara Temple


On Nov 20, 2010, at 5:31 PM, Jason Pruim wrote:


?PHP

function ddbYear($name, $message, $_POST, $option){



Maybe it's just me, but using the name of a global as a function  
parameter just seems like a bad idea. Yes, you can do it. Should you?  
I think not. Especially, as, you are passing it a scalar below and  
treating it here like the global array.



   //Make sure to post form start/stop OUTSIDE of this function...
   //It's not meant to be a one size fits all function!
echo NAME:  . $name . BR;
echo MESSAGE:  . $message . BR;

echo POST:  . $_POST . BR;
echo OPTION:  . $option . BR;


$sticky = '';
if(isset($_POST['submit'])) {


Check the error messages -- since you're passing in $startYear as a  
scalar below, you shouldn't be able to access $_POST as an associative  
array.



$sticky = $_POST[{$name}];
echo STICKY:  . $sticky;
}
//echo OPTION: ;
//print_r($option);

   echo HTML
select name={$name}
option value=0{$message}/option

HTML;

foreach ($option as $key = $value){

if($key == $sticky) {
echo 'option value=' . $key .' selected' . $value . '/option';
}else{
echo 'option value=' . $key .'' . $value . '/option';
}

}

echo HTML

/select
HTML;
unset($value);
return;
}

?

One for Month, Day  Year... All the same exact code... When I get  
brave I'll combine it into 1 functions :)


Now... What it's trying to do.. It's on a update form on my  
website. Basically pulls the info from the database and displays it  
in the form again so it can be edited and resubmitted...


As I'm sure you can tell from the function it checks to see if the a  
value has been selected in the drop down box and if it has then set  
the drop down box to that value.


I call the function like this:
?PHP
$startYear = date(Y, $row['startdate']); //Actual DBValue:  
1265000400


You're setting $startYear as a scalar value here.

$optionYear = array(2010 = 2010, 2011 = 2011, 2012 =  
2012, 2013 = 2013, 2014 = 2014);


ddbYear(startYear, Select Year, $startYear, $optionYear);


And passing it in to the $_POST variable in your function. Then you  
treat the $_POST variable as an associative array (seemingly much like  
the global $_POST array).





?

The output I'm getting is:
THESE ARE THE ACTUAL UNPROCESSED (OTHER THEN SEPARATING) VALUES FROM  
THE DATABASE

startmonth: 2
startday: 1
startYear: 2010
endmonth: 11
endDay: 30
endYear: 1999

THESE ARE THE VALUES INSIDE THE FUNCTION
NAME: startYear
MESSAGE: Select Year
POST: 2010
OPTION: Array
STICKY: 2

Now... The problem is that $sticky get set to 2 instead of  
2010... But I can't figure out why...


Anyone have any ideas?

And just incase I didn't provide enough info here's a link that  
shows it happening:


HTTP://jason.pruimphotography.com/dev/cms2/events/update_form.php? 
id=62


Again, I will reiterate that taking the name of a global variable and  
using it as a parameter in a function is a bad idea. It can be done,  
and my in some cases have some uses, but I don't think the way you're  
using it is a good idea, and looks wrong to me as well.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] How to install ext/intl on Mac OSX (NumberFormatter and so on)

2010-11-21 Thread cimodev
Hallo

Apple is shipping PHP 5.3.3 on Mac OSX Darwin without the PECL-Extension
ext/intl.

So i tried to install ext/intl with pecl install intl.

The Error Message is:
/private/var/tmp/apache_mod_php/apache_mod_php-53~1/Build/tmp/pear/temp/intl/collator/collator_class.c:92:
error: duplicate ‘static’
/private/var/tmp/apache_mod_php/apache_mod_php-53~1/Build/tmp/pear/temp/intl/collator/collator_class.c:96:
error: duplicate ‘static’
/private/var/tmp/apache_mod_php/apache_mod_php-53~1/Build/tmp/pear/temp/intl/collator/collator_class.c:101:
error: duplicate ‘static’
/private/var/tmp/apache_mod_php/apache_mod_php-53~1/Build/tmp/pear/temp/intl/collator/collator_class.c:107:
error: duplicate ‘static’
make: *** [collator/collator_class.lo] Error 1
ERROR: `make' failed


phpize output is:

Configuring for:
PHP Api Version: 20090626
Zend Module Api No:  20090626
Zend Extension Api No:   220090626

gcc -v:

gcc -v
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5664~105/src/configure --disable-checking
--enable-werror --prefix=/usr --mandir=/share/man
--enable-languages=c,objc,c++,obj-c++
--program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib
--build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10-
--host=x86_64-apple-darwin10 --target=i686-apple-darwin10
--with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5664)

Has anyone good tips for solving this?


[PHP] range header in curl?

2010-11-21 Thread Tontonq Tontonq
hi im downloading files from h0tf1le as a premium user by curl i want to do
something like streaming i want it resend to user what it got from server
i couldnt find any resource about curl and streaming the executed source
so i did by the Range header but sometimes i see files are corrupted i check
the logs

GET
http://s137.hotfile.com/get/7006d266367d7975861e5f7200b604ad478674fc/4ce9a4ff/1/f37a0969e2e26077/332dfdf/2137758/pimp.rarHTTP/1.1
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.9.2)
Gecko/20100115 Firefox/3.6
Host: s137.hotfile.com
Pragma: no-cache
Accept: */*
Connection: Keep-Alive
Range: bytes=1-2

i only get 1 byte for learn length


Content-Disposition: attachment; filename=pimp.rar
Content-Transfer-Encoding: binary
Content-Range: bytes 1-2/5781810

i see the range

request:Range: bytes=0-2097152
response:
Content-Disposition: attachment; filename=pimp.rar
Content-Transfer-Encoding: binary
Content-Range: bytes 0-2097152/5781810
Connection: close

request:Range: bytes=2097152-4194304
response:
Content-Disposition: attachment; filename=pimp.rar
Content-Transfer-Encoding: binary
Content-Range: bytes 2097152-4194304/5781810
Connection: close

request:Range: bytes=4194304-5781810

Content-Disposition: attachment; filename=pimp.rar
Content-Transfer-Encoding: binary
Content-Range: bytes 4194304-5781810/5781810
Connection: close


i can not see any error do you?

and this is a part of it



$kackb=arasi('Content-Range: bytes 1-2/','
',$cikti);
$bytes=(int)$kackb;
$infocuk=curl_getinfo($ch);
$sabiturl=$infocuk[url];
curl_close($ch);
$sinir*=1024;
$kackez=$bytes/$sinir;


for($i=0;$i=$kackez;$i++)
{
$bsinir=$i*$sinir;
$ssinir+=$sinir;
if($bytes$ssinir) { $ssinir=$bytes; }
$header = array(Range: bytes=$bsinir-$ssinir);
$ch = curl_init();
curl_setopt($ch , CURLOPT_URL, $sabiturl);
curl_setopt($ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT
5.1; tr; rv:1.9.2) Gecko/20100115 Firefox/3.6');
curl_setopt($ch , CURLOPT_COOKIEJAR, dirname(__FILE__).'/cookies.txt');
curl_setopt($ch , CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookies.txt');
curl_setopt($ch , CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookies.txt');
if($proxy) { curl_setopt($ch , CURLOPT_PROXY, $proxy); }
curl_setopt ( $ch , CURLOPT_HTTPHEADER, $header );
curl_setopt($ch , CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch , CURLOPT_RETURNTRANSFER , 1);
$cikti = curl_exec($ch);
echo $cikti;

}


Re: [PHP] range header in curl?

2010-11-21 Thread Michael Shadle
Is range the right header to be sending? I thought it was something else.

Also I believe there is a curl_setopt option for range... Look at php.net's 
predefined constants for the curl modul

On Nov 21, 2010, at 3:05 PM, Tontonq Tontonq root...@gmail.com wrote:

 hi im downloading files from h0tf1le as a premium user by curl i want to do
 something like streaming i want it resend to user what it got from server
 i couldnt find any resource about curl and streaming the executed source
 so i did by the Range header but sometimes i see files are corrupted i check
 the logs
 
 GET
 http://s137.hotfile.com/get/7006d266367d7975861e5f7200b604ad478674fc/4ce9a4ff/1/f37a0969e2e26077/332dfdf/2137758/pimp.rarHTTP/1.1
 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.9.2)
 Gecko/20100115 Firefox/3.6
 Host: s137.hotfile.com
 Pragma: no-cache
 Accept: */*
 Connection: Keep-Alive
 Range: bytes=1-2
 
 i only get 1 byte for learn length
 
 
 Content-Disposition: attachment; filename=pimp.rar
 Content-Transfer-Encoding: binary
 Content-Range: bytes 1-2/5781810
 
 i see the range
 
 request:Range: bytes=0-2097152
 response:
 Content-Disposition: attachment; filename=pimp.rar
 Content-Transfer-Encoding: binary
 Content-Range: bytes 0-2097152/5781810
 Connection: close
 
 request:Range: bytes=2097152-4194304
 response:
 Content-Disposition: attachment; filename=pimp.rar
 Content-Transfer-Encoding: binary
 Content-Range: bytes 2097152-4194304/5781810
 Connection: close
 
 request:Range: bytes=4194304-5781810
 
 Content-Disposition: attachment; filename=pimp.rar
 Content-Transfer-Encoding: binary
 Content-Range: bytes 4194304-5781810/5781810
 Connection: close
 
 
 i can not see any error do you?
 
 and this is a part of it
 
 
 
 $kackb=arasi('Content-Range: bytes 1-2/','
 ',$cikti);
 $bytes=(int)$kackb;
 $infocuk=curl_getinfo($ch);
 $sabiturl=$infocuk[url];
 curl_close($ch);
 $sinir*=1024;
 $kackez=$bytes/$sinir;
 
 
 for($i=0;$i=$kackez;$i++)
 {
 $bsinir=$i*$sinir;
 $ssinir+=$sinir;
 if($bytes$ssinir) { $ssinir=$bytes; }
 $header = array(Range: bytes=$bsinir-$ssinir);
 $ch = curl_init();
 curl_setopt($ch , CURLOPT_URL, $sabiturl);
 curl_setopt($ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT
 5.1; tr; rv:1.9.2) Gecko/20100115 Firefox/3.6');
 curl_setopt($ch , CURLOPT_COOKIEJAR, dirname(__FILE__).'/cookies.txt');
 curl_setopt($ch , CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookies.txt');
 curl_setopt($ch , CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookies.txt');
 if($proxy) { curl_setopt($ch , CURLOPT_PROXY, $proxy); }
 curl_setopt ( $ch , CURLOPT_HTTPHEADER, $header );
 curl_setopt($ch , CURLOPT_FOLLOWLOCATION, 1);
 curl_setopt($ch , CURLOPT_RETURNTRANSFER , 1);
 $cikti = curl_exec($ch);
 echo $cikti;
 
 }

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php