public function display()
 {
     $GLOBALS['db']->queries = eF_multisort($GLOBALS['db']->queries, 'times', 'asc');
     foreach ($GLOBALS['db']->queries as $key => $value) {
         $GLOBALS['db']->queries[$key]['sql'] = htmlentities($value['sql']);
         if ($value['times'] > 0.05) {
             $heavyQueries[] = $value;
         }
     }
     $str = "\r\n\t\t<div onclick = 'this.style.display=\"none\"' style = 'position:absolute;top:0px;right:0px;background-color:lightblue;border:1px solid black' >\r\n\t    <table>\r\n\t        <tr><th colspan = '100%'>Benchmarking info (click to remove)</th></tr>\r\n\t        <tr><td>Initialization time: </td><td>" . round($this->times['init'] - $this->times['start'], 5) . " sec</td></tr>\r\n\t        <tr><td>Script time: </td><td>" . round($this->times['script'] - $this->times['init'], 5) . " sec</td></tr>\r\n\t        <tr><td>Database time (" . $this->dbtimes['queries'] . " q): </td><td>" . ($this->dbtimes['time'] > 100 ? 0 : round($this->dbtimes['time'], 5)) . " sec (<a href = 'javascript:void(0)' onclick = 'eF_js_showDivPopup(event, \"Queries\", 2, \"queries_table\");return false;'>show queries</a>)</td></tr>\r\n\t        <tr><td>Smarty time: </td><td>" . round($this->times['smarty'] - $this->times['script'], 5) . " sec</td></tr>\r\n\t        <tr><td colspan = \"2\" class = \"horizontalSeparator\"></td></tr>\r\n\t        <tr><td>Total execution time: </td><td>" . round($this->times['end'] - $this->times['start'], 5) . " sec</td></tr>\r\n\t        <tr><td>Peak memory usage: </td><td>" . round(memory_get_peak_usage(true) / 1024) . " KB</td></tr>";
     if (sizeof($this->defaultValues) != sizeof($this->times)) {
         $current = 'start';
         foreach ($this->times as $key => $value) {
             if (!in_array($key, $this->defaultValues)) {
                 $str .= "<tr><td>Time from " . $current . " to " . $key . ": </td><td>" . round($this->times[$key] - $this->times[$current], 5) . " sec</td></tr>";
                 $current = $key;
             }
         }
         $str .= "<tr><td>Time from " . $current . " to end: </td><td>" . round($this->times['end'] - $this->times[$current], 5) . " sec</td></tr>";
     }
     $str .= "\r\n\t\t\t</table>\r\n\t\t\t<div style = 'display:none;' id = 'queries_table'>\r\n\t\t\t<table style = 'background-color:white;width:1000px' >";
     if (isset($heavyQueries)) {
         $str .= "\r\n\t\t\t\t<tr><td>&nbsp;</td></tr>\r\n\t\t\t\t<tr><td class = 'topTitle'>Heavy queries</td></tr>\r\n\t\t\t\t<tr><td><re>" . str_replace(array("\n", " ", "\t"), array("<br>", "&nbsp;", "&nbsp;&nbsp;&nbsp;&nbsp;"), print_r($heavyQueries, true)) . "</pre></td></tr>";
     }
     $str .= "\r\n\t\t\t\t<tr><td>&nbsp;</td></tr>\r\n\t\t\t\t<tr><td class = 'topTitle'>All queries</td></tr>\r\n\t\t\t\t<tr><td><re>" . str_replace(array("\n", "     ", "\t"), array("<br>", "&nbsp;", "&nbsp;&nbsp;&nbsp;&nbsp;"), print_r($GLOBALS['db']->queries, true)) . "</pre></td></tr>\r\n\t\t\t</table>\r\n\t\t\t</div>\r\n\t\t    </div>";
     $fields = array("url" => htmlentities($_SERVER['REQUEST_URI']), "init_time" => round($this->times['init'] - $this->times['start'], 5), "script_time" => round($this->times['script'] - $this->times['init'], 5), "database_time" => $this->dbtimes['time'] > 100 ? 0 : round($this->dbtimes['time'], 5), "smarty_time" => round($this->times['smarty'] - $this->times['script'], 5), "total_time" => round($this->times['end'] - $this->times['start'], 5), "memory_usage" => round(memory_get_peak_usage(true) / 1024), "total_queries" => $this->dbtimes['queries'], "max_query" => serialize(array_slice($GLOBALS['db']->queries, 0, 1)), "timestamp" => time());
     /*
     		try {
     			eF_insertTableData("benchmark", $fields);
     			eF_deleteTableData("benchmark", "timestamp < ".(time() - 3600*24*7));	//Keep a week's data only
     		} catch (Exception $e) {}
     */
     return $str;
 }
