/**
  * Set the User geolocation and page
  */
 function init($link = null, $id = null, $online_time = USER_ONLINE_TIME)
 {
     $file = basename($_SERVER['SCRIPT_FILENAME']);
     $url = $_SERVER['REQUEST_URI'];
     $user_localization = isset($_SESSION['user_localization']) ? $_SESSION['user_localization'] : null;
     $sid = session_id();
     $browser = BROWSER . " " . BROWSER_VERSION;
     $os = BROWSER_OS;
     $ip = IP;
     if (!$user_localization) {
         $time = TIME - HOUR;
         DB::query("DELETE FROM " . DB_PREFIX . "user_localization WHERE time < " . HOUR);
     }
     $user_localization_id = $user_localization ? $_SESSION['user_localization']['user_localization_id'] : DB::get_field("SELECT user_localization_id FROM " . DB_PREFIX . "user_localization WHERE sid='{$sid}'");
     if ($user_id = User::get_user_id()) {
         $guest_id = 0;
         $name = User::get_user_field("name");
     } else {
         $guest_id = isset($user_localization['guest_id']) ? $user_localization['guest_id'] : 1 + DB::get_field("SELECT guest_id FROM " . DB_PREFIX . "user_localization ORDER BY guest_id DESC LIMIT 1;");
         $name = get_msg('guest') . " " . $guest_id;
     }
     if ($user_localization_id) {
         DB::query("UPDATE " . DB_PREFIX . "user_localization SET ip='{$ip}', user_id='{$user_id}', name='{$name}', url='{$url}', id='{$id}', file='{$file}', time='" . TIME . "', sid='{$sid}' WHERE user_localization_id='{$user_localization_id}'");
     } else {
         if (!($location = ip_to_location($ip, $assoc = true))) {
             $location = array('CountryCode' => null, 'CountryName' => null, 'RegionCode' => null, 'RegionName' => null, 'City' => null, 'ZipPostalCode' => null, 'Latitude' => null, 'Longitude' => null, 'TimezoneName' => null, 'Gmtoffset' => null);
         }
         //replace_sql_injection( $location );
         DB::query("INSERT INTO " . DB_PREFIX . "user_localization\r\n                        (ip,sid,user_id,guest_id,name,url,id,file,os,browser,time,time_first_click,country_code,country_name,region_code,region_name,city_name,zip,latitude,longitude,timezone_name,gmt_offset)\r\n                        VALUES\r\n                        ('{$ip}','{$sid}','{$user_id}','{$guest_id}','{$name}','{$url}','{$id}','{$file}','{$os}','{$browser}', " . TIME . ", " . TIME . ", '{$location['CountryCode']}', '{$location['CountryName']}', '{$location['RegionCode']}', '{$location['RegionName']}','{$location['City']}', '{$location['ZipPostalCode']}', '{$location['Latitude']}', '{$location['Longitude']}', '{$location['TimezoneName']}', '{$location['Gmtoffset']}')");
         $user_localization_id = DB::get_last_id();
     }
     $_SESSION['user_localization'] = array('user_localization_id' => $user_localization_id, 'id' => $id, 'guest_id' => $guest_id, 'name' => $name, 'time' => TIME, 'file' => $file, 'user_id' => $user_id, 'os' => $os, 'browser' => $browser);
 }
Example #2
0
/**
 * 	Test User 
 */
