Esempio n. 1
0
 public function index()
 {
     if ($this->isPost()) {
         $params = $this->input->post();
         $return_url = $params['return_url'];
         unset($params['return_url']);
         $ret = $this->user_model->checkLogin($params);
         if ($ret) {
             if ($return_url) {
                 $result = array_for_result(true, 'login success', array(), $return_url);
             } else {
                 $result = array_for_result(true, 'login success', array(), '/index.php/tips/index');
             }
             $cookie_d['u_id'] = $ret;
             $cookie_d['sso_key'] = encrypt_string_by_time();
             $cookie_data = json_encode($cookie_d);
             setcookie('admin_permit', $cookie_data, time() + 3600, '/', getDomain($_SERVER['HTTP_HOST']));
         } else {
             $result = array_for_result(false, 'login failed');
         }
         $this->renderJsonp($result, $params);
     } else {
         $params = $this->input->get();
         $return_url = isset($params['returnurl']) ? $params['returnurl'] : '';
         $data['title'] = 'Login';
         $data['return_url'] = $return_url;
         $this->render('login/index', $data);
     }
 }
Esempio n. 2
0
 /**
  * Формирование данных доступных в шаблоне.
  */
 function createData()
 {
     if ($this->params['sort'] != 2) {
         $this->supportCached();
     }
     switch ($this->params['sort']) {
         default:
         case 1:
             $sort = "sort";
             break;
         case 2:
             $sort = "RAND()";
             break;
     }
     $where = "i.idsec={$this->section_id}";
     if ($this->params['idalb'] > 0) {
         $where .= " AND i.iditem=" . (int) $this->params['idalb'];
     } elseif ($this->params['idcat'] > 0) {
         if ($idalbs = A::$DB->getCol("SELECT id FROM {$this->section}_albums WHERE idcat=" . (int) $this->params['idcat'])) {
             $where .= " AND (i.iditem=" . implode(" OR i.iditem=", $idalbs) . ")";
         }
     }
     $images = array();
     A::$DB->query("\r\r\n\tSELECT i.* FROM " . getDomain($this->section) . "_images AS i\r\r\n\tLEFT JOIN {$this->section}_albums AS a ON a.id=i.iditem\r\r\n\tWHERE {$where} AND a.active='Y' ORDER BY {$sort}" . (!empty($this->params['rows']) ? " LIMIT 0," . (int) $this->params['rows'] : ""));
     while ($row = A::$DB->fetchRow()) {
         if (isset($links[$row['iditem']])) {
             $row['link'] = $links[$row['iditem']];
         } else {
             $row['link'] = $links[$row['iditem']] = gallery_createItemLink($row['iditem'], $this->section);
         }
         $images[] = $row;
     }
     $this->Assign("images", $images);
 }
Esempio n. 3
0
/**
 * This helper function can be used to get a valid uri from an url and return it.
 *
 * @param string $url
 *
 * @return mixed
 */
function getUri($url)
{
    if (!empty($url)) {
        // Sanitize URL first by removing unwanted chars
        $url = preg_replace("/[\n\r]/", '', $url);
        // Sanitize URL accourding to RFC1738 (perhaps use RFC3986?)
        $entities = [' '];
        $replacements = ['%20'];
        $url = str_replace($entities, $replacements, $url);
        // Check weither the domain is actually valid
        if (getDomain($url) == false) {
            return false;
        }
        $pslManager = new Pdp\PublicSuffixListManager();
        $urlParser = new Pdp\Parser($pslManager->getList());
        $urlData = $urlParser->parseUrl($url)->toArray();
        $path = $urlData['path'] . (!empty($urlData['query']) ? '?' . $urlData['query'] : '');
        // Set the path to root if empty (default)
        if (empty($path)) {
            $path = '/';
        }
        // Sanitize PATH accourding to RFC1738 (perhaps use RFC3986?)
        $entities = [' '];
        $replacements = ['%20'];
        $path = str_replace($entities, $replacements, $path);
        return $path;
    } else {
        return false;
    }
}
 public function check_permission()
 {
     $WebSiteID = $this->session->userdata('WebSiteID');
     $GroupID = $this->session->userdata('GroupID');
     $AccID = $this->session->userdata('AccID');
     $PreWebSiteID = $this->session->userdata('WebSiteID');
     $url = trim($this->uri->uri_string());
     $routestring = explode('/', $url);
     $controller = @$routestring[0];
     $method = @$routestring[1];
     $WebID = $WebSiteID;
     $curr_class = @$controller;
     $curr_method = @$method;
     if (trim($curr_class) == '') {
         $curr_class = "redirect";
     }
     if (trim($curr_method) == '') {
         $curr_method = "index";
     }
     $controllerfile = 'application/controllers/' . $WebID . '/' . $curr_class . '.php';
     if (!file_exists($controllerfile)) {
         if ($curr_class == 'ajax') {
             $controllerfile = 'application/controllers/ajax.php';
         } else {
             $controllerfile = 'application/controllers/common/' . $curr_class . '.php';
             if (!file_exists($controllerfile)) {
                 $curr_class = "redirect";
                 $curr_method = "index";
             }
         }
     }
     $sql = "SELECT WebSiteID, Suspend FROM tbl_websites WITH (NOLOCK) WHERE Domain='" . mssql_real_escape_string(getDomain()) . "' AND Activate=1 AND StartTime< GETDATE() AND GETDATE()< ExpireTime";
     $query = $this->db->query($sql);
     $rowcount = $query->num_rows();
     if ($rowcount > 0) {
         $row = $query->row();
         if ($row->Suspend) {
             //show suspend page
             echo "suspend";
             show_404();
         } else {
             $WebSiteID = $row->WebSiteID;
             $this->session->set_userdata('WebSiteID', $row->WebSiteID);
         }
     } else {
         show_404();
     }
     if ($GroupID == '' || $GroupID === false) {
         $GroupID = 'public';
         $this->session->set_userdata('GroupID', $GroupID);
     }
     $sql = "SELECT count(*) total FROM tbl_websites_accounts_groups_models WITH (NOLOCK) WHERE Activate=1 AND GroupID='" . mssql_real_escape_string($GroupID) . "' AND ModelID='" . mssql_real_escape_string($curr_class) . "' AND (AccID='" . mssql_real_escape_string($AccID) . "' OR AccID='') AND (WebSiteID='" . mssql_real_escape_string($WebSiteID) . "' OR WebSiteID='')";
     $query = $this->db->query($sql);
     $row = $query->row();
     $total = $row->total;
     if ($total <= 0) {
         show_404();
     }
 }
