-1

I created a php project a few days ago, when this error was not coming, but since 2 days this error is coming, I do not know what the problem is, please help someone.

Strict Standards: Only variables should be passed by reference in /home/indiamaz/public_html/musicwala.cf/get-zip.php on line 31

Warning: filesize(): stat failed for /home/indiamaz/public_html/musicwala.cf/siteuploads/Gulabo Sitabo (2020) Mp3 Songs-musicwala.zip in /home/indiamaz/public_html/musicwala.cf/get-zip.php on line 51

##get-zip.php##

<?php
require_once('config/functions.php');
if(isset($_GET["code"]))
{
    if(!empty($_GET["code"]) == true)
    {
        $zipname = __dir__.'/siteuploads/'.$_GET["name"].'-musicwala.zip';
        if(file_exists($zipname))
        {
            $rp = str_replace(array("_","%20","+")," ",$_GET["name"]);
            $size = filesize($zipname);
            echo '
            
            <div id="dlzip"> <a class="dwnLink2" rel="nofollow" href="/siteuploads/'.$_GET["name"].'-musicwala.zip">download Zip Of '.$rp.' - '.vars::bytes($size).'</a>
                <center>    <b style="color:red">Note*Only 10 Files Compressed Due To Server Bandwidth Limition!</b></center></div>
            
            ';
            exit;
        }
        $url = vars::$siteUrl.$_GET["code"];
        $data = vars::cURL($url);
        $match  = preg_match_all("|<!-- WapkaHost.Com Web Solution :: File List -->(.*?)<!-- WapkaHost.Com Web Solution :: File List Complete -->|mis",$data,$cats);
        $rp = str_replace("/download/",vars::$siteUrl."download/",$cats[1][0]);
        preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $rp,$urls);
        $count = count($urls[1]);
        if($count < 12){
        //  $zipname = __dir__.'/siteuploads/'.$_GET["name"].'-musicwala.zip';
            $files="";
            foreach($urls[0] as $url)
            {
                $name = end(explode("/",$url));
            //  echo $name;
                $rm = preg_replace("|https://(.*?)/(.*?)/(.*?)/{$name}|mis","http://musicwala.cf/files/download/id/$3",$url);
                $headers = get_headers($rm);
                $location = str_replace("Location: /","",$headers[3]);
                
                $files[] = $location;
            }
            
        
            $zip = new ZipArchive; $zip->open($zipname, ZipArchive::CREATE);
              
            foreach ($files as $file) 
            { 
            //  echo $file;
                $zip->addFile($file);
            }
         
            $zip->close();
            $rp = str_replace(array("_","%20","+")," ",$_GET["name"]);
            $size = filesize($zipname);
            echo '
            <div class="download">
            <div id="dlzip"> <a class="dwnLink2" rel="nofollow" href="/siteuploads/'.$_GET["name"].'-musicwala.zip">download Zip Of '.$rp.' - '.vars::bytes($size).'</a> </div>
            <center>    <b style="color:red">Note*Only 10 Files Compressed Due To Server Bandwidth Limition!</b></center>
            </div>
            ';
        }
        else
        {
            echo "Sorry Max File Size Allow 10";
        }
    }
    else
    {
        echo "Faild To Compress!";
    }
}
?>
DACrosby
  • 11,116
  • 3
  • 39
  • 51

1 Answers1

1

Regarding the Strict Standards error on the end function, from the documentation:

Parameters (1)

array. The array. This array is passed by reference because it is modified by the function. This means you must pass it a real variable and not a function returning an array because only actual variables may be passed by reference.

explode is a function that returns an array - not a real variable, Since end modifies real variables, you must set the return value of explode to a separate real variable and send that variable to end.

// $url = __dir__.'/siteuploads/'.$_GET["name"].'-musicwala.zip';
   foreach($urls[0] as $url)
   {
       $exploded_array = explode("/", $url);
       $name = end( $exploded_array );
   // ...

As a guess, the OP's code should actually be foreach ( $urls as $url ){ (not $urls[0]) but that isn't specifically related to the error code.

The second message: Warning: filesize(): stat failed for.. is a bit harder to diagnose here. Possibly the file wasn't created, maybe it's too large (filesize can get weird over 2GB files), or some other issue. Try using the following to determine more of an error message (docs here).

var_dump( $zip->getStatusString() ); // Returns a string with the status message on success or false on failure.
var_dump( $zip->close() ); // Returns true on success or false on failure.
DACrosby
  • 11,116
  • 3
  • 39
  • 51