/** * saveWebForm() * this will check if contact exists with firname, lastname, name and email * If exist add to it, if doesn't exists create a new one. */ function eventAddContact(EventControler $event_controler) { //$fields = $_REQUEST['fields']; $fields = $event_controler->fields; $this->setLog("\n eventAddContact, creating new contact from form, using " . count($fields) . " fields. (" . date("Y/m/d H:i:s") . ")"); //$dropcode = $_POST['dropcode']; if (isset($this->iduser)) { $do_contact = new Contact(); $do_contact->iduser = $this->iduser; $do_contact->add(); $this->setLog("\n new contact:" . $do_contact->idcontact . " for user:"******"\n new contact:" . $do_contact->idcontact . " for user:"******"\n Processing field:" . $field_name . " with value:" . $field_value); if (isset($this->idwebformuser)) { $do_webform_fields = new WebFormUserField(); $do_webform_fields->query("SELECT wfu.name, wff.class as class_name, wff.variable, wff.variable_type, wfu.required \n\t\t FROM webformfields as wff, webformuserfield as wfu \n WHERE wff.name=wfu.name\n AND wfu.name = '" . $field_name . "'\n AND wfu.idwebformuser= "******"SELECT wfu.name, wff.class as class_name, wff.variable, wff.variable_type, wfu.required \n FROM webformfields as wff, webformuserfield as wfu \n WHERE wff.name=wfu.name\n AND wfu.name = '" . $field_name . "'\n AND wfu.idwebformuser= "******"\n Field information class:" . $do_webform_fields->class_name . " Variable:" . $do_webform_fields->variable); $this->setLog("\n rows:" . $do_webform_fields->getNumRows()); if ($do_webform_fields->getNumRows() == 1) { if ($do_webform_fields->class_name == "Contact") { $this->setLog("\n Updating contact"); $do_contact->{$do_webform_fields->variable} = $field_value; $do_contact->update(); } else { $update = false; if (is_object(${'sub_' . $do_webform_fields->class_name})) { if (${'sub_' . $do_webform_fields->class_name}->getType() == $do_webform_fields->variable_type) { $update = true; } } if ($update) { $this->setLog("\n Updating class:" . $do_webform_fields->class_name); $obj = ${'sub_' . $do_webform_fields->class_name}; $obj->{$do_webform_fields->variable} = $field_value; $obj->update(); } else { $class_name = $do_webform_fields->class_name; ${'sub_' . $class_name} = new $class_name(); $obj = ${'sub_' . $class_name}; $obj->{$do_webform_fields->variable} = $field_value; if (method_exists($obj, "setType") && strlen($do_webform_fields->variable_type) > 0) { $obj->setType($do_webform_fields->variable_type); } $obj->idcontact = $do_contact->getPrimaryKeyValue(); $obj->iduser = $event_controler->uid; $obj->add(); } } } } if (isset($this->iduser)) { $contact_view = new ContactView(); $contact_view->setUser($this->iduser); $contact_view->addFromContact($do_contact); } else { $contact_view = new ContactView(); $contact_view->setUser($event_controler->uid); $contact_view->addFromContact($do_contact); } if (isset($this->tags)) { $tags = explode(",", $this->tags); foreach ($tags as $tag) { $tag = trim($tag); $do_tag = new Tag(); $do_tag->addNew(); $do_tag->addTagAssociation($do_contact->getPrimaryKeyValue(), $tag, "contact", $this->iduser); $contact_view->addTag($tag); } if (strlen($this->urlnext) > 0) { $event_controler->setUrlNext($this->urlnext); } else { $event_controler->setUrlNext($GLOBALS['cfg_ofuz_site_http_base'] . 'web_form_thankyou.php'); } $event_controler->addParam("do_contact", $do_contact); } else { $sql = "SELECT * FROM {$this->table} WHERE idwebformuser={$event_controler->fid}"; $this->query($sql); while ($this->fetch()) { $tags = $this->getData("tags"); $urlnext = $this->getData("urlnext"); } $tags = explode(",", $tags); foreach ($tags as $tag) { $tag = trim($tag); $do_tag = new Tag(); $do_tag->addNew(); $do_tag->addTagAssociation($do_contact->getPrimaryKeyValue(), $tag, "contact", $this->iduser); $contact_view->addTag($tag); } if (strlen($urlnext) > 0) { $event_controler->setUrlNext($urlnext); } else { $url = $GLOBALS['cfg_ofuz_site_http_base'] . 'web_form_thankyou.php'; //$event_controler->setUrlNext($url); //header("location:$url"); $err_disp = new Display($url); $event_controler->setDisplayNext($err_disp); $event_controler->doForward(); } //$event_controler->addParam("do_contact", $do_contact); } }
<?php // Copyright 2001 - 2007 SQLFusion LLC info@sqlfusion.com /** * Main event Controler * This is an instance of the Event controler that will be managing the execution of the events and set the next url * @see EventControler * @package RadriaSiteTemplate * @author Philippe Lewicki <*****@*****.**> * @copyright SQLFusion LLC 2001-2007 * @version 4.0 */ include_once "config.php"; // "start event control" ; $eventControler = new EventControler($conx); $eventControler->setMyDbPath($cfg_local_mydbdir); $eventControler->addparam("dbc", $conx); $eventControler->addparam("doSave", "yes"); $eventControler->setMessagePage("message.php"); // If you want to secure your site to only authorize request with local referer // comment the line bellow. // Notes: doesn't work with ssl or some IE version and Ajax $eventControler->setCheckReferer(false); $eventControler->addallvars(); $eventControler->listenEvents($_REQUEST['mydb_events']); $eventControler->doForward();
/** * Login event method checks different identification * @param $eventControler -- Object */ function eventCheckIdentification(EventControler $eventControler) { $login_error = false; setcookie("ofuz", "1", time() + 25920000); $this->setLog("\n (User) Registration Sign on " . date("Y/m/d H:i:s")); $conx = $this->getDbCon(); $strWrongLoginPassword = $eventControler->strWrongLoginPassword; if (strlen($eventControler->password_field) > 0) { $password_field = $eventControler->password_field; $this->setPasswordField($eventControler->password_field); } else { $password_field = $this->getPasswordField(); } if (strlen($eventControler->username_field) > 0) { $username_field = $eventControler->username_field; $this->setUsernameField($eventControler->username_field); } else { $username_field = $this->getUsernameField(); } $fields = $eventControler->fields; $auth_username = $fields[$username_field]; $auth_password = $fields[$password_field]; // Changes made to encrypt the password before looking in the DB $do_user_rel = new UserRelations(); $auth_password = $do_user_rel->encrypt($auth_password); $goto = $eventControler->goto; if (empty($strWrongLoginPassword)) { $strWrongLoginPassword = _('Wrong login or password'); } if (strlen($auth_username) > 0 && strlen($auth_password) > 0) { $this->setLog("\n(User) database: " . $conx->db . ", table:" . $this->getTable()); $this->query("select * from `" . $this->getTable() . "` \n where `" . $this->getUsernameField() . "`='" . $this->quote($auth_username) . "' \n and `" . $this->getPasswordField() . "`='" . $this->quote($auth_password) . "'"); $this->setLog("\n(User) Query executed for sign on:" . $this->sql_query); if ($this->getNumrows() == 1) { if (isset($_SESSION["google"]["openid_identity"])) { $this->setGoogleOpenIdIdentity($this->iduser); } unset($_SESSION['upgrade']); if ($this->plan == "trial") { $date1 = strtotime($this->regdate); $date2 = strtotime(date("Y-m-d")); $diff = ($date2 - $date1) / (60 * 60 * 24); if ($diff >= '30') { $_SESSION["upgrade"] = true; $err_disp = new Display("api_upgrade_invoice.php"); $eventControler->setDisplayNext($err_disp); $eventControler->doForward(); } } if ($this->status == 'active') { $do_login_audit = new LoginAudit(); if ($this->fb_user_id) { // IS a FB connected User if ($this->email == '') { // Oups!!!! no email id then you must login with facebook $login_error = true; $msg = _('Seems like you have registered through facebook. Please login with facebook !'); } else { $this->setSessionVariable(); // Ok you are smart you set an email id also !!! $do_login_audit->do_login_audit(); } } else { $this->setSessionVariable(); $do_login_audit->do_login_audit(); } // There you are a general user you can try our FB connent !!! /* Scope to check other login features Ex: $other_id = $this->otherMethod(); We can also change the $msg to class var to hold a message from a message array */ if ($login_error) { //echo $eventControler->$errPage; $err_disp = new Display($eventControler->errPage); $_SESSION['crdmsg'] = $msg; $err_disp->addParam("message", $msg); $eventControler->setDisplayNext($err_disp); } else { //echo '2'; // check if the user has contacts // if not redirect to welcome_to_ofuz.php $contacts = $this->getChildContact(); if ($contacts->getNumrows() < 2) { if ($eventControler->goto == 'settings_myinfo.php') { $eventControler->setDisplayNext(new Display("/settings_myinfo.php")); } else { $eventControler->setDisplayNext(new Display("/welcome_to_ofuz.php")); } } else { $eventControler->setUrlNext($eventControler->goto); } } } else { $err_disp = new Display($eventControler->errPage); $msg = _("Your account is not currently active, contact our tech support at " . $GLOBALS['cfg_ofuz_email_support']); $_SESSION['crdmsg'] = $msg; $err_disp->addParam("message", $msg); $eventControler->setDisplayNext($err_disp); } } else { //echo '3'; $err_disp = new Display($eventControler->errPage); $msg = _("Wrong Login !"); $err_disp->addParam("message", $msg); $eventControler->setDisplayNext($err_disp); } } }