Example #1
0
 /**
  * User::register()
  * 
  * @return
  */
 public function register()
 {
     Filter::checkPost('username', Core::$word->UR_USERNAME_R);
     if ($value = $this->usernameExists($_POST['username'])) {
         if ($value == 1) {
             Filter::$msgs['username'] = Core::$word->UR_USERNAME_R1;
         }
         if ($value == 2) {
             Filter::$msgs['username'] = Core::$word->UR_USERNAME_R2;
         }
         if ($value == 3) {
             Filter::$msgs['username'] = Core::$word->UR_USERNAME_R3;
         }
     }
     Filter::checkPost('fname', Core::$word->UR_FNAME);
     Filter::checkPost('lname', Core::$word->UR_LNAME);
     Filter::checkPost('address', Core::$word->UR_ADDRESS);
     Filter::checkPost('city', Core::$word->UR_CITY);
     Filter::checkPost('state', Core::$word->UR_STATE);
     Filter::checkPost('zip', Core::$word->UR_ZIP);
     Filter::checkPost('country', Core::$word->UR_COUNTRY);
     Filter::checkPost('pass', Core::$word->UR_PASSWORD_R);
     if (strlen($_POST['pass']) < 6) {
         Filter::$msgs['pass'] = Core::$word->UR_PASSWORD_R1;
     } elseif (!preg_match("/^.*(?=.{6,})(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).*\$/", $_POST['pass'] = trim($_POST['pass']))) {
         Filter::$msgs['pass'] = Core::$word->UR_PASSWORD_R2;
     } elseif ($_POST['pass'] != $_POST['pass2']) {
         Filter::$msgs['pass'] = Core::$word->UR_PASSWORD_R3;
     }
     Filter::checkPost('email', Core::$word->UR_EMAIL_R);
     if ($this->emailExists($_POST['email'])) {
         Filter::$msgs['email'] = Core::$word->UR_EMAIL_R1;
     }
     if (!$this->isValidEmail($_POST['email'])) {
         Filter::$msgs['email'] = Core::$word->UR_EMAIL_R2;
     }
     Filter::checkPost('captcha', Core::$word->UA_REG_RTOTAL_R);
     if ($_SESSION['captchacode'] != $_POST['captcha']) {
         Filter::$msgs['captcha'] = Core::$word->UA_REG_RTOTAL_R1;
     }
     $this->verifyCustomFields("register");
     if (empty(Filter::$msgs)) {
         $token = Registry::get("Core")->reg_verify == 1 ? $this->generateRandID() : 0;
         $pass = sanitize($_POST['pass']);
         if (Registry::get("Core")->reg_verify == 1) {
             $active = "t";
         } elseif (Registry::get("Core")->auto_verify == 0) {
             $active = "n";
         } else {
             $active = "y";
         }
         $data = array('username' => sanitize($_POST['username']), 'password' => sha1($_POST['pass']), 'email' => sanitize($_POST['email']), 'fname' => sanitize($_POST['fname']), 'lname' => sanitize($_POST['lname']), 'address' => sanitize($_POST['address']), 'city' => sanitize($_POST['city']), 'country' => sanitize($_POST['country']), 'state' => sanitize($_POST['state']), 'zip' => sanitize($_POST['zip']), 'token' => $token, 'active' => $active, 'created' => "NOW()");
         $fl_array = array_key_exists_wildcard($_POST, 'custom_*', 'key-value');
         if (isset($fl_array)) {
             $fields = $fl_array;
             $total = count($fields);
             if (is_array($fields)) {
                 $fielddata = '';
                 foreach ($fields as $fid) {
                     $fielddata .= $fid . "::";
                 }
             }
             $data['custom_fields'] = $fielddata;
         }
         self::$db->insert(self::uTable, $data);
         require_once BASEPATH . "lib/class_mailer.php";
         if (Registry::get("Core")->reg_verify == 1) {
             $actlink = SITEURL . "/activate.php?token=" . $token . "&email=" . $data['email'];
             $row = Registry::get("Core")->getRowById(Content::eTable, 1);
             $body = str_replace(array('[NAME]', '[USERNAME]', '[PASSWORD]', '[TOKEN]', '[EMAIL]', '[URL]', '[LINK]', '[SITE_NAME]'), array($data['fname'] . ' ' . $data['lname'], $data['username'], $_POST['pass'], $token, $data['email'], SITEURL, $actlink, Registry::get("Core")->site_name), $row->body);
             $newbody = cleanOut($body);
             $mailer = Mailer::sendMail();
             $message = Swift_Message::newInstance()->setSubject($row->subject)->setTo(array($data['email'] => $data['username']))->setFrom(array(Registry::get("Core")->site_email => Registry::get("Core")->site_name))->setBody($newbody, 'text/html');
             $mailer->send($message);
         } elseif (Registry::get("Core")->auto_verify == 0) {
             $row = Registry::get("Core")->getRowById(Content::eTable, 14);
             $body = str_replace(array('[NAME]', '[USERNAME]', '[PASSWORD]', '[URL]', '[SITE_NAME]'), array($data['fname'] . ' ' . $data['lname'], $data['username'], $_POST['pass'], SITEURL, Registry::get("Core") > site_name), $row->body);
             $newbody = cleanOut($body);
             $mailer = Mailer::sendMail();
             $message = Swift_Message::newInstance()->setSubject($row->subject)->setTo(array($data['email'] => $data['username']))->setFrom(array(Registry::get("Core")->site_email => Registry::get("Core")->site_name))->setBody($newbody, 'text/html');
             $mailer->send($message);
         } else {
             $row = Registry::get("Core")->getRowById(Content::eTable, 7);
             $body = str_replace(array('[NAME]', '[USERNAME]', '[PASSWORD]', '[URL]', '[SITE_NAME]'), array($data['fname'] . ' ' . $data['lname'], $data['username'], $_POST['pass'], SITEURL, Registry::get("Core")->site_name), $row->body);
             $newbody = cleanOut($body);
             $mailer = Mailer::sendMail();
             $message = Swift_Message::newInstance()->setSubject($row->subject)->setTo(array($data['email'] => $data['username']))->setFrom(array(Registry::get("Core")->site_email => Registry::get("Core")->site_name))->setBody($newbody, 'text/html');
             $mailer->send($message);
         }
         if (Registry::get("Core")->notify_admin) {
             $arow = Registry::get("Core")->getRowById(Content::eTable, 13);
             $abody = str_replace(array('[USERNAME]', '[EMAIL]', '[NAME]', '[IP]'), array($data['username'], $data['email'], $data['fname'] . ' ' . $data['lname'], $_SERVER['REMOTE_ADDR']), $arow->body);
             $anewbody = cleanOut($abody);
             $amailer = Mailer::sendMail();
             $amessage = Swift_Message::newInstance()->setSubject($arow->subject)->setTo(array(Registry::get("Core")->site_email => Registry::get("Core")->site_name))->setFrom(array(Registry::get("Core")->site_email => Registry::get("Core")->site_name))->setBody($anewbody, 'text/html');
             $amailer->send($amessage);
         }
         if (self::$db->affected() && $mailer) {
             $json['type'] = 'success';
             $json['title'] = Core::$word->SUCCESS;
             $json['message'] = Core::$word->UA_REG_OK;
             print json_encode($json);
         } else {
             $json['type'] = 'error';
             $json['title'] = Core::$word->ERROR;
             $json['message'] = Core::$word->UA_REG_ERR;
             print json_encode($json);
         }
     } else {
         $json['type'] = 'error';
         $json['title'] = Core::$word->SYSTEM_ERR;
         $json['message'] = Filter::msgSingleStatus();
         print json_encode($json);
     }
 }
