示例#1
0
 public static function handleAddContact()
 {
     //login user or display loginForm with errors
     $first_name = $_POST["first_name"];
     $last_name = $_POST["last_name"];
     $location = $_POST["location"];
     $email = $_POST["email"];
     $comments = $_POST["comments"];
     if (!add_contact(array("first_name" => $first_name, "last_name" => $last_name, "location" => $location, "email" => $email, "comments" => $comments))) {
         self::displayAddContactForm(array("error" => "Error inserting contact to list"));
     } else {
         //redirect to homepage on success
         header("Location: /contacts.php?action=list");
     }
 }
$emails = get_person_contact($organization_id, 8);
$email = mysql_fetch_assoc($emails);
if ($email) {
    if ($_POST["organization_mail"] != $email["CONTACT_STRING"]) {
        del_contact($email['ID']);
        if (!empty($_POST["organization_mail"])) {
            add_contact($organization_id, $_POST["organization_mail"], '', 8);
        }
    }
} else {
    if (!empty($_POST["organization_mail"])) {
        add_contact($organization_id, $_POST["organization_mail"], '', 8);
    }
}
$webs = get_person_contact($organization_id, 7);
$web = mysql_fetch_assoc($webs);
if ($web) {
    if ($_POST["organization_web"] != $web["CONTACT_STRING"]) {
        del_contact($web['ID']);
        if (!empty($_POST["organization_web"])) {
            add_contact($organization_id, $_POST["organization_web"], '', 7);
        }
    }
} else {
    if (!empty($_POST["organization_web"])) {
        add_contact($organization_id, $_POST["organization_web"], '', 7);
    }
}
set_updatetime($id);
header('Location:../view/detail_organization.php?id=' . $id);
// back page
示例#3
0
function install_step_5()
{
    include_config('inc_connect_install');
    include_lcm('inc_meta');
    include_lcm('inc_access');
    global $lcm_lang_left, $lcm_lang_right;
    // Either leave the form completely empty, or fill in everything
    if (_request('username') || _request('name_first') || _request('name_last') || _request('email')) {
        $_SESSION['form_data']['name_first'] = _request('name_first');
        $_SESSION['form_data']['name_middle'] = _request('name_middle');
        $_SESSION['form_data']['name_last'] = _request('name_last');
        $_SESSION['form_data']['username'] = _request('username');
        $_SESSION['form_data']['password'] = _request('password');
        $_SESSION['form_data']['password_confirm'] = _request('password_confirm');
        $_SESSION['form_data']['email'] = _request('email');
        $_SESSION['form_data']['getnews'] = _request('getnews');
        // Test mandatory fields, sorry for the ugly code
        $mandatory = array('name_first' => 'person_input', 'name_last' => 'person_input', 'username' => 'authoredit_input', 'password' => 'authorconf_input', 'password_confirm' => 'authorconf_input', 'getnews' => 'install_input');
        foreach ($mandatory as $mn => $str) {
            if (!_request($mn)) {
                $_SESSION['errors'][$mn] = _T($str . '_' . $mn) . ' ' . _T('warning_field_mandatory');
            }
        }
        if (_session('password') != _session('password_confirm')) {
            $_SESSION['errors']['password'] = _T('login_warning_password_dont_match');
        }
        if (count($_SESSION['errors'])) {
            return install_step_4();
        }
        $query = "SELECT id_author FROM lcm_author WHERE username='******'username') . "'";
        $result = lcm_query($query);
        unset($id_author);
        while ($row = lcm_fetch_array($result)) {
            $id_author = $row['id_author'];
        }
        // If user exists, allow to reset a forgotten password, which is possible
        // by deleting inc_connect.php and re-installing (it does not affect the DB).
        if ($id_author) {
            $query = "UPDATE lcm_author " . "SET name_first = '" . _session('name_first') . "', \n\t\t\t\t\tname_middle = '" . _session('name_middle') . "', \n\t\t\t\t\tname_last = '" . _session('name_last') . "', \n\t\t\t\t\tusername = '******'username') . "', \n\t\t\t\t\tdate_update = NOW(),\n\t\t\t\t\talea_actuel = '', \n\t\t\t\t\talea_futur = FLOOR(32000*RAND()), \n\t\t\t\t\tstatus = 'admin'\n\t\t\t\t  WHERE id_author = " . $id_author;
            lcm_query_db($query);
        } else {
            $query = "INSERT INTO lcm_author " . "(name_first, name_middle, name_last, username, prefs, cookie_recall, pgp, " . "password, alea_actuel, alea_futur, status, date_update, date_creation)" . "VALUES (" . "'" . _session('name_first') . "'," . "'" . _session('name_middle') . "'," . "'" . _session('name_last') . "'," . "'" . _session('username') . "'," . "'', '', '', " . "'temp'," . "''," . "FLOOR(32000*RAND())," . "'admin'," . "NOW()," . "NOW()" . ")";
            lcm_query_db($query);
            $id_author = lcm_insert_id('lcm_author', 'id_author');
        }
        //
        // Set password
        //
        $class_auth = 'Auth_db';
        include_lcm('inc_auth_db');
        $auth = new $class_auth();
        if (!$auth->init()) {
            lcm_log("pass change: failed auth init: " . $auth->error);
            $_SESSION['errors']['password'] = $auth->error;
            return install_step_4();
        }
        if (!$auth->newpass($id_author, _session('username'), _session('password'))) {
            $_SESSION['errors']['password'] = $auth->error;
        }
        if (count($_SESSION['errors'])) {
            return install_step_4();
        }
        //
        // Set e-mail for author
        //
        if (_session('email')) {
            include_lcm('inc_contacts');
            if (!is_existing_contact('author', $id_author, 'email_main', _session('email'))) {
                add_contact('author', $id_author, 'email_main', _session('email'));
            }
            // Insert email as main system administrator
            write_meta('email_sysadmin', _session('email'));
        }
    } else {
        // Test if an administrator already exists
        $number_admins = get_number_admins();
        if (!$number_admins) {
            $_SESSION['errors']['generic'] = _T('install_warning_no_admins_exist');
            return install_step_4();
        }
    }
    $site_address = read_meta('site_address');
    if (!$site_address) {
        global $HTTP_SERVER_VARS, $HTTP_HOST;
        // Replace www.site.net/foo/name.php -> www.site.net/foo/
        $site_address = $_SERVER['REQUEST_URI'];
        if (!$site_address) {
            $site_address = $_ENV['PHP_SELF'];
        }
        // [ML] unsure
        $site_address = preg_replace("/\\/[^\\/]+\\.php\$/", "/", $site_address);
        $site_address = 'http://' . $_SERVER['HTTP_HOST'] . $site_address;
        write_meta('site_address', $site_address);
    }
    // Force regeneration of metas, just in case..
    $lcm_meta_cache = 'inc_meta_cache.php';
    if (isset($_SERVER['LcmDataDir'])) {
        $lcm_meta_cache = $_SERVER['LcmDataDir'] . '/' . $lcm_meta_cache;
    } else {
        $lcm_meta_cache = 'inc/data/' . $lcm_meta_cache;
    }
    @unlink($lcm_meta_cache);
    write_metas();
    // Finalise installation
    $lcm_config_prefix = isset($_SERVER['LcmConfigDir']) ? $_SERVER['LcmConfigDir'] : 'inc/config';
    if (!@rename($lcm_config_prefix . '/inc_connect_install.php', $lcm_config_prefix . '/inc_connect.php')) {
        copy($lcm_config_prefix . '/inc_connect_install.php', $lcm_config_prefix . '/inc_connect.php');
        @unlink($lcm_config_prefix . '/inc_connect_install.php');
    }
    // If requested, send registration request to News mailing-list
    if (_request('getnews') == 'yes') {
        if (_session('email') && is_valid_email(_session('email'))) {
            send_email("*****@*****.**", "subscribe", "subscribe", _session('email'));
            send_email("*****@*****.**", "[lcm-news] subscribe " . _session('email'), "[lcm-news] subscribe " . _session('email'));
        }
    }
    install_html_start('AUTO', '', 5);
    echo "<h3><small>" . _T('install_step_last') . "</small></h3>\n";
    echo "<div class='box_success'>\n";
    echo "<p><b>" . _T('install_info_application_ready') . "</b></p>\n";
    echo '<p align="center">' . _T('install_info_do_not_forget') . "</p>\n";
    if (_request('getnews') == 'yes') {
        echo '<p align="' . $lcm_lang_left . '">' . _T('install_info_subscribe_may_fail') . "</p>\n";
    }
    echo '<p align="' . $lcm_lang_left . '">' . _T('install_info_more_about_software', array("url" => '<a class="content_link" href="http://www.lcm.ngo-bg.org">www.lcm.ngo-bg.org</a>')) . "</p>\n";
    echo "</div>\n";
    echo "<form action='index.php' method='post'>\n";
    echo "<div align='" . $lcm_lang_right . "'>" . "<button type='submit' name='Next'>" . _T('button_next') . " >></button>&nbsp;" . "</div>\n";
    echo "</form>\n";
    install_html_end();
}
<?php