Exemple #2
0
 private function getRssSource($source, $mode, $lesson)
 {
     $feeds = $this->getProvidedFeeds();
     foreach ($feeds as $value) {
         if ($value['active'] && $value['mode'] == 'system') {
             $systemFeeds[$value['type']] = $value;
         } else {
             if ($value['active'] && $value['mode'] == 'lesson') {
                 $lessonFeeds[$value['type']] = $value;
             }
         }
     }
     if ($mode == 'system' && !in_array($source, array_keys($systemFeeds))) {
         return array();
     } elseif ($mode == 'lesson' && !in_array($source, array_keys($lessonFeeds))) {
         return array();
     }
     $data = array();
     switch ($source) {
         case 'announcements':
             if ($mode == 'system') {
                 $news = news::getNews(0, true);
             } elseif ($mode == 'lesson') {
                 if ($lesson) {
                     $news = news::getNews($lesson, true);
                 } else {
                     $lessons = eF_getTableDataFlat("lessons", "id, name");
                     $lessonNames = array_combine($lessons['id'], $lessons['name']);
                     $news = news::getNews($lessons['id'], true);
                 }
             }
             $count = 1;
             foreach ($news as $value) {
                 if ($mode == 'lesson' && !$lesson) {
                     $value['title'] = $lessonNames[$value['lessons_ID']] . ': ' . $value['title'];
                     $link = G_SERVERNAME . 'userpage.php?lessons_ID=' . $value['lessons_ID'] . '&amp;ctg=news&amp;view=' . $value['id'];
                 } else {
                     $link = G_SERVERNAME . 'userpage.php?ctg=news&amp;view=' . $value['id'];
                 }
                 $data[] = array('title' => $value['title'], 'link' => $link, 'description' => $value['data']);
                 /*
                     				if ($count++ == $this -> feedLimit) {
                     					break;
                     				}
                 */
             }
             break;
         case 'catalog':
             $constraints = array("return_objects" => false, 'archive' => false, 'active' => true);
             $result = EfrontCourse::getAllCourses($constraints);
             $directionsTree = new EfrontDirectionsTree();
             $directionPaths = $directionsTree->toPathString();
             foreach ($result as $value) {
                 $pathString = $directionPaths[$value['directions_ID']] . '&nbsp;&rarr;&nbsp;' . $value['name'];
                 $data[] = array('title' => $pathString, 'link' => G_SERVERNAME . 'index.php?ctg=lesson_info&amp;courses_ID=' . $value['id'], 'description' => implode("<br>", unserialize($value['info'])));
             }
             $result = eF_getTableData("lessons", "id,name,directions_ID, info", "archive=0 and instance_source = 0 and active=1 and course_only=0", "name");
             foreach ($result as $value) {
                 $pathString = $directionPaths[$value['directions_ID']] . '&nbsp;&rarr;&nbsp;' . $value['name'];
                 $data[] = array('title' => $pathString, 'link' => G_SERVERNAME . 'index.php?ctg=lesson_info&amp;lessons_ID=' . $value['id'], 'description' => implode("<br>", unserialize($value['info'])));
             }
             $data = array_values(eF_multisort($data, 'title', 'asc'));
             //Sort results based on path string
             break;
         case 'calendar':
             if ($mode == 'system') {
                 $events = calendar::getGlobalCalendarEvents();
             } elseif ($mode == 'lesson') {
                 if ($lesson) {
                     $events = calendar::getLessonCalendarEvents($lesson);
                 } else {
                     $events = calendar::getCalendarEventsForAllLessons();
                 }
             }
             foreach ($events as $value) {
                 $value['name'] ? $title = formatTimestamp($value['timestamp']) . ' (' . $value['name'] . ')' : ($title = formatTimestamp($value['timestamp']));
                 $data[] = array('title' => $title, 'link' => G_SERVERNAME . 'userpage.php?ctg=calendar&amp;view_calendar=' . $value['timestamp'] . '&amp;type=0', 'description' => $value['data']);
             }
             break;
             /*
                 		case 'history':
                 			$currentUser = $this -> getCurrentUser();
             
             				$eventObjects = array();
                 			$result = eF_getTableData("events", "*", "", "timestamp DESC limit 100");
             				foreach ($result as $value) {
             					$eventObject = new EfrontEvent($value);
             					$eventObject -> createMessage();
             					pr($eventObject);
             				}
             
                 			break;
             */
         /*
             		case 'history':
             			$currentUser = $this -> getCurrentUser();
         
         				$eventObjects = array();
             			$result = eF_getTableData("events", "*", "", "timestamp DESC limit 100");
         				foreach ($result as $value) {
         					$eventObject = new EfrontEvent($value);
         					$eventObject -> createMessage();
         					pr($eventObject);
         				}
         
             			break;
         */
         case 'structure':
             if ($lesson) {
                 $contentTree = new EfrontContentTree($lesson);
                 $contentPath = $contentTree->toPathStrings();
                 foreach ($contentPath as $key => $value) {
                     $data[] = array('title' => $value, 'link' => G_SERVERNAME . 'userpage.php?lessons_ID=' . $lesson . '&amp;unit=' . $key, 'description' => $value);
                 }
             }
             break;
         case 'forum':
             if ($mode == 'system') {
                 $result = eF_getTableData("f_messages fm JOIN f_topics ft JOIN f_forums ff LEFT OUTER JOIN lessons l ON ff.lessons_ID = l.id", "ff.title as forum_name, fm.body, fm.title, fm.id, ft.id as topic_id, ft.title as topic_title, fm.users_LOGIN, fm.timestamp, l.name as lessons_name, lessons_id as show_lessons_id", "ft.f_forums_ID=ff.id AND fm.f_topics_ID=ft.id ", "fm.timestamp desc LIMIT 100");
             } elseif ($mode == 'lesson') {
                 if ($lesson) {
                     $result = eF_getTableData("f_messages fm JOIN f_topics ft JOIN f_forums ff LEFT OUTER JOIN lessons l ON ff.lessons_ID = l.id", "ff.title as forum_name, fm.body, fm.title, fm.id, ft.id as topic_id, ft.title as topic_title, fm.users_LOGIN, fm.timestamp, l.name as lessons_name, lessons_id as show_lessons_id", "ft.f_forums_ID=ff.id AND fm.f_topics_ID=ft.id AND ff.lessons_ID = '" . $lesson . "'", "fm.timestamp desc LIMIT 100");
                 } else {
                     $result = eF_getTableData("f_messages fm JOIN f_topics ft JOIN f_forums ff LEFT OUTER JOIN lessons l ON ff.lessons_ID = l.id", "ff.title as forum_name, fm.body, fm.title, fm.id, ft.id as topic_id, ft.title as topic_title, fm.users_LOGIN, fm.timestamp, l.name as lessons_name, lessons_id as show_lessons_id", "ft.f_forums_ID=ff.id AND fm.f_topics_ID=ft.id AND ff.lessons_ID != 0", "fm.timestamp desc LIMIT 100");
                 }
             }
             foreach ($result as $value) {
                 $value['title'] = $value['forum_name'] . ' >> ' . $value['topic_title'] . ' >> ' . $value['title'];
                 if ($mode == 'system' && $value['lessons_name'] || $mode == 'lesson' && !$lesson) {
                     $value['title'] = $value['lessons_name'] . ': ' . $value['title'];
                 }
                 $data[] = array('title' => $value['title'], 'link' => G_SERVERNAME . 'userpage.php?ctg=forum&amp;topic=' . $value['topic_id'], 'description' => $value['body']);
             }
             break;
         default:
             break;
     }
     return $data;
 }
