示例#1
0
 public function index()
 {
     $u = new SwfUpload();
     $t = new Thumbnail();
     $u->files = $_FILES;
     //设置file数组。(只能单张)
     //请记住先检测,再上传
     $r = $u->check();
     if ($r === true && ($r = $u->upload())) {
         //            echo_log($r);
         if (!isset($r['error'])) {
             // 生成200的缩略图
             $t->setSrcImg($r['savePath']);
             $height = $t->getImgHeight();
             $width = $t->getImgWidth();
             if ($this->savePicture($r['saveName'], $r['title'], $width, $height)) {
                 // 生成小的缩略图
                 $t->setDstImg($r['savePath'] . '_' . THUMBNAIL_WIDTH_SMALL);
                 $t->createImg(THUMBNAIL_WIDTH_SMALL);
                 // 生成打的缩略图
                 $t->setSrcImg($r['savePath']);
                 $t->setDstImg($r['savePath'] . '_' . THUMBNAIL_WIDTH_LARGE);
                 $t->createImg(THUMBNAIL_WIDTH_LARGE);
                 $rt = array('thumbUrl' => $r['saveName'], 'title' => $r['title'], 'width' => $width, 'height' => $height);
                 json_success($rt);
             } else {
                 json_failure('图片信息入库异常');
             }
         } else {
             json_failure($r['error']);
         }
     } else {
         json_failure($r['error']);
     }
 }
示例#2
0
 public function update()
 {
     $idx = user()->getIdx();
     if ($idx) {
         $meta = new PhilgoMeta();
         $stamp = $meta->get("attend.complete.{$idx}");
         if ($stamp) {
             // 1 분 이내에 중복 신청이 안되도록 한다.
             if ($stamp < time() - 60) {
                 // 총 포인트가 10만 점이 넘지 않도록 한다.
                 $point = $meta->get("total.event.point.{$idx}");
                 if ($point > 100000) {
                     json_success(array('code' => -40470, 'message' => "한도 초과: 포인트는 50,000 점까지만 획득 가능합니다."));
                 }
                 global $sys;
                 $d = array('idx_member' => $idx, 'idx_member_from' => $idx, 'point' => 77, 'idx_post' => 0, 'etc' => 'point event 2016-01-26');
                 $sys->point->update($d);
                 $meta->set("attend.complete.{$idx}", time());
                 $meta->set("total.event.point.{$idx}", $point + 77);
                 json_success(array('code' => 0, 'message' => "OK"));
             } else {
                 $left = 60 - (time() - $stamp);
                 json_success(array('code' => -40450, 'message' => "너무 빠른 포인트 증가 시도입니다. {$left} 초 남았음."));
             }
         } else {
             json_success(array('code' => -40449, 'message' => "출석 이벤트를 완료하십시오."));
         }
     } else {
         json_success(array('code' => -40104, 'message' => "로그인을 하십시오."));
     }
 }
示例#3
0
 public function runAjax()
 {
     $in = http_input();
     $table = $in['table'];
     $in['rows'] = $this->db->rows("SELECT * FROM  {$table}");
     json_success($in);
 }
 /**
  * 搜索需求
  */
 public function search()
 {
     $key = get_query('key');
     if (empty($key)) {
         this . getList();
     }
     $list = $this->pM->search($key, LIST_PPN, get_query('p', 1));
     json_success(array('isEnd' => empty($list), 'list' => $list));
 }
示例#5
0
 /**
  *
  *
  * @note 호출 예: http://philgo.org/?module=overframe&action=index&model=philgo.attend.collect&idx_member=test1016&session_id=a4c4d294aa2a91f25c326ae36d16d941&page=front&mobile=false&platform=isNotCordova
  *
  */
 public function collect()
 {
     $my_idx = user()->getID();
     $ret = array();
     for ($i = 9; $i >= 0; $i--) {
         $date = date('Ymd', time() - 60 * 60 * 24 * $i);
         $row = $this->row("user_id={$my_idx} AND date={$date}");
         $row['ymd'] = preg_replace('/([0-9]{4})([0-9]{2})([0-9]{2})/', "\$1-\$2-\$3 ", $date);
         $ret[] = $row;
     }
     json_success($ret);
 }
示例#6
0
/**
 * Выполнение ajax действия
 * 
 * @param AjaxClassProvider $provider
 */