function test_user($user_url)
{
    $user = new User($user_url);
    echo "--------------------------- Test User --------------------------------";
    // 获取用户ID
    $user_id = $user->get_user_id();
    var_dump($user_id);
    // 获取用户关注数
    $followees_num = $user->get_followees_num();
    var_dump($followees_num);
    // 获取用户粉丝数
    $followers_num = $user->get_followers_num();
    var_dump($followers_num);
    // 获取用户获得的赞同数
    $agree_num = $user->get_agree_num();
    var_dump($agree_num);
    // 获取用户获得感谢数
    $thanks_num = $user->get_thanks_num();
    var_dump($thanks_num);
    // 获取用户问题提问数
    $asks_num = $user->get_asks_num();
    var_dump($asks_num);
    // 获取用户问题回答数
    $answer_num = $user->get_answers_num();
    var_dump($answer_num);
    // 获取用户收藏数
    $collection_num = $user->get_collections_num();
    var_dump($collection_num);
    // 获取用户关注列表
    $followees_list = $user->get_followees();
    foreach ($followees_list as $followees) {
        var_dump($followees);
    }
    // 获取用户粉丝列表
    $followers_list = $user->get_followers();
    foreach ($followers_list as $followers) {
        var_dump($followers);
    }
    // 获取用户提问列表
    $asks_list = $user->get_asks();
    foreach ($asks_list as $asks) {
        var_dump($asks);
    }
    // 获取用户回答列表
    $answer_list = $user->get_answers();
    foreach ($answer_list as $answer) {
        var_dump($answer);
    }
    // 获取用户头像URL
    $avatar = $user->get_avatar();
    var_dump($avatar);
    // 获取用户信息
    $about = $user->get_about();
    var_dump($about);
    // 获取用户关注话题数
    $topics_num = $user->get_topics_num();
    var_dump($topics_num);
    // 获取用户关注话题列表
    $topic_list = $user->get_topics();
    foreach ($topic_list as $topic) {
        var_dump($topic);
    }
}
Example #3
0
function save_post($message_id)
{
    global $link, $db, $message, $current_user, $globals, $site_key;
    $message = new PrivateMessage();
    $to_user = User::get_valid_username($_POST['to_user']);
    if (!$to_user) {
        echo 'ERROR: ' . _('nombre de usuario erróneo');
        die;
    }
    $to = User::get_user_id($to_user);
    if (!$to > 0) {
        echo 'ERROR: ' . _('usuario erróneo');
        die;
    }
    if (!PrivateMessage::can_send($current_user->user_id, $to)) {
        echo 'ERROR: ' . _('el destinatario no lo tiene amigado');
        die;
    }
    $_POST['post'] = clean_text_with_tags($_POST['post'], 0, false, $globals['posts_len']);
    if (!empty($_FILES['image']['tmp_name'])) {
        $limit_exceded = Upload::current_user_limit_exceded($_FILES['image']['size']);
        if ($limit_exceded) {
            echo 'ERROR: ' . $limit_exceded;
            die;
        }
    }
    if (mb_strlen($_POST['post']) < 2) {
        echo 'ERROR: ' . _('texto muy corto');
        die;
    }
    if ($current_user->user_id != intval($_POST['author'])) {
        die;
    }
    // Check the post wasn't already stored
    $message->randkey = intval($_POST['key']);
    $message->author = $current_user->user_id;
    $message->to = $to;
    $message->content = $_POST['post'];
    $db->transaction();
    $dupe = intval($db->get_var("select count(*) from privates where user = {$current_user->user_id} and date > date_sub(now(), interval 5 minute) and randkey = {$message->randkey} FOR UPDATE"));
    if (!$dupe) {
        // Verify that there are a period of 1 minute between posts.
        if (intval($db->get_var("select count(*) from privates where user= {$current_user->user_id} and date > date_sub(now(), interval 15 second)")) > 0) {
            echo 'ERROR: ' . _('debe esperar 15 segundos entre mensajes');
            $db->rollback();
            die;
        }
        // Verify that there less than X messages from the same user in a day
        if (intval($db->get_var("select count(*) from privates where user= {$current_user->user_id} and date > date_sub(now(), interval 1 day)")) > 160) {
            echo 'ERROR: ' . _('demasiados mensajes en un día');
            die;
        }
        $db->commit();
        $message->store();
        notify_user($current_user->user_id, $to, $message->content);
        User::add_notification($message->to, 'private');
    } else {
        $db->commit();
        echo 'ERROR: ' . _('mensaje grabado previamente');
        die;
    }
    // Check image upload or delete
    if ($_POST['image_delete']) {
        $message->delete_image();
    } else {
        $message->store_image_from_form('image');
    }
    $message = PrivateMessage::from_db($message->id);
    // Reread the object
    $message->print_summary();
}
Example #4
0
<?php

