function render($name) { $dataManager = new \DataManager(); $doc = $dataManager->getDocument($name); if ($doc === null) { $resp = new \Symfony\Component\HttpFoundation\Response("", 404); return $resp; } $url1 = $doc->member_one->photo_url; $data1 = $dataManager->getPhotoDataBase64($url1); $url2 = $doc->member_two->photo_url; $data2 = $dataManager->getPhotoDataBase64($url2); $url3 = $doc->vehicle->photo_url; $data3 = $dataManager->getPhotoDataBase64($url3); $imageData = base64_encode($imageContent); $template = new \PHPTemplate(); $template->assign("document", $doc); $template->assign("member_one", $doc->member_one); $template->assign("member_one_photo_data_base64", $data1); $template->assign("member_two", $doc->member_two); $template->assign("member_two_photo_data_base64", $data2); $template->assign("home_base", $doc->home_base); $template->assign("completed_journeys", $doc->completed_journeys); $template->assign("planned_journeys", $doc->planned_journeys); $template->assign("wish_list_journeys", $doc->wish_list_journeys); $template->assign("vehicle", $doc->vehicle); $template->assign("vehicle_photo_data_base64", $data3); $h = $template->fetch('html'); file_put_contents($name . "_html_." . "html", $h); return $h; }
function list_all() { $page = (int) $this->uri->segment(3, 1); //echo $page; $page = $page ? $page : 1; $items_per_page = 7; $dm = new DataManager($this->dm_profile, $this->dm_sqlsrv); $dm->setItemsPerPage($items_per_page); $dm->setPage($page); $dm->setMode('list'); $dm->setOrderingField('id', 0); if ($dm->loadData() === false) { var_dump($dm->getErrors()); exit; } $data['pages_count'] = $dm->getPagesCount(); $message = $this->uri->segment(4); switch ($message) { case 'deleted': $data['message'] = 'Item deleted.'; break; case 'saved': $data['message'] = 'Item saved.'; break; default: $data['message'] = ''; } $data['titles'] = $dm->getTitles(); $data['fields'] = $dm->getFields(); $data['controller'] = $this->controller; $data['page'] = $this->controller . '/list'; $this->ag_auth->view('reseller/list', $data); }
public function test_create_db() { $dm = new \DataManager(); system("rm -Rvf " . $dm->dataRoot . "/*"); $obj1 = $dm->getDefaultDocument(); $obj1->unique_identifier = "robert_blackwell"; $dm->putFile("robert_blackwell", $obj1); $obj1->unique_identifier = "blackwells"; $dm->putFile("blackwells", $obj1); }
function edit($document_id, $section) { // return __METHOD__." $document_id $section "; $dataManager = new \DataManager(); $doc = $dataManager->getDocument($document_id); $template = new \PHPTemplate(); $template->assign("document", $doc); $template_name = "form_" . $section; return $template->fetch($template_name); }
function show($name) { $dataManager = new \DataManager(); $doc = $dataManager->getDocument($name); if ($doc === null) { $resp = new \Symfony\Component\HttpFoundation\Response("", 404); return $resp; } $template = new \PHPTemplate(); $template->assign("document", $doc); return $template->fetch('show'); }
public static function GetInstance() { if (self::$instance == null) { self::$instance = new DataManager(); } return self::$instance; }
public function processRequest(MMapRequest $request, MMapResponse $response) { ob_start('mb_output_handler'); MMapManager::startSession(); //check if the session has expired MMapManager::checkSessionExpiration(); $return = null; $dataManager = DataManager::getInstance(); $POST = $request->getPOST(); $params = array(); if (isset($POST['params'])) { $params = $dataManager->doInput($POST['params']); } else { if ($request->issetGET('params')) { $params = $request->getGET('params'); } } $return = array(); foreach ($params as $call) { $call[2] = json_encode($call[2]); $_POST['params'] = $call[2]; $request->setPost('params', $call[2]); $_GET['message'] = $call[1]; $request->setGET('message', $call[1]); $_GET['checknum'] = $call[0]; $request->setGET('checknum', $call[0]); MMapMsg::getInstance()->processRequest($request, $response); MMapManager::getInstance()->doResponse($response); $response->clear(); $content = ob_get_contents(); ob_clean(); $return[] = $content; } $response->setBodyRenderer(new DataManagerBodyRenderer($return)); }
/** * @return GroundManager * @param SiteSettings $o_settings * @param MySqlConnection $o_db * @desc Read and write Grounds */ function __construct(SiteSettings $o_settings, MySqlConnection $o_db) { parent::DataManager($o_settings, $o_db); $this->s_item_class = 'Ground'; # Exclude once-only teams by default $this->filter_team_types = array(Team::CLOSED_GROUP, Team::OCCASIONAL, Team::REGULAR, Team::REPRESENTATIVE); }
/** * connect to the database * * note: alternatively put those in parameter list or as class variables * * @return connection resource */ private static function getConnection() { if (!isset(self::$__connection)) { self::$__connection = new PDO('mysql:host=localhost;dbname=fh_2015_scm4_1310307036;charset=utf8', 'root', ''); } return self::$__connection; }
public static function lookup($hostname) { self::init(); Profiler::StartTimer("DNSResolver::lookup()", 2); $data = DataManager::singleton(); $records = $apc = NULL; $cachekey = "dnsresolver.lookup.{$hostname}"; if (self::$cache && !empty($data->caches["apc"]) && $data->caches["apc"]["default"]->enabled) { $apc = $data->caches["apc"]["default"]; $cached = $apc->get($cachekey); if ($cached !== false) { $records = unserialize($cached); Logger::Info("DNSResolver: found '{$hostname}' in APC cache"); } } if ($records === NULL) { Logger::Info("DNSResolver: Looking up '{$hostname}'"); foreach (self::$search as $suffix) { $fqdn = $hostname . (!empty($suffix) ? "." . $suffix : ""); $records = dns_get_record($fqdn, DNS_A); if (!empty($records)) { break; } } if (self::$cache && !empty($records) && $apc !== NULL && $apc->enabled) { $ttl = any(self::$ttl, $records[0]["ttl"]); $apc->set($cachekey, serialize($records), array("lifetime" => $ttl)); } } Profiler::StopTimer("DNSResolver::lookup()"); return $records; }
/** * @return MatchManager * @param SiteSettings $o_settings * @desc Read and write matches */ public function __construct($o_settings, $o_db) { parent::DataManager($o_settings, $o_db); $this->s_item_class = 'Match'; $this->filter_by_match_types = array(); $this->filter_by_player_types = array(); $this->filter_by_teams = array(); }
/** * @return TeamManager * @param SiteSettings $o_settings * @param MySqlConnection $o_db * @desc Read and write Teams */ public function TeamManager(SiteSettings $o_settings, MySqlConnection $o_db) { parent::DataManager($o_settings, $o_db); $this->s_item_class = 'Team'; $this->b_inactive_last = true; # Exclude once-only teams and schools by default $this->filter_team_types = array(Team::CLOSED_GROUP, Team::OCCASIONAL, Team::REGULAR, Team::REPRESENTATIVE); }
public function controller_category($args) { $vars["category"] = $args["category"]; if (is_string($vars["category"])) { $categories = DataManager::fetch("db.demos.{$vars['category']}", "demo_categories", array("category" => $vars["category"])); $vars["category"] = $categories[0]; } return $this->GetComponentResponse("./category.tpl", $vars); }
public static function init() { $cookieinfo = explode(",", $_COOKIE['fl-uid']); $fluid = $cookieinfo[0]; $device = DataManager::fetch("db.session.{$deviceid}:nocache", "usersession.usersession", array("fl_uid" => $fluid)); if (count($device) == 1) { self::set(preg_match("/^a:\\d+:{/", $device[0]["data"]) ? unserialize($device[0]["data"]) : json_decode($device[0]["data"])); } }
/** * Instantiates a ShortUrlManager * * @param SiteSettings $o_settings * @param MySqlConnection $o_db */ public function __construct(SiteSettings $o_settings, MySqlConnection $o_db) { parent::DataManager($o_settings, $o_db); $this->SetItemClass('ShortUrl'); $a_formats = $this->GetSettings()->GetShortUrlFormats(); foreach ($a_formats as $o_format) { $this->AddUrlFormat($o_format); } }
public function processRequest(MMapRequest $request, MMapResponse $response) { ob_start('mb_output_handler'); MMapManager::startSession(); //check if the session has expired MMapManager::checkSessionExpiration(); $return = null; $dataManager = DataManager::getInstance(); // restore current process using checknum $myProcManager = ProcManager::getInstance(); $myProcess = $myProcManager->getProcessByChecknum($request->getGET('checknum')); $myProcManager->setCurrentProcess($myProcess); $appDesc = new EyeMobileApplicationDescriptor($myProcess->getName()); $POST = $request->getPOST(); $params = array(); if (isset($POST['params'])) { $params = $dataManager->doInput($POST['params']); } else { if ($request->issetGET('params')) { $params = $request->getGET('params'); } } $methodName = $request->getGET('message'); // calling an ExecModule if (strpos($methodName, '__') === 0) { $moduleName = explode('_', substr($methodName, 2)); $methodName = $moduleName[1]; //ex: "FileChooser" $moduleName = $moduleName[0]; //ex: "browsePath" $return = call_user_func_array(array($appDesc->getApplicationClassName(), '__callModule'), array($moduleName, $methodName, $params)); } else { if ($appDesc->isJavascriptOnlyApplication()) { $return = call_user_func(array('EyeosJavascriptApplicationExecutable', $methodName), $params); } else { if (method_exists($appDesc->getApplicationClassName(), $methodName)) { $return = call_user_func(array($appDesc->getApplicationClassName(), $methodName), $params); } else { //If no function is present, call the NOT mobile function MMapMsg::getInstance()->processRequest($request, $response); return; } // try { // $return = call_user_func(array($appDesc->getApplicationClassName(), $methodName), $params); // } catch (Exception $e) { // //If no function is present, call the NOT mobile function // MMapMsg::getInstance()->processRequest($request, $response); // return; // } } } if ($response->getBodyRenderer() === null && $response->getBody() == '') { $response->setBodyRenderer(new DataManagerBodyRenderer($return)); } }
function upload($name, $entity, $mime_type, $tmp_name) { $dataManager = new \DataManager(); $ext = $this->mimeToExtension($mime_type); // // Test that upload worked and all is ok // if (!(file_exists($tmp_name) && is_uploaded_file($tmp_name))) { return new JsonResponse(["error" => ["msg" => "upload failed", "tmp" => $tmp_name]], 500); } $fn = $dataManager->getNewPathForPhoto($name, $entity, $ext); //unlink($fn); move_uploaded_file($tmp_name, $fn); if (!file_exists($fn)) { return new JsonResponse(['result' => "got here but file did not move {$fn}"], 500); } $this->orientation_fixer->fix($fn); $url = $dataManager->savePhoto($name, $entity, $ext, $fn); $r = ["result" => ["url" => $url, "size" => $size]]; return new JsonResponse($r, 200); }
/** * Add sidebars to project overview page * * @param array $sidebars * @param Project $project * @param User $user */ function frosso_estimated_cost_handle_on_project_overview_sidebars(&$sidebars, Project &$project, User &$user) { if (($user->canUseReports() || $project->isLeader($user)) && $project->canEdit($user)) { $arguments = array('conditions' => array('project_id = ? AND type = ? AND state >= ? AND visibility >= ? AND completed_on IS NULL', $project->getId(), 'Milestone', STATE_VISIBLE, VISIBILITY_NORMAL)); $milestones = DataManager::find($arguments, TABLE_PREFIX . 'project_objects', DataManager::CLASS_NAME_FROM_TABLE, 'RemediaMilestone'); if (is_foreachable($milestones)) { $result = array(); $view = SmartyForAngie::getInstance()->createTemplate(AngieApplication::getViewPath('eta_project_sidebar', 'sidebar', FROSSO_EC_MODULE, AngieApplication::INTERFACE_DEFAULT)); $view->assign(array('milestones' => $milestones, 'logged_user' => $user)); $sidebars[] = array('label' => lang('ETA for this project'), 'is_important' => false, 'id' => 'project_milestones_complete', 'body' => $view->fetch()); } } }
static function GetConnection() { if (!self::$connection) { // open the connection self::$connection = mysql_connect(Config::SERVER_NAME, Config::USERNAME, Config::PASSWORD); if (!self::$connection) { die('Could not connect: ' . mysql_error()); } // pick the database to use mysql_select_db(Config::DATABASE_NAME, self::$connection); } return self::$connection; }
function component_generate($args, $output = "text") { // Only return this data when run from the commandline if ($output == "commandline") { $ret = "[not found]"; if (!empty($args["model"])) { $data = DataManager::singleton(); $model = new ORMModel($args["model"]); $ret = $model->Generate(); } } else { $ret = ""; } return $ret; }
function getControlMessage($sid) { $dbM = new DataManager(SXN_USER, SXN_PASSWORD, "localhost", SXN_DATABASE_CONTROL); $dbM->selectAllFromTable(SXN_CONTROL_TABLE_COMMANDS, SXN_CONTROL_COMMANDS_COLUMN_SID . "=" . "{$sid} AND " . SXN_CONTROL_COMMANDS_COLUMN_STATUS . "=" . "'new'"); //TODO add enum table for new, etc.. $numRes = $dbM->retrieveNumberOfResults(); if ($numRes > 0) { while ($data = $dbM->retrieveResult()) { echo " :" . $data[SXN_CONTROL_COMMANDS_COLUMN_COMMAND] . "\n"; } //Update status to "executed" $columns = array(SXN_CONTROL_COMMANDS_COLUMN_STATUS); $values = array("executed"); $dbM->updateRow(SXN_CONTROL_TABLE_COMMANDS, $columns, $values, SXN_CONTROL_COMMANDS_COLUMN_SID . "=" . "{$sid} AND " . SXN_CONTROL_COMMANDS_COLUMN_STATUS . "=" . "'new'"); } }
public function processRequest(MMapRequest $request, MMapResponse $response) { ob_start('mb_output_handler'); MMapManager::startSession(); //check if the session has expired MMapManager::checkSessionExpiration(); $return = null; $dataManager = DataManager::getInstance(); // restore current process using checknum $myProcManager = ProcManager::getInstance(); $myProcess = $myProcManager->getProcessByChecknum($request->getGET('checknum')); $myProcManager->setCurrentProcess($myProcess); $appDesc = new EyeosApplicationDescriptor($myProcess->getName()); $POST = $request->getPOST(); $params = array(); if (isset($POST['params'])) { $params = $dataManager->doInput($POST['params']); } else { if ($request->issetGET('params')) { $params = $request->getGET('params'); } } $methodName = $request->getGET('message'); // calling an ExecModule if (strpos($methodName, '__') === 0) { $moduleName = explode('_', substr($methodName, 2)); $methodName = $moduleName[1]; //ex: "FileChooser" $moduleName = $moduleName[0]; //ex: "browsePath" $return = call_user_func_array(array($appDesc->getApplicationClassName(), '__callModule'), array($moduleName, $methodName, $params)); } else { if ($appDesc->isJavascriptOnlyApplication()) { $return = call_user_func(array('EyeosJavascriptApplicationExecutable', $methodName), $params); } else { $return = call_user_func(array($appDesc->getApplicationClassName(), $methodName), $params); } } //try to force mime type. If there is a previous mime type defined at application level //this have no effect if (!headers_sent()) { $response->getHeaders()->append('Content-type:text/plain'); } if ($response->getBodyRenderer() === null && $response->getBody() == '') { $response->setBodyRenderer(new DataManagerBodyRenderer($return)); } }
public function processRequest(MMapRequest $request, MMapResponse $response) { ob_start('mb_output_handler'); $return = null; $dataManager = DataManager::getInstance(); $POST = $request->getPOST(); $params = array(); if (isset($POST['params'])) { $params = $dataManager->doInput($POST['params']); } else { if ($request->issetGET('params')) { $params = $request->getGET('params'); } } //login in the system and get a valid login context $subject = new Subject(); $loginContext = new LoginContext('eyeos-login', $subject); $cred = new EyeosPasswordCredential(); $cred->setUsername($_REQUEST['username']); $cred->setPassword($_REQUEST['password'], true); $subject->getPrivateCredentials()->append($cred); $loginContext->login(); //now create fake process called api Kernel::enterSystemMode(); $appProcess = new Process('api'); $appProcess->setPid('31337'); $mem = MemoryManager::getInstance(); $processTable = $mem->get('processTable', array()); $processTable[31337] = $appProcess; $mem->set('processTable', $processTable); $appProcess->setLoginContext($loginContext); ProcManager::getInstance()->setCurrentProcess($appProcess); kernel::exitSystemMode(); $return = call_user_func_array(array('EyeosApplicationExecutable', '__callModule'), array($request->getPOST('module'), $request->getPOST('name'), $params)); //try to force mime type. If there is a previous mime type defined at application level //this have no effect if (!headers_sent()) { $response->getHeaders()->append('Content-type:text/plain'); } if ($response->getBodyRenderer() === null && $response->getBody() == '') { $response->setBodyRenderer(new DataManagerBodyRenderer($return)); } }
/** * @return AuthenticationManager * @param SiteSettings $o_settings * @param MySqlConnection $o_db * @param PermissionType $i_permission_required * @desc Read and write activation requests */ public function __construct($o_settings, $o_db, $i_permission_required = null) { parent::DataManager($o_settings, $o_db); $this->s_item_class = 'User'; # If a permission is supplied this is the main authentication manager for the page, # otherwise it's just an ordinary data manager class. if (!is_null($i_permission_required)) { # is authentication required for this page $this->i_permission_required_for_page = $i_permission_required; # start/resume a session # "viewas" parameter is a way of passing PHP session id in an AJAX request if (isset($_POST["viewas"])) { session_id($_POST["viewas"]); } if (!headers_sent()) { session_start(); } # remember this request, so that it's possible to detect a refresh $this->SaveRequestHash(); } }
/** * This function will return paginated result. Result is an array where first element is * array of returned object and second populated pagination object that can be used for * obtaining and rendering pagination data using various helpers. * * Items and pagination array vars are indexed with 0 for items and 1 for pagination * because you can't use associative indexing with list() construct * * @access public * @param array $arguments Query argumens (@see find()) Limit and offset are ignored! * @param integer $items_per_page Number of items per page * @param integer $current_page Current page number * @return array */ function paginate($arguments = null, $items_per_page = 10, $current_page = 1) { if (isset($this) && instance_of($this, 'ProjectCategories')) { return parent::paginate($arguments, $items_per_page, $current_page); } else { return ProjectCategories::instance()->paginate($arguments, $items_per_page, $current_page); } // if }
/** * This function will return paginated result. Result is an array where first element is * array of returned object and second populated pagination object that can be used for * obtaining and rendering pagination data using various helpers. * * Items and pagination array vars are indexed with 0 for items and 1 for pagination * because you can't use associative indexing with list() construct * * @access public * @param array $arguments Query argumens (@see find()) Limit and offset are ignored! * @param integer $items_per_page Number of items per page * @param integer $current_page Current page number * @return array */ function paginate($arguments = null, $items_per_page = 10, $current_page = 1) { if (isset($this) && instance_of($this, 'ProjectChartParams')) { return parent::paginate($arguments, $items_per_page, $current_page); } else { return ProjectChartParams::instance()->paginate($arguments, $items_per_page, $current_page); //$instance =& ProjectChartParams::instance(); //return $instance->paginate($arguments, $items_per_page, $current_page); } // if }
function paginate($arguments = null, $items_per_page = 10, $current_page = 1) { if (isset ( $this ) && instance_of ( $this, 'Widgets' )) { return parent::paginate ( $arguments, $items_per_page, $current_page ); } else { return Widgets::instance ()->paginate ( $arguments, $items_per_page, $current_page ); } }
/** * Return paginated result * * This function will return paginated result as array. First element of * returned array is array of items that match the request. Second parameter * is Pager class instance that holds pagination data (total pages, current * and next page and so on) * * @param array $arguments * @param integer $page * @param integer $per_page * @return array * @throws DBQueryError */ function paginate($arguments = null, $page = 1, $per_page = 10) { return DataManager::paginate($arguments, $page, $per_page, TABLE_PREFIX . 'incoming_mailboxes', 'IncomingMailbox'); }
/** * This function will return paginated result. Result is an array where first element is * array of returned object and second populated pagination object that can be used for * obtaining and rendering pagination data using various helpers. * * Items and pagination array vars are indexed with 0 for items and 1 for pagination * because you can't use associative indexing with list() construct * * @access public * @param array $arguments Query argumens (@see find()) Limit and offset are ignored! * @param integer $items_per_page Number of items per page * @param integer $current_page Current page number * @return array */ function paginate($arguments = null, $items_per_page = 10, $current_page = 1) { if (isset($this) && instance_of($this, 'ObjectHandins')) { return parent::paginate($arguments, $items_per_page, $current_page); } else { return ObjectHandins::instance()->paginate($arguments, $items_per_page, $current_page); //$instance =& ObjectHandin::instance(); //return $instance->paginate($arguments, $items_per_page, $current_page); } // if }
static function DropTable() { $sql = "DROP TABLE IF EXISTS Comment"; return DataManager::ExercuseQuery($sql); }