session_start();
require_once '../file-includes.php';
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
$info = array();
$info[] = fix_string($request->name);
$info[] = fix_string($request->address);
$info[] = fix_string($request->number);
$info[] = fix_string($request->email);
$userID = get_userID_session();
add_contact($info, $userID);
示例#5
0
}
//echo $organization_id;
if (isset($_POST["organization_tel"]) && !empty($_POST["organization_tel"]) && $organization_id != 0) {
    // echo $organization_tel = $_POST["organization_tel"];
    if (isset($_POST["organization_tel_comment"]) && !empty($_POST["organization_tel_comment"])) {
        $organization_tel_comment = $_POST["organization_tel_comment"];
        add_contact($organization_id, $organization_tel, $organization_tel_comment, 6);
    } else {
        add_contact($organization_id, $organization_tel, '', 6);
    }
}
if (isset($_POST["organization_mail"]) && !empty($_POST["organization_mail"]) && $organization_id != 0) {
    $organization_mail = $_POST["organization_mail"];
    add_contact($organization_id, $organization_mail, '', 8);
}
if (isset($_POST["organization_web"]) && !empty($_POST["organization_web"]) && $organization_id != 0) {
    $organization_web = $_POST["organization_web"];
    add_contact($organization_id, $organization_web, '', 7);
}
if (isset($_POST["organization_fax"]) && !empty($_POST["organization_fax"]) && $organization_id != 0) {
    $organization_fax = $_POST["organization_fax"];
    if (isset($_POST["organization_fax_comment"]) && !empty($_POST["organization_fax_comment"])) {
        $organization_fax_comment = $_POST["organization_fax_comment"];
        add_contact($organization_id, $organization_fax, $organization_fax_comment, 9);
    } else {
        add_contact($organization_id, $organization_fax, '', 9);
    }
}
echo "<script type='text/javascript'>";
echo "window.close();";
echo "</script>";
示例#6
0
$fb = mysql_fetch_assoc($fbs);
if ($fb) {
    if ($_POST["facebook"] != $fb["CONTACT_STRING"]) {
        del_contact($fb['ID']);
        if (!empty($_POST["facebook"])) {
            add_contact($id, $_POST["facebook"], '', 5);
        }
    }
} else {
    if (!empty($_POST["facebook"])) {
        add_contact($id, $_POST["facebook"], '', 5);
    }
}
$lines = get_person_contact($id, 4);
$line = mysql_fetch_assoc($lines);
if ($line) {
    if ($_POST["line"] != $line["CONTACT_STRING"]) {
        del_contact($line['ID']);
        if (!empty($_POST["line"])) {
            add_contact($id, $_POST["line"], '', 4);
        }
    }
} else {
    if (!empty($_POST["line"])) {
        add_contact($id, $_POST["line"], '', 4);
    }
}
set_updatetime($id);
echo "<script type='text/javascript'>";
echo "window.close();";
echo "</script>";
示例#7
0
function update_contacts_request($type_person, $id_of_person)
{
    // This will be useful later, to check mandatory/optional contacts
    $all_contact_kwg = get_kwg_all('contact');
    //
    // Update existing contacts
    //
    if (isset($_REQUEST['contact_value'])) {
        $contacts = $_REQUEST['contact_value'];
        $c_ids = $_REQUEST['contact_id'];
        $c_types = $_REQUEST['contact_type'];
        //
        // Check if the contacts provided are really attached to the person
        // or else the user can provide a form with false contacts.
        //
        $all_contacts = get_contacts($type_person, $id_of_person);
        for ($cpt = 0; isset($c_ids[$cpt]) && $c_ids[$cpt]; $cpt++) {
            $valid = false;
            foreach ($all_contacts as $c) {
                if ($c['id_contact'] == $c_ids[$cpt]) {
                    $valid = true;
                }
            }
            if (!$valid) {
                lcm_panic("Invalid modification of existing contact detected.");
            }
        }
        for ($cpt = 0; isset($c_ids[$cpt]); $cpt++) {
            // Check first to see if the contact is mandatory
            $kwg = get_kwg_from_id($c_types[$cpt]);
            $delete_allowed = true;
            if ($kwg['policy'] == 'mandatory') {
                // XXX Having policy == 'mandatory' but quantity = many
                // really makes a mess, and is not handled.
                $delete_allowed = false;
            }
            if (_request('del_contact_' . $c_ids[$cpt])) {
                if ($delete_allowed) {
                    lcm_debug("Contact DEL: {$type_person}, {$id_of_person}, " . $c_ids[$cpt], 1);
                    delete_contact($c_ids[$cpt]);
                } else {
                    $_SESSION['errors']['upd_contact_' . $cpt] = _T('warning_field_mandatory');
                }
            } else {
                if (!$delete_allowed && !$contacts[$cpt]) {
                    $_SESSION['errors']['upd_contact_' . $cpt] = _T('warning_field_mandatory');
                } else {
                    lcm_debug("Contact UPD: {$type_person}, {$id_of_person}, " . $c_ids[$cpt] . ' = ' . $contacts[$cpt], 1);
                    $err = update_contact($c_ids[$cpt], $contacts[$cpt]);
                    if ($err) {
                        $_SESSION['errors']['upd_contact_' . $cpt] = $err;
                    }
                }
            }
        }
    }
    //
    // New contacts
    //
    if (isset($_REQUEST['new_contact_value'])) {
        $cpt = 0;
        $new_contacts = $_REQUEST['new_contact_value'];
        $c_type_names = $_REQUEST['new_contact_type_name'];
        while (isset($new_contacts[$cpt])) {
            // Process only new contacts which have a value
            if ($new_contacts[$cpt]) {
                // And make sure that they have a "type of contact"
                if ($c_type_names[$cpt]) {
                    lcm_debug("Contact NEW: {$type_person}, {$id_of_person}, Name = " . $c_type_names[$cpt] . ', ' . $new_contacts[$cpt], 1);
                    $err = add_contact($type_person, $id_of_person, $c_type_names[$cpt], $new_contacts[$cpt]);
                    if ($err) {
                        $_SESSION['errors']['new_contact_' . $cpt] = $err;
                    }
                } else {
                    $_SESSION['errors']['new_contact_' . $cpt] = "Please specify the type of contact.";
                    // TRAD
                }
            }
            $cpt++;
        }
    }
    //
    // Check if all mandatory contacts were provided
    //
    $all_contacts = get_contacts($type_person, $id_of_person);
    foreach ($all_contact_kwg as $c) {
        if ($c['policy'] == 'mandatory') {
            $found = false;
            foreach ($all_contacts as $a) {
                if ($a['name'] == $c['name'] && trim($a['value'])) {
                    $found = true;
                }
            }
            if (!$found) {
                $_SESSION['errors']['contact_' . $c['name']] = _Ti($c['title']) . _T('warning_field_mandatory');
            }
        }
    }
}
示例#8
0
 if (isset($_POST["organization_fax"]) && !empty($_POST["organization_fax"])) {
     $organization_fax = $_POST["organization_fax"];
     if (isset($_POST["organization_fax_comment"]) && !empty($_POST["organization_fax_comment"])) {
         $organization_fax_comment = $_POST["organization_fax_comment"];
         add_contact($o_id, $organization_fax, $organization_fax_comment, 9);
     } else {
         add_contact($o_id, $organization_fax, '', 9);
     }
 }
 if (isset($_POST["organization_web"]) && !empty($_POST["organization_web"])) {
     $organization_web = $_POST["organization_web"];
     add_contact($o_id, $organization_web, '', 7);
 }
 if (isset($_POST["organization_mail"]) && !empty($_POST["organization_mail"])) {
     $organization_mail = $_POST["organization_mail"];
     add_contact($o_id, $organization_mail, '', 8);
 }
 if (isset($_POST["chinahouse_name"]) || !empty($_POST["CHINAHOUSE_VILLAGE"]) || !empty($_POST["CHINAHOUSE_VILLAGE_TH"]) || !empty($_POST["CHINAHOUSE_DISTRICT"]) || !empty($_POST["CHINAHOUSE_DISTRICT_TH"])) {
     $chinahouse_name = "";
     $chinahouse_village_id = 0;
     $chinahouse_amphur_id = 0;
     $chinahouse_district_id = 0;
     $chinahouse_province_id = 0;
     $chinahouse_tel = "";
     if (isset($_POST["CHINAHOUSE_NAME"]) && !empty($_POST["CHINAHOUSE_NAME"])) {
         $chinahouse_name = $_POST["CHINAHOUSE_NAME"];
     }
     if (isset($_POST["CHINAHOUSE_VILLAGE"]) && !empty($_POST["CHINAHOUSE_VILLAGE"]) || isset($_POST["CHINAHOUSE_VILLAGE_TH"]) && !empty($_POST["CHINAHOUSE_VILLAGE_TH"])) {
         $chinahouse_village_id = get_chinahouse_id($_POST["CHINAHOUSE_VILLAGE"], $_POST["CHINAHOUSE_VILLAGE_TH"]);
     }
     if (isset($_POST["CHINAHOUSE_AMPHUR"]) && !empty($_POST["CHINAHOUSE_AMPHUR"]) || isset($_POST["CHINAHOUSE_AMPHUR_TH"]) && !empty($_POST["CHINAHOUSE_AMPHUR_TH"])) {
示例#9
0
<?php

session_start();
include "config.php";
include "db.php";
dbconnect() or send_err_mail("Cannot connect to server" . mysql_error(), $PHP_SELF);
$user_id = $_SESSION[vis_user_id];
$organiser_id = $_SESSION[vis_organiser_id];
$contact_rln_id = add_contact($parent_contact_id, $contact_id);
echo $contact_rln_id;
示例#10
0
connect_database();
$time = date("Y-m-d H:i:s", time());
$data_id = $_POST["id"];
if (isset($_POST["tel"]) && !empty($_POST["tel"])) {
    $tel = $_POST["tel"];
    if (isset($_POST["tel_comment"]) && !empty($_POST["tel_comment"])) {
        $tel_comment = $_POST["tel_comment"];
        add_contact($data_id, $tel, $tel_comment, 1);
    } else {
        add_contact($data_id, $tel, "", 1);
    }
}
if (isset($_POST["moblie"]) && !empty($_POST["moblie"])) {
    $moblie = $_POST["moblie"];
    add_contact($data_id, $moblie, '', 2);
}
if (isset($_POST["email"]) && !empty($_POST["email"])) {
    $email = $_POST["email"];
    add_contact($data_id, $email, '', 3);
}
if (isset($_POST["line"]) && !empty($_POST["line"])) {
    $line = $_POST["line"];
    add_contact($data_id, $line, '', 4);
}
if (isset($_POST["facebook"]) && !empty($_POST["facebook"])) {
    $facebook = $_POST["facebook"];
    add_contact($data_id, $facebook, '', 5);
}
echo "<script type='text/javascript'>";
echo "window.close();";
echo "</script>";
示例#11
0
}
if (!checkdate($_POST['month'], $_POST['day'], $_POST['year']) || mktime(0, 0, 0, $_POST['month'], $_POST['day'], $_POST['year']) > mktime() || !checkdate($_POST['nc_month'], $_POST['nc_day'], $_POST['nc_year']) || $_POST['nc_type'] !== 'brak' && mktime(0, 0, 0, $_POST['month'], $_POST['day'], $_POST['year']) > mktime(0, 0, 0, $_POST['nc_month'], $_POST['nc_day'], $_POST['nc_year'])) {
    display_warning('Wprowad¼ poprawn± datê!');
    exit;
}
$data = array();
if (!isset($_POST['contact_id'])) {
    $data['organisation_id'] = $_POST['organisation_id'];
    $data['user_id'] = $_SESSION['valid_user_id'];
    $data['project_id'] = $_POST['project_id'];
    $warning[true] = 'Dodanie kontaktu zakoñczone sukcesem!';
    $warning[false] = 'Dodanie kontaktu zakoñczone niepowodzeniem!';
} else {
    $data['contact_id'] = $_POST['contact_id'];
    $warning[true] = 'Edycja kontaktu zakoñczona sukcesem!';
    $warning[false] = 'Edycja kontaktu zakoñczona niepowodzeniem!';
}
$data['type'] = "'" . $_POST['type'] . "'";
$data['date'] = "'" . $_POST['year'] . '-' . $_POST['month'] . '-' . $_POST['day'] . "'";
$data['contact_person'] = "'" . $_POST['contact_person'] . "'";
$data['contact_function'] = "'" . $_POST['contact_function'] . "'";
$data['comments'] = "'" . str_replace("\r", '', $_POST['comments']) . "'";
$data['aim_id'] = $_POST['aim_id'];
$data['next_contact_type'] = $_POST['nc_type'] == 'brak' ? 'null' : "'" . $_POST['nc_type'] . "'";
$data['next_contact_date'] = $_POST['nc_type'] == 'brak' ? 'null' : "'" . $_POST['nc_year'] . '-' . $_POST['nc_month'] . '-' . $_POST['nc_day'] . "'";
if (!isset($_POST['contact_id']) && contact_exists($data)) {
    display_warning('Kontakt zosta³ ju¿ dodany!');
    exit;
}
display_warning($warning[add_contact($data)]);
示例#12
0
             print_myaddressbook_page();
             break;
         case "edit":
             echo '<h2>Kontakty - edycja</h2>';
             print_editcontact_page();
             break;
         case "editsave":
             update_contact();
             header("Location: ./index.php?kat=addressbook&id=view");
             break;
         case "addcontact":
             echo '<h2>Kontakty - dodaj nowy kontakt</h2>';
             print_addcontact_page();
             break;
         case "addcontactsave":
             add_contact();
             header("Location: ./index.php?kat=addressbook&id=view");
             break;
         case "delcontact":
             delete_contact();
             header("Location: ./index.php?kat=addressbook&id=view");
             break;
     }
     break;
 case "mytasks":
     echo '<h2>Historia zadań</h2>';
     print_mytasks_page();
     break;
 case "users":
     if ($_SESSION['access_level'] == 100) {
         switch ($id) {
示例#13
0
文件: ajax.php 项目: newnius/contacts
}
switch ($action) {
    case 'getAllContacts':
        $contacts = get_all_contacts_by_uid($uid);
        echo json_encode($contacts);
        break;
    case 'getAllGroups':
        $groups = get_all_groups_by_uid($uid);
        echo json_encode($groups);
        break;
    case 'addContact':
        if (!isset($_POST['contactName']) || !isset($_POST['telephones']) || !isset($_POST['remark']) || !isset($_POST['groupId'])) {
            echo $invalid_request;
            exit;
        }
        $res = add_contact($_POST['contactName'], $_POST['telephones'], $_POST['remark'], $uid, $_POST['groupId']);
        $response['errno'] = $res == 1 ? 0 : 1;
        $response['msg'] = $res == 1 ? '' : '添加联系人失败';
        echo json_encode($response);
        break;
    case 'deleteContact':
        if (!isset($_POST['contactId'])) {
            echo $invalid_request;
            exit;
        }
        $res = delete_contact_by_id($_POST['contactId'], $uid);
        $response['errno'] = $res == true ? 0 : 1;
        $response['msg'] = $res == 1 ? '' : '删除联系人失败';
        echo json_encode($response);
        break;
    case 'updateContact':