require_once 'includes/include.php';
$loginObj = LoginInstance::GetInstance();
$loginObj->loginCheck();
$dbObj = DatabaseInstance::GetInstance();
$utilsObj = UtilsInstance::GetInstance();
$userObj = new User($_SESSION['user_id']);
if (isset($_GET)) {
    $form_class = $_GET["formClass"];
    $form_type = $_GET["formType"];
    $current_user_id = $userObj->get_user_id();
    $group_id = 0;
    $sql = "SELECT group_id FROM user_mgt_table WHERE id = '{$current_user_id}';";
    //echo $sql."<BR>";
    $dbObj->Execute($sql);
    $data = $dbObj->FetchData();
    if ($data) {
        $group_id = $data[0]["group_id"];
    }
    $verifyByWhom = array(1 => "savant", 2 => "association");
    $who = $_GET["who"];
    $whoseStatus = $verifyByWhom[$who] . "_verify_status";
    //1 for savants and 2 for association
    $verifyStatus = "a";
    if (isset($_GET["verifyStatus"])) {
        $verifyStatus = $_GET["verifyStatus"];
        //a,0,1,2,3
    }
    if ($form_class == 1) {
        //verify status = scholar status & association status
Example #5
0
 /**
  * @throws ProjectIDMissingException
  * @throws ProjectSecurityAccessDeniedException
  */
 public static function permission_add_user()
 {
     global $project_security, $user;
     if ($_GET['project_id']) {
         $project_id = $_GET['project_id'];
         $project = new Project($project_id);
         if ($user->get_user_id() == $project->get_owner_id() or $project_security->is_access(2, false) == true or $project_security->is_access(4, false) == true or $project_security->is_access(7, false) == true) {
             if ($_GET['nextpage'] == 1) {
                 if (is_numeric($_POST['user'])) {
                     $page_1_passed = true;
                 } else {
                     $page_1_passed = false;
                     $error = "You must select an user.";
                 }
             } elseif ($_GET['nextpage'] > 1) {
                 $page_1_passed = true;
             } else {
                 $page_1_passed = false;
                 $error = "";
             }
             if ($page_1_passed == false) {
                 $template = new HTMLTemplate("project/admin/permission_add_user.html");
                 $paramquery = $_GET;
                 $paramquery['nextpage'] = "1";
                 $params = http_build_query($paramquery, '', '&#38;');
                 $template->set_var("params", $params);
                 $template->set_var("error", $error);
                 $user_array = User::list_entries();
                 $result = array();
                 $counter = 0;
                 foreach ($user_array as $key => $value) {
                     $user = new User($value);
                     $result[$counter]['value'] = $value;
                     $result[$counter]['content'] = $user->get_username() . " (" . $user->get_full_name(false) . ")";
                     $counter++;
                 }
                 $template->set_var("option", $result);
                 $template->output();
             } else {
                 if ($_GET['nextpage'] == 2) {
                     if ($_POST['re'] == "1" or $_POST['sr'] == "1" or $_POST['wr'] == "1" or $_POST['sw'] == "1" or $_POST['ra'] == "1" or $_POST['de'] == "1" or $_POST['sp'] == "1") {
                         $page_2_passed = true;
                     } else {
                         $page_2_passed = false;
                         $error = "You must select min. one permission.";
                     }
                 } elseif ($_GET['nextpage'] > 2) {
                     $page_2_passed = true;
                 } else {
                     $page_2_passed = false;
                     $error = "";
                 }
                 if ($page_2_passed == false) {
                     $template = new HTMLTemplate("project/admin/permission_add_edit.html");
                     $template->set_var("add_edit", "Add");
                     $new_user = new User($_POST['user']);
                     $paramquery = $_GET;
                     $paramquery['nextpage'] = "2";
                     $params = http_build_query($paramquery, '', '&#38;');
                     $template->set_var("params", $params);
                     $template->set_var("name", $new_user->get_username());
                     $template->set_var("type", "user");
                     $template->set_var("error", $error);
                     if ($project_security->is_access(2, false) or $project->get_owner_id() == $user->get_user_id()) {
                         $template->set_var("disabled_re", "");
                     } else {
                         $template->set_var("disabled_re", "disabled");
                     }
                     if ($project_security->is_access(7, false) or $project->get_owner_id() == $user->get_user_id()) {
                         $template->set_var("disabled_sr", "");
                     } else {
                         $template->set_var("disabled_sr", "disabled");
                     }
                     if ($project_security->is_access(4, false) or $project->get_owner_id() == $user->get_user_id()) {
                         $template->set_var("disabled_wr", "");
                     } else {
                         $template->set_var("disabled_wr", "disabled");
                     }
                     if ($project_security->is_access(7, false) or $project->get_owner_id() == $user->get_user_id()) {
                         $template->set_var("disabled_sw", "");
                     } else {
                         $template->set_var("disabled_sw", "disabled");
                     }
                     if ($project_security->is_access(7, false)) {
                         $template->set_var("disabled_ra", "");
                         $template->set_var("disabled_de", "");
                         $template->set_var("disabled_sp", "");
                     } else {
                         $template->set_var("disabled_ra", "disabled");
                         $template->set_var("disabled_de", "disabled");
                         $template->set_var("disabled_sp", "disabled");
                     }
                     $template->set_var("checked_re", "");
                     $template->set_var("checked_sr", "");
                     $template->set_var("checked_wr", "");
                     $template->set_var("checked_sw", "");
                     $template->set_var("checked_ra", "");
                     $template->set_var("checked_de", "");
                     $template->set_var("checked_sp", "");
                     $template->set_var("user", $_POST['user']);
                     $template->set_var("group", "");
                     $template->set_var("ou", "");
                     $template->output();
                 } else {
                     $paramquery = $_GET;
                     unset($paramquery['nextpage']);
                     unset($paramquery['id']);
                     $paramquery['run'] = "admin_permission";
                     $params = http_build_query($paramquery);
                     $project_permission = new ProjectPermissionUser(null);
                     $new_permssion = 0;
                     if ($_POST['re'] == "1") {
                         $new_permission = $new_permission + 1;
                     }
                     if ($_POST['sr'] == "1") {
                         $new_permission = $new_permission + 2;
                     }
                     if ($_POST['wr'] == "1") {
                         $new_permission = $new_permission + 4;
                     }
                     if ($_POST['sw'] == "1") {
                         $new_permission = $new_permission + 8;
                     }
                     if ($_POST['ra'] == "1") {
                         $new_permission = $new_permission + 16;
                     }
                     if ($_POST['de'] == "1") {
                         $new_permission = $new_permission + 32;
                     }
                     if ($_POST['sp'] == "1") {
                         $new_permission = $new_permission + 64;
                     }
                     if ($project_permission->create($_POST['user'], $project_id, $new_permission, $user->get_user_id(), null)) {
                         Common_IO::step_proceed($params, "Add Permission", "Operation Successful", null);
                     } else {
                         Common_IO::step_proceed($params, "Add Permission", "Operation Failed", null);
                     }
                 }
             }
         } else {
             throw new ProjectSecurityAccessDeniedException();
         }
     } else {
         throw new ProjectIDMissingException();
     }
 }
Example #6
0
 /**
  * @see ProjectInterface::create()
  * @param integer $organisation_unit_id
  * @param integer $parent_project_id
  * @param string $name
  * @param integer $owner_id
  * @param integer $template_id
  * @param string $description
  * @return integer
  * @throws ProjectCreateException
  * @throws ProjectCreateProjectExistsException
  * @throws ProjectCreateStatusException
  * @throws ProjectCreateFolderException
  * @throws ProjectCreateStatusFolderException
  * @throws ProjectCreateStatusSubFolderException
  * @throws ProjectCreateSupplementaryFolderException
  * @throws ProjectCreateDescriptionException
  * @throws ProjectCreateMasterDataException
  * @throws ProjectCreatePermissionUserException
  * @throws ProjectCreatePermissionLeaderException
  * @throws ProjectCreatePermissionGroupException
  * @throws ProjectCreatePermissionOrganisationUnitException
  * @throws ProjectCreatePermissionQualityManagerException
  */
 public function create($organisation_unit_id, $parent_project_id, $name, $owner_id, $template_id, $description)
 {
     global $transaction;
     if ($organisation_unit_id xor $parent_project_id) {
         if ($name and $owner_id and $template_id and $description and $this->project) {
             if ($organisation_unit_id) {
                 $organisation_unit = new OrganisationUnit($organisation_unit_id);
                 if ($organisation_unit->is_permission($owner_id)) {
                     if (self::exist_project_name($organisation_unit_id, null, $name) == true) {
                         throw new ProjectCreateProjectExistsException("Project already exists in this Organisation Unit");
                     }
                 } else {
                     throw new ProjectCreateException("Cannot access on this Organisation Unit");
                 }
             } else {
                 if (self::exist_project_name(null, $parent_project_id, $name) == true) {
                     throw new ProjectCreateProjectExistsException("Project already exists in this Project");
                 }
             }
             $transaction_id = $transaction->begin();
             $user = new User($owner_id);
             $project_user = new ProjectUserData($owner_id);
             $project_quota = $project_user->get_quota();
             // Create Project
             if (($project_id = $this->project->create($organisation_unit_id, $parent_project_id, $name, $owner_id, $template_id, $project_quota)) == null) {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id, false);
                 }
                 throw new ProjectCreateException("Could not create Project in DB");
             } else {
                 self::__construct($project_id);
                 $project_template = new ProjectTemplate($template_id);
                 $project_all_status_array = $project_template->get_all_status();
                 $project_has_project_status = new ProjectHasProjectStatus_Access(null);
                 if ($project_has_project_status->create($project_id, $project_all_status_array[0]) != true) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id, false);
                     }
                     throw new ProjectCreateStatusException("Could not create status");
                 }
                 if ($organisation_unit_id) {
                     $base_folder_id = constant("PROJECT_FOLDER_ID");
                 } else {
                     $base_folder_id = ProjectFolder::get_folder_by_project_id($parent_project_id);
                 }
                 $base_folder = Folder::get_instance($base_folder_id);
                 $path = new Path($base_folder->get_path());
                 $path->add_element($project_id);
                 $project_folder = new ProjectFolder(null);
                 if (($folder_id = $project_folder->create($project_id, $base_folder_id)) == null) {
                     $project_folder->delete(true, true);
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id, false);
                     }
                     throw new ProjectCreateFolderException("Could not create main folder");
                 }
                 // Create Supplementary Folder
                 $supplementary_path = new Path($path->get_path_string());
                 $supplementary_path->add_element("supplementary");
                 $supplementary_folder = Folder::get_instance(null);
                 if ($supplementary_folder->create("supplementary", $folder_id, $supplementary_path->get_path_string(), $owner_id, null) == null) {
                     $project_folder->delete();
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id, false);
                     }
                     throw new ProjectCreateSupplementaryFolderException("Could not create supplementary folder");
                 }
                 // Status Folder
                 $folder_array = array();
                 foreach ($project_all_status_array as $key => $value) {
                     $project_status_array = $project_template->get_status_requirements($value);
                     if (is_array($project_status_array) and count($project_status_array) >= 1) {
                         foreach ($project_status_array as $status_key => $status_value) {
                             if (!in_array($value, $folder_array)) {
                                 array_push($folder_array, $value);
                             }
                         }
                     }
                 }
                 foreach ($folder_array as $key => $value) {
                     $projet_status_folder = new ProjectStatusFolder(null);
                     if (($status_folder_id = $projet_status_folder->create($project_id, $value)) == null) {
                         $project_folder->delete(true, true);
                         if ($transaction_id != null) {
                             $transaction->rollback($transaction_id, false);
                         }
                         throw new ProjectCreateStatusFolderException("Could not create status folder");
                     }
                     $project_status = new ProjectStatus($value);
                     $project_status_requirements = $project_template->get_status_requirements($value);
                     // Create Subfolder
                     $sub_folder_array = array();
                     foreach ($project_status_requirements as $sub_key => $sub_value) {
                         if (($sub_value['type'] == "file" or $sub_value['type'] == "value") and $sub_value['folder']) {
                             if (array_search(trim($sub_value['folder']), $sub_folder_array) === false) {
                                 array_push($sub_folder_array, trim($sub_value['folder']));
                             }
                         }
                     }
                     if (is_array($sub_folder_array) and count($sub_folder_array) >= 1) {
                         foreach ($sub_folder_array as $sub_key => $sub_value) {
                             $folder_name = strtolower(trim($sub_value));
                             $folder_name = str_replace(" ", "-", $folder_name);
                             $folder_path = new Path($projet_status_folder->get_path());
                             $folder_path->add_element($folder_name);
                             $sub_folder = Folder::get_instance(null);
                             if ($sub_folder->create($sub_value, $status_folder_id, $folder_path->get_path_string(), $user->get_user_id(), null) == null) {
                                 $project_folder->delete(true, true);
                                 if ($transaction_id != null) {
                                     $transaction->rollback($transaction_id, false);
                                 }
                                 throw new ProjectCreateStatusSubFolderException("Could not create status sub folder");
                             }
                         }
                     }
                 }
                 // Create Project Description
                 $value = Value::get_instance(null);
                 if ($value->create($folder_id, $owner_id, 2, $description) == null) {
                     $project_folder->delete(true, true);
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id, false);
                     }
                     throw new ProjectCreateDescriptionException("Could not create description value");
                 }
                 $project_item = new ProjectItem($project_id);
                 $project_item->set_gid(1);
                 $project_item->set_status_id(1);
                 $project_item->set_item_id($value->get_item_id());
                 if ($project_item->link_item() == false) {
                     $project_folder->delete(true, true);
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id, false);
                     }
                     throw new ProjectCreateDescriptionException("Could not create description item link");
                 }
                 if ($project_item->set_required(true) == false) {
                     $project_folder->delete(true, true);
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id, false);
                     }
                     throw new ProjectCreateDescriptionException("Could not create description item role");
                 }
                 // Create Project Master Data
                 if ($this->template_data_array and is_numeric($this->template_data_type_id)) {
                     $value = Value::get_instance(null);
                     if ($value->create($folder_id, $owner_id, $this->template_data_type_id, $this->template_data_array) == null) {
                         $project_folder->delete(true, true);
                         if ($transaction_id != null) {
                             $transaction->rollback($transaction_id, false);
                         }
                         throw new ProjectCreateMasterDataException("Could not create master-data value");
                     }
                     $project_item = new ProjectItem($project_id);
                     $project_item->set_gid(1);
                     $project_item->set_status_id(1);
                     $project_item->set_item_id($value->get_item_id());
                     if ($project_item->link_item() == false) {
                         $project_folder->delete(true, true);
                         if ($transaction_id != null) {
                             $transaction->rollback($transaction_id, false);
                         }
                         throw new ProjectCreateMasterDataException("Could not create master-data item link");
                     }
                     if ($project_item->set_required(true) == false) {
                         $project_folder->delete(true, true);
                         if ($transaction_id != null) {
                             $transaction->rollback($transaction_id, false);
                         }
                         throw new ProjectCreateMasterDataException("Could not create master-data item role");
                     }
                 }
                 // Permissions
                 if ($organisation_unit_id) {
                     $organisation_unit = new OrganisationUnit($organisation_unit_id);
                     try {
                         $project_permission = new ProjectPermissionUser(null);
                         $project_permission->create($owner_id, $project_id, (int) Registry::get_value("project_user_default_permission"), null, 1);
                     } catch (ProjectPermissionUserException $e) {
                         $project_folder->delete(true, true);
                         if ($transaction_id != null) {
                             $transaction->rollback($transaction_id, false);
                         }
                         throw new ProjectCreatePermissionUserException("Could not create user/owner permission");
                     }
                     $leader_array = $organisation_unit->list_leaders();
                     if (is_array($leader_array) and count($leader_array) >= 1) {
                         foreach ($leader_array as $key => $value) {
                             try {
                                 $project_permission = new ProjectPermissionUser(null);
                                 $project_permission->create($value, $project_id, (int) Registry::get_value("project_leader_default_permission"), null, 2);
                             } catch (ProjectPermissionUserException $e) {
                                 $project_folder->delete(true, true);
                                 if ($transaction_id != null) {
                                     $transaction->rollback($transaction_id, false);
                                 }
                                 throw new ProjectCreatePermissionLeaderException("Could not create leader permission");
                             }
                         }
                     }
                     try {
                         $project_permission = new ProjectPermissionOrganisationUnit(null);
                         $project_permission->create($organisation_unit_id, $project_id, (int) Registry::get_value("project_organisation_unit_default_permission"), null, 3);
                     } catch (ProjectPermissionOrganisationUnitException $e) {
                         $project_folder->delete(true, true);
                         if ($transaction_id != null) {
                             $transaction->rollback($transaction_id, false);
                         }
                         throw new ProjectCreatePermissionOrganisationUnitException("Could not create Organisation Unit permission");
                     }
                     $quality_manager_array = $organisation_unit->list_quality_managers();
                     if (is_array($quality_manager_array) and count($quality_manager_array) >= 1) {
                         foreach ($quality_manager_array as $key => $value) {
                             try {
                                 $project_permission = new ProjectPermissionUser(null);
                                 $project_permission->create($value, $project_id, (int) Registry::get_value("project_quality_manager_default_permission"), null, 5);
                             } catch (ProjectPermissionUserException $e) {
                                 $project_folder->delete(true, true);
                                 if ($transaction_id != null) {
                                     $transaction->rollback($transaction_id, false);
                                 }
                                 throw new ProjectCreatePermissionQualityManagerException("Could not create quality-manager permission");
                             }
                         }
                     }
                     $group_array = $organisation_unit->list_groups();
                     if (is_array($group_array) and count($group_array) >= 1) {
                         foreach ($group_array as $key => $value) {
                             try {
                                 $project_permission = new ProjectPermissionGroup(null);
                                 $project_permission->create($value, $project_id, (int) Registry::get_value("project_group_default_permission"), null, 4);
                             } catch (ProjectPermissionGroupException $e) {
                                 $project_folder->delete(true, true);
                                 if ($transaction_id != null) {
                                     $transaction->rollback($transaction_id, false);
                                 }
                                 throw new ProjectCreatePermissionGroupException("Could not create group permissions");
                             }
                         }
                     }
                 }
                 self::__construct($project_id);
                 if ($transaction_id != null) {
                     $transaction->commit($transaction_id);
                 }
                 return $project_id;
             }
         } else {
             throw new ProjectCreateException("Needed values are missing");
         }
     } else {
         throw new ProjectCreateException("Project target is ambiguous");
     }
 }
