/** * getSid * * * @return * */ function getSid() { if (rand(1, 10) == 9) { $nDaysAgo = 3; $query = "DELETE FROM `#wp__easycontactforms_sessions` WHERE opentime < '" . date("Y-m-d H:i:s", time() - 24 * 60 * 60 * $nDaysAgo) . "'"; EasyContactFormsDB::query($query); } $pwd = EasyContactFormsSecurityManager::getServerPwd(); $maxid = EasyContactFormsDB::getValue('SELECT MAX(id) FROM #wp__easycontactforms_sessions'); $sid = md5($maxid + 10 . $pwd); $query = 'INSERT INTO #wp__easycontactforms_sessions(sid, value) VALUES (\'' . $sid . '\', \'<data />\')'; EasyContactFormsDB::query($query); return $sid; }
/** * getfilespec * * @param $fid * * * @return * */ function getfilespec($fid) { $ds = DIRECTORY_SEPARATOR; $pwd = EasyContactFormsSecurityManager::getServerPwd(); $spec = (object) array(); $spec->htmlfile = 'form-' . $fid . '.html'; $spec->subpath = array(); $spec->subpath[] = 'forms'; $spec->subpath[] = 'tmp'; $spec->subpath[] = md5($pwd); $spec->dir = dirName(__FILE__) . $ds . implode($ds, $spec->subpath); $spec->filepath = $spec->dir . $ds . $spec->htmlfile; $spec->webfolder = EASYCONTACTFORMS__engineWebAppDirectory . '/' . implode('/', $spec->subpath); $spec->fileurl = $spec->webfolder . '/' . $spec->htmlfile; return $spec; }
/** * getStorageFileName * * return a new file name * * @param object $filespec * file data * * @return string * file name */ function getStorageFileName($filespec) { $storagename = $filespec->docType . '_' . $filespec->id . '_' . $filespec->fieldname . '_' . $filespec->filename; if (!$filespec->protect) { return $storagename; } $strarr = explode(".", $filespec->filename); $ext = $strarr[count($strarr) - 1]; $md5name = md5(EasyContactFormsSecurityManager::getServerPwd() . $storagename . 'easycontactforms'); $newfilename = $storagename . '_' . $md5name . '.' . $ext; return $newfilename; }