function execute_ajax_action(AbstractAjaxAction $action = null)
{
    /* Для безопасности не будем писать детали обработки */
    if (!$action) {
        json_error('Действие не опеределено');
    }
    $result = $action->execute();
    $result = $result ? $result : 'Ошибка выполнения действия';
    if ($result instanceof AjaxSuccess) {
        json_success($result->getJsParams());
    }
    json_error($result);
}
示例#7
0
 /**
  *
  * @return void
  */
 public function edit()
 {
     if ($this->input->is_ajax_request()) {
         if (($domain = $this->input->post("domain")) !== NULL && $this->auth->has_right(Auth::ADMIN, $domain)) {
             if ($domain !== "<new>" && !($this->data["domain"] = $this->domains_model->get($domain)) instanceof PA_DB_Domain) {
                 json_success($this->data["domain"]);
             }
             //add_js( "domains_edit", true );
             $this->load->view('forms/domain_edit', $this->data);
             return;
         }
         json_access_denied();
     }
     redirect($this->router->default_controller);
 }
示例#8
0
 /**
  *
  *
  * @note HTTP 입력 변수로 condition 값이 들어오며 적절한 처리를 하여 JSON 으로 리턴한다.
  *
  * 내부적으로는 Entity::search() 를 사용하므로 where, limit, offset, page, order_by, fields 의 값을 그대로 사용 할 수 있다.
  *
  *
  *  &entity=데이터베이스 테이블
  *  &where=의 값은 entity->search() 의 where SQL 컨디션과 동일
  *  &order_by=SQL ORDER BY 컨디션
  *  &limit=, &offset=, &page= 의 값은 entity::search() 의 것과 동일
  *
  * @return JSON 내부의 동작은 entity::search() 의 것과 동일하지만, 결과는 JSON 으로 리턴한다.
  *
  * @code 쿼리 예제
  * http://philgo.org/?module=overframe&action=index&model=entity.crud.collect&entity=data&order_by=id%20ASC&fields=id,finish,name&where=id%3E3&limit=3
  * @endcode
  */
 public function collect()
 {
     $in = http_input();
     $o['fields'] = isset($in['fields']) ? $in['fields'] : '*';
     $o['where'] = isset($in['where']) ? $in['where'] : null;
     $o['order_by'] = isset($in['order_by']) ? $in['order_by'] : 'id DESC';
     $o['limit'] = isset($in['limit']) ? $in['limit'] : 10;
     $o['page'] = isset($in['page']) ? $in['page'] : 1;
     $o['offset'] = isset($in['offset']) ? $in['offset'] : 0;
     $entity_name = $in['entity'];
     $node = node($entity_name);
     $entities = $node->search($o);
     $data = array();
     foreach ($entities as $e) {
         $data[] = $e->getRecord();
     }
     json_success($data);
 }
