Ejemplo n.º 1
0
    /**
     * Do the magic
     */
    function handle_start(&$event, $param)
    {
        global $conf;
        $bans = @file($conf['cachedir'] . '/ipbanplugin.txt');
        $client = clientIP(true);
        if (is_array($bans)) {
            foreach ($bans as $ban) {
                $fields = explode("\t", $ban);
                if ($fields[0] == $client) {
                    $text = $this->locale_xhtml('banned');
                    $text .= sprintf('<p>' . $this->getLang('banned') . '</p>', hsc($client), strftime($conf['dformat'], $fields[1]), hsc($fields[3]));
                    $title = $this->getLang('denied');
                    header("HTTP/1.0 403 Forbidden");
                    echo <<<EOT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title>{$title}</title></head>
<body style="font-family: Arial, sans-serif">
  <div style="width:60%; margin: auto; background-color: #fcc;
              border: 1px solid #faa; padding: 0.5em 1em;">
  {$text}
  </div>
</body>
</html>
EOT;
                    exit;
                }
            }
        }
    }
Ejemplo n.º 2
0
 /**
  * Current user identifier
  *
  * @return string
  */
 public function userID()
 {
     if (isset($_SERVER['REMOTE_USER'])) {
         return $_SERVER['REMOTE_USER'];
     }
     return clientIP(true);
 }
Ejemplo n.º 3
0
 /**
  * Constructor.
  */
 function __construct($debug, $settings)
 {
     global $conf;
     // call parent constructor
     $this->debugClass = $debug;
     $this->settings = $settings;
     parent::__construct();
     $this->timeout = 60;
     //max. 25 sec
     $this->headers['If-Modified-Since'] = substr(gmdate('r', 0), 0, -5) . 'GMT';
     $this->status = -1;
     $this->debug = true;
     if ($this->settings->cookie == null) {
         $this->_debug("Has to re-authenticate request.");
         if (!$this->authenticate()) {
             $this->_debug("Trying other Authentication (auth.php):", auth_setup() && $this->authenticate(true) ? 'authenticated' : 'not authenticated');
             // Try again.
         }
         $this->_debug("Using Authentication:", array('user' => $this->user, 'password' => '*****'));
     } else {
         $this->cookies = $this->settings->cookie;
     }
     $this->headers['X-Real-Ip'] = clientIP(true);
     $this->headers['Accept-Encoding'] = $_SERVER['HTTP_ACCEPT_ENCODING'];
     $this->headers['Accept-Charset'] = $_SERVER['HTTP_ACCEPT_CHARSET'];
     $this->agent = $_SERVER['HTTP_USER_AGENT'];
 }
Ejemplo n.º 4
0
 public function action_index()
 {
     $this->template = 'profile';
     $loginHistory = ORM::factory('User_LoginHistory')->getAll($this->user['id']);
     $ipAddress = getAddressByIP(clientIP());
     $currentLogin = $ipAddress['country'] . $ipAddress['area'] . $ipAddress['region'] . $ipAddress['city'] . $ipAddress['county'] . $ipAddress['isp'];
     $array = array('loginHistory' => $loginHistory, 'currentLogin' => $currentLogin);
     $this->data = $array;
 }
Ejemplo n.º 5
0
 /**
  * Create a new event instance.
  *
  * @return void
  */
 public function __construct(Request $request)
 {
     $browser = getBrowserInfo();
     $this->request = $request->all();
     array_set($this->request, 'name', $request->user()->name);
     array_set($this->request, 'ip', clientIP());
     array_set($this->request, 'browser', $browser['browser']);
     array_set($this->request, 'platform', $browser['platform']);
 }
 /**
  * Handle the event.
  *
  * @param  Events  $event
  * @return void
  */
 public function handle(UserLoggedFailed $event)
 {
     //dd($event->request->user()->id);
     $data = ['ip' => clientIP(), 'user' => $event->request->input('email'), 'password' => $event->request->input('password'), 'browser' => $_SERVER['HTTP_USER_AGENT']];
     Mail::queue('emails.loggederror', $data, function ($message) {
         $message->subject('Failed Logged In');
         $message->from('*****@*****.**', 'GI App - Cashier');
         $message->to('*****@*****.**');
     });
 }
 /**
  * Handle the event.
  *
  * @param  Events  $event
  * @return void
  */
 public function handle(GoogleUserLoggedIn $event)
 {
     //dd($event->request->user()->id);
     $data = ['ip' => clientIP(), 'user' => $event->email . ' via Google', 'lat' => '', 'lng' => '', 'browser' => $_SERVER['HTTP_USER_AGENT']];
     Mail::queue('emails.loggedin', $data, function ($message) {
         $message->subject('User Logged In');
         $message->from('*****@*****.**', 'GI App - Cashier');
         $message->to('*****@*****.**');
     });
 }
