Example #1
0
/**
 * This function returns the user ID of the logged in user on your site.  Technical support will not
 * help you with this for stand-alone installations.  You must purchase the professional installation
 * if you are having trouble.
 *
 * Suggestion: Check out the other integration files in the functions/integrations directory for
 * many examples of how this can be done.  The easiest way is to get the user ID through a cookie.
 *
 * @return the user ID of the logged in user or NULL if not logged in
 */
function get_user_id()
{
    global $db;
    $userid = NULL;
    $result = $db->execute("\n\t\t\tSELECT option_value \n\t\t\tFROM " . TABLE_PREFIX . "options \n\t\t\tWHERE option_name = 'siteurl'\n\t\t");
    if ($row = $db->fetch_array($result)) {
        $site_url = $row['option_value'];
    }
    $cookiehash = md5($site_url);
    if (!empty($_COOKIE['wordpress_logged_in_' . $cookiehash])) {
        $username = strstrb($_COOKIE['wordpress_logged_in_' . $cookiehash], '|');
        $result = $db->execute("\n\t\t\t\tSELECT " . DB_USERTABLE_USERID . " \n\t\t\t\tFROM " . TABLE_PREFIX . DB_USERTABLE . " \n\t\t\t\tWHERE user_login = '******'\n\t\t\t");
        if ($row = $db->fetch_array($result)) {
            $userid = $row[DB_USERTABLE_USERID];
        }
    }
    return $userid;
}
Example #2
0
function checkAccess($login, $password)
{
    // Fichier des login et mots de passe
    $accountFile = "usersList/users.acl";
    if (basename($_SESSION['parentURL']) == 'admin.php') {
        $accountFile = "usersList/admin.acl";
    }
    // Renvoie toutes les erreurs sauf les warning
    error_reporting(E_ALL ^ E_WARNING);
    $fp = fopen($accountFile, "r");
    // to emulate the before_needle php V5.3
    function strstrb($h, $n)
    {
        return array_shift(explode($n, $h, 2));
    }
    if ($fp) {
        $passwordArray = array();
        while (!feof($fp)) {
            $line = fgets($fp);
            // Only after php V5.3
            //$loginFind = strstr($line, '::', true);
            // Before php V5.3
            $loginFind = strstrb($line, '::');
            $pwdFind = substr(strstr($line, '::'), 2);
            if ($loginFind == $login) {
                $passwordArray[] = trim($pwdFind);
            }
        }
        if (count($passwordArray) > 0) {
            if (in_array($password, $passwordArray)) {
                return true;
            } else {
                return false;
            }
        }
    } else {
        echo "Pas de liste d'utilisateurs!";
    }
    fclose($fp);
    return false;
}
Example #3
0
|| # ---------------------------------------------------------------- # ||
|| #    Copyright �2010-2012 ArrowSuites LLC. All Rights Reserved.    # ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- ARROWCHAT IS NOT FREE SOFTWARE ---------------- # ||
|| #   http://www.arrowchat.com | http://www.arrowchat.com/license/   # ||
|| #################################################################### ||
*/
// ########################## INCLUDE BACK-END ###########################
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "bootstrap.php";
// ########################## START MAIN SCRIPT ###########################
$get_file = get_var('file');
$dir = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . AC_FOLDER_UPLOADS;
$dh = opendir($dir);
// Get each filename in the upload directory to see if it exists
while (($file = readdir($dh)) !== false) {
    $test = strstrb($file, ".");
    if (strcasecmp($test, $get_file) == 0) {
        $tmp = explode('.', $file);
        $extension = strtolower(end($tmp));
        $contentType = "application/zip";
        if ($extension == "jpg" || $extension == "jpeg" || $extension == "gif" || $extension == "png") {
            $content = getimagesize($file);
            $contentType = $content['mime'];
        }
        header("Cache-Control: public");
        header("Content-Description: File Transfer");
        header("Content-Disposition: attachment; filename={$file}");
        header("Content-Type: {$contentType}");
        header("Content-Transfer-Encoding: binary");
        readfile($dir . "/" . $file);
    }