Example #1
0
function check_error($model)
{
    $error = get_error($model);
    if (!empty($error)) {
        return_value_json(false, 'msg', $error);
    }
}
function get_subscribed_topic_func()
{
    global $config, $db, $user, $auth, $mobiquo_config;
    // Only registered users can go beyond this point
    if (!$user->data['is_registered']) {
        return get_error(9);
    }
    $topic_list = array();
    if ($config['allow_topic_notify']) {
        $forbidden_forums = $auth->acl_getf('!f_read', true);
        $forbidden_forums = array_unique(array_keys($forbidden_forums));
        if (isset($mobiquo_config['hide_forum_id'])) {
            $forbidden_forums = array_unique(array_merge($forbidden_forums, $mobiquo_config['hide_forum_id']));
        }
        $sql_array = array('SELECT' => 't.*, 
                            f.forum_name,
                            u.user_avatar,
                            u.user_avatar_type', 'FROM' => array(TOPICS_WATCH_TABLE => 'tw', TOPICS_TABLE => 't', USERS_TABLE => 'u'), 'WHERE' => 'tw.user_id = ' . $user->data['user_id'] . '
                AND t.topic_id = tw.topic_id
                AND u.user_id = t.topic_last_poster_id
                AND ' . $db->sql_in_set('t.forum_id', $forbidden_forum_ary, true, true), 'ORDER_BY' => 't.topic_last_post_time DESC');
        $sql_array['LEFT_JOIN'] = array();
        $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 't.forum_id = f.forum_id');
        if ($config['allow_bookmarks']) {
            $sql_array['SELECT'] .= ', bm.topic_id as bookmarked';
            $sql_array['LEFT_JOIN'][] = array('FROM' => array(BOOKMARKS_TABLE => 'bm'), 'ON' => 'bm.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = bm.topic_id');
        }
        $sql = $db->sql_build_query('SELECT', $sql_array);
        $result = $db->sql_query_limit($sql, 20);
        $topic_list = array();
        while ($row = $db->sql_fetchrow($result)) {
            $forum_id = $row['forum_id'];
            $topic_id = isset($row['b_topic_id']) ? $row['b_topic_id'] : $row['topic_id'];
            // Replies
            $replies = $auth->acl_get('m_approve', $forum_id) ? $row['topic_replies_real'] : $row['topic_replies'];
            if ($row['topic_status'] == ITEM_MOVED && !empty($row['topic_moved_id'])) {
                $topic_id = $row['topic_moved_id'];
            }
            // Get folder img, topic status/type related information
            $folder_img = $folder_alt = $topic_type = '';
            topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);
            $short_content = get_short_content($row['topic_last_post_id']);
            if ($forum_id) {
                $topic_tracking = get_complete_topic_tracking($forum_id, $topic_id);
                $new_post = $topic_tracking[$topic_id] < $row['topic_last_post_time'] ? true : false;
            } else {
                $new_post = false;
            }
            $user_avatar_url = get_user_avatar_url($row['user_avatar'], $row['user_avatar_type']);
            $allow_change_type = $auth->acl_get('m_', $forum_id) || $user->data['is_registered'] && $user->data['user_id'] == $row['topic_poster'] ? true : false;
            $xmlrpc_topic = new xmlrpcval(array('forum_id' => new xmlrpcval($forum_id), 'forum_name' => new xmlrpcval(html_entity_decode($row['forum_name']), 'base64'), 'topic_id' => new xmlrpcval($topic_id), 'topic_title' => new xmlrpcval(html_entity_decode(strip_tags(censor_text($row['topic_title']))), 'base64'), 'reply_number' => new xmlrpcval(intval($replies), 'int'), 'view_number' => new xmlrpcval(intval($row['topic_views']), 'int'), 'short_content' => new xmlrpcval($short_content, 'base64'), 'post_author_id' => new xmlrpcval($row['topic_last_poster_id']), 'post_author_name' => new xmlrpcval(html_entity_decode($row['topic_last_poster_name']), 'base64'), 'new_post' => new xmlrpcval($new_post, 'boolean'), 'post_time' => new xmlrpcval(mobiquo_iso8601_encode($row['topic_last_post_time']), 'dateTime.iso8601'), 'icon_url' => new xmlrpcval($user_avatar_url), 'can_delete' => new xmlrpcval($auth->acl_get('m_delete', $forum_id), 'boolean'), 'can_bookmark' => new xmlrpcval($user->data['is_registered'] && $config['allow_bookmarks'], 'boolean'), 'isbookmarked' => new xmlrpcval($row['bookmarked'] ? true : false, 'boolean'), 'can_close' => new xmlrpcval($auth->acl_get('m_lock', $forum_id) || $auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $row['topic_poster'], 'boolean'), 'is_closed' => new xmlrpcval($row['topic_status'] == ITEM_LOCKED, 'boolean'), 'can_stick' => new xmlrpcval($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $row['topic_type'] != POST_STICKY, 'boolean')), 'struct');
            $topic_list[] = $xmlrpc_topic;
        }
        $db->sql_freeresult($result);
    }
    $topic_num = count($topic_list);
    $response = new xmlrpcval(array('total_topic_num' => new xmlrpcval($topic_num, 'int'), 'topics' => new xmlrpcval($topic_list, 'array')), 'struct');
    return new xmlrpcresp($response);
}
Example #3
0
 public function log($data)
 {
     $Sms = M('Sms');
     check_error($Sms);
     $Sms->create($data);
     check_error($Sms);
     if (false === $Sms->add()) {
         return_value_json(false, 'msg', get_error($Sms));
     }
 }
 /**
  * 保存参数设置
  */
 public function update()
 {
     $Setting = M('Setting');
     check_error($Setting);
     $hasData = $Setting->count() > 0;
     $Setting->create();
     $result = $hasData ? $Setting->where('1')->save() : $Setting->add();
     if ($result === false) {
         //TODO Log
         return_value_json(false, 'msg', get_error($Setting));
     }
     //TODO Log
     return_value_json(true);
 }