Ejemplo n.º 8
0
 /**
  * Handle the event.
  *
  * @param  Events  $event
  * @return void
  */
 public function handle(UserLoggedIn $event)
 {
     //dd($event->request->user()->id);
     $data = ['ip' => clientIP(), 'user' => $event->request['username'], 'browser' => $_SERVER['HTTP_USER_AGENT']];
     Mail::send('emails.loggedin', $data, function ($message) use($data) {
         $message->subject('Manager Logged In');
         $message->from('*****@*****.**', 'GI App - Manager');
         $message->to('*****@*****.**');
         $message->to('*****@*****.**');
     });
 }
 /**
  * Handle the event.
  *
  * @param  Events  $event
  * @return void
  */
 public function handle(UserChangePassword $event)
 {
     //dd($event->request->user()->id);
     $data = ['ip' => clientIP(), 'user' => $event->request->user()->name, 'from' => $event->request->input('passwordo'), 'to' => $event->request->input('password')];
     \Mail::queue('emails.change_password', $data, function ($message) {
         $message->subject('User Change Password');
         $message->from('*****@*****.**', 'GI App - Cashier');
         $message->to('*****@*****.**');
         $message->to('*****@*****.**');
     });
 }
Ejemplo n.º 10
0
 /**
  * Handle the event.
  *
  * @param  Events  $event
  * @return void
  */
 public function handle(UserLoggedIn $event)
 {
     $data = ['ip' => clientIP(), 'user' => $event->request['username'], 'lat' => $event->request['lat'], 'lng' => $event->request['lng'], 'browser' => $_SERVER['HTTP_USER_AGENT']];
     /*
     app('pusher')->trigger('gi.cashier', 'auth', [
       'title'=>'Giligan\'s Cashier', 
       'message'=> $data['user'].' successfully logged in at this IP: '.clientIP()
     ]);
     */
     Mail::queue('emails.loggedin', $data, function ($message) {
         $message->subject('User Logged In');
         $message->from('*****@*****.**', 'GI App - Cashier');
         $message->to('*****@*****.**');
     });
 }
Ejemplo n.º 11
0
 public function saveLinkback($type, $title, $sourceUri, $excerpt, $id)
 {
     $comment = array('source' => $type, 'name' => $title, 'web' => $sourceUri, 'text' => $excerpt, 'pid' => md5($id), 'page' => $id, 'subscribe' => null, 'status' => 'hidden', 'ip' => clientIP(true));
     $sqlitehelper = plugin_load('helper', 'blogtng_sqlite');
     $query = 'SELECT web, source FROM comments WHERE pid = ?';
     $resid = $sqlitehelper->query($query, $comment['pid']);
     if ($resid === false) {
         return false;
     }
     $comments = $sqlitehelper->res2arr($resid);
     foreach ($comments as $c) {
         if ($c['web'] === $comment['web'] && $c['source'] === $comment['source']) {
             return false;
         }
     }
     $chelper = plugin_load('helper', 'blogtng_comments');
     $chelper->save($comment);
     return true;
 }