Esempio n. 5
0
function getSocialUser()
{
    global $twitterFollowers;
    global $facebookFriends;
    global $relationshipStatus;
    global $politicalViews;
    global $logFileHandle;
    $thisUser = getUserBasics();
    $yob = substr($thisUser["birthday"], 0, 4);
    $age = date("Y") - $yob;
    $userValues["domain"] = getDomain();
    fwrite($logFileHandle, "<p>The domain is " . $userValues["domain"]);
    $userValues["identifier"] = getIdentifier($userValues["domain"]);
    /******************* Facebook ************************/
    if ($userValues["domain"] == "facebook.com") {
        if ($age > 18 && rand(1, 100) > 20) {
            $userValues["profile"]["relationshipStatus"] = getRelationshipStatus($age);
        }
        // if (!empty($relStatus)) { $userValues["profile"]["relationshipStatus"] = $relStatus; }
        // get political views
        if ($thisUser["primaryAddress"]["country"] == "United States") {
            if (rand(1, 100) > 61) {
                $polViews = getRandomValue($politicalViews);
                $userValues["profile"]["politicalViews"] = skewPoliticalViews($polViews, $age, $thisUser["gender"], $thisUser["primaryAddress"]["stateAbbreviation"]);
            }
        }
        $range = getRandomValue($facebookFriends);
        $numberOfFBfriends = rand($range["min"], $range["max"]);
        fwrite($logFileHandle, "<p>The number of friends is: " . $numberOfFBfriends);
        $userValues["friends"] = getFriendsOrFollowersArray($numberOfFBfriends, $userValues["domain"]);
        //*************** Interests, Movies, Books, Music **************/
        // parameters: &attribute_name=profiles%23181683&uuid=ea1bc321-4320-4fbb-8f07-fb939b90cf46&value={"profile":{"interests":[{"interest":"scrapbooking"},{"interest":"cats"},{"interest":"dogs"}],"movies":[{"movie":"Platoon"},{"movie":"Star+Trek+Into+Darkness"}],"books":[{"book":"Call+It+Sleep"},{"book":"The+Death+of+the+Heart"},{"book":"The+French+Lieutenant%27s+Woman"}],"music":[{"music":"Britney+Spears"}]}}
        $psychInfoTypes = array("interests" => "interest", "movies" => "movie", "books" => "book", "music" => "music");
        foreach ($psychInfoTypes as $categoryName => $itemName) {
            $numberOfItems = getNumberOfItems($itemName);
            $itemString = $itemName . "s";
            if ($itemName == "music") {
                $itemString = $itemName . " artists";
            }
            fwrite($logFileHandle, "<p>The number of {$itemString} is: " . $numberOfItems);
            if ($numberOfItems > 0) {
                $userValues["profile"][$categoryName] = getItems($itemName, $numberOfItems);
            }
        }
    }
    /********************* Twitter ***********************/
    if ($userValues["domain"] == "twitter.com") {
        $range = getRandomValue($twitterFollowers);
        $numberOfTWfollowers = rand($range["min"], $range["max"]);
        fwrite($logFileHandle, "<p>The number of followers is: " . $numberOfTWfollowers);
        $userValues["followers"] = getFriendsOrFollowersArray($numberOfTWfollowers, $userValues["domain"]);
    }
    $thisUser["profiles"] = array();
    $thisUser["profiles"][] = $userValues;
    return $thisUser;
}
Esempio n. 6
0
 /**
  * Формирование данных доступных в шаблоне.
  */
 function createData()
 {
     if ($this->params['sort'] != 5) {
         $this->supportCached();
     }
     $this->params['idcat'] = (int) $this->params['idcat'];
     $this->params['rows'] = (int) $this->params['rows'];
     if ($this->params['idcat']) {
         $catrow = A::$DB->getRowById($this->params['idcat'], "{$this->section}_categories");
         $catrow['link'] = gallery_createCategoryLink($this->params['idcat'], $this->section);
         $this->Assign("category", $catrow);
     }
     switch ($this->params['sort']) {
         default:
         case 1:
             $sort = "date DESC";
             break;
         case 2:
             $sort = "date";
             break;
         case 3:
             $sort = "name";
             break;
         case 4:
             $sort = "sort";
             break;
         case 5:
             $sort = "RAND()";
             break;
     }
     $sql = "\r\r\n\tSELECT *,svote/cvote AS vote FROM {$this->section}_albums\r\r\n\tWHERE active='Y'" . ($this->params['idcat'] ? " AND idcat={$this->params['idcat']}" : "") . (!empty($this->params['filter']) ? " AND {$this->params['filter']}" : "") . "\r\r\n\tORDER BY {$sort}";
     if ($this->params['rows']) {
         A::$DB->queryLimit($sql, 0, $this->params['rows']);
     } else {
         A::$DB->query($sql);
     }
     $albums = array();
     while ($row = A::$DB->fetchRow()) {
         $row['category'] = getTreePath($this->section . "_categories", $row['idcat']);
         $row['link'] = gallery_createItemLink($row['id'], $this->section);
         $row['vote'] = round($row['vote'], 2);
         $row['images'] = A::$DB->getAll("\r\r\n\t  SELECT * FROM " . getDomain($this->section) . "_images\r\r\n\t  WHERE idsec=? AND iditem=? ORDER BY sort", array($this->section_id, $row['id']));
         if ($this->options['usetags']) {
             $row['tags'] = A_SearchEngine::getInstance()->convertTags($row['tags']);
         }
         prepareValues($this->section, $row);
         $row = A::$OBSERVER->Modifier('gallery_prepareValues', $this->section, $row);
         $albums[] = $row;
     }
     A::$DB->free();
     $this->Assign("albums", $albums);
 }
