CRM-14499: Update FourFour upgrade script and changes image urls to improve security...
[civicrm-core.git] / CRM / Contact / Page / ImageFile.php
CommitLineData
5da97e99
M
1<?php
2/*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26*/
27
28/**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2014
32 * $Id$
33 *
34 */
35class CRM_Contact_Page_ImageFile extends CRM_Core_Page {
36 function run(){
37 $currentURL = CRM_Utils_System::makeURL(NULL, FALSE, FALSE, NULL, TRUE);
38 $sql = "SELECT id FROM civicrm_contact WHERE image_url=%1;";
39 $params = array(1 => array($currentURL, 'String'));
40 $dao = CRM_Core_DAO::executeQuery($sql, $params);
41 while ($dao->fetch()){
42 $cid=$dao->id;
43 }
44 if ($cid){
45 $config = CRM_Core_Config::singleton();
46 $buffer = file_get_contents($config->customFileUploadDir . $_GET['photo']);
47 $mimeType = 'image/' .pathinfo($_GET['photo'], PATHINFO_EXTENSION);
48 CRM_Utils_System::download($_GET['photo'], $mimeType, $buffer,
49 NULL,
50 TRUE,
51 'inline'
52 );
53 }
54 else{
55 echo 'image url not in database';
56 }
57 CRM_Utils_System::civiExit();
58 }
59}
60
61