Example #7
0
// It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise.
// You can get copies of the licenses here:
//		http://www.affero.org/oagpl.html
// AFFERO GENERAL PUBLIC LICENSE is also included in the file called "COPYING".
include 'config.php';
include mnminclude . 'html1.php';
$globals['extra_js'][] = 'autocomplete/jquery.autocomplete.min.js';
$globals['extra_css'][] = 'jquery.autocomplete.css';
$globals['extra_js'][] = 'jquery.user_autocomplete.js';
$page_size = 20;
$offset = (get_current_page() - 1) * $page_size;
$globals['ads'] = true;
$u1 = User::get_valid_username(clean_input_string($_REQUEST['u1']));
$u2 = User::get_valid_username(clean_input_string($_REQUEST['u2']));
$id1 = User::get_user_id($u1);
$id2 = User::get_user_id($u2);
switch ($_REQUEST['type']) {
    case 'comments':
        $type = 'comments';
        $prefix = 'comment';
        break;
    case 'posts':
    default:
        $type = 'posts';
        $prefix = 'post';
}
do_header(sprintf(_('debate entre %s y %s'), $u1, $u2));
do_tabs('main', _('debate'), $globals['uri']);
/*** SIDEBAR ****/
echo '<div id="sidebar">';
do_banner_right();
Example #8
0
 /**
  * @throws FileIDMissingException
  * @throws DataSecurityAccessDeniedException
  */
 public static function detail()
 {
     global $regional;
     if ($_GET['file_id']) {
         $file = File::get_instance($_GET['file_id']);
         if ($file->is_read_access()) {
             $template = new HTMLTemplate("data/file_detail.html");
             $folder = Folder::get_instance($file->get_parent_folder_id());
             if ($_GET['version'] and is_numeric($_GET['version'])) {
                 $file->open_internal_revision($_GET['version']);
                 $internal_revision = $_GET['version'];
             } else {
                 $internal_revision = $file->get_internal_revision();
             }
             $template = new HTMLTemplate("data/file_detail.html");
             $folder = Folder::get_instance($file->get_parent_folder_id());
             $user = new User($file->get_owner_id());
             $file_version_array = $file->get_file_internal_revisions();
             if (is_array($file_version_array) and count($file_version_array) > 0) {
                 $result = array();
                 $counter = 1;
                 $result[0]['version'] = 0;
                 $result[0]['text'] = "----------------------------------------------";
                 $file_version = File::get_instance($_GET['file_id'], true);
                 foreach ($file_version_array as $key => $value) {
                     $file_version->open_internal_revision($value);
                     $version_datetime_handler = new DatetimeHandler($file_version->get_datetime());
                     $result[$counter]['version'] = $file_version->get_internal_revision();
                     $result[$counter]['text'] = "Version " . $file_version->get_version() . " - " . $version_datetime_handler->get_datetime();
                     $counter++;
                 }
                 $template->set_var("version_option", $result);
             }
             $result = array();
             $counter = 0;
             foreach ($_GET as $key => $value) {
                 if ($key != "version") {
                     $result[$counter]['value'] = $value;
                     $result[$counter]['key'] = $key;
                     $counter++;
                 }
             }
             $template->set_var("get", $result);
             $template->set_var("version", $file->get_version());
             $paramquery = $_GET;
             $paramquery['action'] = "file_history";
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("version_list_link", $params);
             $template->set_var("title", $file->get_name());
             $template->set_var("name", $file->get_name());
             $template->set_var("path", $folder->get_object_path());
             $template->set_var("size", Convert::convert_byte_1024($file->get_size()));
             $template->set_var("size_in_byte", $regional->format_number($file->get_size()));
             $create_datetime_handler = new DatetimeHandler($file->get_datetime());
             $version_datetime_handler = new DatetimeHandler($file->get_version_datetime());
             $template->set_var("creation_datetime", $create_datetime_handler->get_datetime());
             $template->set_var("version_datetime", $version_datetime_handler->get_datetime());
             $template->set_var("mime_type", $file->get_mime_type());
             $template->set_var("owner", $user->get_full_name(false));
             $template->set_var("checksum", $file->get_checksum());
             $template->set_var("permission", $file->get_permission_string());
             $template->set_var("comment", "");
             if ($file->is_image() == true) {
                 $template->set_var("thumbnail_image", "<img src='image.php?session_id=" . $_GET['session_id'] . "&file_id=" . $_GET['file_id'] . "&max_width=340&max_height=350' alt='' />");
             } else {
                 $template->set_var("thumbnail_image", "");
             }
             $paramquery = array();
             $paramquery['username'] = $_GET['username'];
             $paramquery['session_id'] = $_GET['session_id'];
             $paramquery['file_id'] = $_GET['file_id'];
             if ($_GET['version']) {
                 $paramquery['version'] = $_GET['version'];
             }
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("download_params", $params);
             $paramquery = $_GET;
             $paramquery['action'] = "file_update";
             $paramquery['version'] = $internal_revision;
             $paramquery['retrace'] = Retrace::create_retrace_string();
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("update_params", $params);
             $paramquery = $_GET;
             $paramquery['action'] = "file_update_minor";
             $paramquery['version'] = $file->get_internal_revision();
             $paramquery['retrace'] = Retrace::create_retrace_string();
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("update_minor_params", $params);
             $paramquery = $_GET;
             $paramquery['action'] = "permission";
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("set_permission_params", $params);
             $template->set_var("write_access", $file->is_write_access());
             if ($file->is_control_access() == true or $file->get_owner_id() == $user->get_user_id()) {
                 $template->set_var("change_permission", true);
             } else {
                 $template->set_var("change_permission", false);
             }
             $template->set_var("delete_access", $file->is_delete_access());
             $paramquery = $_GET;
             $paramquery['action'] = "file_delete";
             unset($paramquery['sure']);
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("delete_file_params", $params);
             $paramquery = $_GET;
             $paramquery['action'] = "file_delete_version";
             $paramquery['version'] = $internal_revision;
             unset($paramquery['sure']);
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("delete_file_version_params", $params);
             $paramquery = $_GET;
             unset($paramquery['file_id']);
             unset($paramquery['version']);
             unset($paramquery['action']);
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("back_link", $params);
             $template->output();
         } else {
             throw new DataSecurityAccessDeniedException();
         }
     } else {
         throw new FileIDMissingException();
     }
 }