Ejemplo n.º 12
0
function updateMeta($id, $parid, $lastrev, $revert = -1)
{
    $meta = unserialize(io_readFile(metaFN($id, '.translateHistory'), false));
    for ($i = 0; $i < count($meta['current']); $i++) {
        if (!empty($meta['current'][$i]['changed'])) {
            # This paragraph was not changed in the last revision,
            # copy last change entry only
            $meta[$lastrev][$i]['changed'] = $meta['current'][$i]['changed'];
        } else {
            # This paragraph has been changed, copy full entry
            # and set revision pointer
            $meta[$lastrev][$i] = $meta['current'][$i];
            $meta['current'][$i]['changed'] = $lastrev;
        }
    }
    $revert = intval($revert);
    if ($revert < 0) {
        # Saving new data, reset entry for changed paragraph
        $meta['current'][$parid]['changed'] = '';
        $meta['current'][$parid]['ip'] = clientIP(true);
        $meta['current'][$parid]['user'] = isset($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'] : '';
        $meta['current'][$parid]['reviews'] = array();
    } else {
        # Reverting old revision, restore metadata of reverted page
        for ($i = 0; $i < count($meta['current']); $i++) {
            if (empty($meta[$revert][$i]['changed'])) {
                # Paragraph last changed in the reverted
                # revision
                $meta['current'][$i] = $meta[$revert][$i];
                $meta['current'][$i]['changed'] = $revert;
            } else {
                # Paragraph last changed in even earlier
                # revision
                $tmp = $meta[$revert][$i]['changed'];
                $meta['current'][$i] = $meta[$tmp][$i];
                $meta['current'][$i]['changed'] = $tmp;
            }
        }
    }
    # Save metadata
    io_saveFile(metaFN($id, '.translateHistory'), serialize($meta));
    io_saveFile(metaFN($id, '.translate'), serialize($meta['current']));
}
Ejemplo n.º 13
0
 public function action_login()
 {
     $this->auto_render = FALSE;
     if ($this->request->is_ajax()) {
         $post = $this->request->post();
         $success = Auth_ORM::instance()->login($post['username'], $post['password']);
         if ($success) {
             $loginHistory = ORM::factory('User_LoginHistory');
             $loginHistory->uid = $success;
             $loginHistory->ip = clientIP();
             $loginHistory->userAgent = $_SERVER['HTTP_USER_AGENT'];
             $loginHistory->created = time();
             $loginHistory->updated = time();
             $loginHistory->save();
             jsonReturn(1001, '登陆成功', '/manage/dashboard/index');
         } else {
             jsonReturn(1800);
         }
     }
     $this->response->body(View::factory($this->theme . 'login', array('registerUrl' => '/register', 'findPasswordUrl' => '/findPassword')));
 }
Ejemplo n.º 14
0
/**
 * Add's an entry to the media changelog
 *
 * @author Michael Hamann <*****@*****.**>
 * @author Andreas Gohr <*****@*****.**>
 * @author Esther Brunner <*****@*****.**>
 * @author Ben Coburn <*****@*****.**>
 */
function addMediaLogEntry($date, $id, $type = DOKU_CHANGE_TYPE_EDIT, $summary = '', $extra = '', $flags = null)
{
    global $conf;
    $id = cleanid($id);
    if (!$date) {
        $date = time();
    }
    //use current time if none supplied
    $remote = clientIP(true);
    $user = $_SERVER['REMOTE_USER'];
    $strip = array("\t", "\n");
    $logline = array('date' => $date, 'ip' => $remote, 'type' => str_replace($strip, '', $type), 'id' => $id, 'user' => $user, 'sum' => utf8_substr(str_replace($strip, '', $summary), 0, 255), 'extra' => str_replace($strip, '', $extra));
    // add changelog lines
    $logline = implode("\t", $logline) . "\n";
    io_saveFile($conf['media_changelog'], $logline, true);
    //global media changelog cache
    io_saveFile(mediaMetaFN($id, '.changes'), $logline, true);
    //media file's changelog
}
Ejemplo n.º 15
0
/**
 * Delete a draft
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function ajax_draftdel()
{
    $id = cleanID($_REQUEST['id']);
    if (empty($id)) {
        return;
    }
    $client = $_SERVER['REMOTE_USER'];
    if (!$client) {
        $client = clientIP(true);
    }
    $cname = getCacheName($client . $id, '.draft');
    @unlink($cname);
}
Ejemplo n.º 16
0
 /**
  * Uploads a file to the wiki.
  *
  * Michael Klier <*****@*****.**>
  */
 function putAttachment($id, $file, $params)
 {
     $id = cleanID($id);
     $auth = auth_quickaclcheck(getNS($id) . ':*');
     if (!isset($id)) {
         throw new RemoteException('Filename not given.', 231);
     }
     global $conf;
     $ftmp = $conf['tmpdir'] . '/' . md5($id . clientIP());
     // save temporary file
     @unlink($ftmp);
     io_saveFile($ftmp, $file);
     $res = media_save(array('name' => $ftmp), $id, $params['ow'], $auth, 'rename');
     if (is_array($res)) {
         throw new RemoteException($res[0], -$res[1]);
     } else {
         return $res;
     }
 }
Ejemplo n.º 17
0
/**
 * Sends a notify mail on page change or registration
 *
 * @param  string  $id       The changed page
 * @param  string  $who      Who to notify (admin|subscribers|register)
 * @param  int     $rev      Old page revision
 * @param  string  $summary  What changed
 * @param  boolean $minor    Is this a minor edit?
 * @param  array   $replace  Additional string substitutions, @KEY@ to be replaced by value
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = array())
{
    global $lang;
    global $conf;
    global $INFO;
    // decide if there is something to do
    if ($who == 'admin') {
        if (empty($conf['notify'])) {
            return;
        }
        //notify enabled?
        $text = rawLocale('mailtext');
        $to = $conf['notify'];
        $bcc = '';
    } elseif ($who == 'subscribers') {
        if (!$conf['subscribers']) {
            return;
        }
        //subscribers enabled?
        if ($conf['useacl'] && $_SERVER['REMOTE_USER'] && $minor) {
            return;
        }
        //skip minors
        $data = array('id' => $id, 'addresslist' => '', 'self' => false);
        trigger_event('COMMON_NOTIFY_ADDRESSLIST', $data, 'subscription_addresslist');
        $bcc = $data['addresslist'];
        if (empty($bcc)) {
            return;
        }
        $to = '';
        $text = rawLocale('subscr_single');
    } elseif ($who == 'register') {
        if (empty($conf['registernotify'])) {
            return;
        }
        $text = rawLocale('registermail');
        $to = $conf['registernotify'];
        $bcc = '';
    } else {
        return;
        //just to be safe
    }
    $ip = clientIP();
    $text = str_replace('@DATE@', dformat(), $text);
    $text = str_replace('@BROWSER@', $_SERVER['HTTP_USER_AGENT'], $text);
    $text = str_replace('@IPADDRESS@', $ip, $text);
    $text = str_replace('@HOSTNAME@', gethostsbyaddrs($ip), $text);
    $text = str_replace('@NEWPAGE@', wl($id, '', true, '&'), $text);
    $text = str_replace('@PAGE@', $id, $text);
    $text = str_replace('@TITLE@', $conf['title'], $text);
    $text = str_replace('@DOKUWIKIURL@', DOKU_URL, $text);
    $text = str_replace('@SUMMARY@', $summary, $text);
    $text = str_replace('@USER@', $_SERVER['REMOTE_USER'], $text);
    $text = str_replace('@NAME@', $INFO['userinfo']['name'], $text);
    $text = str_replace('@MAIL@', $INFO['userinfo']['mail'], $text);
    foreach ($replace as $key => $substitution) {
        $text = str_replace('@' . strtoupper($key) . '@', $substitution, $text);
    }
    if ($who == 'register') {
        $subject = $lang['mail_new_user'] . ' ' . $summary;
    } elseif ($rev) {
        $subject = $lang['mail_changed'] . ' ' . $id;
        $text = str_replace('@OLDPAGE@', wl($id, "rev={$rev}", true, '&'), $text);
        $df = new Diff(explode("\n", rawWiki($id, $rev)), explode("\n", rawWiki($id)));
        $dformat = new UnifiedDiffFormatter();
        $diff = $dformat->format($df);
    } else {
        $subject = $lang['mail_newpage'] . ' ' . $id;
        $text = str_replace('@OLDPAGE@', 'none', $text);
        $diff = rawWiki($id);
    }
    $text = str_replace('@DIFF@', $diff, $text);
    if (utf8_strlen($conf['title']) < 20) {
        $subject = '[' . $conf['title'] . '] ' . $subject;
    } else {
        $subject = '[' . utf8_substr($conf['title'], 0, 20) . '...] ' . $subject;
    }
    mail_send($to, $subject, $text, $conf['mailfrom'], '', $bcc);
}
Ejemplo n.º 18
0
/**
 * Unlock a page if it was locked by the user
 *
 * @author Andreas Gohr <*****@*****.**>
 * @param string $id page id to unlock
 * @return bool true if a lock was removed
 */
function unlock($id)
{
    $lock = wikiLockFN($id);
    if (@file_exists($lock)) {
        list($ip, $session) = explode("\n", io_readFile($lock));
        if ($ip == $_SERVER['REMOTE_USER'] || $ip == clientIP() || $session == session_id()) {
            @unlink($lock);
            return true;
        }
    }
    return false;
}
Ejemplo n.º 19
0
/**
 * Builds a pseudo UID from browser and IP data
 *
 * This is neither unique nor unfakable - still it adds some
 * security. Using the first part of the IP makes sure
 * proxy farms like AOLs are still okay.
 *
 * @author  Andreas Gohr <*****@*****.**>
 *
 * @return  string  a MD5 sum of various browser headers
 */
function auth_browseruid()
{
    /* @var Input $INPUT */
    global $INPUT;
    $ip = clientIP(true);
    $uid = '';
    $uid .= $INPUT->server->str('HTTP_USER_AGENT');
    $uid .= $INPUT->server->str('HTTP_ACCEPT_ENCODING');
    $uid .= $INPUT->server->str('HTTP_ACCEPT_CHARSET');
    $uid .= substr($ip, 0, strpos($ip, '.'));
    $uid = strtolower($uid);
    return md5($uid);
}
Ejemplo n.º 20
0
/**
 * check X-Forwarded-For and get the pass-by IP addresses to log
 *
 * @author  wkpark at kldp.org
 *
 * @return  X-Forwarded-For address list + Remote Address if it needed
 */
function get_log_addr()
{
    $REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];
    if (!empty($Config['use_cloudflare']) && !empty($_SERVER['HTTP_CF_CONNECTING_IP'])) {
        return $_SERVER['HTTP_CF_CONNECTING_IP'];
    }
    if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) and $REMOTE_ADDR != $_SERVER['HTTP_X_FORWARDED_FOR']) {
        // XFF contains the REMOTE_ADDR ?
        $xff = str_replace(' ', '', $_SERVER['HTTP_X_FORWARDED_FOR']);
        $tmp = explode(',', $xff);
        // Real IP == REMOTE_ADDR case. (mod_remoteip etc.)
        if ($tmp[0] == $REMOTE_ADDR) {
            return $REMOTE_ADDR;
        }
        require_once 'lib/clientip.php';
        $filtered = clientIP(false);
        $tmp = explode(',', $filtered);
        $last = array_pop($tmp);
        if ($last == $REMOTE_ADDR) {
            $REMOTE_ADDR = $filtered;
        } else {
            // append REMOTE_ADDR
            $REMOTE_ADDR = $filtered . ',' . $REMOTE_ADDR;
        }
    }
    return $REMOTE_ADDR;
}
Ejemplo n.º 21
0
/**
 * Unlock a page if it was locked by the user
 *
 * @author Andreas Gohr <*****@*****.**>
 * @return bool true if a lock was removed
 */