Exemple #3
0
function askJobs()
{
    try {
        eF_checkParameter($_POST['preffix'], 'text') ? $preffix = $_POST['preffix'] : ($preffix = '%');
        $jobs = array();
        $job_descriptions_without_skills = eF_getTableData("module_hcd_job_description LEFT OUTER JOIN module_hcd_employee_has_job_description ON module_hcd_employee_has_job_description.job_description_ID = module_hcd_job_description.job_description_ID LEFT OUTER JOIN module_hcd_branch ON module_hcd_branch.branch_ID = module_hcd_job_description.branch_ID", "module_hcd_job_description.job_description_ID, description, module_hcd_job_description.branch_ID, module_hcd_branch.name, count(users_login) as Employees, employees_needed", "", "module_hcd_job_description.description", "module_hcd_job_description.job_description_ID");
        $job_descriptions_with_skills = eF_getTableData("module_hcd_job_description LEFT OUTER JOIN module_hcd_job_description_requires_skill ON module_hcd_job_description.job_description_ID = module_hcd_job_description_requires_skill.job_description_ID", "count(skill_ID) as skill_req", "", "module_hcd_job_description.description", "module_hcd_job_description.job_description_ID");
        $size = sizeof($job_descriptions_without_skills);
        for ($k = 0; $k < $size; $k++) {
            $job_descriptions[$k] = array_merge($job_descriptions_without_skills[$k], $job_descriptions_with_skills[$k]);
        }
        foreach ($job_descriptions as $key => $job_description) {
            $diff = $job_description["employees_needed"] - $job_description["Employees"];
            $job_descriptions[$key]['more_needed'] = $diff > 0 ? $diff : 0;
        }
        for ($i = 0; $i < sizeof($job_descriptions); $i++) {
            if ($preffix == '%' || stripos($job_descriptions[$i]['description'], $preffix) !== false) {
                $hiname = highlightSearch($job_descriptions[$i]['description'], $preffix);
                $jobs[$i] = array('id' => $job_descriptions[$i]['job_description_ID'], 'description' => $job_descriptions[$i]['description'] . ' (' . $job_descriptions[$i]['name'] . ')');
            }
        }
        $jobs = array_values(eF_multisort($jobs, 'description', 'asc'));
        $str = '<ul>';
        for ($k = 0; $k < sizeof($jobs); $k++) {
            $str = $str . '<li id="' . $jobs[$k]['id'] . '">' . $jobs[$k]['description'] . '</li>';
        }
        $str .= '</ul>';
        echo $str;
    } catch (Exception $e) {
        handleAjaxExceptions($e);
    }
}
Exemple #4
0
function askSkills()
{
    try {
        eF_checkParameter($_POST['preffix'], 'text') ? $preffix = $_POST['preffix'] : ($preffix = '%');
        $skills = array();
        $result = EfrontSkill::getAllSkills();
        for ($i = 0; $i < sizeof($result); $i++) {
            if ($preffix == '%' || stripos($result[$i]['description'], $preffix) !== false) {
                $hiname = highlightSearch($result[$i]['description'], $preffix);
                $skills[$i] = array('id' => $result[$i]['skill_ID'], 'description' => $result[$i]['description'], 'path_string' => $result[$i]['category_description'] . '&nbsp;&rarr;&nbsp;' . $hiname);
            }
        }
        $skills = array_values(eF_multisort($skills, 'path_string', 'asc'));
        //Sort results based on path string
        $str = '<ul>';
        for ($k = 0; $k < sizeof($skills); $k++) {
            $str = $str . '<li id=' . $skills[$k]['id'] . '>' . $skills[$k]['path_string'] . '</li>';
        }
        $str .= '</ul>';
        echo $str;
    } catch (Exception $e) {
        handleAjaxExceptions($e);
    }
}