I have a strange php issue.
I have a custom front-end post submission form for WordPress. It most of the time but the other times it seemingly at random doesn't work.
My PHP error log spits out the following:
PHP Warning: copy(): Filename cannot be empty in /home/y567889/public_html/wp-content/themes/colormag/inc/front_deck.php on line 1071
PHP Warning: file_get_contents(https://ygoprodeck.com/pics/Trinity World Chalice-deck-14461.png): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in /home/y567889/public_html/wp-content/themes/colormag/inc/front_deck.php on line 1025
PHP Warning: unlink(/home/y567889/public_html/pics/Trinity World Chalice-deck-14461.png): No such file or directory in /home/y567889/public_html/wp-content/themes/colormag/inc/front_deck.php on line 172
So in theory, a user could submit 10 posts. Sometimes 2 of those posts would generate with errors (missing featured image etc etc) with the above error in the php log.
What I have tried:
Changed copy() to move_uploaded_file() with no joy.
Changed permissions on the "pics" folder to 775.
It occurs to one of my users in particular. It happens him with every post he attempts to upload. Generating a new WP account fixes this for him (although it still fails occasionally as per usual).
Because the error starts at line 1017 I'll show what the code is for that:
function moveYdktoDeck($ydkId,$postid){
$ydkUrl = wp_get_attachment_url( $ydkId );
$newfile = $_SERVER['DOCUMENT_ROOT'].'/UploadedDecks/3/'.$postid.'.ydk';
copy($ydkUrl, $newfile)
}
Function wp_get_attachment_url can return false. Check that before you use it in copy function.
Related
Warning: filemtime(): stat failed for includes\img\defaultimg.jpg in
I read and researched but found nothing useful
in the php manual only says this:
If PHP's integer type is only 32 bits on your system, filemtime() will fail on files over 2GB with the warning "stat failed". All stat()-related commands will exhibit the same behavior.
but is just a jpg 900k
this is my code works fine in xammp, but not in production
$dirimg="includes/img/"; //this one also throws warning
$filename = "".$dirimg."".$resultsb['Img'].".jpg"; //the path
if(file_exists ($filename)){ // exists?
$timeimg=filemtime($filename);
$srci="".$dirimg."".$resultsb['Img'].".jpg?=".$timeimg."";
}else{$timeimg=filemtime("includes\img\defaultimg.jpg"); //another path, the file does exists
$srci="includes\img\defaultimg.jpg?=".$timeimg.""; } //
both throw the same warning in the respective path, the file exits btw
the image can be seen,
but i need to know
when it is modified so the browser refreshes it
It was the slashes hahaha , the server is in Linux
So, they have to be like this "includes/img/defaultimg.jpg?="
instead of "includes\img\defaultimg.jpg?="
LOL
I've updated my mediawiki from 1.26.2 to 1.27, the installation process finished ok, but when I try to access I received this error:
Warning:
require(/var/app/current/includes/specials/SpecialUserLogin.php):
failed to open stream: No such file or directory in
/var/app/current/includes/AutoLoader.php on line 81 Fatal error:
require(): Failed opening required
'/var/app/current/includes/specials/SpecialUserLogin.php'
(include_path='/var/app/current/vendor/pear/pear_exception:/var/app/current/vendor/pear/console_getopt:/var/app/current/vendor/pear/pear-core-minimal/src:/var/app/current/vendor/pear/mail_mime:/var/app/current/vendor/pear/mail_mime-decode:/var/app/current/vendor/pear/net_socket:/var/app/current/vendor/pear/net_smtp:/var/app/current/vendor/pear/mail:.:/usr/share/pear:/usr/share/php')
in /var/app/current/includes/AutoLoader.php on line 81
I have no idea why is this happening. If I check the files in my server they're there. I'm also having template issues if I choose vector I only get a messed up template, without styling.
I'm using PHP 5.6.
I hope someone can help me.
I just stumbled across this same exact error after upgrading to MW 1.27.
In my case, the SpecialUserlogin.php existed and all of the permissions were right BUT the word login was written in lowercase so the system thought this file didn't exist. So I just renamed the SpecialUserlogin.php to SpecialUserLogin.php and b00m, it worked!
As for your templating issues, check the common.css file. Copy paste everything out of there, so it's empty, if you don't use it. And check that you're calling your style files correctly in your template.
Getting this error after I hit this website 20 times IP blocking or any other thing I don't know why.
Warning:
file_get_contents(http://www.azlyrics.com/a.html?time=1454075435):
failed to open stream: HTTP request failed! in
C:\xampp\htdocs\travel\simple_html_dom.php on line 77 Fatal error:
Call to a member function find() on boolean in
C:\xampp\htdocs\travel\searchplaylist.php on line 61
I've Code files
If you want to I'll upload
both file codes in this link
https://drive.google.com/folderview?id=0BzMyD6UnaIfWZDZFWXN3akFwd2s&usp=sharing
Just add # infront of file_get_contents. (#file_get_contents).
This will not raise any errors if the request fails due to any reason.
My issue was that the server i was getting content from might be down sometimes and during those times i got an error. # will not raise them.
But remember to use this only in cases where you understand why it might fail and you just want to handle those cases. Don't use it somewhere where you might have made mistakes and want to hide them.
I am trying to figure out ways to determine whether the url I am passing is an image or not. I have thought using getimagesize() to accomplish this task. But the main problem is, what if I want to check the image size of an encrypted image such as this url (https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcTup5KSMveqkgrDKZR6p-0ANhPkJ7srbJOlKR78DUqqh85I_3MUrw)?
I am always getting this error:
Warning: getimagesize(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in C:\xampp\htdocs\series\index.php on line 4
Warning: getimagesize(https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcTup5KSMveqkgrDKZR6p-0ANhPkJ7srbJOlKR78DUqqh85I_3MUrw): failed to open stream: No such file or directory in C:\xampp\htdocs\folder\index.php on line 4
0
Couple of bits:
If you are running PHP5 (or could do) then you can use the HTTP Stream wrapper with the php.ini setting 'allow_url_fopen' set to on:
This will allow you to do a 'straight forward' copy of any remote data to your server for processing.
e.g
<?php copy('https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcTup5KSMveqkgrDKZR6p-0ANhPkJ7srbJOlKR78DUqqh85I_3MUrw', 'FileName.jpg'); ?>
Then you can do:
<?php
$size = getimagesize("FileName.jpg");
echo $size;
/*delete temp file*/
unlink("FileName.jpg");
?>
Obviously not complete - but you can see the theory there
I have a PHP script which reads from an xml file to generate a table. The first thing it does is check to make sure the file exists.
$path = getcwd();
if(file_exists($path.'\inc\php\kbs.xml')){
$kbs = simplexml_load_file($path.'\inc\php\kbs.xml');
} else {
echo "Error: No KB file found";
}
For some reason, intermittently, it doesn't find the file. I've tried removing the file_exists check all together (since I know the file does exist) but it still doesn't load the file at times. I can refresh the page and 7 times out of 10 it doesn't load, but sometimes it does.
I never ran into this problem during development, but once it went production (being used by maybe 200 users now) it started happening.
How do I go about troubleshooting this? (PHP 5.2.14 running on IIS)
EDIT: Error logs give me the following messages when it fails:
Notice: Undefined variable: kbs in <the path> on line 16
Notice: Trying to get property of non-object in <the path> on line 16
Warning: Invalid argument supplied for foreach() in <the path> on line 16
line 16 is the first time the variable $kbs is accessed. Obviously $kbs isn't set if the file isn't found.
Please use the absolute path, relative path make things a mess.
Is the location relative to PHP? Do permissions allow the web server to see it?