Пример #1
0
 /**
  * Send and email to the user
  * @param string $userIdTo - to users id
  * @param string $userIdFrom - user from id
  * @return string - form output
  */
 public function emailUser($userIdTo, $userIdFrom)
 {
     $form = new sfc\Form(SSP_Path(), "noTable", "emailUser");
     $form->tpl = $this->tpl(array("title" => "Email member"));
     $form->tplf = "sendemailtomember.tpl";
     $form->errorAutoFormDisplay = false;
     $form->fe("text", "subject", "Subject");
     $form->fep("required=true");
     $form->fe("textarea", "message", "Message");
     $form->fep("required=true, width=40, lines=10");
     $form->fe("submit", "submit", "Send Email");
     if ($form->processForm($_POST)) {
         if (!$form->error) {
             // get to email
             $query = sprintf("select u.%s, m.%s, m.%s from %s as u, %s as m where u.%s = ? and m.%s = u.%s", $this->db->qt("UserEmail"), $this->db->qt("FamilyName"), $this->db->qt("FirstName"), $this->cfg->userTable, $this->cfg->userMiscTable, $this->db->qt("UserId"), $this->db->qt("UserId"), $this->db->qt("UserId"));
             $values = array($userIdTo);
             $this->db->query($query, $values, "SSP Admin send email: Getting to email and name");
             $rowTo = $this->db->fetchRow();
             $emailTo = SSP_Decrypt($rowTo->UserEmail);
             // get from information
             $where = array("UserId" => $userIdFrom);
             $rowFrom = $this->db->get($this->cfg->userMiscTable, $where, "SSP Admin send email: Getting from name");
             // build email
             $content["message"] = $form->getField("message");
             $content["subject"] = $form->getField("subject");
             $content["firstName"] = $rowFrom->FirstName;
             $content["familyName"] = $rowFrom->FamilyName;
             $email = new Email($this->cfg);
             $result = $email->generalEmail($content, "emailmember.tpl", $this->session->userEmail, $rowFrom->FirstName . " " . $rowFrom->FamilyName, $emailTo, $rowTo->FirstName . " " . $rowTo->FamilyName);
             if ($result === false) {
                 SSP_error('SSP Admin: failed to send email to user ' . $emailTo, E_USER_ERROR);
             }
             $form->tda("saved");
             return $form->create(true);
         } else {
             return $form->create(true);
         }
     } else {
         return $form->create();
     }
 }
Пример #2
0
 /**
  * Check a data has only the correct characters within it
  * @param string $type - required type of data - text, password, data, time, phone, int,
  * 							real, hex, oct, bin, email, emailchk, dom, domchk, lable, gen
  * @param string $data - data to be checked
  * @return int - error number, 0 no error
  */
 function check($type, $data)
 {
     $type = strtolower($type);
     if (!isset($this->dataTypes[$type])) {
         SSP_error("Unknown data type " . $type);
     } else {
         // general data type, do not check
         if (strcmp($type, "gen") == 0) {
             $this->error = 0;
             $this->errorMessage = "";
             return $this->error;
         }
         // check for dns checking of urls
         if (is_string($this->dataTypes[$type])) {
             $type = $this->dataTypes[$type];
             $checkDns = true;
         } else {
             $checkDns = false;
         }
         // check the data
         if ($this->dataTypes[$type]->check($data, $checkDns)) {
             $this->error = $this->dataTypes[$type]->error;
             $this->errorMessage = $this->t($this->dataTypes[$type]->errorMessage);
         } else {
             $this->error = 0;
             $this->errorMessage = "";
         }
     }
     return $this->error;
 }
Пример #3
0
/**
 * Display an error, save to log and email to admins
 * @global SSP_Configure $SSP_Config
 * @param int $errno
 * @param string $errstr - error generated
 * @param string $errfile - file in whioch the error occurs
 * @param int $errline
 */
function SSP_errorHandler($errno, $errstr, $errfile, $errline)
{
    /* @var $SSP_Config SSP_Configuration */
    $SSP_Config = Configuration::getConfiguration();
    $error = SSP_error($errstr, $errno, false);
    if ($SSP_Config->displayNoticesWarnings) {
        echo '<pre>';
        echo $error;
        echo '</pre>';
    } else {
        error_log($error, $SSP_Config->message_type, $SSP_Config->errorLog, $SSP_Config->adminEmail);
        foreach ($SSP_Config->errorAdmins as $toAddress => $toName) {
            ECRIAmailer("SSP error handler", $SSP_Config->noReplyEmail, $toName, $toAddress, "Notice or warning on " . $SSP_Config->siteName, $error);
        }
    }
}
Пример #4
0
 /**
  * re-starts the pointer at the top of the template with new data
  * @param array/string $replaces - content replaces
  * @param boolean $overwriteData - merge data if false
  */
 public function restart($replaces, $overwriteData = false)
 {
     if (is_string($replaces)) {
         // just replaces the title
         $this->replaces["title"] = $replaces;
     } elseif (is_array($replaces)) {
         // set up array for many string replaces
         if (!$overwriteData) {
             $this->replaces = array_merge($this->replaces, $replaces);
         } else {
             $this->replaces = $replaces;
         }
     } elseif (is_object($replaces)) {
         // set up array for many string replaces
         if ($overwriteData) {
             $this->replaces = get_object_vars($replaces);
         } else {
             $this->replaces = array_merge($this->replaces, get_object_vars($replaces));
         }
     } else {
         SSP_error("Template: Invalid template replacement data for " . $this->templatePath, E_USER_ERROR);
         exit;
     }
     $this->contentPosition = 0;
     $this->output = "";
 }
Пример #5
0
 /**
  * Add more translations strings to a language
  * @param type $langCode
  * @param array $strings
  * @return bool returns true on success
  */
 public static function addToLanguage($langCode, array $strings)
 {
     if (isset(self::$translationStrings[$langCode])) {
         if (isset(self::$translationStrings[$langCode]['strings'])) {
             // merges new translations with existing
             self::$translationStrings[$langCode]['strings'] = array_merge(self::$translationStrings[$langCode]['strings'], $strings);
         } else {
             self::$translationStrings[$langCode]['strings'] = $strings;
         }
     } else {
         SSP_error('SSP Language not configured, cannot load extra strings for ' . $langCode);
     }
 }
Пример #6
0
 public function setPreview($previewDir, $previewView)
 {
     // configure preview function
     //
     // parameters
     //	$previewDir - string - path to preview directory
     //	$previewView - string - path to view preview
     $this->preview = true;
     if ($previewDir != "" and file_exists($previewDir)) {
         $this->previewDir = $previewDir;
     } else {
         SSP_error("File::construc: file upload object, invalid preview directory: {$previewDir} for {$this->desc}");
     }
     $this->previewView = $previewView;
 }