public function save() { $method = dhtml($_GET['method']); if (empty($method)) { $this->error('', __URL__); } $DB = new ProjectModel('project'); if (!$DB->create()) { $this->error($DB->getError(), __URL__); } else { $module = "img"; $path = date("Ymd"); $DB->date = time(); switch ($method) { case "add": $pic = $this->_upload($module, $path); $img = $pic[0]['savepath'] . $pic[0]['savename']; $DB->pic = $img; $query = $DB->add(); $this->_jump($query, ""); break; case "edit": if (!empty($_FILES['pic']['name'])) { $pic = $this->_upload($module, $path); $img = $pic[0]['savepath'] . $pic[0]['savename']; $DB->pic = $img; } $query = $DB->save(); $this->_jump($query, "", "edit"); break; } } }
/** * @param ProjectModel $projectModel * @param string $id */ public function __construct($projectModel, $id = '') { $this->id = new Id(); $this->content = ''; $this->regarding = new SemDomTransFieldReference(); $this->entryRef = new Id(); $databaseName = $projectModel->databaseName(); parent::__construct(self::mapper($databaseName), $id); }
/** * * @param ProjectModel $projectModel * @param int $newerThanTimestamp */ public function __construct($projectModel, $newerThanTimestamp = null) { if (!is_null($newerThanTimestamp)) { $startDate = new \MongoDate($newerThanTimestamp); parent::__construct(self::mapper($projectModel->databaseName()), array('dateModified' => array('$gte' => $startDate)), array()); } else { parent::__construct(self::mapper($projectModel->databaseName()), array('name' => array('$regex' => ''))); } }
function wp_egrid_ajax_order_project_callback() { $_REQUEST = stripslashes_deep($_REQUEST); //skip safe slash of Wordpress $ordered = json_decode($_REQUEST['ordered']); // print_r($ordered); //update record in database require 'model/project_model.php'; $projectModel = new ProjectModel(); $projectModel->save_project_ordered($ordered); die; }
function show() { $pid = intval($_GET[pid]); $project = new ProjectModel(); $pro = $project->getby_pid($pid); if ($pro[uid] != $_SESSION['uid']) { cpmsg("无权限", 'error', "?m=xing"); exit; } $xing = new XingModel(); $browsers = $xing->get_browsers($pid); include view_file(); }
public function create() { $e = new MongoTestEnvironment(); $e->clean(); $this->website = $e->website; $this->project = $e->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE); $this->project->appName = 'sfchecks'; $this->project->write(); $this->question = new QuestionModel($this->project); $this->question->write(); $this->userId = $e->createUser('test_user', 'Test User', '*****@*****.**'); $this->projectId = $this->project->id->asString(); $this->questionId = $this->question->id->asString(); }
public function view() { $projectDB = new ProjectModelDB(); //普通条件,检查GET参数 $fieldArr = $projectDB->getFields(); $where = array("`group_id` = ?"); $whereArr = array($_SESSION['group']); foreach ($fieldArr as $v) { if ($_GET[$v] !== null) { $where[] = "`{$v}` = ?"; $whereArr[] = $_GET[$v]; } } $whereStr = count($where) > 0 ? implode(" AND ", $where) : '1=1'; if ($_GET['_search_field'] != '' && in_array($_GET['_search_field'], $fieldArr) && $_GET['_search_keyword'] != '') { $whereStr = $whereStr == '1=1' ? $_GET['_search_field'] . " LIKE ?" : $whereStr . " AND " . $_GET['_search_field'] . " LIKE ?"; $whereArr[] = "%" . $_GET['_search_keyword'] . "%"; } //排序条件 $orderStr = '`id` DESC'; if (!empty($_POST['order'])) { foreach ($_POST['order'] as $k => $v) { $orderArr[] = "`{$k}` {$v}"; } $orderStr = implode(',', $orderArr); } //查询操作 $sql = "SELECT * FROM `" . $projectDB->getTableName() . "` WHERE {$whereStr} ORDER BY {$orderStr}"; $data = $projectDB->getData($sql, $whereArr, 80); $pageStr = $projectDB->getPageStr(); $pageJump = $projectDB->getPageJump(); //读取外键数据 $project = new ProjectModel(); $monitorFkArr = $project->getMonitor(); $this->setView('monitorFkArr', $monitorFkArr); $onoffArrDictFkArr = DictConfig::$onoffArr; $this->setView('onoffArrDictFkArr', $onoffArrDictFkArr); //模版显示 $this->setView('commonConfig', $this->commonConfig); $this->setView('svnUrl', $this->svnUrl); $this->setView('pageStr', $pageStr); $this->setView('pageStr', $pageStr); $this->setView('pageJump', $pageJump); $this->setView('data', $data); $this->display('Project.html'); }
/** * @param ProjectModel $projectModel * @param string $id */ public function __construct($projectModel, $id = '') { $this->setReadOnlyProp('authorInfo'); $this->setReadOnlyProp('replies'); $this->setReadOnlyProp('score'); $this->setReadOnlyProp('status'); $this->setPrivateProp('isDeleted'); $this->id = new Id(); $this->entryRef = new IdReference(); $this->isDeleted = false; $this->replies = new ArrayOf(function ($data) { return new LexCommentReply(); }); $this->status = self::STATUS_OPEN; $this->score = 0; $this->authorInfo = new AuthorInfo(); $this->regarding = new LexCommentFieldReference(); $databaseName = $projectModel->databaseName(); parent::__construct(self::mapper($databaseName), $id); }
public function projectAction() { $image_model = new ImageModel(); $project_model = new ProjectModel(); $contribution_model = new ContributionModel(); $active_projects = $project_model->getActive(); //Build thumbs array from active projects $thumbs = array(); foreach ($active_projects as $project) { $thumbs[] = $image_model->getPrimary($project['id']); } $this->view->thumbs = $thumbs; $project_id = $this->_request->getParam('id'); $view_id = $this->_request->getParam('view'); if ($this->is_ajax) { $project_id = $_POST['id']; } if (!$project_id) { $thumbs = reset($thumbs); $project_id = $thumbs['project_id']; } $this->project = $project_model->getOne($project_id); $this->project['description'] = stripslashes($this->project['description']); $this->project['contributions'] = $contribution_model->getOne($project_id); $this->project['images'] = $image_model->getAll($project_id); //If the view is set, loop through the images and find the file_name that matches if (isset($view_id)) { foreach ($this->project['images'] as $image) { if ($image['id'] == $view_id) { $this->project['view'] = $image['file_name']; } } } else { //Else just assume the first file_name $this->project['view'] = $this->project['images']['image1']['file_name']; } if ($this->is_ajax) { $this->_helper->json($this->project); } $this->view->project = $this->project; }
public function get_json_grid_by_id($id) { $json_result = array(); //get egrid data $gridInfo = $this->get_data_by_id($id); $json_result['filterEffect'] = $gridInfo['filter_effect']; $json_result['hoverDirection'] = (bool) $gridInfo['hover_direction']; $json_result['hoverDelay'] = $gridInfo['hover_delay']; $json_result['hoverInverse'] = (bool) $gridInfo['hover_inverse']; $json_result['expandingSpeed'] = $gridInfo['expanding_speed']; $json_result['expandingHeight'] = $gridInfo['expanding_height']; //get project info $projectModel = new ProjectModel(); $projects = $projectModel->get_projects_by_egrid_id($id); //url to image $uploadFolder = wp_upload_dir(); $uploadFolder = $uploadFolder['baseurl'] . '/wp_elastic_grid/'; $json_result['items'] = array(); foreach ($projects as $project) { $item = array(); $item['title'] = $project['title']; $item['description'] = $project['description']; $tags = explode(',', $project['tags']); $tags = array_map('trim', $tags); $tags = array_map('ucfirst', $tags); $item['tags'] = !empty($tags) ? $tags : array(); $item['button_list'] = !empty($project['button_list']) ? json_decode($project['button_list']) : array(); $images = $projectModel->get_images_by_project_id($project['id']); $thumbnails = array(); $large = array(); foreach ($images as $image) { $thumbnails[] = $uploadFolder . 'small/' . $image['filename']; $large[] = $uploadFolder . 'large/' . $image['filename']; } $item['thumbnail'] = $thumbnails; $item['large'] = $large; $json_result['items'][] = $item; } return json_encode($json_result); }
function index() { $uid = $_GET['u']; $i = $_GET['i']; if ($uid) { $project = new ProjectModel(); $pid = $project->url_to_pid($uid); if ($pid) { load_lib('Browser'); $ip = get_client_ip(); $type = htmlentities(Browser::get_client_browser()); $os = htmlentities(Browser::get_clinet_os()); $browser = new BrowserModel($ip, $type, $os, $pid); if ($browser->bid) { } else { // 注册 $browser->reg(); //发送邮件 } if (!$browser->bid) { exit; } // 退出处理 //上线部分完毕 include view_file(); } else { header("Location:?m=xing"); } } else { if ($i) { //邀请码注册 header("Location:?m=user&a=reg&i=" . $i); } else { header("Location:?m=xing"); } } }
protected function do_put() { parent::do_put(); // TODO: Change the autogenerated stub parse_str(file_get_contents("php://input"), $_PUT); if (empty($_PUT["title"])) { $this->exit_error(400, "titleMandatoryAndNotEmpty"); } else { $title = $_PUT["title"]; $date = '02/07/2016 12:00:00'; // to set deadline - maybe change this but it works -_- $date = preg_replace('#(\\d{2})/(\\d{2})/(\\d{4})\\s(.*)#', '$3-$2-$1 $4', $date); ProjectModel::updateProject($title, "test1", $date, 2); echo $title; } }
if (in_array($fileParts['extension'], $fileTypes)) { if (!file_exists($uploadDir)) { mkdir($uploadDir, 0777, true); mkdir($uploadDir . 'small' . DIRECTORY_SEPARATOR, 0777, true); mkdir($uploadDir . 'large' . DIRECTORY_SEPARATOR, 0777, true); } $newName = file_exists($uploadDir . $_FILES['Filedata']['name']) ? $verifyToken . '_' . $_FILES['Filedata']['name'] : $_FILES['Filedata']['name']; move_uploaded_file($tempFile, $uploadDir . $newName); /*** * Create thumbnail image ***/ // *** 1) Initialise / load image $resizeObj = new resize($uploadDir . $newName); // *** 2) Resize image (options: exact, portrait, landscape, auto, crop) $resizeObj->resizeImage($thumb_width, $thumb_height, $thumb_type); // *** 3) Save small image $resizeObj->saveImage($uploadDir . 'small' . DIRECTORY_SEPARATOR . $newName, 100); // *** 4) Resize image (options: exact, portrait, landscape, auto, crop) $resizeObj = new resize($uploadDir . $newName); $resizeObj->resizeImage($resize_width, $resize_height, $resize_type); // *** 3) Save large image $resizeObj->saveImage($uploadDir . 'large' . DIRECTORY_SEPARATOR . $newName, 100); $_photoData['project_photos'][] = $newName; //insert new photo $projectModel = new ProjectModel(); $projectModel->insert_project_images($_photoData['project_photos']); echo '1'; } else { echo 'Invalid file type.'; } }
<?php include_once "../model/ProjectModel.php"; include_once "../model/WebFunctions.php"; require_once "../model/AuthenticateSession.php"; $classes = ""; if (isset($_POST["title"])) { $ok = ProjectModel::CreateProject($_POST['title'], $_POST['subject'], $_POST['deadline'], $_SESSION['trainer_id'], $_POST['class_id']); if ($ok) { header("Location: home-trainer"); } else { $error = "<div id=\"msgUpdate\" class=\"alert alert-warning \" role=\"alert\">Please fill all fields</div>"; } } else { // Get classes corresponding to the trainer $listOfClasses = ProjectModel::getAllClasses($_SESSION['trainer_id']); foreach ($listOfClasses as $class) { $classes .= "<option value=\"" . $class['class_id'] . "\">" . $class['name'] . "</option>"; } } // add view include_once "../view/create-project.php";
<?php include_once "../model/TeamModel.php"; include_once "../model/WebFunctions.php"; include_once "../model/ProjectModel.php"; require_once "../model/AuthenticateSession.php"; $teamId = $_GET['team_id']; $team = TeamModel::getTeamById($teamId); $projectID = $team['project_id']; $classID = ProjectModel::getProjectClassById($projectID); $listOfAvailableStudents = ProjectModel::getFreeStudents($classID); $listOfTeamMembers = TeamModel::getTeamStudents($teamId); $table1 = ""; // table 1 - available students $table2 = ""; // table 2 - students already in team $summary = $team['summary']; $creatorId = $team['creator_id']; if (count($listOfAvailableStudents) > 0) { for ($int = 0; $int < count($listOfAvailableStudents); $int++) { $table1 .= "<li id='" . $listOfAvailableStudents[$int]['student_id'] . "'class=\"list-group-item ui-state-default hand-cursor\">" . $listOfAvailableStudents[$int]['name'] . "</li>"; // table 1 - available students } } if (count($listOfTeamMembers) > 0) { for ($int = 0; $int < count($listOfTeamMembers); $int++) { // table 2 - current students in team if ($listOfTeamMembers[$int]['student_id'] == $creatorId) { $table2 .= "<li id='" . $listOfTeamMembers[$int]['student_id'] . "' class=\"list-group-item ui-state-default ui-state-disabled\">" . $listOfTeamMembers[$int]['name'] . "<span class=\"badge\">Owner</span>" . "</li>"; } else { $table2 .= "<li id='" . $listOfTeamMembers[$int]['student_id'] . "' class=\"list-group-item ui-state-default hand-cursor\">" . $listOfTeamMembers[$int]['name'] . "</li>";
<?php include_once "../model/ProjectModel.php"; include_once "../model/WebFunctions.php"; require_once "../model/AuthenticateSession.php"; if (isset($_POST["project_id"])) { $ok = ProjectModel::updateProject($_POST["title"], $_POST["subject"], $_POST["deadline"], $_POST["project_id"]); $id = $_POST['project_id']; header("Location: ../project-id-" . $_POST["project_id"]); } else { $id = $_GET['project_id']; } $project = ProjectModel::getProjectById($id); // add view include_once "../view/project-edit.php";
<?php /** * Created by PhpStorm. * User: nillernoels * Date: 03/01/16 * Time: 22:17 */ require_once "../model/StudentModel.php"; require_once "../model/TeamModel.php"; require_once "../model/ProjectModel.php"; session_start(); $studentId = $_SESSION['student_id']; if (isset($_POST['project_id'])) { $summary = ""; if (isset($_POST['summary'])) { $summary .= $_POST['summary']; } if (TeamModel::createTeam($summary, $studentId, $_POST['project_id'])) { header("location: home-student"); } $msg = "<div></div>"; } else { $classId = StudentModel::getStudentClassById($studentId); $listOfAvailableProjects = ProjectModel::getAllProjectsInClassById($classId); $projects = ""; foreach ($listOfAvailableProjects as $project) { $projects .= "<option value=\"" . $project['Project_id'] . "\">" . $project['Title'] . "</option>"; } include_once "../view/create-team.php"; }
public function updateAction() { if (!isset($this->admin_session->user)) { header("Location: /"); } $project_model = new ProjectModel(); $contributions_model = new ContributionModel(); $project_id = array($this->_request->getParam('id')); $update = array($_POST['title'], $_POST['description'], $_POST['url'], $_POST['status']); $contributions = explode(", ", $_POST['contributions']); $contributions_model->deleteAll($project_id[0]); if ($project_id && !empty($contributions)) { foreach ($contributions as $contribution) { $contributions_model->addOne($project_id, array($contribution)); } } $success = $project_model->updateOne($project_id, $update); header("Location: /admin/projects"); }
<?php error_reporting(E_ALL); ini_set('display_errors', 1); // include required models require_once "../model/ProjectModel.php"; require_once "../model/ClassModel.php"; require_once "../model/TrainerModel.php"; require_once "../model/StudentModel.php"; require_once "../model/TeamModel.php"; //$var = ClassModel::CreateClass("EPITA MASTERS"); // create new class test $var = TrainerModel::CreateTrainer("Michel Plasse", 1); // test create new trainer //$var = TrainerModel::getLastTrainerID(); // Test latest row insert of trainer //echo $var; $date = '02/07/2016 12:00:00'; // to set deadline - maybe change this but it works -_- $date = preg_replace('#(\\d{2})/(\\d{2})/(\\d{4})\\s(.*)#', '$3-$2-$1 $4', $date); $var = ProjectModel::updateProject("Mor Projektet", "SubjectTest4", $date, 2); //$var = StudentModel::createStudent("newStuden11t", 1); // test create student //$var = TeamModel::createTeam("this is a summary", 1, 2); // test create Team //$var = TeamModel::addStudentToTeam(4,5); // why do we have a Team_id within the Student table?! //$var = TeamModel::removeStudentFromTeam(3,5); //$listOfProjects = ProjectModel::getAllProjects(1);
<?php include_once "../model/ProjectModel.php"; include_once "../model/WebFunctions.php"; require_once "../model/AuthenticateSession.php"; $id = $_GET['project_id']; $project = ProjectModel::getProjectById($id); $listOfTeams = ProjectModel::getProjectTeams($id); $listOfFreeStudents = ProjectModel::getFreeStudents($project['class_id']); $content = ""; foreach ($listOfTeams as $team) { $content .= "<a href=\"team-id-" . $team['team_id'] . "\"> Team " . $team['team_id'] . " <br> </a>"; } $content_students = ""; foreach ($listOfFreeStudents as $student) { $content_students .= "<a href=\"student-id-" . $student['student_id'] . "\">" . $student['name'] . " <br> </a>"; } if (!isset($_SESSION)) { session_start(); } // Check right of the user for editing the project if (array_key_exists('trainer_id', $_SESSION) and $project['trainer_id'] == $_SESSION['trainer_id']) { $edit_button = "<a href=\"project-edit-{$id}\"> \r\n\t\t<button type=\"button\" class=\"btn btn-default\">\tEdit project </button> </a>"; } else { $edit_button = "<button type=\"button\" class=\"btn btn-default\" disabled>\tEdit project </button>"; } // add view include_once "../view/project-detail.php";
<?php include_once "../model/TrainerModel.php"; include_once "../model/ProjectModel.php"; include_once "../model/TeamModel.php"; include_once "../model/WebFunctions.php"; require_once "../model/AuthenticateSession.php"; // TODO repair pagination $projectPerPage = 4; $content = ""; $trainer_id = $_GET['trainer_id']; $trainer_name = TrainerModel::getTrainer($trainer_id); $totalNumberOfProjects = count(ProjectModel::getTrainerProjects($trainer_id)); $totalNumberOfPages = ceil($totalNumberOfProjects / $projectPerPage); $currentPage = isset($_GET['current_page']) ? (int) $_GET['current_page'] : 1; $startPage = ($currentPage - 1) * $projectPerPage; // set content $listOfProjects = ProjectModel::getTrainerProjectsLimit($trainer_id, $startPage, $projectPerPage); $content = ""; if (count($listOfProjects) == 0) { $content .= " <div class=\"row text-center\">\r\n <div class=\"col-lg-12\">\r\n <p>No projects created</p>\r\n </div>\r\n </div>"; } else { foreach ($listOfProjects as $proj) { $content .= "<div class=\"col-md-3 portfolio-item\">\r\n <a href=\"project-id-" . $proj['project_id'] . "\">\r\n <img class=\"img-responsive\" src=\"images/project.png\" alt=\"\">\r\n </a>\r\n <p style='text-align: center'>\"" . $proj['title'] . "</p>\r\n </div>"; } } $pagination = WebFunctions::pagination($currentPage, $totalNumberOfPages); include_once "../view/profile-trainer.php";
// add view include_once "../view/home-student.php"; } else { if ($isTrainer == "true") { $trainerID = $_SESSION['trainer_id']; // get id $trainerName = $_SESSION['name']; // get name $totalNumberOfProjects = count(ProjectModel::getAllProjects($trainerID)); // get total amount $totalNumberOfPages = ceil($totalNumberOfProjects / $projectPerPage); // calc number of pages $currentPage = isset($_GET['current_page']) ? (int) $_GET['current_page'] : 1; // if currentPage var isset else default 1 $startPage = ($currentPage - 1) * $projectPerPage; // calc start page ex. 1 = 0 - 4 projects // set content: $listOfTeams = ProjectModel::getCurrentProjects($trainerID, $startPage, $projectPerPage); // get projects $content = ""; for ($int = 0; $int < count($listOfTeams); $int++) { $name = $listOfTeams[$int]['Title']; $project_id = $listOfTeams[$int]['project_id']; $content .= "<div class=\"col-md-3 portfolio-item\">\n <a href=\"project-id-{$project_id}\">\n <img class=\"img-responsive\" src=\"images/project.png\" alt=\"\">\n </a>\n <p style='text-align: center'> {$name} </p>\n </div>"; } $pagination = WebFunctions::pagination($currentPage, $totalNumberOfPages); // add pagination // add view include_once "../view/home-trainer.php"; } }
public function step1() { // Authentication check $this->_checkSession(); if (!isset($_POST['projectFormSubmit'])) { header('Location: /project/newproject'); } // check CSRF token $this->_checkCsrf($_POST['token']); $errors = array(); $check = true; $inputDesc = isset($_POST['inputDesc']) ? trim($_POST['inputDesc']) : NULL; $inputName = isset($_POST['inputName']) ? trim($_POST['inputName']) : NULL; $inputVersion = isset($_POST['inputVersion']) ? trim($_POST['inputVersion']) : NULL; if (empty($inputName)) { $check = false; array_push($errors, "Project name is required!"); } if (empty($inputVersion)) { $check = false; array_push($errors, "Version is required!"); } if (!$check) { $this->_setView('newproject'); $this->_view->set('title', 'Security Knowledge Framework:: Invalid form data!'); $this->_view->set('menuActiveProject', "class='active'"); $this->_view->set('menuActiveProjectNew', "class='active'"); $this->_view->set('errors', $errors); $this->_view->set('formData', $_POST); return $this->_view->output(); } try { $project = new ProjectModel(); $project->setProjectDescription($inputDesc); $project->setProjectName($inputName); $project->setProjectVersion($inputVersion); $project->storeProject(); $this->_setView('success'); $this->_view->set('title', 'Security Knowledge Framework:: Project is stored!'); $this->_view->set('menuActiveProject', "class='active'"); $this->_view->set('menuActiveProjectNew', "class='active'"); } catch (Exception $e) { $this->_setView('newproject'); $this->_view->set('title', 'Security Knowledge Framework:: There was an error saving the data!'); $this->_view->set('menuActiveProject', "class='active'"); $this->_view->set('menuActiveProjectNew', "class='active'"); $this->_view->set('formData', $_POST); $this->_view->set('saveError', $e->getMessage()); } return $this->_view->output(); }