Example #5
0
 public function createUserHandle($email, $username, $password, $verified, $custom_register_fields, $profile, &$errors)
 {
     global $sourcedir, $context, $modSettings, $maintenance, $mmessage, $scripturl;
     checkSession();
     $_POST['emailActivate'] = true;
     if (empty($password)) {
         get_error('password cannot be empty');
     }
     if (!($maintenance == 0)) {
         get_error('Forum is in maintenance model or Tapatalk is disabled by forum administrator.');
     }
     if ($modSettings['registration_method'] == 0) {
         $register_mode = 'nothing';
     } else {
         if ($modSettings['registration_method'] == 1) {
             $register_mode = $verified ? 'nothing' : 'activation';
         } else {
             $register_mode = isset($modSettings['auto_approval_tp_user']) && $modSettings['auto_approval_tp_user'] && $verified ? 'nothing' : 'approval';
         }
     }
     $email = htmltrim__recursive(str_replace(array("\n", "\r"), '', $email));
     $username = htmltrim__recursive(str_replace(array("\n", "\r"), '', $username));
     $password = htmltrim__recursive(str_replace(array("\n", "\r"), '', $password));
     $group = 0;
     if ($register_mode == 'nothing' && isset($modSettings['tp_iar_usergroup_assignment'])) {
         $group = $modSettings['tp_iar_usergroup_assignment'];
     }
     $regOptions = array('interface' => $register_mode == 'approval' ? 'guest' : 'admin', 'username' => $username, 'email' => $email, 'password' => $password, 'password_check' => $password, 'check_reserved_name' => true, 'check_password_strength' => true, 'check_email_ban' => false, 'send_welcome_email' => isset($_POST['emailPassword']) || empty($password), 'require' => $register_mode, 'memberGroup' => (int) $group);
     define('mobi_register', 1);
     require_once $sourcedir . '/Subs-Members.php';
     $memberID = registerMember($regOptions);
     if (!empty($memberID)) {
         $context['new_member'] = array('id' => $memberID, 'name' => $username, 'href' => $scripturl . '?action=profile;u=' . $memberID, 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $memberID . '">' . $username . '</a>');
         $context['registration_done'] = sprintf($txt['admin_register_done'], $context['new_member']['link']);
         //update profile
         if (isset($profile) && !empty($profile) && is_array($profile)) {
             $profile_vars = array('avatar' => $profile['avatar_url']);
             updateMemberData($memberID, $profile_vars);
         }
         return get_user_by_name_or_email($username, false);
     }
     return null;
 }
 /**
  * 登录系统,并启动刷新线程
  */
 public function login($returnOnSuccess = true, $startRefreshThreadAfterLogin = true)
 {
     $setting = $this->_getSetting();
     if (empty($setting)) {
         return_value_json(false, 'msg', '系统错误:数据导入设置为空');
     }
     $re = $this->_curl_request(self::$base_url . 'bll/doLogin.aspx', array('s' => date('D M m Y H:i:s') . ' GMT 0800', 'username' => $setting['username'], 'userpwd' => $setting['password'], 'system' => 0), self::$base_url . 'login.aspx', false, self::$tempcookiefile);
     if ($re['success'] && $re['response'] === '1') {
         $index = $this->_curl_request(self::$base_url . 'index.aspx', null, self::$base_url . 'login.aspx', false, self::$tempcookiefile);
         $EVENTVALIDATION_pattern = '/<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="(.*)" \\/>/';
         preg_match_all($EVENTVALIDATION_pattern, $index['response'], $matches);
         if (!empty($matches) && !empty($matches[1])) {
             $setting['EVENTVALIDATION'] = $matches[1][0];
         }
         $VIEWSTATE_pattern = '/<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="(.*)" \\/>/';
         preg_match_all($VIEWSTATE_pattern, $index['response'], $matches2);
         if (!empty($matches2) && !empty($matches2[1])) {
             $setting['VIEWSTATE'] = $matches2[1][0];
         }
         $cishu = $this->_curl_request(self::$base_url . 'bll/doIndex.aspx', array('s' => date('D M m Y H:i:s') . ' GMT 0800', 'cishu' => 0), self::$base_url . 'index.aspx', false, self::$tempcookiefile);
         if ($cishu['success'] && !empty($cishu['response'])) {
             $setting['countleft'] = $cishu['response'] + 0;
         }
         $setting['logined'] = 1;
         $setting['last_login'] = date('Y-m-d H:i:s');
         $DataImport = M('DataImport1');
         check_error($DataImport);
         if (false === $DataImport->where('1')->save($setting)) {
             return_value_json(false, 'msg', get_error($DataImport));
         }
         if ($startRefreshThreadAfterLogin) {
             $this->_startRefreshThread();
         }
         if ($returnOnSuccess) {
             return_value_json(true);
         }
     } else {
         return_value_json(false, 'msg', '登录失败:' . $re['response']);
     }
 }
Example #7
0
 function edit($id = null)
 {
     if (empty($id) or !$this->fuel_auth->module_has_action('save')) {
         show_404();
     }
     if ($this->input->post($this->model->key_field())) {
         $this->model->on_before_post();
         $posted = $this->_process();
         if ($this->model->save($posted)) {
             // process $_FILES
             if (!$this->_process_uploads($posted)) {
                 $this->session->set_flashdata('error', get_error());
                 redirect(fuel_uri($this->module_uri . '/edit/' . $id));
             }
             $this->model->on_after_post($posted);
             if (!$this->model->is_valid()) {
                 add_errors($this->model->get_errors());
             } else {
                 // archive data
                 if ($this->archivable) {
                     $this->model->archive($id, $this->model->cleaned_data());
                 }
                 $data = $this->model->find_one_array(array($this->model->table_name() . '.' . $this->model->key_field() => $id));
                 $msg = lang('module_edited', $this->module_name, $data[$this->display_field]);
                 $this->logs_model->logit($msg);
                 $this->session->set_flashdata('success', $this->lang->line('data_saved'));
                 $this->_clear_cache();
                 redirect(fuel_uri($this->module_uri . '/edit/' . $id));
             }
         }
     }
     $vars = $this->_form($id);
     $this->_render($this->views['create_edit'], $vars);
 }
    $row = mysql_fetch_object($abfrage);
}
if (isset($_POST['submit'])) {
    $title = $_POST['title'];
    $news = $_POST['news'];
    $cat = $_POST['cat'];
    $autor = $_SESSION['SESS_FIRST_NAME'];
    if (empty($title) || empty($news) || empty($autor)) {
        echo get_error('Bitte Danke alle benoetigten Felder ausfuellen!');
    } else {
        $eintragen = mysql_query("INSERT INTO w_news (autor, title, news, cat, date) VALUES ('{$autor}','{$title}','{$news}','{$cat}', now())");
    }
    if ($eintragen) {
        header("Location: member-index.php");
    } else {
        echo get_error('Der Eintrag war leider nicht erfolgreich! ".mysql_error()."');
    }
}
?>
<script type="text/javascript">
/* Funtionn BBCode */
var n = 1;
function add(code) {
         document.getElementById('bbcode').news.value += " " + code ;
}
</script>



		<!-- CONTENT -->
