/** * Get smarty template from database * Smarty resource plugin for fetching email templates from * the database. $tpl_name is parsed as a uri type of string where * the path to the template field is encoded as: * * code/module/field * * results in: * SELECT field FROM email_template WHERE code='code' ... * * @param string $tpl_name * @param string $tpl_source * @param ibject $smarty * @param boolean $default * @return string */ function smarty_resource_templatedb_fetch($tpl_name, &$tpl_source, &$smarty, $default = false) { $_url = parse_url($tpl_name); // (required) expected syntax: table/source_field $_path_items = explode('/', $_url['path']); $code = $_path_items[0]; $module = $_path_items[1]; $field = $_path_items[2]; if (!isset($smarty->templatedb_driver)) { $smarty->templatedb_driver =& atkGetDb(); } $tmp_source = $smarty->templatedb_driver->getrows("SELECT {$field} FROM email_template WHERE code='{$code}' AND module='{$module}' LIMIT 1;"); if (count($tmp_source) == 1) { $tmp_source = array_values($tmp_source[0]); $tpl_source = $tmp_source[0]; return true; } else { return $default; } }
<?php $config_atkroot = "../../"; include_once $config_atkroot . './atk.inc'; atkimport('atk.utils.atkyaml'); $table = @$_SERVER['argv'][1]; if ($table == null) { die("Please specify a table name!\n"); } $table = strtolower($table); $db = atkGetDb(); $db->query("SELECT * FROM {$table}"); ob_end_clean(); for ($i = 1; $db->next_record(); $i++) { $record = $db->m_record; $yaml = atkYAML::dump(array("{$table}_{$i}" => $db->m_record)); $yaml = substr($yaml, strpos($yaml, "\n") + 1); echo $yaml; }
function getBooked($projectid) { $db =& atkGetDb(); $rows = $db->getrows("SELECT sum(time) as booked FROM hours, phase\n WHERE hours.phaseid = phase.id AND phase.projectid=" . $projectid); return $rows[0]["booked"]; }
$user =& atkGetUser(); $user['name'] = strtolower($user['name']); /* * if not administrator perform security checks... */ if ($user['name'] != 'administrator') { /* * check if user is suspended or already logged in */ // read data directly from database because session is cached // secutity class.auth_db.inc->selectUser writes user info to db $usertable = atkconfig("auth_usertable"); $userfield = atkconfig("auth_userfield"); $userid = $user['id']; $query = "SELECT allowed_ip, is_suspended, last_seen_on, tbl_prefix FROM {$usertable} WHERE id ='{$userid}'"; $db =& atkGetDb(atkconfig("auth_database")); $recs = $db->getrows($query); $db_allowed_ip = $recs[0]['allowed_ip']; $db_is_suspended = $recs[0]['is_suspended']; $db_last_seen_on = $recs[0]['last_seen_on']; $db_tbl_prefix = $recs[0]['tbl_prefix']; $exp = explode(';', $db_last_seen_on); $db_last_seen_ip = $exp[0]; $last_seen_on = $_SERVER[REMOTE_ADDR] . '; ' . atkconfig('identifier') . '=' . htmlspecialchars($_COOKIE[atkconfig('identifier')]); // check if IP is allowed if ($db_allowed_ip && $db_allowed_ip != '0' && $db_allowed_ip != ';') { $pass_ip = false; $exp = explode(';', $db_allowed_ip); foreach ($exp as $ip) { if (trim($ip) == $_SERVER[REMOTE_ADDR]) { $pass_ip = true;
function getFirmData($id) { $sql = "SELECT * FROM ia32_config"; $conn = atkGetUser(atkconfig('auth_dbconfigfield')); $db =& atkGetDb($conn); $user_prefix = atkGetUser(atkconfig('auth_tblprefixfield')); $sql = str_replace('ia32_', $user_prefix, $sql); $ret = $db->getrows($sql); return $ret[0]; }
{ for ($i=0;$i<count($dep_record);$i++) { $before[] = $dep_record[$i]['dependency_phaseid_row']; $after[] = $dep_record[$i]['dependency_phaseid_col']; } return array("befores"=>$before, "afters"=>$after); }*/ function addDefaultConditions(&$query) { $query->addCondition("phase.startdate IS NOT null"); $query->addCondition("phase.enddate IS NOT null"); } // Select the dependency's for the gantchart $db =& atkGetDb(); $querydep =& $db->createQuery(); $querydep->addTable('phase'); $querydep->addJoin('project', '', 'project.id=phase.projectid', FALSE); $querydep->addJoin('dependency', '', 'dependency.phaseid_row=phase.id', FALSE); $querydep->addField('phaseid_row', ' ', 'dependency', 'dependency_'); $querydep->addField('phaseid_col', ' ', 'dependency', 'dependency_'); $querydep->addCondition("project.id='" . $projectid . "'"); addDefaultConditions($querydep); $querystringdep = $querydep->buildSelect(TRUE); $dbrecordsdep = $db->getrows($querystringdep); $cntrec = count($dbrecordsdep); for ($i = 0; $i < $cntrec; $i++) { $querydep->deAlias($dbrecordsdep[$i]); } // Get the database configuration parameters