function unlock($id)
{
    $lock = wikiLockFN($id);
    if (@file_exists($lock)) {
        $ip = io_readFile($lock);
        if ($ip == clientIP() || $ip == $_SERVER['REMOTE_USER']) {
            @unlink($lock);
            return true;
        }
    }
    return false;
}
Ejemplo n.º 22
0
<?php 
function clientIP()
{
    $cIP = getenv('REMOTE_ADDR');
    $cIP1 = getenv('HTTP_X_FORWARDED_FOR');
    $cIP2 = getenv('HTTP_CLIENT_IP');
    $cIP1 ? $cIP = $cIP1 : null;
    $cIP2 ? $cIP = $cIP2 : null;
    return $cIP;
}
$sql_server = "192.168.50.192";
if (preg_match('/^192\\.168\\.60\\..*/i', clientIP())) {
    $sql_server = "192.168.60.47";
}
$mysqli = new mysqli($sql_server, "testlink", "Eqp9qH9Pya9FMVyV", "testlink");
$mysqli->set_charset("utf8");
if (!isset($_GET['id'])) {
    $mysqli->close();
    exit;
} else {
    $id = $_GET['id'];
    if (isset($_GET['active'])) {
        $active = $_GET['active'];
        $query = " UPDATE testplan_tcversions SET active = '{$active}' WHERE id = {$id} ";
        $mysqli->query($query);
    }
    $mysqli->close();
    exit;
}
Ejemplo n.º 23
0
/**
 * Unlock a page if it was locked by the user
 *
 * @author Andreas Gohr <*****@*****.**>
 *
 * @param string $id page id to unlock
 * @return bool true if a lock was removed
 */