Example #9
0
require_once $DOC_ROOT . '/includes/config.php';
require_once DOC_ROOT . '/includes/classes/class.database.php';
require_once DOC_ROOT . '/includes/classes/class.db_interface.php';
require_once DOC_ROOT . '/includes/classes/class.user.php';
/*
    EVERY CLASS NEEDS THE USER ID, WHICH IS RETRIEVED USING THE DEVICE ID
*/
if (PHONEGAP) {
    $device_id = get_param('uuid');
    if (!$device_id || $device_id == 'test') {
        $user_id = 7;
    } else {
        $user_id = User::get_user_id_by_device($device_id);
    }
} else {
    $user_id = User::get_user_id();
}
/*
define(LOG_FILE, DOC_ROOT . '/log/log_file.txt');
function log_time($point = '')
{
    $log_data = date('U') . $point . "\n";
    file_put_contents(LOG_FILE, $log_data, FILE_APPEND);
}
*/
function remove_accents($str)
{
    setlocale(LC_ALL, 'en_US.utf8');
    $output = iconv('utf-8', 'ascii//TRANSLIT', $str);
    return $output;
}
Example #10
0
<?php

/**
 * 测试 User 类
 */
require_once '../zhihu.php';
require_once 'time.php';
$time = new Time();
$time->star();
$user_url = 'https://www.zhihu.com/people/excited-vczh';
$user = new User($user_url);
// 获取用户ID
$user_id = $user->get_user_id();
var_dump($user_id);
// 获取用户关注数
$followees_num = $user->get_followees_num();
var_dump($followees_num);
// 获取用户粉丝数
$followers_num = $user->get_followers_num();
var_dump($followers_num);
// 获取用户获得的赞同数
$agree_num = $user->get_agree_num();
var_dump($agree_num);
// 获取用户获得感谢数
$thanks_num = $user->get_thanks_num();
var_dump($thanks_num);
// 获取用户问题提问数
$asks_num = $user->get_asks_num();
var_dump($asks_num);
// 获取用户问题回答数
$answer_num = $user->get_answers_num();
 public static function login($user_email, $password)
 {
     global $db;
     $sql = $db->prepare("SELECT * FROM user WHERE user_email=?");
     $success = $sql->execute(array($user_email));
     if ($success && $sql->rowCount()) {
         $row = $sql->fetch(PDO::FETCH_ASSOC);
         if (password_verify($password, $row['user_password'])) {
             $user = new User($row['user_id'], $row['user_email'], $row['user_first_name'], $row['user_last_name']);
             $_SESSION['user_id'] = $user->get_user_id();
             return $user;
         }
     }
     return false;
 }