Esempio n. 7
0
 /**
  * Parse attachments
  * @return array    Returns array with failed or success data
  *                  (See parser-common/src/Parser.php) for more info.
  */
 public function parse()
 {
     $reports = [];
     if ($this->parsedMail->getHeader('subject') == "[SpamCop] summary report") {
         $this->feedName = 'summary';
         $reports = $this->parseSummaryReport();
     } elseif ($this->parsedMail->getHeader('subject') == "[SpamCop] Alert") {
         $this->feedName = 'alert';
         $reports = $this->parseAlerts();
     } elseif (strpos($this->parsedMail->getHeader('from'), "@reports.spamcop.net") !== false && $this->arfMail !== false) {
         $this->feedName = 'spamreport';
         $reports = $this->parseSpamReportArf();
     } elseif (strpos($this->parsedMail->getHeader('from'), "@reports.spamcop.net") !== false && strpos($this->parsedMail->getMessageBody(), '[ Offending message ]')) {
         $this->feedName = 'spamreport';
         $reports = $this->parseSpamReportCustom();
     } else {
         $this->warningCount++;
     }
     foreach ($reports as $report) {
         // If feed is known and enabled, validate data and save report
         if ($this->isKnownFeed() && $this->isEnabledFeed()) {
             // Sanity check
             if ($this->hasRequiredFields($report) === true) {
                 // incident has all requirements met, filter and add!
                 $report = $this->applyFilters($report);
                 if (!empty($report['Spam-URL'])) {
                     $url = $report['Spam-URL'];
                 }
                 if (!empty($report['Reported-URI'])) {
                     $url = $report['Reported-URI'];
                 }
                 if (!empty($url)) {
                     $urlData = getUrldata($url);
                     if (!empty($urlData['host']) && !empty($urlData['path'])) {
                         $this->feedName = 'spamvertizedreport';
                     }
                 }
                 $incident = new Incident();
                 $incident->source = config("{$this->configBase}.parser.name");
                 $incident->source_id = false;
                 $incident->ip = $report['Source-IP'];
                 $incident->domain = empty($url) ? false : getDomain($url);
                 $incident->class = config("{$this->configBase}.feeds.{$this->feedName}.class");
                 $incident->type = config("{$this->configBase}.feeds.{$this->feedName}.type");
                 $incident->timestamp = strtotime($report['Received-Date']);
                 $incident->information = json_encode($report);
                 $this->incidents[] = $incident;
             }
         }
     }
     return $this->success();
 }
Esempio n. 8
0
/**
 * Обработчик события "Создание раздела".
 *
 * @param string $section Полный строковой идентификатор раздела.
 * @param array $params Параметры события.
 */
function archive_createSection($section, $params)
{
    if ($params['module'] == 'archive') {
        $ids = A::$DB->getCol("\r\r\n    SELECT id FROM " . getDomain($section) . "_sections\r\r\n\tWHERE module='catalog' AND (lang='" . A::$LANG . "' OR lang='all')");
        setOption($section, 'sections', serialize($ids));
    } elseif ($params['module'] == 'catalog') {
        if ($archive = getSectionByModule('archive')) {
            $ids = getOption($archive, 'sections');
            $ids = !empty($ids) ? unserialize($ids) : array();
            $ids[] = $params['id'];
            setOption($archive, 'sections', serialize($ids));
        }
    }
}
Esempio n. 9
0
/**
 * Обработчик события "Создание раздела".
 *
 * @param string $section Полный строковой идентификатор раздела.
 * @param array $params Параметры события.
 */
function sitemap_createSection($section, $params)
{
    if ($params['module'] == 'sitemap') {
        $ids = A::$DB->getCol("SELECT id FROM " . getDomain($section) . "_sections WHERE lang='" . A::$LANG . "' OR lang='all'");
        setTextOption($section, 'sections', serialize($ids));
    } elseif ($sitemap = getSectionByModule('sitemap')) {
        $ids = getTextOption($sitemap, 'sections');
        $ids = !empty($ids) ? unserialize($ids) : array();
        if (!$ids) {
            $ids = array();
        }
        $ids[] = $params['id'];
        setTextOption($sitemap, 'sections', serialize($ids));
    }
}
Esempio n. 10
0
 public function termSearchByUrl(Request $request)
 {
     $url = $request['url'];
     $connection = getSiteName(getDomain($url));
     $path_alias = getUri($url);
     if (empty($connection) || empty($path_alias)) {
         return AJAX::argumentError();
     }
     $termModule = new TermModule($connection);
     $result = $termModule->getTermInfo(array('path_alias' => $path_alias));
     if (count($result) > 0) {
         return AJAX::success(array('info' => $result));
     } else {
         return AJAX::notExist();
     }
 }
Esempio n. 11
0
 public function productSearchByURL(Request $request)
 {
     $url = $request['url'];
     $connection = getSiteName(getDomain($url));
     $sn = getSn($url);
     if (empty($connection) || empty($sn)) {
         return AJAX::argumentError();
     }
     $termModule = new ProductModule($connection);
     $result = $termModule->getProductInfo(array('sn' => $sn));
     if (count($result) > 0) {
         return AJAX::success(array('info' => $result));
     } else {
         return AJAX::notExist();
     }
 }
