For comedic purposes, I took a Wikipedia article, downloaded it, and edited the HTML so as to get the page to say particular amusing things I wanted it to. I want to link the page to other people, so I made an account on 000webhost where I uploaded it.
I made sure to upload the folder with all the resources. I checked the reference in the html and it seems to be going to the right place,
<link rel="stylesheet" href="./index_files/load.php">
but opening the page, I just get it unformatted, like the way it might look on a old phone or when dealing with extremely slow internet speeds.
I assume the error has something to do with the filepath. I tried moving the resources folder (it is, in fact, called index_files) to a couple of different locations (inside "temp", inside "public_html", and also inside the highest level of the directory, "/", which is where "temp" and "public_html" reside. None of them worked.
Just to be clear, when I try opening the webpage from the identical html file on my desktop, it works just fine (except that most of the images won't load).
Any suggestions?
Thanks a ton (I need to have figured this out by Wednesday, preferably)
Disclaimer: I know very little about HTML or CSS
Update: Some of the images (which wouldn't load from the file on my hard drive) are in fact loading when I use the link
Related
So I am developing a new course-format, in which a picture is associated with each activity in a course, and presented visually. I created the course format, overrode the renderer etc. That worked all fine. However, the images are supposed to be custom generated and since it has to work for all existing and future, I put some additional code into the general course module form, enabling an image upload.
After admittedly some struggle on my part to get the File API working, it now all works fine. Only in my course format, there is an additional heading, under which you can upload a single image. This gets saved to the database fine, it is not in draft and it is viewable in my dataroots filedir perfectly if I follow the contenthash in the database. It even gets loaded into the form as a default fine. However, if I try to work with the image, all tests run fine (.is_valid_img()etc) and I even get offered to download a file. However, when I do it is corrupted and my file viewer says: "Critical Error: Not a png file". Needless to say it is not displayed on my actual course site.
When I look at the file in filedir, it very clearly is a png. Please, I would be thankful for any help, since I have tried alot and am at my wits end.
It sounds to me like you are getting some sort of output on the page before the PNG file is sent - that would be added to the start of the file and cause it not to work as a PNG file.
I would suggest you open the file in a hex editor and check the start of the file - it should look like https://en.wikipedia.org/wiki/Portable_Network_Graphics#File_header, so look for extra characters before that.
As for where the extra characters come from - they may be an obvious warning / error message (which should be easy to track down and fix). Alternatively, you may have some stray 'echo' statements (again, fairly easy to track down). The worst problems to find are extra characters before the opening 'php' tags of a file somewhere in your install or after the closing tag at the end of a file (which is why you should never use closing PHP tags). Finding these will come down to searching through all your customised code files to locate them.
Today I was looking for my cached page of my website then I find that Google indexed lot of spammy pages which I cannot find in my website.
My website is a college website but in Google there are pages of "nike air max 95 at jd sports" and all my url's are rewrite but in Google it showing a new url (this is similar like my URL: http://example.com/?nike-max-air-343.html).
When I try to find this page in my website I didn't find any of these pages. Kindly provide me any possible solutions so the Google can't list a
"This site maybe Hacked"
message on SERP.
Whenever this happended to me I started the lookforbadguys.php script, you can find here
https://gist.github.com/jasperf/3191259
Copy this file into the DOCUMENT_ROOT of your page and then call in browser
http://example.com/lookforbadguys.php
It then scans your file-system under document root for suscpicious file names and code
It may create a long list of hits, and you have to check every single one (if you don't know exactly that you made it yourself). This is tedious, but I works.
One little hint: Save the output of the scan as html file and open that file in browser. This prevents the script to scan on reload.
After that you must identify the security holes of your server.
You may have to update installed software and/or your scripts.
I don't think you have to do anything. I had a similar warning today.
"Hacked by Andreas Rehm 2006..." seems to be part of the source code for the file on line# 353
Source for file OLERead.php on grad.clemson.edu
I'm in the process of creating a simple image admin tool that allows users to upload and delete images from a server. So far it's very basic stuff. I discovered that uploading files whose file name includes a blank space causes a problem - everything in the name up to the space is included in the uploaded file name, but nothing past that. The problem with this isn't so much broken image links (I can deal with those), but the images can't be deleted using my delete tool or the simplest "unlink" script. Once I discovered the problem and the cause, I contacted our support people and they cleared out the two problem files. Unfortunately, because of system constraints here at work, I don't have FTP access.
Now you'd think it's all resolved, but no. I added very clear warning messages - in bold red text - onto this prototype admin tool, and I let my boss and a few others know of the tool by email, explaining CLEARLY that file names with spaces don't work. So... what does my boss do? She uploaded two files with blanks in the file name.
So until I have a way to add an idiot filter into the script, can anyone suggest how I might be able to delete these two files? I'd even be willing to delete the populated directory and recreate it (none of the images there mean anything, just random stuff).
And if there's no advice about getting these things unstuck, is there any advice as to how I might prevent my boss from acting like a moron, short of cutting off her fingers?
my best answer would be, as you said, move all other files to another folder, delete folder, recreate folder.
After that, I'm thinking you need urlencode in your php to deal with weird characters and spaces in filenames.
One question that might help others, are you in Linux or Windows?
As a test, until it's working, try writing to a drive that you have access to so you can play until it works. Then switch to the live system. This way you don't have to call support to delete your tests.
Also, you could just substitute all spaces for underscores as a quick fix.
While deleting files using unlink() with their names having spaces in them, escape the spaces with "\". This will only work on Linux.
I'm in the process of creating a slideshow Wordpress plugin (although this isn't really a Wordpress question). Through all its various settings, it creates a CSS file through PHP that is used to style the slideshow.
The CSS file is created from all the different styling variables the user has saved to the database and hence the need to dynamically create one.
Problem is that some hosting companies (or shared hosting) cause problems when the PHP tries to save the created file. Generally these are file permission issues. Stopping this file from saving results in the slideshow not appearing correctly and malfunctioning.
Is there anything I can do through PHP as an alternative for users with such file permission issues? As far as I am aware you can modify file permissions and file ownership through PHP but I've personally never done it before and wouldn't really be sure about the right way to go about it yet cover as many different scenarios as possible.
For a lot of users it is simply a case of informing them on how to change the appropriate file permissions, but for the odd few this is completely beyond them and it's not possible for me to log into there FTP and do it for them (often because they wouldn't even know what FTP is).
Can anyone point me in the right direction?
I guess you could have a directory in which you would hold your css file(s) and chmod it to 777 like this in php:
<?php
chmod(dirname(__FILE__) . '/stylesheets', 0777);
?>
The only problem I see here, that a company which denies you access to chmod your files is not that stupid to leave your php that permission... So, why don't you just have a kind of 'gateway'-file which will dynamically grab css values from DB, form a valid css output and serve it to the user?
Your best bet may be:
// Get your values however
$css_values = $database->get_css_values();
// Generate your CSS stylesheet string
$css_string = css_values_to_string($css_values);
// Dump it directly
header('Content-type: text/css');
echo $css_string;
And point to the PHP file as a stylesheet:
<link rel="stylesheet" type="text/css" href="path/to/generator.php" />
While this foregoes the "caching" functionality of dumping to a CSS file, surely you could leverage whatever caching support is available through Wordpress. Likely though, this approach of dynamically generating it every time will not result in bottlenecking (profile anyway, if you're concerned)
I'm creating a website from scratch and I was really into this in the late 90's but the web has changed alot since then! And I'm more of a designer so when I started putting this site together, I basically did a system of php includes to make the site more "dynamic"
When you first visit the site, you'll be presented to a logon screen, if you're not already logged on (cookies). If you're not logged on, a page called access.php is introdused.
I thought I'd preload the most heavy images at this point. So that when the user is done logging on, the images are already cached. And this is working as I want. But I still notice that the biggest image still isn't rendered immediatly anyway. So it's seems kinda pointless.
All of this has made me rethink how the site is structured and how scripts and css files are loaded. Using FireBug and YSlow with Firefox I see a few pointers like expires headers and reducing the size of each script. But is this really the culprit?
For example, would this be really really stupid in the main index.php? The entire site is basically structured like this
<?php
require("dbconnect.php");
?>
<?php
include ("head.php");
?>
And below this is basically just the body and the content of the site.
Head.php however consists of the doctype, head portions, linking of two css style sheets, jQuery library, jQuery validation engine, Cufon and Cufon font file, and then the small Cufon.Replace snippet.
The rest of the body comes with the index.php file, but at the bottom of this again is an include of a file called "footer.php" which basically consists of loading of a couple of jsLoader scripts and a slidepanel and then a js function.
All of this makes the end page source look like a typical complete webpage, but I'm wondering if any of you can see immediatly that "this is really really stupid" and "don't do that, do this instead" etc. :) Are includes a bad way to go?
This site is also pretty image intensive and I can probably do a little more optimization.
But I don't think that's its the primary culprit. YSlow gives me a report of what takes up the most space:
doc(1) - 5.8K
js(5) - 198.7K
css(2) - 5.6K
cssimage(8) - 634.7K
image(6) - 110.8K
I know it looks like it's cssimage(8) that weighs the most, but I've already preloaded these images from before and it doesn't really affect the rendering.
To speed a little, you could assemble all your images on the same image sprite, so that you have only 1 request to download all the images. But that requires you to fine tune your css to let display just the small subset of your image.
To have a better explanation, check out : http://css-tricks.com/css-sprites/
Another answer that could seem a little stupid but I like to think of this when I make a website : Just Keep It Simple. I mean do all your JS add real value, do all this images are fine, could you display less, make a lighter design ? I'm not criticizing your work at all, just suggest you...
I used the following approach on an extranet project:
Using jQuery and a array of file names, I ajax in all the images, .js and .css files so that they are preloaded in the cache. As I iterate through the array, I update a progress bar on the screen that indicates that the site is loading - much like a flash loader.
It worked well.
What I will do is show by default the loading page with pure CSS and HTML then wait for the jQuery to load and preload the images with ImageLoader. Once you are done redirect to the normal website since the images will be already in the cache they won't be loaded again.
Another optimization you can do is minify all JS files and combine all except the jquery.js. Put the jquery.js first into your HTML so it loads first. Also put your SCRIPT tags at the bottom of the HTML.
It sounds like you have pretty much nailed preloading, if you have loaded it once, and the expiry header is set correctly, you have preloaded it, no matter what kind of content it is.
File combination can be key to a quick website, each extra file will add load time, in the worst cases of network and server lag you might add up to a second extra for each separate file. More commonly it will be around 100 - 200 milliseconds per file.
If not already minified, minify the scripts, and put them in the same file, just remember to keep the order. I have no idea why Ivo Sabev wouldn't include jQuery.
Same thing with the CSS files.
How much have you done about testing image compression? There can really be a gain from trying out different compression settings and comparing size vs. quality. For PNG images IrfanView with PNGOUT can often make files 25% smaller than other programs, on top of that, a very big gain in size reduction can be achieved by reducing the image to 8 bit colour, with a lot of graphic elements you simply can't tell the difference. Right here on Stack Overflow there is a great example of well compressed and stacked images in the editor control buttons: http://sstatic.net/so/Img/wmd-buttons.png