function default_Disp($field_value = "") { if (!$this->getRData('hidden')) { $dbc = $this->getDbCon(); //$dbc = $GLOBALS['conx']; list($tablename, $fielduniqid, $fielddisplay, $defaultvalue, $query) = explode(":", $this->getRData('list')); if ($fielduniqid != $fielddisplay) { if (!empty($field_value)) { $qFieldDisplay = new sqlQuery($dbc); $qFieldDisplay->query("select {$fielduniqid}, {$fielddisplay} from {$tablename} where {$fielduniqid}='" . $field_value . "'"); $avfielddisplay = $qFieldDisplay->fetchArray(); $fval = ""; for ($i = 1; $i < count($avfielddisplay); $i++) { $fval .= $avfielddisplay[$i] . " "; } $fval = substr($fval, 0, strlen($fval) - 2); $qFieldDisplay->free(); } else { $fval = ""; } } else { $fval = $field_value; } if (!$this->getRdata('execute')) { $fval = $this->no_PhpCode($fval); } $this->processed .= $fval; } }
function default_Form($field_value = "") { // $rdata = $this->getRData('radiobutton'); $dbc = $this->getDbCon(); //$dbc = $GLOBALS['conx']; $fieldvalue = $field_value; $fname = $this->getFieldName(); if (!$this->getRData('hidden') && !$this->getRData('readonly')) { list($tablename, $fielduniqid, $fielddisplay, $defaultvalue) = explode(":", $this->getRData('radiobutton')); if (substr($defaultvalue, 0, 1) == "[" && substr($defaultvalue, strlen($defaultvalue) - 1, 1) == "]") { $defaultvar = substr($defaultvalue, 1, strlen($defaultvalue) - 2); if (preg_match("/\\;/i", $defaultvar)) { $a_paramdefaultvar = explode(";", $defaultvar); $defaultvalue = $a_paramdefaultvar[0]($a_paramdefaultvar); } else { global ${$defaultvar}; $defaultvalue = ${$defaultvar}; } } if (strlen($fieldvalue) > 0) { $defaultvalue = $fieldvalue; } $qlist = new sqlQuery($dbc); $qlist->query("select {$fielddisplay}, {$fielduniqid} from {$tablename} order by {$fielddisplay}"); while (list($vfielddisplay, $vfielduniqid) = $qlist->fetchArray()) { $tmp_selected = ""; if ($vfielduniqid == $defaultvalue) { $tmp_selected = " checked"; } $fval .= "<input type=\"radio\" name=\"fields[" . $fname . "]\" value=\"" . htmlentities($vfielduniqid) . "\"" . $tmp_selected . " />" . $this->no_PhpCode($vfielddisplay) . "\n"; if ($this->getRData("vertical") != "no") { $fval .= "<br/>"; } else { $fval .= " "; } $tmp_selected = ""; } $this->processed .= $fval; } }
/** * Event registration.getForgotPassword * Returns the username and password for the * email id specified * @package registration * @author Philippe Lewicki, Abhik * @version 2.0 */ function eventGetForgotPassword(EventControler $eventControler) { $disp = new Display($eventControler->message_goto); $this->setLog("\n (" . $this->getObjectName() . ") Get Forgot Password " . date("Y/m/d H:i:s")); $conx = $this->getDbCon(); $fields = $eventControler->fields; $useremail = $fields[$this->getEmailField()]; include_once "class/Emailer.class.php"; $qGetPass = new sqlQuery($this->getDbCon()); $qGetPass->query("select * from `" . $this->getTable() . "` where `" . $this->getEmailField() . "`='" . $useremail . "'"); if ($qGetPass->getNumRows() > 0) { while ($dPass = $qGetPass->fetchArray()) { $email = new Emailer(); $email->loadEmailer($this->getDbCon(), $this->emailtemplate['forgotpassword']); $email->mergeArray($dPass); if ($email->hasHtml()) { $email->sendMailHtml($dPass[$this->getEmailField()]); } else { $email->sendMailStandard($dPass[$this->getEmailField()]); } $disp->addParam("message", _("Your password has been sent to: ") . $useremail); } } else { $disp->addParam("message", _("No user found with that email address")); } $eventControler->setDisplayNext($disp); }
<?php include_once "config.php"; $q = new sqlQuery($GLOBALS['conx']); $q->query("show tables"); $qr = new sqlQuery($GLOBALS['conx']); echo "<table>"; while ($row = $q->fetchArray()) { $qr->query("select count(*) as total from " . $row[0]); $qr->fetch(); if ($qr->getD("total") > 10000) { echo "\n<tr><td>" . $row[0] . "</td><td><b>" . $qr->getD("total") . "</b></td></tr>"; } else { echo "\n<tr><td>" . $row[0] . "</td><td>" . $qr->getD("total") . "</td></tr>"; } } echo "</table>"; ?>
function eventSetCoWorker(EventControler $evtcl) { $goto = $evtcl->goto; if ($evtcl->fields['email_address'] != "") { $email_user = $evtcl->fields['email_address']; } else { $email_user = $evtcl->email; } if ($email_user != '' && !empty($email_user)) { // $email_user = $evtcl->email;//echo $email_user;exit; $iduser = $this->isUserExists($email_user); // user already in the db so just add if ($iduser) { $q = new sqlQuery($this->getDbCon()); $q->query("select * from " . $this->table . " where iduser = "******" AND idcoworker= " . $iduser); //echo "select * from ".$this->table." where iduser = "******" AND idcoworker= ".$iduser;exit; if ($q->getNumRows() > 0) { while ($q->fetch()) { $accepted = $q->getData("accepted"); } if ($accepted == 'Yes') { $_SESSION['in_page_message'] = "cw_user-is-already-cw"; } elseif ($accepted == 'No') { $_SESSION['in_page_message'] = "cw_already-have-pending-invitation"; } } else { $this->iduser = $_SESSION['do_User']->iduser; $this->idcoworker = $iduser; $this->accepted = 'No'; $this->add(); $_SESSION['in_page_message'] = "cw_user-is-already-in-db-notification-sent"; } } else { // Not found send the email. $enc_email = $this->encrypt($email_user); $q = new sqlQuery($this->getDbCon()); $q->query("select * from " . $this->table . " where iduser = "******" AND enc_email = '" . $enc_email . "' AND accepted ='No'"); //echo "select * from ".$this->table." where enc_email = '".$enc_email."' AND accepted ='No'";exit; if ($q->getNumRows() > 0) { // If the invitation is still pending $_SESSION['in_page_message'] = "cw_already-have-pending-invitation-to"; $_SESSION['in_page_message_data']['enc_email'] = $this->decrypt($enc_email); } else { $this->iduser = $_SESSION['do_User']->iduser; $this->idcoworker = 0; $this->accepted = 'No'; $this->enc_email = $enc_email; $this->add(); $last_id = $this->getInsertId($this->table, $this->primary_key); include_once "class/Emailer.class.php"; $q = new sqlQuery($this->getDbCon()); $q->query("select * from " . $this->table . " where " . $this->primary_key . " = " . $last_id); if ($q->getNumRows() > 0) { while ($dData = $q->fetchArray()) { $dData["firstname"] = $_SESSION['do_User']->firstname; $dData["referer"] = $this->encrypt($last_id); $full_name = $_SESSION['do_User']->firstname . " " . $_SESSION['do_User']->lastname; $email = new Emailer(); $email->loadEmailer($this->getDbCon(), "invitation"); $email->setSender($full_name, $_SESSION['do_User']->email); $email->mergeArray($dData); if ($email->hasHtml()) { $email->sendMailHtml($email_user); } else { $email->sendMailStandard($email_user); } $_SESSION['in_page_message'] = "cw_user-not-in-db-register"; } } } } } else { $_SESSION['in_page_message'] = "cw_enter-emailid"; } }
/** * __call magic method to generate DataObject or load data in the object. * * This is where the magic happened. * * Those magic methods display saved view, form or saved query as well a manage relations. * ->get_name_of_saved_query will load and run an SQLfusion from the savedquery/ folder. * ->view_name_of_a_serialized_report will load and display a view from the report/ folder. * ->form_name_of_a_serialized_form will load and display a form from the form/ folder. * Relation: * ->GetChildNameOfChildDataObject ($BlogEntries->GetChildComments()) will return an instance of * the child object with a dataset containing only the child entries of the current Object value. * An example is at: http://radria.sqlfusion.com/documentation/core:by_example_php5#relations * ->GetParent... works the same why but look on the Parent relation and will return one record. * * @param method name of the method called * @param params array of parameters used on the method call. */ public function __call($method, $params) { try { $this->setLog("\n DataObject __call for method:" . $method); if (method_exists($this, $method)) { return; } $method_found = false; // lets use the method as an ordering. if (ereg("^getChild(.*)\$", $method, $match)) { $this->setLog("\n DataObject __call for child:" . $match[1]); $tablename = strtolower($match[1]); $order_limit = $params[0]; $class_name = $match[1]; $this->setLog("\n DataObject:" . $tablename . " Doesn exist checking if the table exists"); $q_tables = new sqlQuery($this->getDbCon()); $q_tables->getTables(); $table_found = false; if (class_exists($class_name)) { $this->setLog("\n DataObject:" . $class_name . " exist instanciating it with child values"); $new_data_object = new $class_name($this->getDbCon()); if (strlen($new_data_object->getTable()) > 0) { $tablename = $new_data_object->getTable(); } $new_data_object->{$this->getPrimaryKey()} = $this->getPrimaryKeyValue(); $new_data_object->query("select * from " . $tablename . " where " . $this->getPrimaryKey() . "=" . $this->getPrimaryKeyValue() . " " . $order_limit); $method_found = true; return $new_data_object; } else { $this->setLog("\n DataObject:" . $class_name . " Doesn't exist checking if the table " . $tablename . " exists"); while ($tables = $q_tables->fetchArray()) { if ($tablename == $tables[0]) { $table_found = true; } } if ($table_found) { $this->setLog("\nDataObject Table Found creating new data object:" . $tablename); $new_data_object = new DataObject($this->getDbCon()); $new_data_object->setTable($tablename); $new_data_object->setPrimaryKey("id" . $tablename); $new_data_object->{$this->getPrimaryKey()} = $this->getData($this->getPrimaryKey()); $new_data_object->query("select * from " . $tablename . " where " . $this->getPrimaryKey() . "=" . $this->getData($this->getPrimaryKey())); $method_found = true; //$this->{$tablename} = $new_data_object; return $new_data_object; } else { throw new RadriaException("Table:" . $tablename . " Not Found Could not create an Object"); } } } if (ereg("^getParent(.*)\$", $method, $match)) { $this->setLog("\n DataObject __call for parent:" . $match[1]); $tablename = strtolower($match[1]); if (class_exists($tablename) && is_subclass_of($tablename, "DataObject")) { $this->setLog("\n DataObject class for" . $tablename . " exists will instanciate it"); $do = new $tablename($this->getDbCon()); //$do->query("select * from ".$tablename." where ".$do->getPrimaryKey()."=".$this->getData($do->getPrimaryKey())); $do->getId($this->{$do->getPrimaryKey()}); $method_found = true; return $do; } else { $this->setLog("\n DataObject class for " . $tablename . " Doesn exist checking if the table exists"); $q_tables = new SqlQuery($this->getDbCon()); $q_tables->getTables(); $table_found = false; while ($tables = $q_tables->fetchArray()) { if ($tablename == $tables[0]) { $table_found = true; } } if ($table_found) { $this->setLog("\n Creating new data object:" . $tablename); $new_data_object = new DataObject($this->getDbCon()); $new_data_object->setTable($tablename); $new_data_object->setPrimaryKey("id" . $tablename); $new_data_object->query("select * from " . $tablename . " where " . $new_data_object->getPrimaryKey() . "=" . $this->getData($new_data_object->getPrimaryKey())); $method_found = true; //$this->{$tablename} = $new_data_object; return $new_data_object; } else { throw new RadriaException("Table:" . $tablename . " Not Found"); } } } if (!$method_found) { // throw new RadriaException("Method:" . $method . " Not Found"); die("Method:" . $method . " Not Found"); } return false; } catch (RadriaException $e) { $this->setError("\n DataObject Exception: " . $e->getMessage()); throw new RadriaException($e->getMessage() . " when calling method:" . $method); } catch (\Exception $e) { trigger_error("Method" . $method . " Not found", E_USER_ERROR); } }