Esempio n. 12
0
 /**
  * Parse attachments
  * @return array    Returns array with failed or success data
  *                  (See parser-common/src/Parser.php) for more info.
  */
 public function parse()
 {
     $xml = simplexml_load_string($this->parsedMail->getMessageBody());
     $timestamp = strtotime($xml->attributes()->date);
     foreach ($xml->list as $reports) {
         $this->feedName = (string) $reports->attributes()->type;
         // If feed is known and enabled, validate data and save report
         if ($this->isKnownFeed() && $this->isEnabledFeed()) {
             foreach ($reports->url_info as $url_info) {
                 $url = (string) $url_info->attributes()->url;
                 $ip = (string) $url_info->attributes()->ip;
                 $urlData = getUrlData($url);
                 if (filter_var($ip, FILTER_VALIDATE_IP) === false) {
                     // No IP supplied by Google
                     if (!empty($urlData['host']) && !filter_var($urlData['host'], FILTER_VALIDATE_IP) === false) {
                         // Hostname is an IP address
                         $ip = $urlData['host'];
                     } else {
                         // We have no IP address, try to get the IP address by resolving the domain
                         $ip = @gethostbyname($urlData['host']);
                         // If it fails, set to localhost
                         $ip = $ip == $urlData['host'] ? '127.0.0.1' : $ip;
                     }
                 }
                 $report = ['domain' => getDomain($url), 'uri' => getUri($url), 'category' => config("{$this->configBase}.feeds.{$this->feedName}.category")];
                 // Sanity check
                 if ($this->hasRequiredFields($report) === true) {
                     // incident has all requirements met, filter and add!
                     $report = $this->applyFilters($report);
                     $incident = new Incident();
                     $incident->source = config("{$this->configBase}.parser.name");
                     $incident->source_id = false;
                     $incident->ip = $ip;
                     $incident->domain = $report['domain'];
                     $incident->class = config("{$this->configBase}.feeds.{$this->feedName}.class");
                     $incident->type = config("{$this->configBase}.feeds.{$this->feedName}.type");
                     $incident->timestamp = $timestamp;
                     $incident->information = json_encode(array_merge($urlData, $report));
                     $this->incidents[] = $incident;
                 }
             }
         }
     }
     return $this->success();
 }
Esempio n. 13
0
 /**
  * Builds a Clean URL. Domain name is pulled from getDomain
  *
  * @param string $c the controller object to invoke
  * @param string $m the method of the controller to call
  * @param int $id (optional) the id of the record being updated
  * @param array $qs (optional) array/assoc array/model of query string variables and values
  * @return string a clean URL
  *
  */
 public function BuildCleanURL($c, $m, $id = null, $qs = null)
 {
     $idStr = "";
     $qsStr = "";
     if (is_object($qs)) {
         $qs2 = array();
         foreach ($qs as $k => $v) {
             $qs2[] = "{$k}={$v}";
         }
         $qsStr = "/?" . implode("&", $qs2);
     } elseif (_isArray($qs)) {
         $qsStr = $this->BuildQSFromArray($qs);
     }
     if ($id != null) {
         $idStr = "/" . (string) $id;
     }
     $dir = $this->state == "live" ? "" : "Public/";
     return str_replace(array("~d~", "~dir~", "~c~", "~m~", "~id~", "~qs~"), array(getDomain(), $dir, $c, $m, $idStr, $qsStr), $this->cleanURLTemplate);
 }
Esempio n. 14
0
 /**
  * Parse attachments
  * @return array    Returns array with failed or success data
  *                  (See parser-common/src/Parser.php) for more info.
  */
 public function parse()
 {
     foreach ($this->parsedMail->getAttachments() as $attachment) {
         if (strpos($attachment->filename, '-report.txt') === false) {
             continue;
         }
         // Handle aliasses first
         foreach (config("{$this->configBase}.parser.aliases") as $alias => $real) {
             if ($attachment->filename == "{$alias}-report.txt") {
                 $this->feedName = $real;
                 break;
             }
         }
         if ($this->isKnownFeed() && $this->isEnabledFeed()) {
             // Sanity check
             $report = str_replace("\r", "", $attachment->getContent());
             if (preg_match_all('/([\\w\\-]+): (.*)[ ]*\\r?\\n/', $report, $matches)) {
                 $report = array_combine($matches[1], $matches[2]);
                 if ($this->hasRequiredFields($report) === true) {
                     // incident has all requirements met, filter and add!
                     $report = $this->applyFilters($report);
                     $incident = new Incident();
                     $incident->source = config("{$this->configBase}.parser.name");
                     $incident->source_id = false;
                     $incident->ip = $report['ip'];
                     $incident->domain = empty($report['uri']) ? false : getDomain($report['uri']);
                     $incident->class = config("{$this->configBase}.feeds.{$this->feedName}.class");
                     $incident->type = config("{$this->configBase}.feeds.{$this->feedName}.type");
                     $incident->timestamp = strtotime($report['last_seen']);
                     $incident->information = json_encode($report);
                     $this->incidents[] = $incident;
                 }
             } else {
                 // Unable to build report
                 $this->warningCount++;
             }
         }
     }
     return $this->success();
 }