示例#9
0
        $identifier = $icao == "" ? $iata : $icao;
        $github = new \Github\Client();
        $github->authenticate($GITHUB_ACCESS_TOKEN, NULL, Github\Client::AUTH_HTTP_TOKEN);
        $issues = $github->api('search')->issues("repo:{$GITHUB_USER}/{$GITHUB_REPO} in:title {$identifier}");
        if (count($issues['items']) > 0) {
            // Existing issue, add comment
            $issue_number = $issues['items'][0]['number'];
            $result = $github->api('issue')->comments()->create($GITHUB_USER, $GITHUB_REPO, $issue_number, array('body' => $body));
        } else {
            // New issue
            $result = $github->api('issue')->create($GITHUB_USER, $GITHUB_REPO, array('title' => $subject, 'body' => $body, 'labels' => array('airport')));
            $issue_number = $result['number'];
        }
        if (TRUE) {
            $message = "Edit submitted for review on Github: Issue {$issue_number}, {$result['html_url']}";
            json_success(array("apid" => $apid, "message" => $message));
        } else {
            json_error("Could not submit edit for review, please contact <a href='/about'>support</a>.");
        }
    }
    exit;
}
if (!$dbname) {
    $dbname = "airports";
}
$sql = "SELECT * FROM " . mysql_real_escape_string($dbname) . " WHERE ";
if ($action == "LOAD") {
    // Single-airport fetch
    $sql .= " apid=" . mysql_real_escape_string($apid);
    $offset = 0;
} else {
示例#10
0
    public function invoke_patients()
    {
        $active = isset($_GET['active']) ? $_GET['active'] : "1";
        //SELECT ALL //////////////////////////////////
        if (get('do') == 'viewall') {
            if (PAGINATION_TYPE == 'Normal') {
                $result = $this->patients_model->SelectAll(RECORD_PER_PAGE, $active);
                //Accept get url  e.g (index.php?id=1&cat=2...)
                $paging = pagination($this->patients_model->CountRow(), RECORD_PER_PAGE, '' . H_ADMIN . '&view=patients&do=viewall&active=' . $active);
            } else {
                $result = $this->patients_model->SelectAll(NULL, $active);
            }
            include APP_FOLDER . '/views/admin/patients/View.php';
        }
        //EXPORT ////////////////////////////////////////////////////
        if (get('do') == 'export') {
            $result = $this->patients_model->SelectAll(NULL, $active);
            include APP_FOLDER . '/views/admin/patients/Export.php';
        } elseif (get('do') == 'export2') {
            $rows = $this->patients_model->SelectOne(get('id'));
            include APP_FOLDER . '/views/admin/patients/Export2.php';
        } elseif (get('do') == 'autosearch') {
            $qstring = post('qstring');
            if (strlen($qstring) > 0) {
                $autosearch = $this->patients_model->AutoSearch(trim($qstring), 10, 'first_name');
                echo ' <div class=widget><ul class="list-group">';
                foreach ($autosearch as $srow) {
                    echo '<span class="searchheading"><a href="' . H_ADMIN . '&view=patients&id=' . $srow->id . '&do=details"><li class="list-group-item">' . $srow->first_name . ' ' . $srow->last_name . '</li></a>
	</span>';
                }
                echo '</ul></div>';
            }
        } elseif (get('do') == 'add') {
            include APP_FOLDER . '/views/admin/patients/Add.php';
        } elseif (get('do') == 'addpro') {
            if ($_POST) {
                //form validation
                if (post('first_name') == '') {
                    json_error('Pleas enter First Name!');
                } elseif (post('last_name') == '') {
                    json_error('Please enter Last Name!');
                } elseif (post('phone') == '') {
                    json_error('Please enter Phone!');
                } elseif (post('email') == '') {
                    json_error('Please enter Email!');
                } elseif (post('source') == '') {
                    json_error('Please select Source!');
                } else {
                    $this->patients_model->Insert(post('first_name'), post('last_name'), post('phone'), post('email'), post('source'), post('notes'));
                    json_send('' . H_ADMIN . '&view=patients&do=viewall&msg=add');
                    json_success('Process Completed');
                }
            }
        } elseif (get('do') == 'update') {
            $rows = $this->patients_model->SelectOne(get('id'));
            //check if patient have card
            $have_card = patient_have_card(get('id'));
            include APP_FOLDER . '/views/admin/patients/Update.php';
        } elseif (get('do') == 'updatepro') {
            if ($_POST) {
                //form validation
                if (post('id') == '') {
                    json_error('The field id cannot be empty!');
                } elseif (post('first_name') == '') {
                    json_error('Please enter First Name!');
                } elseif (post('last_name') == '') {
                    json_error('Please enter Last Name!');
                } elseif (post('phone') == '') {
                    json_error('Please enter Phone!');
                } elseif (post('email') == '') {
                    json_error('Please enter Email!');
                } elseif (post('source') == '') {
                    json_error('Please select Source!');
                } else {
                    $this->patients_model->Update(post('first_name'), post('last_name'), post('phone'), post('email'), post('source'), post('notes'), post('active'), post('id'));
                    json_send('' . H_ADMIN . '&view=patients&id=' . post('id') . '&do=details&msg=update');
                    json_success('Process Completed');
                }
            }
        } elseif (get('do') == 'details') {
            $rows = $this->patients_model->SelectOne(get('id'));
            //check if patient have card
            $have_card = patient_have_card(get('id'));
            include APP_FOLDER . '/views/admin/patients/Details.php';
        } elseif (get('do') == 'truncate') {
            $this->patients_model->TruncateTable('' . H_ADMIN . '&view=patients&do=viewall&msg=truncate');
            include APP_FOLDER . '/views/admin/patients/View.php';
        } elseif (get('do') == 'delete') {
            $dfile = get('dfile');
            if (get('id') and $dfile == '') {
                $del = $this->patients_model->Delete(get('id'), '' . H_ADMIN . '&view=patients&do=viewall&msg=delete');
            } elseif (get('id') and $dfile != '' and get('fdel') == '') {
                delete_files(UPLOAD_PATH . get('dfile'));
                delete_files(THUMB_PATH . get('dfile'));
                $del = $this->patients_model->Delete(get('id'), '' . H_ADMIN . '&view=patients&do=viewall&msg=delete');
            } elseif (get('id') and $dfile != '' and get('fdel') != '') {
                delete_files(UPLOAD_PATH . get('dfile'));
                delete_files(THUMB_PATH . get('dfile'));
                send_to('' . H_ADMIN . '&view=patients&id=' . get('id') . '&do=update&msg=delete');
            }
        }
    }
示例#11
0
 /**
  * Deletes a hotspot by its uuid
  * @param string $uuid
  */
 public function hotspot_delete($uuid = '')
 {
     validate_team_read(get_team_id());
     $hotspot = validate_hotspot_uuid($uuid);
     activity_delete_hotspot($hotspot->id);
     $this->Hotspot->delete($hotspot->id);
     json_success("Hotspot deleted successfully.");
 }
示例#12
0
 /**
  * @note: !!! Draft !!!
  * @return type
  */
 public function forgot_password()
 {
     if ($this->input->is_ajax_request() && $this->auth->type == Auth::ANONYMOUS) {
         $this->load->model("auth_model");
         if (($emailaddress = $this->input->post("emailaddress")) !== NULL && $this->auth_model->reset_password_request($emailaddress)) {
             json_success(TRUE, lang("welcome_index_password_forget_request_success"));
         }
         json_error(FALSE, lang("welcome_index_password_forget_request_failed"));
     }
     redirect($this->router->class);
 }
示例#13
0
<?php

require_once 'AjaxTools.php';
$programmId = RequestArrayAdapter::inst()->int('id');
$errorMsg = null;
if (is_numeric($programmId)) {
    GymManager::getInstance()->deleteProgramm($programmId);
} else {
    $errorMsg = 'Не передан id программы';
}
if ($errorMsg) {
    json_error($errorMsg);
} else {
    json_success('success');
}
示例#14
0
            if (mysql_affected_rows() == 1) {
                json_success(array("apid" => $apid, "message" => "Airport successfully edited."));
            } else {
                json_error("Editing airport failed:", $sql);
            }
        }
    } else {
        $subject = "OpenFlights: Airport edit";
        $body = "New edit submitted by " . $_SESSION['name'] . " (" . $_SESSION['email'] . "):\n{$sql}\n\nExisting airport information:\n" . implode("\n", $duplicates);
        $headers = "From: info+apsearch@openflights.org\r\nTo: info@openflights.org\r\nReply-To: " . $_SESSION['email'];
        if (isset($_POST["unittest"])) {
            echo $headers . "\n\n" . $body;
            exit;
        }
        if (mail($email, $subject, $body, $headers)) {
            json_success(array("apid" => $apid, "message" => "Edit submitted for review.  If you have registered an e-mail address, you will be notified when the edit is reviewed."));
        } else {
            json_error("Could not submit edit for review, please contact <a href='/about'>support</a>.");
        }
    }
    exit;
}
if (!$dbname) {
    $dbname = "airports";
}
$sql = "SELECT * FROM " . mysql_real_escape_string($dbname) . " WHERE ";
if ($action == "LOAD") {
    // Single-airport fetch
    $sql .= " apid=" . mysql_real_escape_string($apid);
    $offset = 0;
} else {
示例#15
0
 /**
  * Deletes a project by its uuid
  * @param string $uuid
  */
 public function meeting_delete($uuid = '')
 {
     $meeting = validate_meeting_uuid($uuid, true);
     activity_delete_meeting($meeting->id);
     $this->Meeting->delete($meeting->id);
     json_success("Message deleted successfully.");
 }
示例#16
0
文件: api.php 项目: rhartness/slc24
                        $withdrawals[] = array("txid" => $row_transfer_withdrawal_a["txid"], "time" => $row_transfer_withdrawal_a["filing_time_u"], "amount" => api_sc_format($row_transfer_withdrawal_a["amount"]));
                    } else {
                        $withdrawals[] = array("txid" => crypte_transaction($row_transfer_withdrawal_a["txid"]), "time" => $row_transfer_withdrawal_a["filing_time_u"], "amount" => api_sc_format($row_transfer_withdrawal_a["amount"]));
                    }
                }
                json_success($withdrawals);
            }
        }
        if ($query[2] == "addresses") {
            $withdrawal_addresses = array();
            $slt_transfer_withdrawal_address_a = "SELECT * FROM transfer_withdrawal_address WHERE user = '******'";
            $rlt_transfer_withdrawal_address_a = mysql_query($slt_transfer_withdrawal_address_a);
            while ($row_transfer_withdrawal_address_a = mysql_fetch_assoc($rlt_transfer_withdrawal_address_a)) {
                $withdrawal_addresses[] = array("id" => $row_transfer_withdrawal_address_a["id"], "address" => $row_transfer_withdrawal_address_a["address"], "group" => $row_transfer_withdrawal_address_a["group"], "type" => $row_transfer_withdrawal_address_a["type"]);
            }
            json_success($withdrawal_addresses);
        }
        json_error("Unknown call.");
    }
    json_error("Unknown call.");
}
json_error("Unknown call.");
function check_authentification()
{
    global $query, $db, $logged_in, $user_id, $user_email, $user_row;
    $userdata = (string) base64_decode($query[0]);
    $logged_in = false;
    $found = false;
    if (!$found) {
        if ($userdata[7] == ":") {
            foreach ($query as $i => $value) {
示例#17
0
    SELECT
        wp.pool_username AS username,
        wp.pool_password AS password,
        p.id AS id,
        p.url AS url

    FROM worker_pool wp, pool p

    WHERE wp.worker_id = :worker
      AND wp.pool_id = p.id
      AND wp.enabled
      AND p.enabled

    ORDER BY wp.priority DESC
');
$q->execute(array(':worker' => $worker_id));
$rows = $q->fetchAll();
$q->closeCursor();
$request = new stdClass();
$request->params = array();
$request->method = "getwork";
$request->id = "json";
foreach ($rows as $row) {
    $response = place_json_call($request, $row['url'], $row['username'], $row['password'], $headers);
    if (is_object($response) && is_object($response->result)) {
        set_lp_header($headers, $row['id'], $row['url']);
        process_work($pdo, $worker_id, $row['id'], $response, $response->id);
        json_success($response->result, $json->id);
    }
}
json_error("No enabled pools responded to the work request.", $json->id);
示例#18
0
 public function ajaxFileFinish()
 {
     sys()->log("ajaxFileFinish() : id=" . $this->in['id']);
     if ($code = data($this->in['id'])->finish()) {
         json_error($code, "failed to finish file");
     } else {
         json_success(array('id' => $this->in['id']));
     }
 }
示例#19
0
 /**
  *
  * @SWG\Api(
  *   path="/team/{uuid}/invite",
  *   description="API for team actions",
  * @SWG\Operation(
  *    method="POST",
  *    type="Response",
  *    summary="Invite a user to a team.  You can only invite people who are not already on your team.",
  * @SWG\Parameter(
  *     name="uuid",
  *     description="UUID of the team",
  *     paramType="path",
  *     required=true,
  *     type="string"
  *     ),
  * @SWG\Parameter(
  *     name="email",
  *     description="The email address of the user you would like to invite",
  *     paramType="form",
  *     required=true,
  *     type="string"
  *     )
  *   )
  * )
  *
  * Invites a user to a team
  * @param string $uuid
  */
 private function team_invite($uuid = '')
 {
     $this->load->library('form_validation');
     $this->load->helper('notification');
     /* Only the team owner can invite people */
     $team = validate_team_uuid($uuid, true);
     validate_team_read($team->id);
     /* Validate that they are the team owner */
     validate_team_owner($team->id, get_user_id());
     /* Validate that they have a valid subscription and can add a team */
     validate_user_add(get_user_id());
     $this->form_validation->set_rules('email', 'Email', 'required|trim|xss_clean|valid_email');
     if ($this->form_validation->run() == FALSE) {
         json_error('There was a problem with your submission: ' . validation_errors(' ', ' '));
     } else {
         $email = $this->post('email', TRUE);
         /* Look to see if there is an existing invite and resend it */
         $invite = $this->Team_Invite->get_for_email_team($email, $team->id);
         $invite_id = 0;
         if ($invite && !$invite->user_id) {
             $invite_id = $invite->id;
             $key = $invite->key;
         } else {
             $key = random_string('unique');
             $invite_id = $this->Team_Invite->add(array('email' => $email, 'team_id' => $team->id, 'key' => $key));
         }
         notify_team_invite($invite_id, get_user_id());
         json_success("User invited successfully", array('invite_id' => $invite_id, 'email' => $email, 'key' => $key));
     }
 }
示例#20
0
             json_error(LANG_ADMIN_INVALID_PASSWORD);
         } else {
             if ($haccess->user_exist_checker($username, H_SYSTEM_ACCESS) === false) {
                 json_error(LANG_ADMIN_INVALID_USERNAME);
             } else {
                 if ($haccess->account_activation($username, H_SYSTEM_ACCESS) === false) {
                     json_error(LANG_ADMIN_INVALID_ACTIVATION);
                 } else {
                     $login = $haccess->HezeLogin($username, $password, H_SYSTEM_ACCESS);
                     if ($login === false) {
                         json_error(LANG_ADMIN_ERROR);
                     } else {
                         $_SESSION[H_USER_SESSION] = $login;
                         $haccess->UpdateLastLogin(date('Y-m-d'), $_SERVER['REMOTE_ADDR'], $haccess->UserID());
                         json_send(H_ADMIN);
                         json_success('Logging in');
                         exit;
                     }
                 }
             }
         }
     }
 } elseif (get('do') == 'logout') {
     $haccess->log_out_access(H_LOGIN);
 } elseif (get('do') == 'delete') {
     $dfile = get('dfile');
     if (get('userid') and $dfile == '') {
         $del = $haccess->Delete(get('userid'), '' . H_ADMIN . '&view=hsys_users&do=viewall&msg=delete');
     } elseif (get('userid') and $dfile != '' and get('fdel') == '') {
         delete_files(UPLOAD_PATH . get('dfile'));
         delete_files(THUMB_PATH . get('dfile'));
示例#21
0
 /**
  * Deletes a video by its uuid
  * @param string $uuid
  */
 public function video_delete($uuid = '')
 {
     $video = validate_video_uuid($uuid);
     $this->Video->delete($video->id);
     json_success("Video deleted successfully.");
 }
示例#22
0
文件: index.php 项目: laiello/openpom
    }
    $query_time = getmicrotime() - $query_start;
    $str_query_time = '%01.4fs';
    if (($nb_rows = mysql_num_rows($rep)) > 0 || !isset($_GET['monitor'])) {
        break;
    } else {
        select_level($level++);
    }
}
/* json output mode */
if (isset($_GET['json'])) {
    $json = array('time' => $query_time, 'data' => array());
    while ($data = mysql_fetch_array($rep, MYSQL_ASSOC)) {
        $json['data'][] = $data;
    }
    json_success($json, 'ISO-8859-1');
}
$array_total_rows = mysql_fetch_row(mysql_query("SELECT FOUND_ROWS( )", $dbconn));
$total_rows = $array_total_rows[0];
/* PREPARE DISPLAY */
$hit_ok = 0;
$hit_warning = 0;
$hit_critical = 0;
$hit_unknown = 0;
$hit_down = 0;
$hit_ack = 0;
$hit_notif = 0;
$hit_check = 0;
$line = 1;
while ($data = mysql_fetch_array($rep, MYSQL_ASSOC)) {
    switch ($data['STATUS']) {
示例#23
0
        while ($result->fetch()) {
            $user = array("uid" => $uid, "name" => $name, "gender" => $gender, "apply_time" => $date);
            array_push($applied_users, $user);
        }
        $result->close();
    }
    // Messages
    $messages = array();
    $query = "SELECT M.mid, M.content, U.name, M.date FROM MESSAGE as M, USER as U WHERE M.uid = U.uid AND M.eid = " . $_GET['eid'];
    $result = $mysqli->prepare($query);
    if (!$result) {
        $msg = $mysqli->error;
        $success = False;
    } else {
        $result->execute();
        $result->bind_result($mid, $msgcontent, $user, $date);
        while ($result->fetch()) {
            $msg = array("mid" => $mid, "name" => $user, "time" => $date, "content" => $msgcontent);
            array_push($messages, $msg);
        }
        $result->close();
    }
    $data = array("name" => $name, "locid" => $locid, "distance" => 0.5, "img" => "http://media-cdn.tripadvisor.com/media/photo-w/06/60/30/a8/beautiful-day-in-august.jpg", "description" => $info, "start_time" => $stime, "end_time" => $etime, "organizer" => $organizer, "available" => $off_num, "total" => $on_num, "tags" => $tags, "joined_users" => $joined_users, "applied_user" => $applied_users, "messages" => $messages);
} else {
    $msg = "GET failed";
}
if ($success) {
    echo json_success($data);
} else {
    echo json_fail($msg);
}
示例#24
0
/**
 * Определим функцию, которая выполнит все действия - не будем лишними переменными засорять глобальное пространство
 */
function psExecuteAjaxAction()
{
    /*
     * Название действия должно быть в переменной запроса. Оно же - название класса, который будет выполнен.
     * Группа действия должны быть не обязательна, при определении действия группа нужна обязательно.
     */
    $actionName = RequestArrayAdapter::inst()->str(AJAX_ACTION_PARAM);
    $actionGroup = RequestArrayAdapter::inst()->str(AJAX_ACTION_GROUP_PARAM, 'client');
    if (!PsCheck::notEmptyString($actionName) || !PsCheck::notEmptyString($actionGroup)) {
        return json_error('Не передан код действия или его группа');
        //---
    }
    /*
     * Экземпляр класса действия - должен быть наследником AbstractAjaxAction
     */
    $action = null;
    /*
     * Поищем в проектных действиях, они для нас имеют больший приоритет
     */
    foreach (ConfigIni::ajaxActionsAbs($actionGroup) as $dirAbsPath) {
        $classPath = file_path($dirAbsPath, $actionName, PsConst::EXT_PHP);
        if (is_file($classPath)) {
            /*
             * Нашли файл. Загрузим и проверим, является ли он наследником AbstractAjaxAction
             */
            require_once $classPath;
            if (!PsUtil::isInstanceOf($actionName, AbstractAjaxAction::getClassName())) {
                continue;
                //---
            }
            $action = new $actionName();
            break;
            //---
        }
    }
    /*
     * Проверим, существует ли действие.
     * Для безопасности не будем писать детали обработки.
     */
    if (!$action || !$action instanceof AbstractAjaxAction) {
        return json_error('Действие не опеределено');
        //---
    }
    /*
     * Выполняем
     */
    $result = null;
    try {
        $result = $action->execute();
    } catch (Exception $e) {
        $result = $e->getMessage();
    }
    /*
     * Проверим результат
     */
    if ($result instanceof AjaxSuccess) {
        json_success($result->getJsParams());
    } else {
        json_error($result ? $result : 'Ошибка выполнения действия');
    }
}
示例#25
0
            } else {
                $addviewer = array('newid' => $newid, 'uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => TIMESTAMP);
                C::t('news_viewer')->insert($addviewer);
            }
        }
        $news['dateline'] = dgmdate($news[dateline], 'u');
        $data = $news;
        $message = 'success';
        break;
    default:
        $result = false;
        $message = '不存在的方法';
        break;
}
if ($result) {
    json_success($message, $data);
} else {
    json_error($message);
}
function catList($catid = 0, $sql, $param)
{
    global $_G;
    //查询
    $params = array('news');
    $params[] = 'news_viewer';
    $params[] = $_G['uid'];
    $params = $param ? array_merge_recursive($params, $param) : $params;
    foreach (C::t('news_cat')->fetch_all_by_pid($catid) as $value) {
        $catids = $common = '';
        $result[$value['catid']] = $value;
        $sun = C::t('news_cat')->fetch_all_by_pid($value['catid']);
示例#26
0
<?php

require_once 'AjaxTools.php';
json_success(GymManager::getInstance()->getProgrammsAsArrays());
示例#27
0
    if (!$result) {
        $msg = $mysqli->error;
        $success = False;
    } else {
        $result->execute();
        $result->bind_result($count);
        $result->fetch();
        $result->close();
        if ($count == 0) {
            $query = "INSERT INTO USER \n\t\t\t\t\t(name, gender, password) \n\t\t\t\t\tVALUES (?,?,?)";
            $result = $mysqli->prepare($query);
            if (!$result) {
                $msg = $mysqli->error;
                $success = False;
            }
            $result->bind_param('sss', $_GET['name'], $_GET['gender'], $_GET['password']);
            $result->execute();
            $result->close();
        } else {
            $msg = "User exists.";
            $success = False;
        }
    }
} else {
    $msg = "GET failed";
}
if ($success) {
    echo json_success();
} else {
    echo json_fail($msg);
}
示例#28
0
 function api_userInfo()
 {
     global $_G;
     $uid = $_GET['uid'];
     $user = C::t('user')->fetch_by_uid($uid);
     $user['avatar'] = $_G['config']['common']['home_url'] . '/' . avatar($uid, 'middle', true);
     json_success('success', $user);
 }
示例#29
0
 /**
  *
  * @SWG\Api(
  *   path="/project/{uuid}/invite",
  *   description="API for project actions",
  * @SWG\Operation(
  *    method="POST",
  *    type="ProjectInvite",
  *    summary="Invite a user to a project.  You can either invite a member of your team by passing their uuid or by sending them an external email",
  * @SWG\Parameter(
  *     name="uuid",
  *     description="UUID of the project",
  *     paramType="path",
  *     required=true,
  *     type="string"
  *     ),
  * @SWG\Parameter(
  *     name="user_uuid",
  *     description="The uuid of the user you would like to invite (optional)",
  *     paramType="form",
  *     required=false,
  *     type="string"
  *     ),
  * @SWG\Parameter(
  *     name="email",
  *     description="The email address of the external user you would like to invite (optional)",
  *     paramType="form",
  *     required=false,
  *     type="string"
  *     ),
  *   )
  * )
  *
  * Invites a user to a project
  * @param string $uuid
  */
 private function project_invite($uuid = '')
 {
     $this->load->helper('notification');
     $project = validate_project_uuid($uuid);
     /* Validate that the team owner has a valid subscription or free trial */
     validate_team_read($project->team_id);
     /* Validate that they are the team owner */
     validate_team_owner($project->team_id, get_user_id());
     $user_uuid = $this->post('user_uuid', TRUE);
     $email = $this->post('email', TRUE);
     /* Validate that they have a valid subscription and can add a project */
     validate_user_add(get_user_id(), $user_uuid);
     if ($email) {
         /** Look to see if there is an existing invite and resend it */
         $invite = $this->Project_Invite->get_for_email_project($email, $project->id);
         $invite_id = 0;
         if ($invite && !$invite->user_id) {
             $invite_id = $invite->id;
             $key = $invite->key;
         } else {
             $key = random_string('unique');
             $invite_id = $this->Project_Invite->add(array('email' => $email, 'project_id' => $project->id, 'key' => $key));
         }
         notify_project_invite_new_user($invite_id, get_user_id());
         json_success("User invited successfully", array('invite_id' => $invite_id, 'email' => $email, 'key' => $key));
         exit;
     } else {
         if ($user_uuid) {
             $user = validate_user_uuid($user_uuid);
             /* Validate that the user is on the project */
             if (!$this->User->is_on_team(get_team_id(), $user->id)) {
                 json_error('The user you are inviting is not on your team.  Please invite them to your team first.');
                 exit;
             }
             $invite = $this->Project_Invite->get_for_user_id_project($user->id, $project->id);
             if ($invite) {
                 $invite_id = $invite->id;
                 $key = $invite->key;
             } else {
                 $key = random_string('unique');
                 $invite_id = $this->Project_Invite->add(array('project_id' => $project->id, 'user_id' => $user->id, 'email' => $user->email, 'key' => $key));
             }
             notify_project_invite_new_user($invite_id, get_user_id());
             json_success("User invited successfully", array('invite_id' => $invite_id, 'email' => $email, 'key' => $key));
             exit;
         }
     }
     json_error("You must provide either a user id or an email address to invite to this project.");
 }
示例#30
0
 /**
  * Deletes a screen by its uuid
  * @param string $uuid
  */
 public function screen_delete($uuid = '')
 {
     $screen = validate_screen_uuid($uuid);
     /* Add the activity item to indicate that a screen was deleted */
     activity_delete_screen($screen->id, get_user_id());
     $this->Screen->delete($screen->id);
     json_success("Screen deleted successfully.");
 }