function unlock($id)
{
    /* @var Input $INPUT */
    global $INPUT;
    $lock = wikiLockFN($id);
    if (file_exists($lock)) {
        @(list($ip, $session) = explode("\n", io_readFile($lock)));
        if ($ip == $INPUT->server->str('REMOTE_USER') || $ip == clientIP() || $session == session_id()) {
            @unlink($lock);
            return true;
        }
    }
    return false;
}
Ejemplo n.º 24
0
 /**
  * Prepare default token replacement strings
  *
  * Populates the '$replacements' property.
  * Should be called by the class constructor
  */
 protected function prepareTokenReplacements()
 {
     global $INFO;
     global $conf;
     /* @var Input $INPUT */
     global $INPUT;
     global $lang;
     $ip = clientIP();
     $cip = gethostsbyaddrs($ip);
     $this->replacements['text'] = array('DATE' => dformat(), 'BROWSER' => $INPUT->server->str('HTTP_USER_AGENT'), 'IPADDRESS' => $ip, 'HOSTNAME' => $cip, 'TITLE' => $conf['title'], 'DOKUWIKIURL' => DOKU_URL, 'USER' => $INPUT->server->str('REMOTE_USER'), 'NAME' => $INFO['userinfo']['name'], 'MAIL' => $INFO['userinfo']['mail']);
     $signature = str_replace('@DOKUWIKIURL@', $this->replacements['text']['DOKUWIKIURL'], $lang['email_signature_text']);
     $this->replacements['text']['EMAILSIGNATURE'] = "\n-- \n" . $signature . "\n";
     $this->replacements['html'] = array('DATE' => '<i>' . hsc(dformat()) . '</i>', 'BROWSER' => hsc($INPUT->server->str('HTTP_USER_AGENT')), 'IPADDRESS' => '<code>' . hsc($ip) . '</code>', 'HOSTNAME' => '<code>' . hsc($cip) . '</code>', 'TITLE' => hsc($conf['title']), 'DOKUWIKIURL' => '<a href="' . DOKU_URL . '">' . DOKU_URL . '</a>', 'USER' => hsc($INPUT->server->str('REMOTE_USER')), 'NAME' => hsc($INFO['userinfo']['name']), 'MAIL' => '<a href="mailto:"' . hsc($INFO['userinfo']['mail']) . '">' . hsc($INFO['userinfo']['mail']) . '</a>');
     $signature = $lang['email_signature_text'];
     if (!empty($lang['email_signature_html'])) {
         $signature = $lang['email_signature_html'];
     }
     $signature = str_replace(array('@DOKUWIKIURL@', "\n"), array($this->replacements['html']['DOKUWIKIURL'], '<br />'), $signature);
     $this->replacements['html']['EMAILSIGNATURE'] = $signature;
 }
