Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
How do I know whether the website is using robot.txt and sitemap.txt? I have done extracting keyword, description, title; however I am unable to find the way to code to check whther the website is using robot.txt and sitemap.txt.
I am doing something like this http://www.seoptimer.com/report/loadster.in/5553240531d12
Use file_get_contents:
$robotsContents = file_get_contents("http://targetdomain.com/robots.txt");
$sitemapContents = file_get_contents("http://targetdomain.com/sitemap.xml");
Check if contents are false, false will mean 404 Not Found, then check if it's not HTML contents (because some sites redirect every URL) with strpos($robotsContents, '<html') === false, if there is no tag, that mean it can be txt ou xml file.
So:
function pathExistsAndIsNotHtml($path) {
$contents = #file_get_contents($path);
return ! empty($contents) && strpos($contents, '<html') === false;
}
if(pathExistsAndIsNotHtml("http://targetdomain.com/robots.txt")) {
echo 'http://targetdomain.com/robots.txt';
} else {
echo 'There is no robots.txt';
}
if(pathExistsAndIsNotHtml("http://targetdomain.com/sitemap.xml")) {
echo 'http://targetdomain.com/sitemap.xml';
} else {
echo 'There is no sitemap.xml';
}
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 10 months ago.
Improve this question
That is my way to check file image uploaded or not , send from view to controller php laravel
$dataImages=$request->images;
if($dataImages[0] == ""){
print_r("file null");
}else{
print_r("file not null");
$pathImage='product_images/1/image-1651261589260.jpg';
if(File::exists($pathImage)){
File::delete($pathImage);
}
}
Laravel has a helper function in the request object fo that case called hasFile
if($request->hasFile('images')){
// true
} else {
// false
}
for more info check the Retrieving Uploaded Files
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I have Iframe that inserts data into my DB from another websites using $_SERVER['HTTP_HOST'] value.
One of the column inserted is website URL that can start with
www (e.g: www.viber.ge) or without it (just viber.ge).
I need to compare URL that Iframe has already inserted into DB to URL that Iframe is on at the moment.
But there can be www as subdomain name
So how can I be sure starting www is subdomain or not?
(I putted hello at the top but it is not showing up -_- )
Question is not about comparing "www.viber.ge" with "viber.ge"
it is more about comparing "www.www.viber.ge"(which I think can be inserted into the DB as "www.viber.ge")
with www.viber.ge (which I think can be inserted into DB as "viber.ge" or "www.viber.ge").
Additional question:
is it possible user to go to "www.www.viber.ge" and $_SERVER to save it as "www.viber.ge" (subdomain)?
You can use str_replace and remove the shorter url from the longer.
If what is left is "www." Only then it's the same domain.
$url1 = "www.viber.ge";
$url2 = "viber.ge";
If(strlen($url1) > strlen($url2)){
If(str_replace($url2,"",$url1) == "www."){
Echo "same domain";
}Else{
Echo "not same";
}
}Else{
If(str_replace($url1,"",$url2) == "www."){
Echo "same domain";
}Else{
Echo "not same";
}
}
https://3v4l.org/XtHWr
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have 4 types of users in my system. So i have to include header files using conditions.
I tried below code.
if($this->session->userdata('email_admin')){
include('header_admin.php');
}
if($this->session->userdata('email_zone_manager')){
include('header_zone_manager.php');
}
if($this->session->userdata('email_state_manager')){
include('header_state_manager.php');
}
if($this->session->userdata('email_user')){
include('header_user.php');
}
When i tried with echo something and exit() its working means condition works file but header css and js etc. are not including.
if($this->session->userdata('email_admin'))
{
echo "Admin";
include('header_admin.php');
}
Above code echo "Admin" but header_admin's contents are not including.
You can load views like this...
if(isset($this->session->userdata('email_admin'))){
$this->load->view('header_admin');
}
if(isset($this->session->userdata('email_zone_manager'))){
$this->load->view('header_zone_manager');
}
if(isset($this->session->userdata('email_state_manager'))){
$this->load->view('header_state_manager');
}
if(isset($this->session->userdata('email_user'))){
$this->load->view('email_user');
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I need write some code in Silex. I have template, witch tell user when route doesn't exist. How do it in Silex? Maybe somebody faced with it?
If I understood you correctly, you can show a 404 page to your users when the route is not found, like so:
use Symfony\Component\HttpFoundation\Response;
$app->error(function (\Exception $e, $code) {
switch ($code) {
case 404:
$message = 'The requested page could not be found.';
break;
default:
$message = 'We are sorry, but something went terribly wrong.';
}
return new Response($message);
});
Obviously replacing the example with your template.
See http://silex.sensiolabs.org/doc/usage.html#error-handlers
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I need help on how to make an API for PHP. I was trying to make one web server communicate with another webserver through PHP.
I also want it to update MySQL code. I was using $_GET but it was less secure. Here is my code, can you please take a look at it?
<?php
/*
example: website-url-here.com/?command=insert-command-here&password=testing
*/
$command = $_GET["command"];
$password = $_GET["password"];
if ($password == "testing") {
//Was not a good idea, less secure.
//echo eval($command);
//More secure
if ($command == "create-user")
{
//create user command here
}
else if ($command == "delete-user")
{
//delete user command here
}
else
{
die("Command is incorrect");
}
}
echo "Success";
?>
This question is way too open ended to answer in a StackOverflow answer. Try reading up a little on REST, and a lot on PDO, especially in the context of sanitizing user input.
Think about what would happen if somebody called your api with [url]?command=rm -rf .&password=testing