if (file_exists($destinationDirectory . "originals/" . $pic_name)) {
                $pic_name = md5($tmpName . time() . uniqid()) . uniqid() . "." . $extention;
            }
            move_uploaded_file($tmpName, $destinationDirectory . "originals/" . $pic_name);
            $img = new abeautifulsite\SimpleImage($destinationDirectory . "originals/" . $pic_name);
            $img->best_fit(600, 600)->save($destinationDirectory . "mediums/" . $pic_name);
            $img->thumbnail(150, 150)->save($destinationDirectory . "thumbnails/" . $pic_name);
        }
        if (empty($error)) {
            $sql = "UPDATE users \n\t\t\t\t\tSET pic_name = :pic_name\n\t\t\t\t\tWHERE id = :id";
            $sth = $dbh->prepare($sql);
            $sth->bindValue(":id", $_SESSION['user']['id']);
            $sth->bindValue(':pic_name', $pic_name);
            $sth->execute();
            $succes = "Modification enregistrer";
        }
    }
    // insert dans la BDD
    if (empty($error)) {
        $sql = "UPDATE users \n\t\t\t\t\tSET user_name = :user_name, email = :email, bio = :bio\n\t\t\t\t\tWHERE id = :id";
        $sth = $dbh->prepare($sql);
        $sth->bindValue(":id", $_SESSION['user']['id']);
        $sth->bindValue(':user_name', $user_name);
        $sth->bindValue(':email', $email);
        $sth->bindValue(':bio', $bio);
        $sth->execute();
        $succes = "Modification enregistrer";
    }
}
refreshUser();
Beispiel #2
0
function refreshContent($lastID, $userID, $num)
{
    global $_SESSION, $auth, $isModerator;
    if (!$num) {
        $num = 20;
    }
    $userID = $auth->user;
    $objResponse = new xajaxResponse();
    refreshUser($userID);
    $res = mysql_query("\n\t\t\tselect chat_messages.ID,ut_users.Login, chat_messages.Message, chat_messages.MessageTime, chat_messages.PrivateUserID,chat_messages.UserID\n\t\t\t\tfrom chat_messages,ut_users \n\t\t\t\twhere ut_users.UserID = chat_messages.UserID and chat_messages.ID>'{$lastID}' and (chat_messages.PrivateUserID='{$userID}' or chat_messages.UserID='{$userID}' or chat_messages.PrivateUserID=0) and chat_messages.UserID<>'{$userID}' order by chat_messages.ID desc limit {$num}");
    $newLastID = $lastID;
    $str = "";
    while ($data = mysql_fetch_array($res)) {
        if ($newLastID == $lastID) {
            $newLastID = $data[0];
        }
        $date = split(' ', $data[3]);
        $login = iconv('windows-1251', 'utf-8', $data[1]);
        $message = $data[2];
        if (!$data[4] || $data[4] && ($data[4] == $userID || $data[5] == $userID)) {
            $str = date("H:i", $data[3]) . " <a href='javascript:addUserToMessage(\"{$login}\", 0)' class=nickName" . ($data[4] ? "Private" : "") . ">" . $login . "</a>: <span class=chatMessage" . ($data[4] ? "Private" : "") . ">" . $message . "</span><br />" . $str;
            //if($isModerator) $str = "<a href='javascript:DeleteMessage(".$data[0].")' class=nickName>[X]</a> ".$str;
        }
    }
    if ($str) {
        $res2 = mysql_query("\n\t\t\tselect chat_messages.ID,ut_users.Login, chat_messages.Message, chat_messages.MessageTime, chat_messages.PrivateUserID,chat_messages.UserID\n\t\t\t\tfrom chat_messages,ut_users \n\t\t\t\twhere ut_users.UserID = chat_messages.UserID  and (chat_messages.PrivateUserID='{$userID}' or chat_messages.UserID='{$userID}' or chat_messages.PrivateUserID=0) order by chat_messages.ID desc limit {$num}");
        $str2 = "";
        while ($data = mysql_fetch_array($res2)) {
            if ($newLastID == $lastID) {
                $newLastID = $data[0];
            }
            $date = split(' ', $data[3]);
            $login = iconv('windows-1251', 'utf-8', $data[1]);
            $message = $data[2];
            if (!$data[4] || $data[4] && ($data[4] == $userID || $data[5] == $userID)) {
                $str2 = date("H:i", $data[3]) . " <a href='javascript:addUserToMessage(\"{$login}\", 0)' class=nickName" . ($data[4] ? "Private" : "") . ">" . $login . "</a>: <span class=chatMessage" . ($data[4] ? "Private" : "") . ">" . $message . "</span><br />" . $str2;
                //if($isModerator) $str2 = "<a href='javascript:DeleteMessage(".$data[0].")' class=nickName>[X]</a> ".$str2;
            }
        }
        if ($str2) {
            $_SESSION['chatcontent'] = $str2;
        }
    }
    //if($auth->user==455) $objResponse->addAlert("-- $isModerator");
    if ($newLastID) {
        $objResponse->addAssign("lastChatMessageID", "innerHTML", $newLastID);
    }
    if ($lastID) {
        $objResponse->addAppend("chatContent", "innerHTML", stripslashes($str));
    } else {
        $objResponse->addAssign("chatContent", "innerHTML", stripslashes($str2));
    }
    $userList = "";
    $res = mysql_query("select u.Login,u.UserID,c.LastRefresh,u.Rang,if(c.isModerator=1,1,0) isModerator ,s.BanTime ,\nu.GuildID,u.GuildStatusID from ut_users u,chat_users c left outer join chat_settings s on s.UserID=c.UserID where c.UserID=u.UserID");
    while ($data = mysql_fetch_array($res)) {
        $data1 = strtotime($data[2]);
        $data2 = time();
        $seconds = $data2 - $data1;
        if ($seconds > 600) {
            mysql_query("delete from chat_users where UserId={$data['1']}");
            continue;
        }
        $data[Login] = iconv('windows-1251', 'utf-8', htmlspecialchars($data[Login]));
        $nameUser = $data[Login];
        $login = $nameUser;
        //$login=username($data,0);
        if ($data[GuildID] && $data[GuildStatusID] == 1) {
            $login = guildlogo($data[GuildID], 0) . " " . $login;
        }
        if ($data[isModerator]) {
            $login = "******" . $login . "</b>";
        }
        $userList .= ($data[3] > 0 ? "<img src='http://www.butsa.ru/images/vip/{$data['3']}.gif' />&nbsp;" : "") . "<a href='javascript:addUserToMessage(\"{$nameUser}\", 0)'>{$login}</a> \n\t\t<a href='/users/{$data['1']}' >\n\t\t\t<img style='border:none;' src='/images/icons/profile.gif' align=absmiddle title='Info' alt='Info'></a>\n\t\t<a href='javascript:addUserToMessage(\"{$nameUser}\",1)' >\n\t\t\t<img style='border:none;' src='/images/icons/mail.gif' align=absmiddle  title='Private' alt='Private'></a>";
        if ($isModerator) {
            if (mktime() > $data[BanTime]) {
                $userList .= " <a href='javascript:BanUser(\"" . $data[UserID] . "\",\"{$nameUser}\",ban_time.value)' >[ban]</a><br>";
            } else {
                $userList .= " " . date("d.m.Y H:i", $data[BanTime]) . " - " . "<a href='javascript:UnBanUser(\"" . $data[UserID] . "\",\"{$nameUser}\")' >[unban]</a><br>";
            }
        } else {
            $userList .= "<br>";
        }
    }
    if ($userList) {
        $_SESSION['chatusers'] = $userList;
    }
    $objResponse->addAssign("chatUsersList", "innerHTML", $userList);
    $objResponse->addScript("scrollDown()");
    $objResponse->addScript("chatRefreshInterval = window.setInterval(\"refreshContent()\",3000);");
    $chatData = select("select count(*) from chat_users");
    $chatersCount = $chatData ? $chatData[0] : 0;
    $objResponse->addAssign("chatersCount", "innerHTML", $chatersCount);
    if (!$lastID) {
        $objResponse->addScript("chatContent.scrollTop=1000000;");
    }
    return $objResponse;
}