You are here

function mobile_codes_generate in Mobile Codes 6.2

Same name and namespace in other branches
  1. 5 mobile_codes.module \mobile_codes_generate()
  2. 6 mobile_codes.module \mobile_codes_generate()
  3. 7.2 mobile_codes.module \mobile_codes_generate()

Cache a Mobile Code.

Parameters

$url: A processed Mobile Code URL.

Return value

The path of the cached Mobile Code if request is successful, and FALSE if it isn't.

1 call to mobile_codes_generate()
theme_mobilecode in ./mobile_codes.module
Theme function for displaying Mobile Codes

File

./mobile_codes.module, line 135
Mobile Codes core functions.

Code

function mobile_codes_generate($url) {
  if (!file_exists($file = file_directory_path() . '/mobile_codes/' . md5(serialize($url)) . '.png')) {
    $request = drupal_http_request($url);
    if ($request->code == 200) {
      if (file_check_directory($dir = file_directory_path() . '/mobile_codes', FILE_CREATE_DIRECTORY)) {
        file_save_data($request->data, $file);
      }
    }
    else {
      return FALSE;
    }
  }
  return $file;
}