Пример #1
0
 /**
  * 	getObject. a function returing an instantiated object
  *
  * 	an object may be loaded as a classs or an instance
  *
  * @param string $type_name
  * 	A name of type to return an instance for
  * @param boolean $data
  * 	indicates if the object should be loaded as a 'stub' containing class
  * 	methods or there is a need to create a new object instance or
  * 	initialize the instance with data from the database
  * @param int $new_id
  * 	if the new objid is set this method returns object's instance from
  * 	the database. Creates a new object otherwise.
  *
  * @return object
  * 	returns eigther an object 'stub' having only class methods, or a real
  * 	'object' having initialized fields
  */
 function getObject($type_name, $data = FALSE, $new_id = NULL)
 {
     if (@(include_once 'easy-contact-forms-' . strtolower($type_name) . '.php')) {
         $classname = 'EasyContactForms' . $type_name;
         try {
             $inst = new $classname($data, $new_id);
             $valid = $inst->isValid();
             if ($data && !empty($new_id) && !$valid) {
                 return NULL;
             }
             return $inst;
         } catch (Exception $e) {
             return NULL;
         }
     } else {
         EasyContactFormsIHTML::getNotLoggedInHTML();
         exit;
     }
 }
Пример #2
0
 /**
  * 	download
  *
  * 	file download
  *
  * @param array $_map
  * 	request data
  */
 function download($_map)
 {
     $id = '';
     $query = '';
     if (isset($_map['oid'])) {
         $id = intval($_map['oid']);
         $query = 'SELECT * FROM #wp__easycontactforms_files WHERE id=\'' . $id . '\' AND Webdir=FALSE';
     } else {
         EasyContactFormsFiles::fileNotFound($_map);
     }
     $token = isset($_map['token']) ? $_map['token'] : '';
     $md5 = md5(EasyContactFormsSecurityManager::getServerPwd() . $id);
     if (isset($_map['token']) && $md5 != $token) {
         EasyContactFormsFiles::fileNotFound($_map);
     }
     if (!isset($_map['token']) && (!isset($_map['easycontactusr']) || $_map['easycontactusr']->id == 0)) {
         EasyContactFormsIHTML::getNotLoggedInHTML();
         exit;
     }
     $response = EasyContactFormsDB::getObjects($query);
     if (EasyContactFormsDB::err() || count($response) == 0) {
         EasyContactFormsFiles::fileNotFound($_map);
     }
     $ds = DIRECTORY_SEPARATOR;
     $downloaddir = EASYCONTACTFORMS__fileUploadDir;
     $Count = intval($response[0]->Count);
     $Size = $response[0]->Size;
     $Type = $response[0]->Type;
     $Name = $response[0]->Name;
     $filepath = $downloaddir . $ds . $response[0]->Storagename;
     if (!is_file($filepath)) {
         EasyContactFormsFiles::fileNotFound($_map);
     }
     header("Content-length: {$Size}");
     header("Content-type: {$Type}");
     header("Content-Disposition: attachment; filename={$Name}");
     readfile($filepath);
     $valuemap = array();
     $valuemap['Count'] = ++$Count;
     EasyContactFormsDB::update($valuemap, 'Files', $response[0]->id);
     exit;
 }
 /**
  * 	getYouAreNotLoggedInMessage
  *
  * 	Prints a 'not logged in message'
  *
  */
 function getYouAreNotLoggedInMessage()
 {
     require_once 'easy-contact-forms-ihtml.php';
     return EasyContactFormsIHTML::getNotLoggedInHTML();
 }
 /**
  * 	dispatch
  *
  * @param  $dispmap
  * 
  *
  * @return
  * 
  */
 function dispatch($dispmap)
 {
     $dispmap = EasyContactFormsUtils::intercept($dispmap);
     if ($dispmap == null) {
         EasyContactFormsIHTML::getNotLoggedInHTML();
         return;
     }
     $method = 'get' . $this->type . 'Form';
     return $this->{$method}($dispmap);
 }