Esempio n. 15
0
 /**
  * Parse attachments
  * @return array    Returns array with failed or success data
  *                  (See parser-common/src/Parser.php) for more info.
  */
 public function parse()
 {
     if ($this->arfMail !== true) {
         $this->feedName = 'default';
         // If feed is known and enabled, validate data and save report
         if ($this->isKnownFeed() && $this->isEnabledFeed()) {
             // To get some more consitency, remove "\r" from the report.
             $this->arfMail['report'] = str_replace("\r", "", $this->arfMail['report']);
             // Build up the report
             preg_match_all("/([\\w\\-]+): (.*)[ ]*\n/m", $this->arfMail['report'], $matches);
             $report = array_combine($matches[1], $matches[2]);
             // Sanity check
             if ($this->hasRequiredFields($report) === true) {
                 // Grap the domain and user from the authentication results for contact lookup (byDomain)
                 preg_match("/smtp.auth=(?<user>.*)@(?<domain>.*)/m", $report['Authentication-Results'], $matches);
                 if (!empty($matches) && is_array($matches) && !empty($matches[0])) {
                     $report['Source-User'] = $matches['user'];
                     $report['Source-Domain'] = $matches['domain'];
                 }
                 ksort($report);
                 // incident has all requirements met, filter and add!
                 $report = $this->applyFilters($report);
                 $incident = new Incident();
                 $incident->source = config("{$this->configBase}.parser.name");
                 $incident->source_id = false;
                 $incident->ip = $report['Source-IP'];
                 $incident->domain = empty($report['Source-Domain']) ? false : getDomain($report['Source-Domain']);
                 $incident->class = config("{$this->configBase}.feeds.{$this->feedName}.class");
                 $incident->type = config("{$this->configBase}.feeds.{$this->feedName}.type");
                 $incident->timestamp = strtotime($report['Arrival-Date']);
                 $incident->information = json_encode($report);
                 $this->incidents[] = $incident;
             }
         }
     }
     return $this->success();
 }
Esempio n. 16
0
 public static function initCookie()
 {
     //在非命令行下设置相关的cookie
     if (strpos(php_sapi_name(), 'cli') === false) {
         ini_set('session.cookie_domain', getDomain());
         //设置cookie作用域
         ini_set('session.cookie_path', '/');
         //设置cookie的有效路径
         ini_set('session.save_path', ROOT_PATH . 'temp/session');
         //设置session的保存路径
         ini_set('session.cookie_lifetime', 0);
         //表示用于session的cookie的有效期在浏览器打开期间有效
         ini_set('session.gc_maxlifetime', 72000);
         //如果session放在redis那么这里不起作用
         ini_set('session.gc_probability', 1);
         //垃圾收集的处理几率
         ini_set('session.gc_divisor', 50);
         //设置进程比率
         ini_set('session.use_cookies', 1);
         //session使用cookie的功能
         //创建session路径文件夹
         if (!is_dir(ROOT_PATH . 'temp/session')) {
             mkdir(ROOT_PATH . 'temp/session', 0755, true);
         }
         //开启session
         if (SESSION_AUTO_START == true) {
             if (!session_id()) {
                 session_start();
             }
         }
     }
 }
Esempio n. 17
0
 /**
  * Parse attachments
  * @return array    Returns array with failed or success data
  *                  (See parser-common/src/Parser.php) for more info.
  */
 public function parse()
 {
     // Validate user based regex
     try {
         preg_match(config("{$this->configBase}.parser.file_regex"), '', $matches);
     } catch (\Exception $e) {
         $this->warningCount++;
         return $this->failed('Configuration error in the regular expression');
     }
     foreach ($this->parsedMail->getAttachments() as $attachment) {
         if (strpos($attachment->filename, '.zip') !== false && $attachment->contentType == 'application/octet-stream') {
             $zip = new Zipper();
             if (!$this->createWorkingDir()) {
                 return $this->failed("Unable to create working directory");
             }
             file_put_contents($this->tempPath . $attachment->filename, $attachment->getContent());
             $zip->zip($this->tempPath . $attachment->filename);
             $zip->extractTo($this->tempPath);
             foreach ($zip->listFiles() as $index => $compressedFile) {
                 if (strpos($compressedFile, '.csv') !== false) {
                     // For each CSV file we find, we are going to do magic (however they usually only send 1 zip)
                     if (preg_match(config("{$this->configBase}.parser.file_regex"), $compressedFile, $matches)) {
                         $this->feedName = $matches[1];
                         // If feed is known and enabled, validate data and save report
                         if ($this->isKnownFeed() && $this->isEnabledFeed()) {
                             $csvReports = new Reader\CsvReader(new SplFileObject($this->tempPath . $compressedFile));
                             $csvReports->setHeaderRowNumber(0);
                             foreach ($csvReports as $report) {
                                 // Handle field mappings first
                                 $aliasses = config("{$this->configBase}.feeds.{$this->feedName}.aliasses");
                                 if (is_array($aliasses)) {
                                     foreach ($aliasses as $alias => $real) {
                                         if (array_key_exists($alias, $report)) {
                                             $report[$real] = $report[$alias];
                                             unset($report[$alias]);
                                         }
                                     }
                                 }
                                 /*
                                  * Legacy 3.x fix for migrations.
                                  *
                                  * This resolves shadowserver errors where the CSV was send in duplicate resulting
                                  * in the header fields being used as data. If the header is detected the row can
                                  * be skipped safely
                                  */
                                 if ($report['ip'] === 'ip') {
                                     continue;
                                 }
                                 // Sanity check
                                 if ($this->hasRequiredFields($report) === true) {
                                     // incident has all requirements met, filter and add!
                                     $report = $this->applyFilters($report);
                                     $incident = new Incident();
                                     $incident->source = config("{$this->configBase}.parser.name");
                                     $incident->source_id = false;
                                     $incident->ip = $report['ip'];
                                     $incident->domain = false;
                                     $incident->class = config("{$this->configBase}.feeds.{$this->feedName}.class");
                                     $incident->type = config("{$this->configBase}.feeds.{$this->feedName}.type");
                                     $incident->timestamp = strtotime($report['timestamp']);
                                     $incident->information = json_encode($report);
                                     // some rows have a domain, which is an optional column we want to register
                                     switch ($this->feedName) {
                                         case "spam_url":
                                             if (isset($report['url'])) {
                                                 $incident->domain = getDomain($report['url']);
                                             }
                                             break;
                                         case "ssl_scan":
                                             if (isset($report['subject_common_name'])) {
                                                 /*
                                                  * Common name does not add http://, but that is required for
                                                  * the domain helper check so lets add it manually
                                                  */
                                                 $testurl = "http://{$report['subject_common_name']}";
                                                 $incident->domain = getDomain($testurl);
                                             }
                                             break;
                                         case "compromised_website":
                                             if (isset($report['http_host'])) {
                                                 $incident->domain = getDomain($report['http_host']);
                                             }
                                             break;
                                     }
                                     $this->incidents[] = $incident;
                                 }
                                 //End hasRequired fields
                             }
                             // End foreach report loop
                         }
                         // End isKnown & isEnabled
                     } else {
                         // Pregmatch failed to get feedName from attachment
                         $this->warningCount++;
                     }
                 } else {
                     // Attached file is not a CSV within a ZIP file
                     $this->warningCount++;
                 }
             }
             // End each file in ZIP attachment loop
         }
         // End if not a ZIP attachment
     }
     // End foreach attachment loop
     return $this->success();
 }