Ejemplo n.º 25
0
 /**
  * Uploads a file to the wiki.
  *
  * Michael Klier <*****@*****.**>
  */
 function putAttachment($id, $file, $params)
 {
     $id = cleanID($id);
     global $conf;
     global $lang;
     $auth = auth_quickaclcheck(getNS($id) . ':*');
     if ($auth >= AUTH_UPLOAD) {
         if (!isset($id)) {
             return new IXR_ERROR(1, 'Filename not given.');
         }
         $ftmp = $conf['tmpdir'] . '/' . md5($id . clientIP());
         // save temporary file
         @unlink($ftmp);
         $buff = base64_decode($file);
         io_saveFile($ftmp, $buff);
         // get filename
         list($iext, $imime, $dl) = mimetype($id);
         $id = cleanID($id);
         $fn = mediaFN($id);
         // get filetype regexp
         $types = array_keys(getMimeTypes());
         $types = array_map(create_function('$q', 'return preg_quote($q,"/");'), $types);
         $regex = join('|', $types);
         // because a temp file was created already
         if (preg_match('/\\.(' . $regex . ')$/i', $fn)) {
             //check for overwrite
             $overwrite = @file_exists($fn);
             if ($overwrite && (!$params['ow'] || $auth < AUTH_DELETE)) {
                 return new IXR_ERROR(1, $lang['uploadexist'] . '1');
             }
             // check for valid content
             $ok = media_contentcheck($ftmp, $imime);
             if ($ok == -1) {
                 return new IXR_ERROR(1, sprintf($lang['uploadexist'] . '2', ".{$iext}"));
             } elseif ($ok == -2) {
                 return new IXR_ERROR(1, $lang['uploadspam']);
             } elseif ($ok == -3) {
                 return new IXR_ERROR(1, $lang['uploadxss']);
             }
             // prepare event data
             $data[0] = $ftmp;
             $data[1] = $fn;
             $data[2] = $id;
             $data[3] = $imime;
             $data[4] = $overwrite;
             // trigger event
             return trigger_event('MEDIA_UPLOAD_FINISH', $data, array($this, '_media_upload_action'), true);
         } else {
             return new IXR_ERROR(1, $lang['uploadwrong']);
         }
     } else {
         return new IXR_ERROR(1, "You don't have permissions to upload files.");
     }
 }
