当前位置: 首页>>代码示例>>PHP>>正文


PHP my_ip2long函数代码示例

本文整理汇总了PHP中my_ip2long函数的典型用法代码示例。如果您正苦于以下问题:PHP my_ip2long函数的具体用法?PHP my_ip2long怎么用?PHP my_ip2long使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了my_ip2long函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: install_done

function install_done()
{
    global $output, $db, $mybb, $errors, $cache, $lang;
    if (empty($mybb->input['adminuser'])) {
        $errors[] = $lang->admin_step_error_nouser;
    }
    if (empty($mybb->input['adminpass'])) {
        $errors[] = $lang->admin_step_error_nopassword;
    }
    if ($mybb->input['adminpass'] != $mybb->input['adminpass2']) {
        $errors[] = $lang->admin_step_error_nomatch;
    }
    if (empty($mybb->input['adminemail'])) {
        $errors[] = $lang->admin_step_error_noemail;
    }
    if (is_array($errors)) {
        create_admin_user();
    }
    require MYBB_ROOT . 'inc/config.php';
    $db = db_connection($config);
    require MYBB_ROOT . 'inc/settings.php';
    $mybb->settings =& $settings;
    ob_start();
    $output->print_header($lang->finish_setup, 'finish');
    echo $lang->done_step_usergroupsinserted;
    // Insert all of our user groups from the XML file
    $usergroup_settings = file_get_contents(INSTALL_ROOT . 'resources/usergroups.xml');
    $parser = new XMLParser($usergroup_settings);
    $parser->collapse_dups = 0;
    $tree = $parser->get_tree();
    $admin_gid = '';
    $group_count = 0;
    foreach ($tree['usergroups'][0]['usergroup'] as $usergroup) {
        // usergroup[cancp][0][value]
        $new_group = array();
        foreach ($usergroup as $key => $value) {
            if (!is_array($value)) {
                continue;
            }
            $new_group[$key] = $db->escape_string($value[0]['value']);
        }
        $db->insert_query("usergroups", $new_group, false);
        // If this group can access the admin CP and we haven't established the admin group - set it (just in case we ever change IDs)
        if ($new_group['cancp'] == 1 && !$admin_gid) {
            $admin_gid = $usergroup['gid'][0]['value'];
        }
        $group_count++;
    }
    // Restart usergroup sequence with correct # of groups
    if ($config['database']['type'] == "pgsql") {
        $db->query("SELECT setval('{$config['database']['table_prefix']}usergroups_gid_seq', (SELECT max(gid) FROM {$config['database']['table_prefix']}usergroups));");
    }
    echo $lang->done . '</p>';
    echo $lang->done_step_admincreated;
    $now = TIME_NOW;
    $salt = random_str();
    $loginkey = generate_loginkey();
    $saltedpw = md5(md5($salt) . md5($mybb->input['adminpass']));
    $newuser = array('username' => $db->escape_string($mybb->input['adminuser']), 'password' => $saltedpw, 'salt' => $salt, 'loginkey' => $loginkey, 'email' => $db->escape_string($mybb->input['adminemail']), 'usergroup' => $admin_gid, 'regdate' => $now, 'lastactive' => $now, 'lastvisit' => $now, 'website' => '', 'icq' => '', 'aim' => '', 'yahoo' => '', 'msn' => '', 'birthday' => '', 'signature' => '', 'allownotices' => 1, 'hideemail' => 0, 'subscriptionmethod' => '0', 'receivepms' => 1, 'pmnotice' => 1, 'pmnotify' => 1, 'showsigs' => 1, 'showavatars' => 1, 'showquickreply' => 1, 'invisible' => 0, 'style' => '0', 'timezone' => 0, 'dst' => 0, 'threadmode' => '', 'daysprune' => 0, 'regip' => $db->escape_string(get_ip()), 'longregip' => intval(my_ip2long(get_ip())), 'language' => '', 'showcodebuttons' => 1, 'tpp' => 0, 'ppp' => 0, 'referrer' => 0, 'buddylist' => '', 'ignorelist' => '', 'pmfolders' => '', 'notepad' => '', 'showredirect' => 1, 'usernotes' => '');
    $db->insert_query('users', $newuser);
    echo $lang->done . '</p>';
    echo $lang->done_step_adminoptions;
    $adminoptions = file_get_contents(INSTALL_ROOT . 'resources/adminoptions.xml');
    $parser = new XMLParser($adminoptions);
    $parser->collapse_dups = 0;
    $tree = $parser->get_tree();
    $insertmodule = array();
    $db->delete_query("adminoptions");
    // Insert all the admin permissions
    foreach ($tree['adminoptions'][0]['user'] as $users) {
        $uid = $users['attributes']['uid'];
        foreach ($users['permissions'][0]['module'] as $module) {
            foreach ($module['permission'] as $permission) {
                $insertmodule[$module['attributes']['name']][$permission['attributes']['name']] = $permission['value'];
            }
        }
        $defaultviews = array();
        foreach ($users['defaultviews'][0]['view'] as $view) {
            $defaultviews[$view['attributes']['type']] = $view['value'];
        }
        $adminoptiondata = array('uid' => intval($uid), 'cpstyle' => '', 'notes' => '', 'permissions' => $db->escape_string(serialize($insertmodule)), 'defaultviews' => $db->escape_string(serialize($defaultviews)));
        $insertmodule = array();
        $db->insert_query('adminoptions', $adminoptiondata);
    }
    echo $lang->done . '</p>';
    // Automatic Login
    my_unsetcookie("sid");
    my_unsetcookie("mybbuser");
    my_setcookie('mybbuser', $uid . '_' . $loginkey, null, true);
    ob_end_flush();
    // Make fulltext columns if supported
    if ($db->supports_fulltext('threads')) {
        $db->create_fulltext_index('threads', 'subject');
    }
    if ($db->supports_fulltext_boolean('posts')) {
        $db->create_fulltext_index('posts', 'message');
    }
    echo $lang->done_step_cachebuilding;
    require_once MYBB_ROOT . 'inc/class_datacache.php';
    $cache = new datacache();
//.........这里部分代码省略.........
开发者ID:ThinhNguyenVB,项目名称:Gradient-Studios-Website,代码行数:101,代码来源:index.php

示例2: isset

     } else {
         if (!$result->result && empty($mybb->input['email']) && !empty($result->email)) {
             $mybb->input['email'] = $result->email;
             $mybb->input['email2'] = $result->email;
         }
     }
 }
 $usergroup = 5;
 if ($verify_result && $mybb->settings['regtype'] != "admin") {
     $usergroup = isset($mybb->settings['tapatalk_register_group']) ? $mybb->settings['tapatalk_register_group'] : 2;
 }
 if (!$verify_result) {
     tt_is_spam();
 }
 // Set the data for the new user.
 $user = array("username" => $mybb->input['username'], "password" => $mybb->input['password'], "password2" => $mybb->input['password2'], "email" => $mybb->input['email'], "email2" => $mybb->input['email2'], "usergroup" => $usergroup, "referrer" => $mybb->input['referrername'], "timezone" => $mybb->settings['timezoneoffset'], "language" => $mybb->input['language'], "profile_fields" => $mybb->input['profile_fields'], "regip" => $session->ipaddress, "longregip" => my_ip2long($session->ipaddress), "coppa_user" => intval($mybb->cookies['coppauser']));
 $user['options'] = array("allownotices" => $mybb->input['allownotices'], "hideemail" => $mybb->input['hideemail'], "subscriptionmethod" => $mybb->input['subscriptionmethod'], "receivepms" => $mybb->input['receivepms'], "pmnotice" => $mybb->input['pmnotice'], "emailpmnotify" => $mybb->input['emailpmnotify'], "invisible" => $mybb->input['invisible'], "dstcorrection" => $mybb->input['dstcorrection']);
 $userhandler->set_data($user);
 $errors = "";
 if (!$userhandler->validate_user()) {
     $errors = $userhandler->get_friendly_errors();
 }
 if (is_array($errors)) {
     error($errors[0]);
 } else {
     $user_info = $userhandler->insert_user();
     if ($mybb->settings['regtype'] == "randompass") {
         $emailsubject = $lang->sprintf($lang->emailsubject_randompassword, $mybb->settings['bbname']);
         switch ($mybb->settings['username_method']) {
             case 0:
                 $emailmessage = $lang->sprintf($lang->email_randompassword, $user['username'], $mybb->settings['bbname'], $user_info['username'], $user_info['password']);
开发者ID:dthiago,项目名称:tapatalk-mybb,代码行数:31,代码来源:member.php

示例3: upgrade12_dbchanges7

function upgrade12_dbchanges7()
{
    global $db, $output;
    $output->print_header("Konwersja adresów IP użytkowników");
    if (!$_POST['ipspage']) {
        $ipp = 5000;
    } else {
        $ipp = $_POST['ipspage'];
    }
    if ($_POST['ipstart']) {
        $startat = $_POST['ipstart'];
        $upper = $startat + $ipp;
        $lower = $startat;
    } else {
        $startat = 0;
        $upper = $ipp;
        $lower = 1;
    }
    $query = $db->simple_select("users", "COUNT(uid) AS ipcount");
    $cnt = $db->fetch_array($query);
    if ($upper > $cnt['ipcount']) {
        $upper = $cnt['ipcount'];
    }
    $contents .= "<p>Konwersja adresu IP z {$lower} na {$upper} (Łącznie: {$cnt['ipcount']})</p>";
    $ipaddress = false;
    $update_array = array();
    $query = $db->simple_select("users", "regip, lastip, longlastip, longregip, uid", "", array('limit_start' => $lower, 'limit' => $ipp));
    while ($user = $db->fetch_array($query)) {
        // Have we already converted this ip?
        if (!$user['longregip']) {
            $update_array['longregip'] = intval(my_ip2long($user['regip']));
        }
        if (!$user['longlastip']) {
            $update_array['longlastip'] = intval(my_ip2long($user['lastip']));
        }
        if (!empty($update_array)) {
            $db->update_query("users", $update_array, "uid = '{$user['uid']}'");
        }
        $update_array = array();
        $ipaddress = true;
    }
    $remaining = $upper - $cnt['ipcount'];
    if ($remaining && $ipaddress) {
        $nextact = "12_dbchanges7";
        $startat = $startat + $ipp;
        $contents .= "<p><input type=\"hidden\" name=\"ipspage\" value=\"{$ipp}\" /><input type=\"hidden\" name=\"ipstart\" value=\"{$startat}\" />Zakończono. Naciśnij przycisk Dalej, aby przejść do konwersji innego typu adresów IP.</p>";
    } else {
        $nextact = "12_dbchanges8";
        $contents .= "<p>Zakończono</p><p>Wszystkie adresy IP użytkowników zostały skonwertowane do nowego formatu. Naciśnij przycisk Dalej, aby kontynuować.</p>";
    }
    $output->print_contents($contents);
    global $footer_extra;
    $footer_extra = "<script type=\"text/javascript\">window.onload = function() { var button = \$\$('.submit_button'); if(button[0]) { button[0].value = 'Automatyczne przekierowanie...'; button[0].disabled = true; button[0].style.color = '#aaa'; button[0].style.borderColor = '#aaa'; document.forms[0].submit(); }}</script>";
    $output->print_footer($nextact);
}
开发者ID:Nidrax,项目名称:ppm-1.6,代码行数:55,代码来源:upgrade12.php

示例4: upgrade12_dbchanges7

function upgrade12_dbchanges7()
{
    global $db, $output;
    $output->print_header("User IP Conversion");
    if (!$_POST['ipspage']) {
        $ipp = 5000;
    } else {
        $ipp = $_POST['ipspage'];
    }
    if ($_POST['ipstart']) {
        $startat = $_POST['ipstart'];
        $upper = $startat + $ipp;
        $lower = $startat;
    } else {
        $startat = 0;
        $upper = $ipp;
        $lower = 1;
    }
    $query = $db->simple_select("users", "COUNT(uid) AS ipcount");
    $cnt = $db->fetch_array($query);
    if ($upper > $cnt['ipcount']) {
        $upper = $cnt['ipcount'];
    }
    $contents .= "<p>Converting ip {$lower} to {$upper} ({$cnt['ipcount']} Total)</p>";
    $ipaddress = false;
    $update_array = array();
    $query = $db->simple_select("users", "regip, lastip, longlastip, longregip, uid", "", array('limit_start' => $lower, 'limit' => $ipp));
    while ($user = $db->fetch_array($query)) {
        // Have we already converted this ip?
        if (!$user['longregip']) {
            $update_array['longregip'] = intval(my_ip2long($user['regip']));
        }
        if (!$user['longlastip']) {
            $update_array['longlastip'] = intval(my_ip2long($user['lastip']));
        }
        if (!empty($update_array)) {
            $db->update_query("users", $update_array, "uid = '{$user['uid']}'");
        }
        $update_array = array();
        $ipaddress = true;
    }
    $remaining = $upper - $cnt['ipcount'];
    if ($remaining && $ipaddress) {
        $nextact = "12_dbchanges7";
        $startat = $startat + $ipp;
        $contents .= "<p><input type=\"hidden\" name=\"ipspage\" value=\"{$ipp}\" /><input type=\"hidden\" name=\"ipstart\" value=\"{$startat}\" />Done. Click Next to move on to the next set of user ips.</p>";
    } else {
        $nextact = "12_dbchanges8";
        $contents .= "<p>Done</p><p>All user ips have been converted to the new ip format. Click next to continue.</p>";
    }
    $output->print_contents($contents);
    global $footer_extra;
    $footer_extra = "<script type=\"text/javascript\">window.onload = function() { var button = \$\$('.submit_button'); if(button[0]) { button[0].value = 'Automatically Redirecting...'; button[0].disabled = true; button[0].style.color = '#aaa'; button[0].style.borderColor = '#aaa'; document.forms[0].submit(); }}</script>";
    $output->print_footer($nextact);
}
开发者ID:slothly,项目名称:mybb,代码行数:55,代码来源:upgrade12.php

示例5: fetch_longipv4_range

/**
 * Fetch an IPv4 long formatted range for searching IPv4 IP addresses.
 *
 * @param string The IP address to convert to a range based LONG
 * @rturn mixed If a full IP address is provided, the ip2long equivalent, otherwise an array of the upper & lower extremities of the IP
 */
function fetch_longipv4_range($ip)
{
    $ip_bits = explode(".", $ip);
    $ip_string1 = $ip_string2 = "";
    if ($ip == "*") {
        return array(my_ip2long('128.0.0.0'), my_ip2long('127.255.255.255'));
    }
    if (strpos($ip, ".*") === false) {
        $ip = str_replace("*", "", $ip);
        if (count($ip_bits) == 4) {
            return my_ip2long($ip);
        } else {
            return array(my_ip2long($ip . ".0"), my_ip2long($ip . ".255"));
        }
    } else {
        $sep = "";
        foreach ($ip_bits as $piece) {
            if ($piece == "*") {
                $ip_string1 .= $sep . "0";
                $ip_string2 .= $sep . "255";
            } else {
                $ip_string1 .= $sep . $piece;
                $ip_string2 .= $sep . $piece;
            }
            $sep = ".";
        }
        return array(my_ip2long($ip_string1), my_ip2long($ip_string2));
    }
}
开发者ID:khanfusiion,项目名称:mybb,代码行数:35,代码来源:functions.php

示例6: insert_user

 /**
  * Inserts a user into the database.
  */
 function insert_user()
 {
     global $db, $cache, $plugins;
     // Yes, validating is required.
     if (!$this->get_validated()) {
         die("The user needs to be validated before inserting it into the DB.");
     }
     if (count($this->get_errors()) > 0) {
         die("The user is not valid.");
     }
     $user =& $this->data;
     $this->user_insert_data = array("username" => $db->escape_string($user['username']), "password" => $user['saltedpw'], "salt" => $user['salt'], "loginkey" => $user['loginkey'], "email" => $db->escape_string($user['email']), "postnum" => intval($user['postnum']), "avatar" => $db->escape_string($user['avatar']), "avatartype" => $db->escape_string($user['avatartype']), "usergroup" => intval($user['usergroup']), "additionalgroups" => $db->escape_string($user['additionalgroups']), "displaygroup" => intval($user['displaygroup']), "usertitle" => $db->escape_string(htmlspecialchars_uni($user['usertitle'])), "regdate" => intval($user['regdate']), "lastactive" => intval($user['lastactive']), "lastvisit" => intval($user['lastvisit']), "website" => $db->escape_string(htmlspecialchars_uni($user['website'])), "icq" => intval($user['icq']), "aim" => $db->escape_string(htmlspecialchars_uni($user['aim'])), "yahoo" => $db->escape_string(htmlspecialchars_uni($user['yahoo'])), "msn" => $db->escape_string(htmlspecialchars_uni($user['msn'])), "birthday" => $user['bday'], "signature" => $db->escape_string($user['signature']), "allownotices" => $user['options']['allownotices'], "hideemail" => $user['options']['hideemail'], "subscriptionmethod" => intval($user['options']['subscriptionmethod']), "receivepms" => $user['options']['receivepms'], "receivefrombuddy" => $user['options']['receivefrombuddy'], "pmnotice" => $user['options']['pmnotice'], "pmnotify" => $user['options']['pmnotify'], "showsigs" => $user['options']['showsigs'], "showavatars" => $user['options']['showavatars'], "showquickreply" => $user['options']['showquickreply'], "showredirect" => $user['options']['showredirect'], "tpp" => intval($user['options']['tpp']), "ppp" => intval($user['options']['ppp']), "invisible" => $user['options']['invisible'], "style" => intval($user['style']), "timezone" => $db->escape_string($user['timezone']), "dstcorrection" => intval($user['options']['dstcorrection']), "threadmode" => $user['options']['threadmode'], "daysprune" => intval($user['options']['daysprune']), "dateformat" => $db->escape_string($user['dateformat']), "timeformat" => $db->escape_string($user['timeformat']), "regip" => $db->escape_string($user['regip']), "longregip" => intval(my_ip2long($user['regip'])), "language" => $db->escape_string($user['language']), "showcodebuttons" => $user['options']['showcodebuttons'], "away" => $user['away']['away'], "awaydate" => $user['away']['date'], "returndate" => $user['away']['returndate'], "awayreason" => $db->escape_string($user['away']['awayreason']), "notepad" => $db->escape_string($user['notepad']), "referrer" => intval($user['referrer_uid']), "referrals" => 0, "buddylist" => '', "ignorelist" => '', "pmfolders" => '', "notepad" => '', "warningpoints" => 0, "moderateposts" => 0, "moderationtime" => 0, "suspendposting" => 0, "suspensiontime" => 0, "coppauser" => intval($user['coppa_user']), "classicpostbit" => $user['options']['classicpostbit'], "usernotes" => '');
     if ($user['options']['dstcorrection'] == 1) {
         $this->user_insert_data['dst'] = 1;
     } else {
         if ($user['options']['dstcorrection'] == 0) {
             $this->user_insert_data['dst'] = 0;
         }
     }
     $plugins->run_hooks("datahandler_user_insert", $this);
     $this->uid = $db->insert_query("users", $this->user_insert_data);
     $user['user_fields']['ufid'] = $this->uid;
     $query = $db->simple_select("profilefields", "fid");
     while ($profile_field = $db->fetch_array($query)) {
         if (array_key_exists("fid{$profile_field['fid']}", $user['user_fields'])) {
             continue;
         }
         $user['user_fields']["fid{$profile_field['fid']}"] = '';
     }
     $db->insert_query("userfields", $user['user_fields'], false);
     if ($this->user_insert_data['referrer'] != 0) {
         $db->write_query("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "users\n\t\t\t\tSET referrals=referrals+1\n\t\t\t\tWHERE uid='{$this->user_insert_data['referrer']}'\n\t\t\t");
     }
     // Update forum stats
     update_stats(array('numusers' => '+1'));
     return array("uid" => $this->uid, "username" => $user['username'], "loginkey" => $user['loginkey'], "email" => $user['email'], "password" => $user['password'], "usergroup" => $user['usergroup']);
 }
开发者ID:GeorgeLVP,项目名称:mybb,代码行数:40,代码来源:user.php

示例7: register

 /**
  * Registers an user with Facebook data
  */
 public function register($user)
 {
     if (!$user) {
         return false;
     }
     global $mybb, $session, $plugins, $lang;
     require_once MYBB_ROOT . "inc/datahandlers/user.php";
     $userhandler = new UserDataHandler("insert");
     $plength = 8;
     if ($mybb->settings['minpasswordlength']) {
         $plength = (int) $mybb->settings['minpasswordlength'];
     }
     $password = random_str($plength);
     $new_user = array("username" => $user['name'], "password" => $password, "password2" => $password, "email" => $user['email'], "email2" => $user['email'], "usergroup" => (int) $mybb->settings['myfbconnect_usergroup'], "regip" => $session->ipaddress, "longregip" => my_ip2long($session->ipaddress), "options" => array("hideemail" => 1));
     /* Registration might fail for custom profile fields required at registration... workaround = IN_ADMINCP defined.
     		Placed straight before the registration process to avoid conflicts with third party plugins messying around with
     		templates (I'm looking at you, PHPTPL) */
     define("IN_ADMINCP", 1);
     $userhandler->set_data($new_user);
     if ($userhandler->validate_user()) {
         $user_info = $userhandler->insert_user();
         $plugins->run_hooks("member_do_register_end");
         // Deliver a welcome PM
         if ($mybb->settings['myfbconnect_passwordpm']) {
             require_once MYBB_ROOT . "inc/datahandlers/pm.php";
             $pmhandler = new PMDataHandler();
             $pmhandler->admin_override = true;
             // Make sure admins haven't done something bad
             $fromid = (int) $mybb->settings['myfbconnect_passwordpm_fromid'];
             if (!$mybb->settings['myfbconnect_passwordpm_fromid'] or !user_exists($mybb->settings['myfbconnect_passwordpm_fromid'])) {
                 $fromid = 0;
             }
             $message = $mybb->settings['myfbconnect_passwordpm_message'];
             $subject = $mybb->settings['myfbconnect_passwordpm_subject'];
             $thingsToReplace = array("{user}" => $user_info['username'], "{password}" => $password);
             // Replace what needs to be replaced
             foreach ($thingsToReplace as $find => $replace) {
                 $message = str_replace($find, $replace, $message);
             }
             $pm = array("subject" => $subject, "message" => $message, "fromid" => $fromid, "toid" => array($user_info['uid']));
             // Some defaults :)
             $pm['options'] = array("signature" => 1);
             $pmhandler->set_data($pm);
             // Now let the PM handler do all the hard work
             if ($pmhandler->validate_pm()) {
                 $pmhandler->insert_pm();
             } else {
                 error($lang->sprintf($lang->myfbconnect_error_report, $pmhandler->get_friendly_errors()));
             }
         }
         // Post a message on the user's wall
         if ($mybb->settings['myfbconnect_postonwall']) {
             $this->post_on_wall($mybb->settings['myfbconnect_postonwall_message']);
         }
         // Finally return our new user data
         return $user_info;
     } else {
         return array('error' => $userhandler->get_friendly_errors());
     }
     return true;
 }
开发者ID:umitkavuran,项目名称:MyFacebook-Connect,代码行数:64,代码来源:class_facebook.php

示例8: upgrade17_dbchanges7

function upgrade17_dbchanges7()
{
    global $db, $output;
    $output->print_header("User IP Repair Conversion");
    if (!$_POST['ipspage']) {
        $ipp = 5000;
    } else {
        $ipp = (int) $_POST['ipspage'];
    }
    if ($_POST['ipstart']) {
        $startat = (int) $_POST['ipstart'];
        $upper = $startat + $ipp;
        $lower = $startat;
    } else {
        $startat = 0;
        $upper = $ipp;
        $lower = 1;
    }
    $query = $db->simple_select("users", "COUNT(uid) AS ipcount");
    $cnt = $db->fetch_array($query);
    if ($upper > $cnt['ipcount']) {
        $upper = $cnt['ipcount'];
    }
    $contents .= "<p>Repairing ip {$lower} to {$upper} ({$cnt['ipcount']} Total)</p>";
    $ipaddress = false;
    $update_array = array();
    $query = $db->simple_select("users", "regip, lastip, uid", "", array('limit_start' => $lower, 'limit' => $ipp));
    while ($user = $db->fetch_array($query)) {
        $update_array = array('longregip' => (int) my_ip2long($user['regip']), 'longlastip' => (int) my_ip2long($user['lastip']));
        $db->update_query("users", $update_array, "uid = '{$user['uid']}'");
        $update_array = array();
        $ipaddress = true;
    }
    $remaining = $upper - $cnt['ipcount'];
    if ($remaining && $ipaddress) {
        $nextact = "17_dbchanges7";
        $startat = $startat + $ipp;
        $contents .= "<p><input type=\"hidden\" name=\"ipspage\" value=\"{$ipp}\" /><input type=\"hidden\" name=\"ipstart\" value=\"{$startat}\" />Done. Click Next to move on to the next set of user ips.</p>";
    } else {
        $nextact = "17_redoconfig";
        $contents .= "<p>Done</p><p>All user ips have been successfully repaired. Click next to continue.</p>";
    }
    $output->print_contents($contents);
    global $footer_extra;
    $footer_extra = "<script type=\"text/javascript\">\$(document).ready(function() { var button = \$('.submit_button'); if(button) { button.val('Automatically Redirecting...'); button.prop('disabled', true); button.css('color', '#aaa'); button.css('border-color', '#aaa'); document.forms[0].submit(); } });</script>";
    $output->print_footer($nextact);
}
开发者ID:mainhan1804,项目名称:xomvanphong,代码行数:47,代码来源:upgrade17.php

示例9: sign_in_func

function sign_in_func()
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups, $mobiquo_config, $user, $register;
    // Load global language phrases
    $lang->load("member");
    $parser = new postParser();
    $token = trim($_POST['token']);
    $code = trim($_POST['code']);
    $username = $mybb->input['username'];
    $password = $mybb->input['password'];
    $post_email = $mybb->input['email'];
    $status = '';
    if (!empty($token) && !empty($code)) {
        $result = tt_register_verify($token, $code);
        if ($result->result && !empty($result->email)) {
            $email = $result->email;
            if (!empty($post_email) && $post_email != $email) {
                $status = 3;
            } else {
                if ($user = tt_get_user_by_email($email)) {
                    if (!empty($username) && strtolower($username) != strtolower($user['username'])) {
                        $status = 3;
                    } else {
                        $register = 0;
                        return tt_login_success();
                    }
                } else {
                    if (!empty($username) && !empty($email)) {
                        $profile = $result->profile;
                        if ($mybb->settings['disableregs'] == 1) {
                            error($lang->registrations_disabled);
                        }
                        // Set up user handler.
                        require_once MYBB_ROOT . "inc/datahandlers/user.php";
                        $userhandler = new UserDataHandler("insert");
                        $birthday_arr = explode('-', $profile->birthday);
                        $bday = array("day" => $birthday_arr[2], "month" => $birthday_arr[1], "year" => $birthday_arr[0]);
                        $user_field = array('fid3' => ucfirst($profile->gender), 'fid1' => $profile->location, 'fid2' => $profile->description);
                        if ($mybb->settings['regtype'] == "admin") {
                            $usergroup = 5;
                        } else {
                            $usergroup = isset($mybb->settings['tapatalk_register_group']) ? $mybb->settings['tapatalk_register_group'] : 2;
                        }
                        // Set the data for the new user.
                        $user = array("username" => $mybb->input['username'], "password" => $mybb->input['password'], "password2" => $mybb->input['password'], "email" => $email, "email2" => $email, "usergroup" => $usergroup, "referrer" => '', "timezone" => $mybb->settings['timezoneoffset'], "language" => '', "regip" => $session->ipaddress, "longregip" => my_ip2long($session->ipaddress), "coppa_user" => 0, "birthday" => $bday, "website" => $profile->link, "user_fields" => $user_field, "signature" => $profile->signature, "option" => array(), "regdate" => TIME_NOW, "lastvisit" => TIME_NOW);
                        if (!empty($profile->avatar_url)) {
                            $updated_avatar = tt_update_avatar_url($profile->avatar_url);
                        }
                        $userhandler->set_data($user);
                        $userhandler->verify_birthday();
                        $userhandler->verify_options();
                        if ($userhandler->verify_username_exists()) {
                            $status = 1;
                        } else {
                            if (!$userhandler->verify_password() || !$userhandler->verify_username()) {
                                $errors = $userhandler->get_friendly_errors();
                                error($errors[0]);
                            } else {
                                $userhandler->set_validated(true);
                                $user = $userhandler->insert_user();
                                if (!empty($updated_avatar)) {
                                    $db->update_query("users", $updated_avatar, "uid='" . $user['uid'] . "'");
                                }
                                $register = 1;
                                return tt_login_success();
                            }
                        }
                    } else {
                        $status = 2;
                    }
                }
            }
        } else {
            if (!$result->result) {
                if (!empty($result->result_text)) {
                    error($result->result_text);
                } else {
                    error("Tapatalk ID verify faile!");
                }
            }
        }
        if (!empty($status)) {
            $response = new xmlrpcval(array('result' => new xmlrpcval(0, 'boolean'), 'result_text' => new xmlrpcval('', 'base64'), 'status' => new xmlrpcval($status, 'string')), 'struct');
            return new xmlrpcresp($response);
        }
    } else {
        error("Invlaid params!");
    }
}
开发者ID:dthiago,项目名称:tapatalk-mybb,代码行数:89,代码来源:sign_in.php

示例10: steam_output_to_misc

/**
 *
 * Redirect Output - steam_output_to_misc
 * - - - - - - - - - - - - - - -
 * @desc This function is holds the actions issued by the Steam Login plugin.
 * @since 1.0
 * @version 1.6
 *
 */
function steam_output_to_misc()
{
    global $mybb, $db, $session;
    // The standard action to redirect the user to Steam community.
    if ($mybb->input['action'] == 'steam_login') {
        steam_redirect();
    }
    // close if($mybb->input['action'] == 'steam_login')
    if ($mybb->input['action'] == 'steam_return') {
        $get_key = $db->fetch_array($db->simple_select("settings", "name, value", "name = 'steamlogin_api_key'"));
        $check_update_username = $db->fetch_array($db->simple_select("settings", "name, value", "name = 'steamlogin_update_username'"));
        $check_update_avatar = $db->fetch_array($db->simple_select("settings", "name, value", "name = 'steamlogin_update_avatar'"));
        $check_avatar_size = $db->fetch_array($db->simple_select("settings", "name, value", "name = 'steamlogin_avatar_size'"));
        $check_required_field = $db->fetch_array($db->simple_select("settings", "name, value", "name = 'steamlogin_required_field'"));
        if ($get_key['value'] == null) {
            die("<strong>Not Configured</strong> The Steam Login plugin hasn't been configured correctly. Please ensure an API key is set in the Configuration settings.");
        } else {
            require_once MYBB_ROOT . 'inc/class_steam.php';
            require_once MYBB_ROOT . 'inc/class_lightopenid.php';
            require_once MYBB_ROOT . 'inc/functions.php';
            require_once MYBB_ROOT . 'inc/class_session.php';
            $steam = new steam();
            $steam_open_id = new LightOpenID();
            $steam_open_id->validate();
            $return_explode = explode('/', $steam_open_id->identity);
            $steamid = end($return_explode);
            $steam_info = $steam->get_user_info($steamid);
            // Check the status.
            if ($steam_info['status'] == 'success') {
                $steamid = $steam_info['steamid'];
                $personaname = $steam_info['personaname'];
                $profileurl = $steam_info['profileurl'];
                $avatar = $steam_info['avatars']['medium'];
                // Check the avatar size set in the database.
                if ($check_avatar_size['value'] == '0') {
                    $avatar = $steam_info['avatars']['small'];
                }
                if ($check_avatar_size['value'] == '2') {
                    $avatar = $steam_info['avatars']['large'];
                }
                $personaname = strip_tags($personaname);
                //This is so people can not use tags that display.
                $personaname = $db->escape_string($personaname);
                // Perform a check to see if the user already exists in the database.
                $user_check = $db->num_rows($db->simple_select("users", "*", "loginname = '{$steamid}'"));
                if ($user_check == 0) {
                    $password = random_str(8);
                    $email = $steamid . '@steamcommunity.com';
                    $default_usergroup = 2;
                    // On a standard MyBB installation this is the group: Registered
                    require_once MYBB_ROOT . "inc/datahandlers/user.php";
                    $userhandler = new UserDataHandler("insert");
                    $new_user_data = array("username" => $personaname, "password" => $password, "password2" => $password, "email" => $email, "email2" => $email, "avatar" => $avatar, "usergroup" => $default_usergroup, "displaygroup" => $default_usergroup, "website" => $profileurl, "regip" => $session->ipaddress, "longregip" => my_ip2long($session->ipaddress), "loginname" => $steamid);
                    if ($check_required_field['value'] != "" and is_numeric($check_required_field['value'])) {
                        // Check the field exists.
                        $field_exists = $db->num_rows($db->simple_select("profilefields", "*", "fid = '" . $check_required_field['value'] . "'"));
                        if ($field_exists > 0) {
                            $new_user_data['profile_fields']['fid' . $check_required_field['value']] = $steamid;
                        }
                    }
                    $userhandler->set_data($new_user_data);
                    if ($userhandler->validate_user()) {
                        $user_info = $userhandler->insert_user();
                    }
                    // close if ($userhandler->validate_user())
                } else {
                    // close if($user_check == 0)
                    $update = array();
                    // Init our update array.
                    // Do our checks for both username and avatar.
                    if ($check_update_username['value'] == 1) {
                        $update['username'] = $personaname;
                    }
                    if ($check_update_avatar['value'] == 1) {
                        $update['avatar'] = $avatar;
                    }
                    // Run our update query if the array isn't empty.
                    if (!empty($update)) {
                        $db->update_query('users', $update, "loginname = '{$steamid}'");
                    }
                }
                // close else
                $user = $db->fetch_array($db->simple_select("users", "*", "loginname = '{$steamid}'"));
                // Login the user.
                my_setcookie("mybbuser", $user['uid'] . "_" . $user['loginkey'], true, true);
                my_setcookie("sid", $session->sid, -1, true);
                redirect("index.php", 'Your account has been authenticated and you have been logged in.<br/> Powered By <a href="http://www.steampowered.com" target="_blank">Steam</a>', 'Login via Steam');
            }
            // close if($steam_info['status'] == 'success')
        }
        // close else
//.........这里部分代码省略.........
开发者ID:johnpauljj,项目名称:Steam-OpenID--MyBB-,代码行数:101,代码来源:steamlogin.php

示例11: my_ip2long

<?php

function my_ip2long($ip)
{
    list($ip1, $ip2, $ip3, $ip4) = explode(".", $ip);
    return $ip1 * pow(256, 3) + $ip2 * pow(256, 2) + $ip3 * 256 + $ip4;
}
function my_long2ip($long)
{
    $base = 256;
    $ip = "";
    $i = 3;
    while ($long > 0) {
        $ip_index = floor($long / pow(256, $i));
        $long -= pow($base, $i) * $ip_index;
        $ip .= $ip_index . ".";
        $i--;
    }
    return substr($ip, 0, -1);
}
$ip = "192.100.100.100";
// echo sprintf("%u", ip2long($ip));//3227804772 echo "<br>";
// echo long2ip($long_num); echo "<br>";
// echo my_ip2long($ip); echo "<br>";
echo $long_num = my_ip2long($ip);
echo "<br>";
echo my_long2ip($long_num);
开发者ID:yunkaiyueming,项目名称:php_lib_code_center,代码行数:27,代码来源:Ip2Long.php

示例12: insert_thread

 /**
  * Insert a thread into the database.
  *
  * @return array Array of new thread details, tid and visibility.
  */
 function insert_thread()
 {
     global $db, $mybb, $plugins, $cache, $lang;
     // Yes, validating is required.
     if (!$this->get_validated()) {
         die("The thread needs to be validated before inserting it into the DB.");
     }
     if (count($this->get_errors()) > 0) {
         die("The thread is not valid.");
     }
     $thread =& $this->data;
     // Fetch the forum this thread is being made in
     $forum = get_forum($thread['fid']);
     // This thread is being saved as a draft.
     if ($thread['savedraft']) {
         $visible = -2;
     } else {
         // Decide on the visibility of this post.
         if (($forum['modthreads'] == 1 || $forum['modposts'] == 1) && !is_moderator($thread['fid'], "", $thread['uid'])) {
             $visible = 0;
         } else {
             $visible = 1;
         }
         // Are posts from this user being moderated? Change visibility
         if ($mybb->user['uid'] == $thread['uid'] && $mybb->user['moderateposts'] == 1) {
             $visible = 0;
         }
     }
     // Have a post ID but not a thread ID - fetch thread ID
     if ($thread['pid'] && !$thread['tid']) {
         $query = $db->simple_select("posts", "tid", "pid='{$thread['pid']}");
         $thread['tid'] = $db->fetch_field($query, "tid");
     }
     if ($thread['pid'] > 0) {
         $query = $db->simple_select("posts", "pid", "pid='{$thread['pid']}' AND uid='{$thread['uid']}' AND visible='-2'");
         $draft_check = $db->fetch_field($query, "pid");
     } else {
         $draft_check = false;
     }
     // Are we updating a post which is already a draft? Perhaps changing it into a visible post?
     if ($draft_check) {
         $this->thread_insert_data = array("subject" => $db->escape_string($thread['subject']), "icon" => intval($thread['icon']), "username" => $db->escape_string($thread['username']), "dateline" => intval($thread['dateline']), "lastpost" => intval($thread['dateline']), "lastposter" => $db->escape_string($thread['username']), "visible" => $visible);
         $plugins->run_hooks("datahandler_post_insert_thread", $this);
         $db->update_query("threads", $this->thread_insert_data, "tid='{$thread['tid']}'");
         $this->post_insert_data = array("subject" => $db->escape_string($thread['subject']), "icon" => intval($thread['icon']), "username" => $db->escape_string($thread['username']), "dateline" => intval($thread['dateline']), "message" => $db->escape_string($thread['message']), "ipaddress" => $db->escape_string(get_ip()), "includesig" => $thread['options']['signature'], "smilieoff" => $thread['options']['disablesmilies'], "visible" => $visible);
         $plugins->run_hooks("datahandler_post_insert_thread_post", $this);
         $db->update_query("posts", $this->post_insert_data, "pid='{$thread['pid']}'");
         $this->tid = $thread['tid'];
         $this->pid = $thread['pid'];
     } else {
         $this->thread_insert_data = array("fid" => $thread['fid'], "subject" => $db->escape_string($thread['subject']), "prefix" => intval($thread['prefix']), "icon" => intval($thread['icon']), "uid" => $thread['uid'], "username" => $db->escape_string($thread['username']), "dateline" => intval($thread['dateline']), "lastpost" => intval($thread['dateline']), "lastposter" => $db->escape_string($thread['username']), "views" => 0, "replies" => 0, "visible" => $visible, "notes" => '');
         $plugins->run_hooks("datahandler_post_insert_thread", $this);
         $this->tid = $db->insert_query("threads", $this->thread_insert_data);
         $this->post_insert_data = array("tid" => $this->tid, "fid" => $thread['fid'], "subject" => $db->escape_string($thread['subject']), "icon" => intval($thread['icon']), "uid" => $thread['uid'], "username" => $db->escape_string($thread['username']), "dateline" => intval($thread['dateline']), "message" => $db->escape_string($thread['message']), "ipaddress" => $db->escape_string(get_ip()), "longipaddress" => intval(my_ip2long(get_ip())), "includesig" => $thread['options']['signature'], "smilieoff" => $thread['options']['disablesmilies'], "visible" => $visible);
         $plugins->run_hooks("datahandler_post_insert_thread_post", $this);
         $this->pid = $db->insert_query("posts", $this->post_insert_data);
         // Now that we have the post id for this first post, update the threads table.
         $firstpostup = array("firstpost" => $this->pid);
         $db->update_query("threads", $firstpostup, "tid='{$this->tid}'");
     }
     // If we're not saving a draft there are some things we need to check now
     if (!$thread['savedraft']) {
         if ($thread['options']['subscriptionmethod'] != "" && $thread['uid'] > 0) {
             switch ($thread['options']['subscriptionmethod']) {
                 case "instant":
                     $notification = 1;
                     break;
                 default:
                     $notification = 0;
             }
             require_once MYBB_ROOT . "inc/functions_user.php";
             add_subscribed_thread($this->tid, $notification, $thread['uid']);
         }
         // Perform any selected moderation tools.
         if (is_moderator($thread['fid'], "", $thread['uid']) && is_array($thread['modoptions'])) {
             $lang->load($this->language_file, true);
             $modoptions = $thread['modoptions'];
             $modlogdata['fid'] = $this->tid;
             $modlogdata['tid'] = $thread['tid'];
             // Close the thread.
             if ($modoptions['closethread'] == 1) {
                 $newclosed = "closed=1";
                 log_moderator_action($modlogdata, $lang->thread_closed);
             }
             // Stick the thread.
             if ($modoptions['stickthread'] == 1) {
                 $newstick = "sticky='1'";
                 log_moderator_action($modlogdata, $lang->thread_stuck);
             }
             // Execute moderation options.
             if ($newstick && $newclosed) {
                 $sep = ",";
             }
             if ($newstick || $newclosed) {
                 $db->write_query("\n\t\t\t\t\t\tUPDATE " . TABLE_PREFIX . "threads\n\t\t\t\t\t\tSET {$newclosed}{$sep}{$newstick}\n\t\t\t\t\t\tWHERE tid='{$this->tid}'\n\t\t\t\t\t");
//.........这里部分代码省略.........
开发者ID:ThinhNguyenVB,项目名称:Gradient-Studios-Website,代码行数:101,代码来源:post.php

示例13: load_user

 /**
  * Load a user via the user credentials.
  *
  * @param int The user id.
  * @param string The user's loginkey.
  */
 function load_user($uid, $loginkey = '')
 {
     global $mybb, $db, $time, $lang, $mybbgroups, $session, $cache;
     // Read the banned cache
     $bannedcache = $cache->read("banned");
     // If the banned cache doesn't exist, update it and re-read it
     if (!is_array($bannedcache)) {
         $cache->update_banned();
         $bannedcache = $cache->read("banned");
     }
     $uid = intval($uid);
     $query = $db->query("\r\n\t\t\tSELECT u.*, f.*\r\n\t\t\tFROM " . TABLE_PREFIX . "users u\r\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "userfields f ON (f.ufid=u.uid)\r\n\t\t\tWHERE u.uid='{$uid}'\r\n\t\t\tLIMIT 1\r\n\t\t");
     $mybb->user = $db->fetch_array($query);
     if (!empty($bannedcache[$uid])) {
         $banned_user = $bannedcache[$uid];
         $mybb->user['bandate'] = $banned_user['dateline'];
         $mybb->user['banlifted'] = $banned_user['lifted'];
         $mybb->user['banoldgroup'] = $banned_user['oldgroup'];
         $mybb->user['banolddisplaygroup'] = $banned_user['olddisplaygroup'];
         $mybb->user['banoldadditionalgroups'] = $banned_user['oldadditionalgroups'];
     }
     // Check the password if we're not using a session
     if (empty($loginkey) || $loginkey != $mybb->user['loginkey'] || !$mybb->user['uid']) {
         unset($mybb->user);
         $this->uid = 0;
         return false;
     }
     $this->uid = $mybb->user['uid'];
     // Set the logout key for this user
     $mybb->user['logoutkey'] = md5($mybb->user['loginkey']);
     // Sort out the private message count for this user.
     if (($mybb->user['totalpms'] == -1 || $mybb->user['unreadpms'] == -1) && $mybb->settings['enablepms'] != 0) {
         $update = 0;
         if ($mybb->user['totalpms'] == -1) {
             $update += 1;
         }
         if ($mybb->user['unreadpms'] == -1) {
             $update += 2;
         }
         require_once MYBB_ROOT . "inc/functions_user.php";
         $pmcount = update_pm_count('', $update);
         if (is_array($pmcount)) {
             $mybb->user = array_merge($mybb->user, $pmcount);
         }
     }
     $mybb->user['pms_total'] = $mybb->user['totalpms'];
     $mybb->user['pms_unread'] = $mybb->user['unreadpms'];
     if ($mybb->user['lastip'] != $this->ipaddress && array_key_exists('lastip', $mybb->user)) {
         $lastip_add = ", lastip='" . $db->escape_string($this->ipaddress) . "', longlastip='" . intval(my_ip2long($this->ipaddress)) . "'";
     } else {
         $lastip_add = '';
     }
     // If the last visit was over 900 seconds (session time out) ago then update lastvisit.
     $time = TIME_NOW;
     if ($time - $mybb->user['lastactive'] > 900) {
         $db->shutdown_query("UPDATE " . TABLE_PREFIX . "users SET lastvisit='{$mybb->user['lastactive']}', lastactive='{$time}'{$lastip_add} WHERE uid='{$mybb->user['uid']}'");
         $mybb->user['lastvisit'] = $mybb->user['lastactive'];
         require_once MYBB_ROOT . "inc/functions_user.php";
         update_pm_count('', 2);
     } else {
         $timespent = TIME_NOW - $mybb->user['lastactive'];
         $db->shutdown_query("UPDATE " . TABLE_PREFIX . "users SET lastactive='{$time}', timeonline=timeonline+{$timespent}{$lastip_add} WHERE uid='{$mybb->user['uid']}'");
     }
     // Sort out the language and forum preferences.
     if ($mybb->user['language'] && $lang->language_exists($mybb->user['language'])) {
         $mybb->settings['bblanguage'] = $mybb->user['language'];
     }
     if ($mybb->user['dateformat'] != 0 && $mybb->user['dateformat'] != '') {
         global $date_formats;
         if ($date_formats[$mybb->user['dateformat']]) {
             $mybb->settings['dateformat'] = $date_formats[$mybb->user['dateformat']];
         }
     }
     // Choose time format.
     if ($mybb->user['timeformat'] != 0 && $mybb->user['timeformat'] != '') {
         global $time_formats;
         if ($time_formats[$mybb->user['timeformat']]) {
             $mybb->settings['timeformat'] = $time_formats[$mybb->user['timeformat']];
         }
     }
     // Find out the threads per page preference.
     if ($mybb->user['tpp']) {
         $mybb->settings['threadsperpage'] = $mybb->user['tpp'];
     }
     // Find out the posts per page preference.
     if ($mybb->user['ppp']) {
         $mybb->settings['postsperpage'] = $mybb->user['ppp'];
     }
     // Does this user prefer posts in classic mode?
     if ($mybb->user['classicpostbit']) {
         $mybb->settings['postlayout'] = 'classic';
     } else {
         $mybb->settings['postlayout'] = 'horizontal';
     }
//.........这里部分代码省略.........
开发者ID:ThinhNguyenVB,项目名称:Gradient-Studios-Website,代码行数:101,代码来源:class_session.php


注:本文中的my_ip2long函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。