<?php

// print_r($_POST);
session_start();
if (empty($_POST['username']) || empty($_POST['password'])) {
    header('Location: index.php');
} else {
    require_once '../lib/User.class.php';
    $username = $_POST['username'];
    $password = md5($_POST['password']);
    $user = new User();
    if ($user->find($username)) {
        if ($user->login()) {
            $_SESSION['login_user'] = $user->get_user_name();
            $_SESSION['login_user_id'] = $user->get_user_id();
            $_SESSION['login_user_firstname'] = $user->get_user_firstname();
            $result = array('success' => true, 'message' => 'Hello ' . $user->get_user_firstname() . ', welcome back to FineTable!', 'userinfo' => $user->get_user_info_json());
            setcookie('login_user', $user->get_user_name(), time() + 86400);
            setcookie('login_user_id', $user->get_user_id(), time() + 86400);
            setcookie('login_user_firstname', $user->get_user_firstname(), time() + 86400);
            setcookie('login_user_email', $user->get_user_email(), time() + 86400);
            setcookie('login_user_phone', $user->get_user_phone(), time() + 86400);
        } else {
            $result = array("success" => false, "message" => "Username or password is invalid!");
        }
    } else {
        $result = array("success" => false, "message" => "Username or password is invalid!");
    }
    echo json_encode($result);
}
Example #13
0
function displayUserManagement()
{
    global $tool, $propertyForm;
    $users = User::get_users();
    echo "<style>";
    foreach ($users as $id => $value) {
        echo "#modalBox #dialog" . $id;
        echo "{\n\t\t\twidth:auto;\n\t\t\tmax-width: 80%;\n\t\t\tmin-width:40%;\n\t\t\theight:auto;\n\t\t\tpadding:10px;\n\t\t\tpadding-top:10px;\n\t\t\toverflow:auto;\n\t\t}";
    }
    echo "</style>";
    $toolNames = array("Add User");
    $toolIcons = array("add");
    $formType = array("newDialog");
    echo $tool->createNewModal($toolNames, $toolIcons, $formType);
    echo "<form method='post' action='' style='width:1024px;'>";
    echo "<table id=\"sortDataTable\" class='sortable' cellspacing=\"0\" cellpadding=\"0\" border=\"1\" style='width:100%; clear:left;'>\n\t\t<thead>\n\t\t<tr><th style='text-align:left;'>Full Name</th>\n\t\t<th style='text-align:left;'>User Name</th>\n\t\t<th style='text-align:left;'>Email</th>\n\t\t<th style='text-align:left;'>User Type</th>\n\t\t<th style='text-align:left;'>Group</th>\n\t\t<th style='text-align:left;'>Action</th>\n\t\t<th style='text-align:left;'>Last Login</th></tr>\n\t\t</thead>\n\t\t<tbody>";
    foreach ($users as $id => $value) {
        echo "<tr>";
        $curUser = new User($id);
        echo "<td><input type='checkbox' name='list[]' value='" . $curUser->get_user_id() . "' />" . $curUser->get_full_name() . "</td>\n\t\t<td>" . $curUser->get_user_name() . "</td>\n\t\t<td>" . $curUser->get_email() . "</td>\n\t\t<td>" . $curUser->get_user_type() . "</td>";
        $group = $curUser->get_groups();
        if (count($group) == 0) {
            $group = array("None");
        }
        echo "<td>";
        foreach ($group as $gid => $value) {
            echo $value . ", ";
        }
        echo "</td>\n\t\t<td><a name='modal' href='#dialog" . $id . "'>Edit</a></td>";
        echo "<td>" . $curUser->get_last_login() . " (" . $curUser->get_last_ip() . ")</td>";
        echo "</tr>";
    }
    echo "</tbody>\n\t</table>";
    echo "<input type='submit' name='delUser' value='Delete Checked Users' style='float:left; clear:left; margin-bottom:5px;' />";
    echo "<select name='groups' style='float:right; margin-bottom:5px;'>";
    $groups = Group::get_groups();
    foreach ($groups as $id => $value) {
        $curGroup = new Group($id);
        echo "<option value=" . $id . ">" . $curGroup->get_name() . "</option>";
    }
    echo "</select>";
    echo "<input type='submit' name='userToGroup' value='Add Users to Group' style='float:right; margin-bottom:5px; margin-right: 5px;' />";
    echo "</form>";
    $heading = array("User Information");
    $title = array("Full Name", "User Name", "Password", "Email");
    $key = array("full", "user", "password", "email");
    foreach ($users as $id => $value) {
        $curUser = new User($id);
        $info = array($id, $curUser->get_full_name(), $curUser->get_user_name(), $curUser->get_email());
        $heading2 = array("User Information");
        $title2 = array("ID", "Full Name", "User Name", "Email");
        $key2 = array("id", "full", "user", "email");
        $fieldType = array("static");
        //create a new modal form for a new interface ports
        $propertyForm->setFieldType($fieldType);
        echo $propertyForm->editModalForm($heading2, $title2, $info, $key2, "dialog" . $id, "updateUser");
    }
    //create a new modal form for a new interface ports
    $fieldType = array();
    $propertyForm->setFieldType($fieldType);
    echo $propertyForm->newModalForm($heading, $title, $key, "addUser");
}