/**
 * Gets a title from a remote URL.
 * @param  [type] $url     The URL to fetch a readable title from.
 * @param  [type] $comment A comment, if you need one.
 * @return [type]          Returns nothing; pushes data directly into $_SESSION
 *                         (This may change later)
 */
function parseURL($url, $comment)
{
    session_name('pubTool');
    header('P3P: CP="CAO PSA OUR"');
    if (verifyURL($url) == false) {
        die("That doesn't look like an URL to me. Click <a href=\"index.php\">here</a> and try again!");
    }
    $url = HttpUri::createFromString($url);
    $url = sanitizeURL($url);
    $title = getTitle($url);
    $domain = getDomain($url);
    $_SESSION["linkList"][] = ['url' => strval($url), 'title' => strval($title), 'domain' => strval($domain), 'comment' => strval($comment)];
}
Esempio n. 19
0
function getPathinDomain()
{
    $dir = getDomain();
    $dir = str_replace("http://" . $_SERVER['HTTP_HOST'], "", $dir);
    if (substr($dir, 0, 1) != "/") {
        $dir = "/" . $dir;
    }
    if (substr($dir, strlen($dir) - 1, 1) == "/") {
        $dir = substr($dir, 0, strlen($dir) - 1);
    }
    return $dir;
}
Esempio n. 20
0
function admin_folder()
{
    $folder_no = substr(uniqid(""), 2, 7);
    $folder_id = strtoupper($folder_no);
    return $folder_id;
}
$full_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$path = dirname($full_url);
$_SESSION["path"] = $path;
$fo = explode('/', $path);
$folder = array_pop($fo);
function getDomain($url)
{
    return preg_replace("/^[\\w]{2,6}:\\/\\/([\\w\\d\\.\\-]+).*\$/", "\$1", $url);
}
if ($folder == getDomain($path)) {
    $folder = "null";
}
$sp = getcwd();
$sp = str_replace('\\', '/', $sp);
$text2 = '';
if ($step == 1) {
    $submit = "Next Step";
    $InputValue = $path;
    $text = "Your website URL:";
    $text2 = "Absolute server path:";
    if (isset($_GET['u']) && $_GET['u'] == 1) {
        $style = 'background-color:#FFCC00;';
        $msg = 'It seems that the website url is incorrect !<br><br>You can continue the installation but certain functions will be disabled.<br>You can rectify the url now or later by editing the file "lib/path.php"';
        $note = "Rectify if is false";
    }
Esempio n. 21
0
	return $userAddress;
}