Example #9
0
function send_error($type, $info = null)
{
    $error = get_error($type);
    if ($info != null) {
        $error['message'] = $error['message'] . ' -' . $info;
    }
    send_json($error);
}
Example #10
0
function draw_site_error()
{
    $error_text = get_error();
    if ($error_text) {
        printf('<p class="error">%s</p>', $error_text);
    }
}
                    if (isHttpUrl($_GET['url']) === false) {
                        $response = array('error' => 'Only http scheme and https scheme are allowed');
                    } else {
                        if (preg_match('#[^A-Za-z0-9_[.]\\[\\]]#', $param_callback) !== 0) {
                            $response = array('error' => 'Parameter "callback" contains invalid characters');
                            $param_callback = JSLOG;
                        } else {
                            if (createFolder() === false) {
                                $err = get_error();
                                $response = array('error' => 'Can not create directory' . ($err !== null && isset($err['message']) && strlen($err['message']) > 0 ? ': ' . $err['message'] : ''));
                                $err = null;
                            } else {
                                $http_port = (int) $_SERVER['SERVER_PORT'];
                                $tmp = createTmpFile($_GET['url'], false);
                                if ($tmp === false) {
                                    $err = get_error();
                                    $response = array('error' => 'Can not create file' . ($err !== null && isset($err['message']) && strlen($err['message']) > 0 ? ': ' . $err['message'] : ''));
                                    $err = null;
                                } else {
                                    $response = downloadSource($_GET['url'], $tmp['source'], 0);
                                    fclose($tmp['source']);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
if (is_array($response) && isset($response['mime']) && strlen($response['mime']) > 0) {
Example #12
0
function after_action_create_message()
{
    global $context;
    if (!empty($context['send_log']['failed'])) {
        foreach ($context['send_log']['failed'] as $error_text) {
            get_error($error_text);
        }
    }
}
Example #13
0
function mob_update_password($rpcmsg)
{
    global $txt, $modSettings;
    global $cookiename, $context;
    global $sourcedir, $scripturl, $db_prefix;
    global $ID_MEMBER, $user_info;
    global $newpassemail, $user_profile, $validationCode;
    loadLanguage('Profile');
    // Start with no updates and no errors.
    $profile_vars = array();
    $post_errors = array();
    $good_password = false;
    // reset directly with tapatalk id credential
    if ($rpcmsg->getParam(2)) {
        $_POST['passwrd1'] = $rpcmsg->getParam(0) ? $rpcmsg->getScalarValParam(0) : '';
        $_POST['passwrd1'] = utf8ToAscii($_POST['passwrd1']);
        $token = $rpcmsg->getParam(1) ? $rpcmsg->getScalarValParam(1) : '';
        $code = $rpcmsg->getParam(2) ? $rpcmsg->getScalarValParam(2) : '';
        // verify Tapatalk Authorization
        if ($token && $code) {
            $ttid = TapatalkSsoVerification($token, $code);
            if ($ttid && $ttid->result) {
                $tapatalk_id_email = $ttid->email;
                if (empty($ID_MEMBER) && ($ID_MEMBER = emailExists($tapatalk_id_email))) {
                    loadMemberData($ID_MEMBER, false, 'profile');
                    $user_info = $user_profile[$ID_MEMBER];
                    $user_info['is_guest'] = false;
                    $user_info['is_admin'] = $user_info['id_group'] == 1 || in_array(1, explode(',', $user_info['additionalGroups']));
                    $user_info['id'] = $ID_MEMBER;
                    if (empty($user_info['additionalGroups'])) {
                        $user_info['groups'] = array($user_info['ID_GROUP'], $user_info['ID_POST_GROUP']);
                    } else {
                        $user_info['groups'] = array_merge(array($user_info['ID_GROUP'], $user_info['ID_POST_GROUP']), explode(',', $user_info['additionalGroups']));
                    }
                    $user_info['groups'] = array_unique(array_map('intval', $user_info['groups']));
                    loadPermissions();
                }
                if (strtolower($user_info['emailAddress']) == strtolower($tapatalk_id_email) && $user_info['ID_GROUP'] != 1) {
                    $good_password = true;
                }
            }
        }
        if (!$good_password) {
            get_error('Failed to update password');
        }
    } else {
        $_POST['oldpasswrd'] = $rpcmsg->getParam(0) ? $rpcmsg->getScalarValParam(0) : '';
        $_POST['passwrd1'] = $rpcmsg->getParam(1) ? $rpcmsg->getScalarValParam(1) : '';
        $_POST['passwrd1'] = utf8ToAscii($_POST['passwrd1']);
    }
    // Clean up the POST variables.
    $_POST = htmltrim__recursive($_POST);
    $_POST = stripslashes__recursive($_POST);
    $_POST = htmlspecialchars__recursive($_POST);
    $_POST = addslashes__recursive($_POST);
    $memberResult = loadMemberData($ID_MEMBER, false, 'profile');
    if (!is_array($memberResult)) {
        fatal_lang_error(453, false);
    }
    $memID = $ID_MEMBER;
    $context['user']['is_owner'] = true;
    isAllowedTo(array('manage_membergroups', 'profile_identity_any', 'profile_identity_own'));
    // You didn't even enter a password!
    if (trim($_POST['oldpasswrd']) == '' && !$good_password) {
        fatal_error($txt['profile_error_no_password']);
    }
    // Since the password got modified due to all the $_POST cleaning, lets undo it so we can get the correct password
    $_POST['oldpasswrd'] = addslashes(un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])));
    // Does the integration want to check passwords?
    if (isset($modSettings['integrate_verify_password']) && function_exists($modSettings['integrate_verify_password'])) {
        if (call_user_func($modSettings['integrate_verify_password'], $user_profile[$memID]['memberName'], $_POST['oldpasswrd'], false) === true) {
            $good_password = true;
        }
    }
    // Bad password!!!
    if (!$good_password && $user_info['passwd'] != sha1(strtolower($user_profile[$memID]['memberName']) . $_POST['oldpasswrd'])) {
        fatal_error($txt['profile_error_bad_password']);
    }
    // Let's get the validation function into play...
    require_once $sourcedir . '/Subs-Auth.php';
    $passwordErrors = validatePassword($_POST['passwrd1'], $user_info['username'], array($user_info['name'], $user_info['email']));
    // Were there errors?
    if ($passwordErrors != null) {
        fatal_error($txt['profile_error_password_' . $passwordErrors]);
    }
    // Set up the new password variable... ready for storage.
    $profile_vars['passwd'] = '\'' . sha1(strtolower($user_profile[$memID]['memberName']) . un_htmlspecialchars(stripslashes($_POST['passwrd1']))) . '\'';
    // If we've changed the password, notify any integration that may be listening in.
    if (isset($modSettings['integrate_reset_pass']) && function_exists($modSettings['integrate_reset_pass'])) {
        call_user_func($modSettings['integrate_reset_pass'], $user_profile[$memID]['memberName'], $user_profile[$memID]['memberName'], $_POST['passwrd1']);
    }
    updateMemberData($memID, $profile_vars);
    require_once $sourcedir . '/Subs-Auth.php';
    setLoginCookie(60 * $modSettings['cookieTime'], $memID, sha1(sha1(strtolower($user_profile[$memID]['memberName']) . un_htmlspecialchars(stripslashes($_POST['passwrd1']))) . $user_profile[$memID]['passwordSalt']));
    $response = array('result' => new xmlrpcval(true, 'boolean'), 'result_text' => new xmlrpcval('', 'base64'));
    return new xmlrpcresp(new xmlrpcval($response, 'struct'));
}
Example #14
0
/**
 * Callback to for proxy page
 */
function ac_templates_proxy()
{
    drupal_add_http_header('Content-Type', 'application/javascript');
    if (isset($_GET['callback']) && strlen($_GET['callback']) > 0) {
        $param_callback = $_GET['callback'];
    }
    if (isset($_SERVER['HTTP_HOST']) === FALSE || strlen($_SERVER['HTTP_HOST']) === 0) {
        $response = array('error' => 'The client did not send the Host header');
    } else {
        if (isset($_SERVER['SERVER_PORT']) === FALSE) {
            $response = array('error' => 'The Server-proxy did not send the PORT (configure PHP)');
        } else {
            if (MAX_EXEC < 10) {
                $response = array('error' => 'Execution time is less 15 seconds, configure this with ini_set/set_time_limit or "php.ini" (if safe_mode is enabled), recommended time is 30 seconds or more');
            } else {
                if (MAX_EXEC <= TIMEOUT) {
                    $response = array('error' => 'The execution time is not configured enough to TIMEOUT in SOCKET, configure this with ini_set/set_time_limit or "php.ini" (if safe_mode is enabled), recommended that the "max_execution_time =;" be a minimum of 5 seconds longer or reduce the TIMEOUT in "define(\'TIMEOUT\', ' . TIMEOUT . ');"');
                } else {
                    if (isset($_GET['url']) === FALSE || strlen($_GET['url']) === 0) {
                        $response = array('error' => 'No such parameter "url"');
                    } else {
                        if (isHttpUrl($_GET['url']) === FALSE) {
                            $response = array('error' => 'Only http scheme and https scheme are allowed');
                        } else {
                            if (preg_match('#[^A-Za-z0-9_[.]\\[\\]]#', $param_callback) !== 0) {
                                $response = array('error' => 'Parameter "callback" contains invalid characters');
                                $param_callback = JSLOG;
                            } else {
                                if (createFolder() === FALSE) {
                                    $err = get_error();
                                    $response = array('error' => 'Can not create directory' . ($err !== NULL && isset($err['message']) && strlen($err['message']) > 0 ? ': ' . $err['message'] : ''));
                                    $err = NULL;
                                } else {
                                    $http_port = (int) $_SERVER['SERVER_PORT'];
                                    $tmp = createTmpFile($_GET['url'], FALSE);
                                    if ($tmp === FALSE) {
                                        $err = get_error();
                                        $response = array('error' => 'Can not create file' . ($err !== NULL && isset($err['message']) && strlen($err['message']) > 0 ? ': ' . $err['message'] : ''));
                                        $err = NULL;
                                    } else {
                                        $response = downloadSource($_GET['url'], $tmp['source'], 0);
                                        fclose($tmp['source']);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if (is_array($response) && isset($response['mime']) && strlen($response['mime']) > 0) {
        clearstatcache();
        if (FALSE === file_exists($tmp['location'])) {
            $response = array('error' => 'Request was downloaded, but file can not be found, try again');
        } else {
            if (filesize($tmp['location']) < 1) {
                $response = array('error' => 'Request was downloaded, but there was some problem and now the file is empty, try again');
            } else {
                $extension = str_replace(array('image/', 'text/', 'application/'), '', $response['mime']);
                $extension = str_replace(array('windows-bmp', 'ms-bmp'), 'bmp', $extension);
                $extension = str_replace(array('svg+xml', 'svg-xml'), 'svg', $extension);
                $extension = str_replace('xhtml+xml', 'xhtml', $extension);
                $extension = str_replace('jpeg', 'jpg', $extension);
                $locationFile = preg_replace('#[.][0-9_]+$#', '.' . $extension, $tmp['location']);
                if (file_exists($locationFile)) {
                    unlink($locationFile);
                }
                if (rename($tmp['location'], $locationFile)) {
                    //set cache
                    setHeaders(FALSE);
                    remove_old_files();
                    if (CROSS_DOMAIN === 1) {
                        $mime = JsonEncodeString($response['mime'], TRUE);
                        $mime = $response['mime'];
                        if ($response['encode'] !== NULL) {
                            $mime .= ';charset=' . JsonEncodeString($response['encode'], TRUE);
                        }
                        $tmp = $response = NULL;
                        if (strpos($mime, 'image/svg') !== 0 && strpos($mime, 'image/') === 0) {
                            echo $param_callback, '("data:', $mime, ';base64,', base64_encode(file_get_contents($locationFile)), '");';
                        } else {
                            echo $param_callback, '("data:', $mime, ',', asciiToInline(file_get_contents($locationFile)), '");';
                        }
                    } else {
                        $tmp = $response = NULL;
                        $dir_name = dirname($_SERVER['SCRIPT_NAME']);
                        if ($dir_name === '\\/' || $dir_name === '\\') {
                            $dir_name = '';
                        }
                        if (strpos($locationFile, 'public://') === FALSE) {
                            $parse_file_location = explode('/', $locationFile);
                            $locationFile = sprintf('%s/%s', PATH, end($parse_file_location));
                        }
                        echo $param_callback, '(', JsonEncodeString(file_create_url($locationFile)), ');';
                    }
                    exit;
                } else {
                    $response = array('error' => 'Failed to rename the temporary file');
                }
            }
        }
    }
    if (is_array($tmp) && isset($tmp['location']) && file_exists($tmp['location'])) {
        //remove temporary file if an error occurred
        unlink($tmp['location']);
    }
    //errors
    setHeaders(TRUE);
    //no-cache
    remove_old_files();
    echo $param_callback, '(', JsonEncodeString('error: html2canvas-proxy-php: ' . $response['error']), ');';
}
Example #15
0
 public function delete()
 {
     if (!$this->isPost()) {
         return_value_json(false, 'msg', '非法的调用');
     }
     $paths = json_decode(file_get_contents("php://input"));
     if (!is_array($paths)) {
         $paths = array($paths);
     }
     $id = array();
     foreach ($paths as $path) {
         $id[] = $path->id;
     }
     if (count($id) > 0) {
         $PathArea = M('PathArea');
         check_error($PathArea);
         if (false === $PathArea->where("`id` IN (" . implode(",", $id) . ")")->delete()) {
             return_value_json(false, 'msg', get_error($PathArea));
         }
         $Point = M('Point');
         check_error($Point);
         if (false === $Point->where("`path_area_id` IN (" . implode(",", $id) . ")")->delete()) {
             return_value_json(false, 'msg', '删除路径的顶点时出错:' . get_error($Point));
         }
     }
     return_value_json(true);
 }
 function action($action)
 {
     $instance = portfolio_instance($this->plugin);
     $current = $instance->get('visible');
     if (empty($current) && $instance->instance_sanity_check()) {
         return get_error('cannotsetvisible', 'portfolio');
     }
     switch ($action) {
         case 'enable':
             $visible = 1;
             break;
         case 'disable':
             $visible = 0;
             break;
     }
     $instance->set('visible', $visible);
     $instance->save();
     return 0;
 }
Example #17
0
 public function http_delete($url)
 {
     list($response, $response_info) = $this->do_curl("DELETE", $url);
     if ($response_info["http_code"] === 204) {
         return NULL;
     }
     throw new BookalopeException(get_error($response));
 }
Example #18
0
    // 数据库配置
    require_once AROOT . 'config' . DS . 'app.php';
    // 应用配置
    require_once AROOT . 'lib' . DS . 'functions.php';
    // 公用函数
    if (is_devmode()) {
        ini_set('display_errors', true);
        error_reporting(E_ALL);
    }
    $force_build = !on_sae() && is_devmode() && c('buildeverytime');
    load_route_file($force_build);
} catch (PDOException $e) {
    $error = get_error('DATABASE');
    $error['message'] = $error['message'] . '- ' . $e->getMessage();
    send_json($error);
} catch (\Lazyphp\Core\RestException $e) {
    $class_array = explode('\\', get_class($e));
    $class = t(end($class_array));
    $prefix = strtoupper(rremove($class, 'Exception'));
    $error = get_error($prefix);
    $error['message'] = $error['message'] . '- ' . $e->getMessage();
    send_json($error);
} catch (\Exception $e) {
    // alway send json format
    $class_array = explode('\\', get_class($e));
    $class = t(end($class_array));
    $prefix = strtoupper(rremove($class, 'Exception'));
    $error = get_error($prefix);
    $error['message'] = $error['message'] . '- ' . $e->getMessage();
    send_json($error);
}
Example #19
0
 public function delete()
 {
     if (!$this->isPost()) {
         return_value_json(false, 'msg', '非法的调用');
     }
     $vehicles = json_decode(file_get_contents("php://input"));
     if (!is_array($vehicles)) {
         $vehicles = array($vehicles);
     }
     $Vehicle = D('Vehicle');
     foreach ($vehicles as $vehicle) {
         if (false === $Vehicle->where("`id`='" . $vehicle->id . "'")->delete()) {
             //保存日志
             R('Log/adduserlog', array('删除车辆资料', '删除车辆资料失败', '失败:系统错误', '删除车辆[' . $vehicle->number . ']时出错:' . get_error($Vehicle)));
             return_value_json(false, 'msg', '删除车辆[' . $vehicle->number . ']时出错:' . get_error($Vehicle));
         }
         //保存日志
         R('Log/adduserlog', array('删除车辆资料', '删除车辆资料成功', '成功', '车牌号码:' . $vehicle->number));
     }
     return_value_json(true);
 }
function get_unread_topic_func($xmlrpc_params)
{
    global $db, $auth, $user, $userinfo, $prefix, $config, $mobiquo_config, $phpbb_home;
    $params = php_xmlrpc_decode($xmlrpc_params);
    $start_num = 0;
    $end_num = 19;
    if (isset($params[0]) && is_int($params[0])) {
        $start_num = $params[0];
    }
    // get end index of topic from parameters
    if (isset($params[1]) && is_int($params[1])) {
        $end_num = $params[1];
    }
    // check if topic index is out of range
    if ($start_num > $end_num) {
        return get_error(5);
    }
    // return at most 50 topics
    if ($end_num - $start_num >= 50) {
        $end_num = $start_num + 49;
    }
    $sql_limit = $end_num - $start_num + 1;
    $not_in_fid = '';
    //$ex_fid_ary = array_unique(array_merge(array_keys($auth->acl_getf('!f_read', true)), array_keys($auth->acl_getf('!f_search', true))));
    //if (isset($mobiquo_config['hide_forum_id']))
    //{
    //$ex_fid_ary = array_unique(array_merge($ex_fid_ary, $mobiquo_config['hide_forum_id']));
    //}
    //$not_in_fid = (sizeof($ex_fid_ary)) ? 'WHERE ' . $db->sql_in_set('f.forum_id', $ex_fid_ary, true) . ';
    $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, forum_order
		FROM ' . $prefix . '_bbforums
		' . $not_in_fid . '
		ORDER BY forum_order';
    $result = $db->sql_query($sql);
    $db->sql_freeresult($result);
    // find out in which forums the user is allowed to view approved posts
    $sql = 'SELECT t.topic_id, t.forum_id, t.topic_last_post_id, p.post_time AS topic_last_post_time FROM ' . $prefix . '_bbtopics t, ' . $prefix . '_bbposts p
		WHERE p.topic_id = t.topic_id AND p.post_time > ' . $userinfo['user_lastvisit'] . ' ORDER BY topic_last_post_time DESC LIMIT ' . $sql_limit . '';
    //if ($fh = fopen('log.txt', 'w'))
    //{
    //fwrite($fh, $userinfo['username']);
    //fclose($fh);
    //}
    $result = $db->sql_query($sql);
    $unread_tids = array();
    while ($row = $db->sql_fetchrow($result)) {
        $topic_id = $row['topic_id'];
        //$forum_id = $row['forum_id'];
        //$topic_tracking = get_complete_topic_tracking($forum_id, $topic_id);
        //if ($topic_tracking[$topic_id] < $row['topic_last_post_time'])
        //{
        $unread_tids[] = $topic_id;
        //}
    }
    $db->sql_freeresult($result);
    $topic_list = array();
    $ur_tids = implode(",", $unread_tids);
    if (count($unread_tids)) {
        $sql = 'SELECT f.forum_id,
			f.forum_name,
			t.topic_id,
			t.topic_title,
			t.topic_replies,
			t.topic_views,
			t.topic_poster,
			t.topic_status,
			t.topic_type,
			t.topic_last_post_id,
			u.user_avatar,
			u.user_avatar_type,
			tw.notify_status,
			p.post_time AS topic_last_post_time,
			u.username AS topic_last_poster_name,
			p.poster_id AS topic_last_poster_id
			FROM ' . $prefix . '_bbtopics t
			LEFT JOIN ' . $prefix . '_bbposts p ON (p.post_id = t.topic_last_post_id)
			LEFT JOIN ' . $prefix . '_bbforums f ON (t.forum_id = f.forum_id)
			LEFT JOIN ' . $prefix . '_users u ON (p.poster_id = u.user_id)
			LEFT JOIN ' . $prefix . '_bbtopics_watch tw ON (tw.user_id = ' . $userinfo['user_id'] . ' AND t.topic_id = tw.topic_id)
			WHERE t.topic_id IN (' . $ur_tids . ')
			ORDER BY topic_last_post_time DESC LIMIT ' . $sql_limit . '';
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            $topic_id = $row['topic_id'];
            $forum_id = $row['forum_id'];
            $short_content = get_short_content($row['topic_last_post_id']);
            $user_avatar_url = get_user_avatar_url($row['user_avatar'], $row['user_avatar_type']);
            //$allow_change_type = ($auth->acl_get('m_', $forum_id) || ($user->data['is_registered'] && $user->data['user_id'] == $row['topic_poster'])) ? true : false;
            $xmlrpc_topic = new xmlrpcval(array('forum_id' => new xmlrpcval($forum_id), 'forum_name' => new xmlrpcval(html_entity_decode($row['forum_name']), 'base64'), 'topic_id' => new xmlrpcval($topic_id), 'topic_title' => new xmlrpcval(html_entity_decode(strip_tags($row['topic_title'])), 'base64'), 'reply_number' => new xmlrpcval($row['topic_replies'], 'int'), 'new_post' => new xmlrpcval(true, 'boolean'), 'view_number' => new xmlrpcval($row['topic_views'], 'int'), 'short_content' => new xmlrpcval($short_content, 'base64'), 'post_author_id' => new xmlrpcval($row['topic_last_poster_id']), 'post_author_name' => new xmlrpcval(html_entity_decode($row['topic_last_poster_name']), 'base64'), 'post_time' => new xmlrpcval(mobiquo_iso8601_encode($row['topic_last_post_time']), 'dateTime.iso8601'), 'icon_url' => new xmlrpcval($user_avatar_url), 'can_delete' => new xmlrpcval(false, 'boolean'), 'can_subscribe' => new xmlrpcval(($config['email_enable'] || $config['jab_enable']) && $config['allow_topic_notify'] && $user->data['is_registered'], 'boolean'), 'can_bookmark' => new xmlrpcval($user->data['is_registered'] && $config['allow_bookmarks'], 'boolean'), 'issubscribed' => new xmlrpcval(!is_null($row['notify_status']) && $row['notify_status'] !== '' ? true : false, 'boolean'), 'is_subscribed' => new xmlrpcval(!is_null($row['notify_status']) && $row['notify_status'] !== '' ? true : false, 'boolean'), 'isbookmarked' => new xmlrpcval($row['bookmarked'] ? true : false, 'boolean'), 'can_close' => new xmlrpcval(false, 'boolean'), 'is_closed' => new xmlrpcval($row['topic_status'] == ITEM_LOCKED, 'boolean'), 'can_stick' => new xmlrpcval(false, 'boolean')), 'struct');
            $topic_list[] = $xmlrpc_topic;
        }
        $db->sql_freeresult($result);
    }
    $response = new xmlrpcval(array('total_topic_num' => new xmlrpcval(count($unread_tids), 'int'), 'topics' => new xmlrpcval($topic_list, 'array')), 'struct');
    return new xmlrpcresp($response);
}
Example #21
0
 /**
  * delete操作根据post数据删除一个用户角色,一并删除相关的角色权限。
  */
 public function delete()
 {
     if (!$this->isPost()) {
         return_value_json(false, 'msg', '非法的调用');
     }
     $roles = json_decode(file_get_contents("php://input"));
     if (!is_array($roles)) {
         $roles = array($roles);
     }
     $Role = M('Role');
     check_error($Role);
     $RolePrivilege = M('RolePrivilege');
     check_error($RolePrivilege);
     foreach ($roles as $role) {
         //删除角色
         if (false === $Role->where("`id`='" . $role->id . "'")->delete()) {
             //保存日志
             R('Log/adduserlog', array('删除角色', '删除角色失败', '失败:系统错误', '删除角色[' . $role->name . ']时出错:' + get_error($Role)));
             return_value_json(false, 'msg', '删除角色[' . $role->name . ']时出错:' + get_error($Role));
         }
         //删除角色权限
         if (false === $RolePrivilege->where("`role_id`='" . $role->id . "'")->delete()) {
             //保存日志
             R('Log/adduserlog', array('删除角色', '删除角色失败', '失败:系统错误', '删除角色[' . $role->name . ']的权限时出错:' + get_error($Role)));
             return_value_json(false, 'msg', '删除角色[' . $role->name . ']的权限时出错:' + get_error($Role));
         }
         //保存日志
         R('Log/adduserlog', array('删除角色', '删除角色成功', '成功', '角色名称:' . $role->name));
     }
     return_value_json(true);
 }
Example #22
0
 public function delete()
 {
     if (!$this->isPost()) {
         return_value_json(false, 'msg', '非法的调用');
     }
     $users = json_decode(file_get_contents("php://input"));
     if (!is_array($users)) {
         $users = array($users);
     }
     $User = D('User');
     check_error($User);
     $ManageTarget = M('ManageTarget');
     check_error($ManageTarget);
     foreach ($users as $user) {
         if (false === $ManageTarget->where("`user_id`='{$user->id}'")->delete()) {
             //保存日志
             R('Log/adduserlog', array('删除用户', '删除用户管理对象失败', '失败:系统错误', '删除用户管理对象时出错:' . get_error($ManageTarget)));
             return_value_json(false, 'msg', '删除用户管理对象时出错:' . get_error($ManageTarget));
         }
         if (false === $User->where("`id`='" . $user->id . "'")->delete()) {
             //保存日志
             R('Log/adduserlog', array('删除用户', '删除用户失败', '失败:系统错误', '删除用户出错:' + get_error($User)));
             return_value_json(false, 'msg', '删除删除用户出错:' + get_error($User));
         }
         //保存日志
         R('Log/adduserlog', array('删除用户', '删除用户成功', '成功', '被删除的用户' . $user->name));
     }
     return_value_json(true);
 }
Example #23
0
 public function log($data)
 {
     if (false === $this->addAll($data)) {
         return_value_json(false, 'msg', get_error($this));
     }
 }
Example #24
0
/*
	$app->get('/wines/', 'getWines');
	$app->post('/wines/', 'insertWine');
	$app->get('/wines/:id',  'getWine');
	$app->get('/wines/search/:query', 'findByName');
	$app->put('/wines/:id', 'updateWine');
	$app->delete('/wines/:id',   'deleteWine');
*/
/**
 * Método que se encarga de la validación de la api key
 */
$app->hook('slim.before.dispatch', function () use($app, $db) {
    //obtengo el parámetro de la key que me tiene que venir como parámetro en el header
    $headers = apache_request_headers();
    $keyToCheck = $headers['Authorization'];
    //compruebo la api key
    $apiUsage = new api_usage($db);
    $api_filter = array();
    add_filter($api_filter, "apikey", $keyToCheck);
    add_filter($api_filter, "enabled", 1);
    $authorized = $apiUsage->authorize($api_filter);
    $development = unserialize(DEVELOPMENT);
    //si no me autorizan el acceso, adios
    if (!$authorized->resultado && !$development['enabled']) {
        //key is false
        $app->halt('403', get_error(1));
        // or redirect, or other something
    }
});
//ejecutamos la api
$app->run();
Example #25
0
}
error_reporting(MOBIQUO_DEBUG);
restore_error_handler();
register_shutdown_function('shutdown');
if (empty($request_params)) {
    $request_params[0] = '';
}
$taptalk_from = '';
if (strpos($_SERVER['HTTP_USER_AGENT'], 'BYO') !== false) {
    $taptalk_from = 'BYO';
}
$_SERVER['QUERY_STRING'] = 'method=' . $request_method . '&params=' . $request_params[0] . '&from=' . $taptalk_from;
define("IN_MYBB", 1);
require_once './global.php';
if (!isset($cache->cache['plugins']['active']['tapatalk']) && $request_method != 'get_config') {
    get_error('Tapatalk will not work on this forum before forum admin Install & Activate tapatalk plugin on forum side!');
}
// hide forum option
if ($mybb->settings['tapatalk_hide_forum']) {
    $t_hfids = array_map('intval', explode(',', $mybb->settings['tapatalk_hide_forum']));
    if (empty($forum_cache)) {
        cache_forums();
    }
    foreach ($t_hfids as $t_hfid) {
        $forum_cache[$t_hfid]['active'] = 0;
    }
}
if ($request_method && isset($server_param[$request_method])) {
    if ($function_file_name == 'thankyoulike' && file_exists('thankyoulike.php')) {
        include 'thankyoulike.php';
    } else {
function login_forum_func($xmlrpc_params)
{
    global $db, $auth, $user, $config;
    $params = php_xmlrpc_decode($xmlrpc_params);
    $forum_id = intval($params[0]);
    $password = $params[1];
    if (!$forum_id) {
        return get_error(1);
    }
    $sql_from = FORUMS_TABLE . ' f';
    $lastread_select = '';
    // Grab appropriate forum data
    if ($config['load_db_lastread'] && $user->data['is_registered']) {
        $sql_from .= ' LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . '
            AND ft.forum_id = f.forum_id)';
        $lastread_select .= ', ft.mark_time';
    }
    if ($user->data['is_registered']) {
        $sql_from .= ' LEFT JOIN ' . FORUMS_WATCH_TABLE . ' fw ON (fw.forum_id = f.forum_id AND fw.user_id = ' . $user->data['user_id'] . ')';
        $lastread_select .= ', fw.notify_status';
    }
    $sql = "SELECT f.* {$lastread_select}\r\n        FROM {$sql_from}\r\n        WHERE f.forum_id = {$forum_id}";
    $result = $db->sql_query($sql);
    $forum_data = $db->sql_fetchrow($result);
    $db->sql_freeresult($result);
    if (!$forum_data) {
        return get_error(3);
    }
    // Configure style, language, etc.
    //$user->setup('viewforum', $forum_data['forum_style']);
    // Permissions check
    if (!$auth->acl_gets('f_list', 'f_read', $forum_id) || $forum_data['forum_type'] == FORUM_LINK && $forum_data['forum_link'] && !$auth->acl_get('f_read', $forum_id)) {
        if ($user->data['user_id'] != ANONYMOUS) {
            return get_error(2);
        }
        return get_error(9);
    }
    $login_status = false;
    // Forum is passworded ... check whether access has been granted to this
    // user this session, if not show login box
    if ($forum_data['forum_password']) {
        $sql = 'SELECT forum_id
            FROM ' . FORUMS_ACCESS_TABLE . '
            WHERE forum_id = ' . $forum_data['forum_id'] . '
                AND user_id = ' . $user->data['user_id'] . "\r\n                AND session_id = '" . $db->sql_escape($user->session_id) . "'";
        $result = $db->sql_query($sql);
        $row = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        if ($row) {
            $login_status = true;
        } elseif ($password) {
            // Remove expired authorised sessions
            $sql = 'SELECT f.session_id
                FROM ' . FORUMS_ACCESS_TABLE . ' f
                LEFT JOIN ' . SESSIONS_TABLE . ' s ON (f.session_id = s.session_id)
                WHERE s.session_id IS NULL';
            $result = $db->sql_query($sql);
            if ($row = $db->sql_fetchrow($result)) {
                $sql_in = array();
                do {
                    $sql_in[] = (string) $row['session_id'];
                } while ($row = $db->sql_fetchrow($result));
                // Remove expired sessions
                $sql = 'DELETE FROM ' . FORUMS_ACCESS_TABLE . '
                    WHERE ' . $db->sql_in_set('session_id', $sql_in);
                $db->sql_query($sql);
            }
            $db->sql_freeresult($result);
            if (phpbb_check_hash($password, $forum_data['forum_password'])) {
                $sql_ary = array('forum_id' => (int) $forum_data['forum_id'], 'user_id' => (int) $user->data['user_id'], 'session_id' => (string) $user->session_id);
                $db->sql_query('INSERT INTO ' . FORUMS_ACCESS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
                $login_status = true;
            }
        }
    }
    $response = new xmlrpcval(array('result' => new xmlrpcval($login_status, 'boolean'), 'result_text' => new xmlrpcval($login_status ? '' : 'Password is wrong', 'base64')), 'struct');
    return new xmlrpcresp($response);
}
Example #27
0
function prefetch_account_func()
{
    global $context, $user_profile, $settings, $scripturl, $modSettings;
    if (empty($_REQUEST['u'])) {
        return get_error();
    }
    loadMemberData($_REQUEST['u']);
    $profile = $user_profile[$_REQUEST['u']];
    if (!empty($settings['show_user_images']) && empty($profile['options']['show_no_avatars'])) {
        $avatar = $profile['avatar'] == '' ? $profile['id_attach'] > 0 ? empty($profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename'] : '' : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']);
    } else {
        $avatar = '';
    }
    $result = new xmlrpcval(array('result' => new xmlrpcval(true, 'boolean'), 'user_id' => new xmlrpcval($user_profile[$_REQUEST['u']]['id_member'], 'string'), 'login_name' => new xmlrpcval(basic_clean($user_profile[$_REQUEST['u']]['member_name']), 'base64'), 'display_name' => new xmlrpcval(basic_clean($user_profile[$_REQUEST['u']]['real_name']), 'base64'), 'avatar' => new xmlrpcval($avatar, 'string')), 'struct');
    return new xmlrpcresp($result);
}
Example #28
0
 public function delete()
 {
     if (!$this->isPost()) {
         return_value_json(false, 'msg', '非法的调用');
     }
     $trains = json_decode(file_get_contents("php://input"));
     if (!is_array($trains)) {
         $trains = array($trains);
     }
     $Train = M('Train');
     check_error($Train);
     $ids = array();
     foreach ($trains as $train) {
         if (false === $Train->where("`id`='" . $train->id . "'")->delete()) {
             //保存日志
             R('Log/adduserlog', array('删除班列资料', '删除班列资料失败', '失败:系统错误', '班列:' . $train->number . ',出错原因:' . get_error($Train)));
             return_value_json(false, 'msg', '删除班列资料[' . $train->number . ']时出错:' . get_error($Train));
         }
         //保存日志
         R('Log/adduserlog', array('删除班列资料', '删除班列资料成功', '成功', '班列:' . $train->number));
     }
     return_value_json(true);
 }
        <h1>Cadastro de novos produtos</h1>
        <p>Preencha o formulário para adicionar um novo produto.</p>
    </div>
    <?php 
if ($_POST) {
    if ($_POST['action'] == 'update') {
        if (update_produto($_POST['id'], $_POST['name'], $_POST['description'], $_POST['price'], $connection) == 'true') {
            echo '<div class="row"><div class="alert alert-success" role="alert"><strong>Sucesso! </strong>Seu produto foi atualizado.</div></div>';
        } else {
            echo get_error();
        }
    } else {
        if (add_produto($_POST['name'], $_POST['description'], $_POST['price'], $connection) == 'true') {
            echo '<div class="row"><div class="alert alert-success" role="alert"><strong>Sucesso! </strong>Seu produto foi adicionado.</div></div>';
        } else {
            echo get_error();
        }
    }
}
?>
    <div class="row">
	    <div class="col-md-8">
	    	<?php 
if ($_GET && is_numeric($_GET['id'])) {
    $object = get_data('produto', $_GET['id'], $connection);
    ?>
	    		<form method="POST" action="<?php 
    echo $_SERVER['PHP_SELF'];
    ?>
" role="form">
	    			<input type="hidden" value="update" name="action" />
Example #30
0
 /**
  * delete操作根据POST数据更新一个分组信息到数据库里,并返回操作结果
  */
 public function delete()
 {
     if (!$this->isPost()) {
         return_value_json(false, 'msg', '非法的调用');
     }
     //数据检查
     $seq = $this->_post('sequence') + 0;
     if (empty($seq)) {
         return_value_json(false, 'msg', '系统出错:司机在分组里的次序为空或者为0');
     }
     $id = $this->_post('id') + 0;
     if (empty($id)) {
         return_value_json(false, 'msg', '系统出错:司机id为空或者为0');
     }
     $dpm_id = $this->_post('department_id') + 0;
     $Driver = M('Driver');
     //先更新次序在插入者之后的分组的次序
     $condition['department_id'] = array('eq', $dpm_id);
     $condition['sequence'] = array('egt', $seq);
     $Driver->where($condition)->setDec('sequence', 1);
     if (false === $Driver->where("`id`='" . $id . "'")->delete()) {
         //保存日志
         R('Log/adduserlog', array('删除司机资料', '删除司机资料失败', '失败:系统错误', '删除司机[' . $this->_post('name') . ']时出错:' + get_error($Driver)));
         return_value_json(false, 'msg', '删除车辆[' . $vehicle->number . ']时出错:' + get_error($Driver));
     }
     //保存日志
     R('Log/adduserlog', array('删除司机资料', '删除司机资料成功', '成功', '司机:' . $this->_post('name')));
     return_value_json(true);
 }