You are here

function webform2pdf_url_decode in Webform2PDF 6.2

Same name and namespace in other branches
  1. 6 webform2pdf.module \webform2pdf_url_decode()
  2. 7.4 includes/webform2pdf.download.inc \webform2pdf_url_decode()
  3. 7.3 includes/webform2pdf.download.inc \webform2pdf_url_decode()

File

includes/webform2pdf.download.inc, line 167

Code

function webform2pdf_url_decode($url) {
  if (function_exists('mcrypt_decrypt')) {
    $key = variable_get('webform2pdf_key', '');
    $url2 = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, urldecode(base64_decode($url)), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)));
    list($tmp, $nid, $tmp, $sid, $tmp) = explode('/', $url2);
    unset($tmp, $url2);
    if (is_int($nid) && is_int($sid)) {
      $node = webform_menu_load($nid);
      $submission = webform_menu_submission_load($sid, $nid);
      if (!empty($node) && !empty($submission)) {
        return webform2pdf_submission_download_pdf($node, $submission);
      }
    }
  }
  drupal_not_found();
}