if(count($_POST)) {
	$unhostedAccount = new UnhostedAccount(getUserAddress("user_address", $_POST), getString("pwd", $_POST));
	$token = $unhostedAccount->addAPP(getDomain("scope", $_POST));
	if($token) {
		header("Location:".getUri("redirect_uri", $_POST)."#access_token=".$token."&token_type=unhosted");
		echo "redirecting you back to the application.\n";
	} else {
		echo "Wrong password!";
	}
} else {
	$userAddress = getUserAddress('user_address', $_GET);
	$clientId = getDomain('client_id', $_GET);
	$dataScope = getDomain('scope', $_GET);
	$redirectUri = getUri('redirect_uri', $_GET);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />

<script src="/jQuery/jquery-1.6.1.min.js"></script>
<script src="/css/html5.js"></script><!-- this is the javascript allowing html5 to run in older browsers -->

<title>My Unhosted node</title>
<link rel="stylesheet" href="/css/uncompressed/reset.css" />
<link rel="stylesheet" href="/css/uncompressed/text.css" />
<link rel="stylesheet" href="/css/general.css" />
<link rel="stylesheet" href="/css/uncompressed/login.css" />
            $(window).resize(function() {
                $("#footer").pinFooter("relative");
            });

            $(document).ready(function() {
                $("#footer").pinFooter();
            });

        </script>

    </head>

<?php 
include "readConf.php";
error_reporting(E_ALL);
$domain = getDomain("config.ini");
function fromURI($uri)
{
    global $domain;
    if (substr($uri, 0, strlen($domain)) == $domain) {
        $uri = substr($uri, strlen($domain), strlen($uri));
    }
    return $uri;
}
$uri = $_GET['uri'];
$file = fromURI($uri);
// Remove file from server
unlink($file);
// Now ping URI to Sindice to get 404 error
// This removes the document from Sindice database
include "sindicePing.php";
$stream .= "  <subtitle>Why Google it when you can SkipSearch?</subtitle>\n";
$stream .= "  <updated>2010-09-09T09:00:57+02:00</updated>\n";
$stream .= "  <author>\n";
$stream .= "    <name>Bryan Copeland</name>\n";
$stream .= "    <uri>http://bryancopeland.com/</uri>\n";
$stream .= "  </author>\n";
$stream .= "  <link rel=\"self\" type=\"application/atom+xml\" href=\"http://skipsearch.net/stream/ActivityStreamsWriter.php\" />\n";
$stream .= "  <link rel=\"alternate\" href=\"http://skipsearch.net/stream/\" />\n";
foreach ($list as $timestamp => $item) {
    $this_day = date("F jS", $timestamp);
    if ($day != $this_day) {
        $day = $this_day;
    }
    $service_type = $item["name"];
    $service_url = $account[$service_type];
    $service_domain = getDomain($service_url);
    $link = str_replace('&', '&amp;', $item["link"]);
    $title = trim(htmlspecialchars($item["title"]));
    $published_year = date("Y", $timestamp);
    $published_time = date("g:ia", $timestamp);
    $published_timestamp = date("c", $timestamp);
    $stream .= "<entry>\n";
    $stream .= "  <id>tag:{$service_domain},{$published_year}:{$link}</id>\n";
    $stream .= "  <title>{$title}</title>\n";
    $stream .= "  <published>{$published_timestamp}</published>\n";
    $stream .= "  <updated>{$published_timestamp}</updated>\n";
    $stream .= "  <author><name>Bryan Copeland</name><uri>http://bryancopeland.com</uri></author>\n";
    $stream .= "  <link type=\"text/html\" rel=\"alternate\" href=\"{$link}\"/>\n";
    $stream .= "  <link type=\"image/gif\" rel=\"image\" href=\"http://skipsearch.net/images/icons/{$service_type}.gif\"/>\n";
    $stream .= "  <activity:verb>http://activitystrea.ms/schema/1.0/{$service_type}</activity:verb>\n";
    $stream .= "  <activity:object>\n";
Esempio n. 24
0
function modifyDomainPerm($domainId, $userId, $admin)
{
    if (!$domainId || !$userId) {
        return FALSE;
    }
    if (!isDomainAdmin()) {
        return FALSE;
    }
    if ($userId == $_SESSION['user']['user_id']) {
        return FALSE;
    }
    if (!userIsActive($userId)) {
        return FALSE;
    }
    $user = getUserEmail($userId);
    if (!$user) {
        return FALSE;
    }
    $domain = getDomain($domainId);
    if (!$domain) {
        return FALSE;
    }
    $adminDomains = getAdminDomains();
    if (!in_array($domain, $adminDomains)) {
        return FALSE;
    }
    $params = array('user_id' => $userId, 'domain_id' => $domainId);
    if ($admin) {
        return db_insert('domain_administrators', $params, 'admin_id');
    } else {
        return db_delete('domain_administrators', $params);
    }
}
Esempio n. 25
0
/**
 * Wrapper function to obtain only the public suffix.
 *
 * @param $url a URL string
 */
function getPublicSuffix(&$url)
{
    global $icannDomains;
    return getDomain($url)[2];
}
Esempio n. 26
0
					<?php 
            } else {
                ?>
					<ul class="list-unstyled photo-info">
					<li class="text-muted"><?php 
                echo _LANG('m1015', 'mediaset');
                ?>
 : <?php 
                echo getDateFormat($_R['d_update'] ? $_R['d_update'] : $_R['d_regis'], 'Y.m.d H:i');
                ?>
</li>
					<li class="text-muted"><?php 
                echo _LANG('m1019', 'mediaset');
                ?>
 : <?php 
                echo getDomain($_R['src']);
                ?>
</li>
					<li class="text-muted"><?php 
                echo _LANG('m1018', 'mediaset');
                ?>
 : <?php 
                echo $_R['ext'];
                ?>
</li>
					</ul>
					<?php 
            }
            ?>
				</div>
			</div>
 /**
  * Contains the added validations centralized on a single loaded place.
  *
  * @return void
  */
 public function boot()
 {
     /*
      * Add timestamp validation
      */
     /* @noinspection PhpUnusedParameterInspection */
     Validator::extend('timestamp', function ($attribute, $value, $parameters, $validator) {
         $check = (is_int($value) or is_float($value)) ? $value : (string) (int) $value;
         return $check === $value && $value <= PHP_INT_MAX && $value >= ~PHP_INT_MAX;
     });
     /*
      * Add validation for multiple comma seperated e-mails
      */
     /* @noinspection PhpUnusedParameterInspection */
     Validator::extend('emails', function ($attribute, $value, $parameters, $validator) {
         $rules = ['email' => 'required|email'];
         $value = explode(',', $value);
         foreach ($value as $email) {
             $data = ['email' => $email];
             $validator = Validator::make($data, $rules);
             if ($validator->fails()) {
                 return false;
             }
         }
         return true;
     });
     /*
      * Add validation for valid and existing files on the filesystem
      */
     /* @noinspection PhpUnusedParameterInspection */
     Validator::extend('file', function ($attribute, $value, $parameters, $validator) {
         if (!is_file($value)) {
             return false;
         }
         if (filesize($value) < 8) {
             return false;
         }
         return true;
     });
     /*
      * Add validation for abuse class
      */
     /* @noinspection PhpUnusedParameterInspection */
     Validator::extend('abuseclass', function ($attribute, $value, $parameters, $validator) {
         $classes = Lang::get('classifications');
         return array_key_exists($value, $classes);
     });
     /*
      * Add validation for abuse type
      */
     /* @noinspection PhpUnusedParameterInspection */
     Validator::extend('abusetype', function ($attribute, $value, $parameters, $validator) {
         $types = config('types.type');
         return in_array($value, $types);
     });
     /*
      * Add validation for string or boolean
      */
     /* @noinspection PhpUnusedParameterInspection */
     Validator::extend('stringorboolean', function ($attribute, $value, $parameters, $validator) {
         foreach (['string', 'boolean'] as $validation) {
             $validator = Validator::make(['field' => $value], ['field' => "required|{$validation}"]);
             if (!$validator->fails()) {
                 return true;
             }
         }
         return false;
     });
     /*
      * Add validation for domain
      */
     /* @noinspection PhpUnusedParameterInspection */
     Validator::extend('domain', function ($attribute, $value, $parameters, $validator) {
         if (is_bool($value)) {
             return true;
         }
         $url = 'http://' . $value;
         $domain = getDomain($url);
         if ($value !== $domain) {
             return false;
         }
         return true;
     });
     /*
      * Add validation for URI
      */
     /* @noinspection PhpUnusedParameterInspection */
     Validator::extend('uri', function ($attribute, $value, $parameters, $validator) {
         if (is_bool($value)) {
             return true;
         }
         if (!filter_var('http://test.for.var.com' . $value, FILTER_VALIDATE_URL) === false) {
             return true;
         }
         return false;
     });
     /*
      * Validator that checks that only one flag is set in all the row of the model
      */
     Validator::extend('uniqueflag', function ($attribute, $value, $parameters, $validator) {
         // gather data
         $data = $validator->getData();
         // check parameters
         if (count($parameters) != 2) {
             Log::alert('uniqueflag validator: called without the needed parameters');
             return true;
         }
         // if it is a string convert to boolean
         if (gettype($value) == 'string') {
             $value = ($value == 'true' or $value == '1' ? true : false);
         }
         if ($value) {
             $table = $parameters[0];
             $field = $parameters[1];
             // create the query
             $query = \DB::table($table)->where($field, true);
             // are we in an update (id is set)
             if (array_key_exists('id', $data)) {
                 $query = $query->andWhereNot('id', $data['id']);
             }
             try {
                 $object = $query->first();
             } catch (QueryException $e) {
                 $message = $e->getMessage();
                 Log::alert("uniqueflag validator: unexpected QueryException [{$message}], possible wrong parameters ?");
                 return true;
             }
             if (!empty($object)) {
                 return false;
             }
         }
         return true;
     });
 }
Esempio n. 28
0
            <table cellspacing="0" cellpadding="0" class="actionsBar">
            <tr>
              <td>
              	<div class="clear">
              		<!-- SOURCE -->
		            <div class="postSource">
		  			  <?php 
if (isset($post->url)) {
    ?>
		                Source : 
		                <a target="_blank" href="<?php 
    echo $post->url;
    ?>
">
		                	<?php 
    echo getDomain($post->url);
    ?>
		            	</a>
		              <?php 
}
?>
		            </div>
              	</div>
              </td>
              <td align="right" class="rightSide">
                <div class="rightItem" id="sharers_<?php 
echo $post->id;
?>
" style="*z-index:201">
                  <img onclick="showLittleBox(jQuery('#sharers_<?php 
echo $post->id;
Esempio n. 29
0
</td>
	<td class="sbj"><a href="#." onclick="whoisSearch('<?php 
    echo $R['ip'];
    ?>
');" title="후이즈 IP정보"><?php 
    echo $R['ip'];
    ?>
</a></td>
	<td class="cat"><a href="<?php 
    echo $R['referer'];
    ?>
" target="_blank" title="<?php 
    echo $R['referer'];
    ?>
"><?php 
    echo getDomain($R['referer']);
    ?>
</a></td>
	<td class="agent">
		<?php 
    if ($_browse == 'Mobile') {
        ?>
		<img src="<?php 
        echo $g['img_core'];
        ?>
/_public/ico_mobile.gif" class="imgpos" alt="모바일" title="모바일(<?php 
        echo isMobileConnect($R['agent']);
        ?>
)접속" />
		<?php 
    }
Esempio n. 30
0
 $data = readURL(getDomain($lang) . '?faction=' . $id, false);
 $rLine = getRewardLine($data);
 if (!$rLine) {
     return false;
 } else {
     $items = array('hated' => array(), 'hostile' => array(), 'unfriendly' => array(), 'neutral' => array(), 'friendly' => array(), 'honored' => array(), 'revered' => array(), 'exalted' => array());
     // loop through the results and extract each item
     while (preg_match("#\\{id:([0-9]{1,10}),name:'[0-9@]{1}(.+?)',(.+?),sourcemore:\\[\\{t:([0-9]{1,2}),ti:([0-9]{1,10}),n:'(.+?)',z:([0-9]{1,10})\\}\\],classs:([0-9]{1,2}),subclass:(.+?),standing:(.+?)}#", $rLine, $match)) {
         // gotta query wowhead for every item (this could take a while)
         $iData = readURL(getDomain($lang) . '?item=' . (string) $match[1] . '&xml');
         if (!$iData) {
             return false;
         }
         $xml = simplexml_load_string($iData, 'SimpleXMLElement', LIBXML_NOCDATA);
         if ($xml->error == '') {
             $items[$standings[(int) $match[10]]][] = array('name' => (string) $xml->item->name, 'id' => (string) $xml->item['id'], 'quality' => (string) $xml->item->quality['id'], 'lang' => $lang, 'icon' => 'http://static.wowhead.com/images/icons/small/' . strtolower($xml->item->icon) . '.jpg', 'url' => getDomain($lang) . '?item=' . (string) $xml->item['id']);
         }
         $rLine = str_replace($match[0], '', $rLine);
         unset($iData, $xml);
     }
     // make sure we found something before we continue
     if (!rewardsFound($items)) {
         echo 'No rewards were found.';
         $cache->close();
         exit;
     }
     // now we need to build the actual html
     $language = new wowhead_language();
     $language->loadLanguage($lang);
     $html = '';
     foreach ($items as $key => $standing) {