Ejemplo n.º 26
0
/**
 * Delete a draft
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function ajax_draftdel()
{
    global $INPUT;
    $id = cleanID($INPUT->str('id'));
    if (empty($id)) {
        return;
    }
    $client = $_SERVER['REMOTE_USER'];
    if (!$client) {
        $client = clientIP(true);
    }
    $cname = getCacheName($client . $id, '.draft');
    @unlink($cname);
}
Ejemplo n.º 27
0
{
    $ipaddress = '';
    if (isset($_SERVER['HTTP_CLIENT_IP'])) {
        $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
    } else {
        if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
            $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
        } else {
            if (isset($_SERVER['HTTP_X_FORWARDED'])) {
                $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
            } else {
                if (isset($_SERVER['HTTP_FORWARDED_FOR'])) {
                    $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
                } else {
                    if (isset($_SERVER['HTTP_FORWARDED'])) {
                        $ipaddress = $_SERVER['HTTP_FORWARDED'];
                    } else {
                        if (isset($_SERVER['REMOTE_ADDR'])) {
                            $ipaddress = $_SERVER['REMOTE_ADDR'];
                        } else {
                            $ipaddress = 'UNKNOWN';
                        }
                    }
                }
            }
        }
    }
    return $ipaddress;
}
echo clientIP();
Ejemplo n.º 28
0
 if ($host_IP != "" && $IPServer != "" && $host_IP != $IPServer) {
     loadGlobalServers();
     $globalServers[$sh_host][1] = $IPServer;
     saveGlobalServers();
 }
 if ($country_whois == true) {
     $tara_nume = taraName($tara_code["tara"]);
 }
 echo "<table border=0 cellpadding=0 cellspacing=0>";
 echo "<tr>";
 echo "<td VALIGN = \"top\">";
 format1("Server", $sh_host);
 if ($host_IP == "unknown") {
     format1("IP/Clients", $host_IP);
 } else {
     format1("IP/Clients", $host_IP . " / " . clientIP($host_IP, $sh_host));
 }
 if ($country_whois == true) {
     if ($tara_code["tara"] == "??") {
         format1("Country", "Unresolved IP");
     } else {
         if ($tara_code["tara"] == "<>") {
             format1("Country", "Local Private IP");
         } else {
             format1("Country", $tara_code["tara"] . " , " . $tara_nume);
         }
     }
 }
 //format1("Connected from IP",clientIP($host_IP,$sh_host));
 if ($nodes["Info"][3] != "") {
     format1("NodeID", $nodes["Info"][3]);
Ejemplo n.º 29
0
/**
 * Builds a pseudo UID from browser and IP data
 *
 * This is neither unique nor unfakable - still it adds some
 * security. Using the first part of the IP makes sure
 * proxy farms like AOLs are stil okay.
 *
 * @author  Andreas Gohr <*****@*****.**>
 *
 * @return  string  a MD5 sum of various browser headers
 */
function auth_browseruid()
{
    $ip = clientIP(true);
    $uid = '';
    $uid .= $_SERVER['HTTP_USER_AGENT'];
    $uid .= $_SERVER['HTTP_ACCEPT_ENCODING'];
    $uid .= $_SERVER['HTTP_ACCEPT_LANGUAGE'];
    $uid .= $_SERVER['HTTP_ACCEPT_CHARSET'];
    $uid .= substr($ip, 0, strpos($ip, '.'));
    return md5($uid);
}
Ejemplo n.º 30
0
function canReview($id, $meta, $parid)
{
    return isModerator($id) && $meta[$parid]['user'] != $_SERVER['REMOTE_USER'] && $meta[$parid]['ip'] != clientIP(true);
}