I am using file read functionality in one my application.
Sometimes I am getting the exception while opening and closing file because in filename I am getting as HTML string, what do I need to do to protect application or to identify this is not the correct name?
Here is the full stack error.
ERROR - 2017-02-27 06:28:21 --> Severity: Warning --> fopen(./upload/
<table cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td class="titleBorderx" width="30">
<table height="25" cellspacing="2" cellpadding="0" width="25" bgcolor="black">
<tbody>
<tr>
<td id="L_default_x" class="x" valign="middle" align="center">X</td>
</tr>
</tbody>
</table>
</td>
<td class="titleBorder" id="L_default_2">Network Access Message:<span class="TitleDescription"> The page cannot be displayed</span> </td>
</tr>
</tbody>
</table>
<table id="spacer">
<tbody>
<tr>
<td height="10"></td></tr></tbody></table>
<table width="400">
<tbody>
<tr>
<td nowrap="" width="25"></td>
<td width="400"><span class="explain"><id id="L_default_3"><b>Explanation:</b></id></span><id id="L_default_4"> There is a problem with the page you are trying to reach and it cannot be displayed. </id><br><br>
<b><span class="tryThings"><id id="L_default_5"><b>Try the following:</b></id></span></b>
<ul class="TryList">
<li id="L_default_6"><b>Refresh page:</b> Search for the page again by clicking the Refresh button. The timeout may have occurred due to Internet congestion.
</li><li id="L_default_7"><b>Check spelling:</b> Check that you typed the Web page address correctly. The address may have been mistyped.
</li><li id="L_default_8"><b>Access from a link:</b> If there is a link to the page you are looking for, try accessing the page from that link.
</li></ul>
<id id="L_default_9">If you are still not able to view the requested page, try contacting your administrator or Helpdesk.</id> <br><br>
</td>
</tr>
</tbody>
</table>
<table id="spacer"><tbody><tr><td height="15"></td></tr></tbody></table>
<table width="400">
<tbody>
<tr>
<td nowrap="" width="25"></td>
<td width="400" id="L_default_10"><b>Technical Information (for support personnel)</b>
<ul class="adminList">
<li id="L_default_11">Error Code: 502 Proxy Error. The request was rejected by the HTTP filter. Contact your Forefront TMG administrator. (12217)
</li><li id="L_default_12">IP Address: 10.40.0.20
</li><li id="L_default_13">Date: 2/27/2017 6:28:21 AM [GMT]
</li><li id="L_default_14">Server: SYS2019.netsolpk.com
</li><li id="L_default_15">Source: web filter
</li></ul>
</td>
</tr>
</tbody>
</table>
): failed to open stream: File name too long /srv/users/serverpilot/apps/php/public/application/controllers/Readfile.php 159
Your fopen function has a too long string in it. And I also think this cant be valid. You are looking for a file in ./upload/ with the name:
<table cellspacing="0" cellpadding="0"...
The name is too long and invalid. I think you pass a variable to the fopen function the content of the variable isn't correct.
Related
I've been battling with this issue for a while now and can't find out why it's happening. I basically have a table which displays Woocommerce variations with each variation being in it's own row. The problem I have is when refreshing the page, the <th> row collapses and doesn't line up with the tbody.
Interestingly, if i change some of the css of the <th> in the console after the page loads, it fixes itself and lines up. The same applies If i open up the console after turn on 'Disable Cache' in the network tab and refresh the page.
My guess is the html is being loaded before the Woocommerce data is being added and doesn't have enough time to get the correct widths. However, this is a recent issue which has only just started happening.
Does anyone know what could cause this?
<table class="variations variations-grid" cellspacing="0">
<thead>
<tr>
<th><img class="camera-icon" src="/wp-content/uploads/2016/10/picture-holder.png"></th>
<th>
Type
</th>
<th>Length</th>
<th class="length">Weight</th>
<th>Height</th>
<th>Depth</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="thumbnail">
<img width="44" height="54" alt="Photinia Red Robin " src="/wp-content/uploads/2016/09/Photinia-Red-Robin-267x325.jpg">
</div>
</td>
<td class="attr attr-attribute_size">
<p>Hedge Bag</p>
</td>
<td class="attr attr-attribute_length">
<p>100cm</p>
</td>
<td class="attr attr-attribute_weight">
<p>75Kg</p>
</td>
<td class="attr attr-attribute_height">
<p>140-150cm+</p>
</td>
<td class="attr attr-attribute_depth">
<p>40cm</p>
</td>
<td class="price">
<span class="price"><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>191.00</span></span>
per metre
</td>
<td class="product-actions">
<a class="button" href="#modal0">More info</a>
</td>
</tr>
</tbody>
</table>
This is what is looks like broken:
This is what is looks like if i the disable cache OR change the css once it's loaded. This is how It should look.
I count more <td> in your <tbody> than <th> in your <thead>. Could this be the issue? Try to add empty <td> to match your <th> head count to test.
I am creating a new email template to replace the defaults on Magento. Having taken some code directly I googled how to add static blocks and followed these basic and brief instructions:
http://www.webcenter.co.in/insert-cms-static-block-into-transactional-email-template-in-magento/
This didn't work for me and resulted in blank spaces when the email was sent and (when viewing the HTML file in chrome, the code appears separate:
Example of email previewed in chrome
I don't really understand why this is happening, other magento code works within the email (the 'What you ordered:' section successfully returns a table and all works perfectly).
Here is the HTML footer where all this takes place:
<!-- // FOOTER BLOCK HERE // -->
<td align="center" valign="top" id="footerContainer" style="padding:20px;">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="text-align:center;">
<p>Follow us to keep updated with all our exclusive offers and competitions!</p>
</td>
</tr>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="20%">
<a href="https://www.facebook.com/*****" title="***** Facebook" target="_blank" style="margin-left:40%;">
<img src="https://www.*******.co.uk/media/******/Email_Icons/facebook.png" alt="Follow on Facebook" height="20px" width="20px">
</a>
</td>
<td width="20%">
<a href="https://www.instagram.com/*****/" title="****** Instagram" target="_blank" style="margin-left:40%;">
<img src="https://www.********.co.uk/media/****/Email_Icons/instagram.png" alt="Follow ******* on Instagram" height="20px" width="20px">
</a>
</td>
<td width="20%">
<a href="https://twitter.com/*******" title="******* Twitter" target="_blank" style="margin-left:40%;">
<img src="https://www.********.co.uk/media/roco/Email_Icons/twitter.png" alt="Follow ******** on Twitter" height="20px" width="20px">
</a>
</td>
<td width="20%">
<a href="https://uk.pinterest.com/*******/" title="******* Pinterest" target="_blank" style="margin-left:40%;">
<img src="https://www.******.co.uk/media/roco/Email_Icons/pintrest.png" alt="Follow ******* on Pinterest" height="20px" width="20px">
</a>
</td>
<td width="20%">
<a href="https://www.youtube.com/user/*******" title="***** YouTube" target="_blank" style="margin-left:40%;">
<img src="https://www.*******.co.uk/media/*****/Email_Icons/youtube.png" alt="Follow ****** on Youtube" height="20px" width="20px">
</a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="text-align:center;">
<p>This inbox is unattended so please don't reply to this email. Just visit our Help Pages if you need extra information. This is a service email and you are recieving
it regardless of your marketing communication preferences.</p>
</td>
</tr>
</table>
<p>{{block type="cms/block" block_id="temp-email-tester" }}</p>
</td>
<!-- // FOOTER BLOCK ENDS HERE // -->
Any answers greatly appreciated!
I am able to get the coding of a website with file_get_contents but I want to be able to get certain values out of the html. This piece of code is always the same but the value between the html tag changes from time to time. This is the HTML Code:
<div class="cheapest-bins">
<h3>Cheapest Live Buy Now</h3>
<table>
<tbody><tr>
<th>Console</th>
<th>Buy Now Price</th>
</tr>
<tr class=" active">
<td class="xb1">XB1</td>
<td>1,480,000</td>
</tr>
<tr class="">
<td class="ps4">PS4</td>
<td>1,590,000</td>
</tr>
<tr class="">
<td class="x360">360</td>
<td>---</td>
</tr>
<tr class="">
<td class="ps3">PS3</td>
<td>2,800,000</td>
</tr>
</tbody></table>
</div>
How would I go about getting the: 1,480,000 .. 1,590,000 .. --- and 2,800,000?
short answer:
find a css selector library such as https://github.com/tj/php-selector
then you could grab all td:last-child elements/innerhtml
for your specific example you could just just
preg_match_all('#<td>(.*?)</td>#', $html, $matches);
I know how to provide or modify a field with CURL curl_setopt function and to work with cookies, but what I could not find is how to modify an HTML element with CURL.
For instance, let's say I want to replace the function "submit_device_form" in below code
<div id="bottombuttons">
<table border="0" cellspacing="0" cellpadding="0" style="width:100%;">
<!-- buttons -->
<tr>
<td> </td>
<td class="separatorButton">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Set</td>
<td>Cancel</td>
</tr>
</table>
</td>
</tr>
<!-- fixes the width of the first column -->
<tr>
<td style="padding:0;"><img src="images/spacer.gif" alt="" width="200" height="1" border="0" ></td>
<td style="padding:0;"><img src="images/spacer.gif" alt="" width="360" height="1" border="0" ></td>
</tr>
</table>
</div>
with "submit_MY_form", a new JavaScript function included in my PHP script. How would I go for it?
I looked into the "PHP Simple HTML DOM Parser" library since it provides the setAttribute and removeAttribute functions that would allow me to do that easily, but then I miss the info on how to give it access to the page read wia CURL, so I'm stuck.
Thanks for your help,
Robert
I am working on a site that isn't SEO friendly. Specifically, the header.tpl is inserted automatically into every page, with no option to change it based on the content of the page. I.e., whether category = Bathroom or category = Kitchen, etc.
So I need an if/else command, but having trouble figuring it out in this instance, plus the change that goes along with it.
The code on the portfolio_category.php page is as follows, and what needs to change based on vf_category is parts/header.tpl (I can create Bathroomheader.tpl, Kitchensheader.tpl, etc so that relevant tpl has the relevant Title and Description tags for the page).
<?php
$vc_root_friendly = '.';
$vc_root_site = '.';
include_once("$vc_root_site/config.php");
include_once("$vc_includes_folder/IT.php");
$template_body = new HTML_Template_IT();
$template_body->loadTemplateFile("tpl_portfolio_category.html");
include_once("$vc_includes_folder/images.php");
if(!isset($_REQUEST['vf_category'])){
header("location:portfolio.php");
die();
}
//Show header
$template_header = new HTML_Template_IT();
$template_header->loadTemplateFile("parts/header.tpl",true,false);
$template_body->setVariable('header', $template_header->get());
//Show footer
$template_footer = new HTML_Template_IT();
$template_footer->loadTemplateFile("parts/footer.tpl",true,false);
$template_body->setVariable('footer', $template_footer->get());
$template_body->setVariable("image_category", $_REQUEST['vf_category']);
//Select photos for this category
etc.
Complicating things there is another page referenced in the code above:
tpl_portfolio_category.html
And this page too has its own header.tpl include:
<? include_once 'parts/header.tpl'; ?>
{header}
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td class="main"><h1><span class="firstLetter">{image_category}</span></h1>
<p>
</p>
<table height="89" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="7"> </td>
</tr>
<!-- BEGIN block_thumb -->
<tr>
<td width='180' height="120" background="./images/thumb-bg.gif"> <div
align="center">{thumb1}</div></td>
<td width="10"> </td>
<td width='180' background="./images/thumb-bg.gif"> <div align="center">{thumb2}
</div></td>
<td width="10"> </td>
<td width='180' background="./images/thumb-bg.gif"> <div align="center">{thumb3}
</div></td>
<td width="10"> </td>
<td width='180' background="./images/thumb-bg.gif"> <div align="center">{thumb4}
</div></td>
</tr>
<tr valign="bottom">
<td height="3"></td>
<td height="3"></td>
<td height="3"></td>
<td height="3"></td>
<td height="3"></td>
<td height="3"></td>
<td height="3"></td>
</tr>
<!-- END block_thumb -->
</table>
<br>
<img src="images/spacer.gif"></td>
</tr>
</table>
{footer}
Any guidance would be appreciated! I'm just trying to get parts/header.tpl to change to parts/Bathroomheader.tpl or parts/Kitchenheader.tpl based on the vf_category pulled from the database. But it's driving me nuts.
Thanks in advance,
Gary
there are a few ways to do this, but in order to minimize the number of files you're changing, I suggest that you:
a) Pull the variable from the database and assign it to smarty, on your first php file, for both the header and body:
//Assuming you have retrieved $vf_category from your database;
$template_header->setVariable('vf_category', $vf_category);
$template_body->setVariable('vf_category', $vf_category);
b) Edit your file header.tpl and append the following code at the top:
{if 'vf_category' == 'some_value'}
{include file="parts/Kitchenheader.tpl"};
{elseif 'vf_category' == 'other_value'}
{include file="parts/Bathroomheader.tpl"};
{else}
//the rest of the header.tpl code goes here
{/if}