All pastes #444967 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-04-17 16:56 UTC
rendered paste body
  public function executeShow()
  {
    $this->setLayout(false);
    $c = new Criteria();
    $c->add(PhotosPeer::PHOTO,$this->getRequestParameter('photo'));
    $photo = PhotosPeer::doSelectOne($c);
    // Check if the person requesting the image actually owns the image
    if($this->getUser()->getAttribute('ultn') != $photo->getUltn())
    {
      $this->foward404();
    }
    // They do, send the file
    $imageName = $this->getRequestParameter('photo');
    $fileToSend = "idPhotos/pending/original/".$imageName;
    // Format the file to send
    $this->getResponse()->setHttpHeader('Content-Type','image/jpg');
    $this->getResponse()->setHttpHeader('Content-Disposition', 'attachment; filename="'.$imageName.'"');
    $this->getResponse()->setContent(@readfile($fileToSend));
    $this->getResponse()->sendHttpHeaders();
    $this->getResponse()->sendContent();
    return sfView::NONE;
  }