0

I am developing an application where there are different users related to different domains.
In the admin panel i am adding a domain.
Now i need to display logo of each domain.
How can i dynamically display logo of any domain?
Is there any way that i input a domain name as a string and it returns domains information along with the image.
I know i can upload logos while adding a domain but i want it to do it with a simple helper function.
How can i achieve it. Let suppose i need a function like this

$autoload['helper'] = array('domain_helper');

And to find domain

<img src = "<?php echo domain_image('https://www.google.com/'); ?>" >
6
  • The safe bet would be storing the domain names in database and referencing them with an image in your directory. Depending upon others mean if they change some configuration, all your codes will be broken. Commented Dec 12, 2012 at 10:09
  • No, you might have seen avatars related to email addresses. I need to do the same thing. Commented Dec 12, 2012 at 10:10
  • Erm haven't seen. Can you give an example site where it is implemented? Commented Dec 12, 2012 at 10:16
  • take a look at Usage github.com/sekati/codeigniter-gravatar-helper Commented Dec 12, 2012 at 12:37
  • @itachi StackOverflow, it uses Gravatars that are attached to your email :) Commented Dec 12, 2012 at 12:38

1 Answer 1

1

Use curl to pull the favicon from the website and save it as a png.

http://php.net/manual/en/curl.examples-basic.php

<?php
$domain = "google.com";
$image_name = "favicon.ico";

touch("/var/www/domain_images/$domain.png");
$fp = fopen("/var/www/domain_images/$domain.png", "w");

$ch = curl_init("https://".$domain."/".$image_name);

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
?>

EDIT

A word of caution: if you are taking input from users to get the domain name, make sure you sanitize it before passing it along (as always)!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.