Example #2
0
function processDeliverableTags($post, $deliverablePkId, $orderDBHandle)
{
    global $log;
    //set this to make sure the tag processor does not fail
    $tagRecords = array();
    $tagsLayout = "[WEB] Project Deliverable Tags";
    $tagsFind = $orderDBHandle->newFindCommand($tagsLayout);
    $tagsFind->addFindCriterion("_fk_Deliverable_pk_ID", '==' . $deliverablePkId);
    $tagsResults = $tagsFind->execute();
    if (FileMaker::isError($tagsResults)) {
        if ($tagsResults->getMessage() == "No records match the request") {
            $log->debug("No Tag records found");
        } else {
            $errorTitle = "FileMaker Error";
            $log->error("Failure to open (processDeliverableTags() ) " . $tagsLayout . " " . $tagsResults->getMessage() . " " . $tagsResults->getCode());
            processError($tagsResults->getMessage(), $tagsResults->getErrorString(), "tagProcessing.php", $deliverablePkId, $errorTitle);
            exit;
        }
    } else {
        $tagRecords = $tagsResults->getRecords();
    }
    //Get __pk_ID from FM tag layout feed PK to POST array to get values
    foreach ($tagRecords as $tagRecord) {
        $tagPk = $tagRecord->getField('__pk_ID');
        if (isset($post[$tagPk])) {
            if ($post[$tagPk] == 'delete') {
                $deleteResult = $tagRecord->delete();
                //This is a FileMaker delete of a record
                if (FileMaker::isError($deleteResult)) {
                    $errorTitle = "FileMaker Error";
                    $log->error("Failure to delete tag (processDeliverableTags() ) " . $tagsLayout . " " . $deleteResult->getMessage() . " " . $deleteResult->getCode());
                    processError($deleteResult->getMessage(), $deleteResult->getErrorString(), "tagProcessing.php", $tagPk, $errorTitle);
                    exit;
                }
            }
        } else {
            $tagRowArray = getTagInfoFromPost($post, $tagPk);
            if (isset($tagRowArray)) {
                $tagRecord->setField('PromoCode_Descriptor_t', getTagCodeValue($tagRowArray[0]));
                $tagRecord->setField('PromoCode_3_TagVersion_t', getTagCodeValue($tagRowArray[1]));
                $tagRecord->setField('Tag_Version_Description_t', stripHtmlWithSpaces($tagRowArray[2]));
                $tagRecord->setField('House_Number_t', $tagRowArray[3]);
            }
            $tagCommit = $tagRecord->commit();
            if (FileMaker::isError($tagCommit)) {
                $errorTitle = "FileMaker Error";
                $log->error("Failure to save tag (processDeliverableTags() ) " . $tagsLayout . " " . $tagCommit->getMessage() . " " . $tagCommit->getCode());
                processError($tagCommit->getMessage(), $tagCommit->getErrorString(), "tagProcessing.php", "N/A", $errorTitle);
                exit;
            }
        }
    }
    $prefix = "noTagPkId";
    $search = $prefix . "_*";
    //Do not forget the wildcard star!!!!!! so anything noTagPkId
    $tagDescriptor = "td";
    $tagVersion = "tv";
    $tagDescription = "tt";
    $tagHouse = "th";
    $us = "_";
    $allFieldsProcessed = 1;
    $maxItemsToProcess = 4;
    echo PHP_EOL . "Now run search for our No Pk Id" . PHP_EOL;
    foreach (array_key_exists_wildcard($post, $search) as $key => $value) {
        $index = getTagIndex($value);
        if (isset($post[$value]) && !empty($post[$value]) && getKetType($value) == $tagDescriptor) {
            $noTagPkWriteArray[0] = getTagCodeValue($post[$prefix . $us . $tagDescriptor . $us . $index]);
        }
        if (isset($post[$value]) && !empty($post[$value]) && getKetType($value) == $tagVersion) {
            $noTagPkWriteArray[1] = getTagCodeValue($post[$prefix . $us . $tagVersion . $us . $index]);
        }
        if (isset($post[$value]) && !empty($post[$value]) && getKetType($value) == $tagDescription) {
            $noTagPkWriteArray[2] = $post[$prefix . $us . $tagDescription . $us . $index];
        }
        if (isset($post[$value]) && !empty($post[$value]) && getKetType($value) == $tagHouse) {
            $noTagPkWriteArray[3] = $post[$prefix . $us . $tagHouse . $us . $index];
        }
        $allFieldsProcessed++;
        //Now we have values or not written to NoPkId tag values if we do the write them to FM otherwise skip
        if (isset($noTagPkWriteArray[0]) || isset($noTagPkWriteArray[1]) || isset($noTagPkWriteArray[2]) || isset($noTagPkWriteArray[3])) {
            if ($allFieldsProcessed > $maxItemsToProcess) {
                $newTagRecord = $orderDBHandle->createRecord($tagsLayout);
                $newTagRecord->setField("_fk_Deliverable_pk_ID", $deliverablePkId);
                if (isset($noTagPkWriteArray[0]) && !empty($noTagPkWriteArray[0])) {
                    $newTagRecord->setField('PromoCode_Descriptor_t', $noTagPkWriteArray[0]);
                }
                if (isset($noTagPkWriteArray[1]) && !empty($noTagPkWriteArray[1])) {
                    $newTagRecord->setField('PromoCode_3_TagVersion_t', $noTagPkWriteArray[1]);
                }
                if (isset($noTagPkWriteArray[2]) && !empty($noTagPkWriteArray[2])) {
                    $newTagRecord->setField('Tag_Version_Description_t', stripHtmlWithSpaces($noTagPkWriteArray[2]));
                }
                if (isset($noTagPkWriteArray[3]) && !empty($noTagPkWriteArray[3])) {
                    $newTagRecord->setField('House_Number_t', $noTagPkWriteArray[3]);
                }
                $addTagResults = $newTagRecord->commit();
                if (FileMaker::isError($addTagResults)) {
                    $errorTitle = "FileMaker Error";
                    $log->error("Failure to save tag (processDeliverableTags() ) " . $tagsLayout . " " . $addTagResults->getMessage() . " " . $addTagResults->getCode());
                    processError($addTagResults->getMessage(), $addTagResults->getErrorString(), "tagProcessing.php", "N/A", $errorTitle);
                    exit;
                }
                $allFieldsProcessed = 1;
                $noTagPkWriteArray = array();
            }
        }
    }
}