martes, 24 de diciembre de 2013

UXTheme patcher black screen - Definitive FIX

UXTheme patcher combined with some windows updates can cause your system to get stuck into a black screen after the Windows logo shows up. Even safe mode won't work in some cases (like mine).
The solution to this problem is really simple: all you have to do is restore the patched uxtheme dlls to the original ones and set your theme back to default Aero by changing the key in the registry.
Here you have more detailed instructions for the process.

You will need to have access to a secondary windows install or a boot disk to follow these steps. Windows recovery command promt will do aswell

  1. Restore the patched dlls with the original ones (in \Windows\System32). The dlls are:
    • themeui.dll
    • uxtheme.dll
    • uxinit.dll

    So rename them to something else. Just do these commands:
    • move themeui.dll themeui.dll.broken
    • move uxtheme.dll uxtheme.dll.broken
    • move uxinit.dll uxinit.dll.broken

    You will find the originals in the same folder just with .backup extension so do these commands to restore them:
    • copy themeui.dll.backup themeui.dll
    • copy uxtheme.dll.backup uxtheme.dll
    • copy uxinit.dll.backup uxinit.dll

  2. Change your theme back to the default one. To do this you need to edit the registry of the non-booting windows installation:
    1. Run regedit.exe from the command prompt.
    2. Once the registry editor is open select (highlight) HKEY_LOCAL_MACHINE
    3. Now click File >>> Load hive
    4. Select your windows drive and go to /Windows/System32/Config
    5. Choose the file called SOFTWARE and when asked for a name call it HKEY_RESCUED_MACHINE or something meaningful.
    6. Now browse to HKEY_LOCAL_MACHINE/HKEY_RESCUED_MACHINE/Microsoft/Windows/CurrentVersion/ThemeManager
    7. Change the value of the entry DllName to %SystemRoot%\resources\themes\Aero\Aero.msstyles
    8. Exit registry editor and reboot your system. It should work fine now
If you have any doubt or problem just let me know via comments.

viernes, 4 de octubre de 2013

All Photon Unity Networking Enums and Network Messages

// Comment
// ----------------------------------------------------------------------------
// 
//   PhotonNetwork Framework for Unity - Copyright (C) 2011 Exit Games GmbH
// 
// 
// 
// 
// developer@exitgames.com
// ----------------------------------------------------------------------------

using ExitGames.Client.Photon;
/// 
/// High level connection state of the client. Better use the more detailed .
/// 

public enum ConnectionState
{
    Disconnected,
    Connecting,
    Connected,
    Disconnecting,
    InitializingApplication
}

/// 
/// Detailed connection / networking peer state.
/// PUN implements a loadbalancing and authentication workflow "behind the scenes", so
/// some states will automatically advance to some follow up state. Those states are
/// commented with "(will-change)".
/// 
/// \ingroup publicApi
public enum PeerState
{
   /// Not running. Only set before initialization and first use.
    Uninitialized,
    /// Created and available to connect.
    PeerCreated,
    /// Working to establish the initial connection to the master server (until this process is finished, no operations can be sent).
    /// (will-change)
 Connecting,
    /// Connection is setup, now PUN will exchange keys for encryption or authenticate.
    /// (will-change)
    Connected,
    /// Not used at the moment.
    Queued,
    /// The application is authenticated. PUN usually joins the lobby now.
    /// (will-change) Unless AutoJoinLobby is false.
    Authenticated,
    /// Client is in the lobby of the Master Server and gets room listings.
    /// Use Join, Create or JoinRandom to get into a room to play.
 JoinedLobby,
    /// Disconnecting.
    /// (will-change)
    DisconnectingFromMasterserver,
    /// Connecting to game server (to join/create a room and play).
    /// (will-change)
    ConnectingToGameserver,
    /// Similar to Connected state but on game server. Still in process to join/create room.
    /// (will-change)
    ConnectedToGameserver,
    /// In process to join/create room (on game server).
    /// (will-change)
    Joining,
    /// Final state of a room join/create sequence. This client can now exchange events / call RPCs with other clients.
    Joined,
    /// Leaving a room.
    /// (will-change)
    Leaving,
    /// Workflow is leaving the game server and will re-connect to the master server.
    /// (will-change)
    DisconnectingFromGameserver,
    /// Workflow is connected to master server and will establish encryption and authenticate your app.
    /// (will-change)
    ConnectingToMasterserver,
    /// Same as Connected but coming from game server.
    /// (will-change)
    ConnectedComingFromGameserver,
    /// Same Queued but coming from game server.
    /// (will-change)
    QueuedComingFromGameserver,
    /// PUN is disconnecting. This leads to Disconnected.
    /// (will-change)
    Disconnecting,
    /// No connection is setup, ready to connect. Similar to PeerCreated.
    Disconnected,
    /// Final state for connecting to master without joining the lobby (AutoJoinLobby is false).
    ConnectedToMaster
}
/// 
/// Internal state how this peer gets into a particular room (joining it or creating it).
/// 

internal enum JoinType
{
    CreateGame,
    JoinGame,
    JoinRandomGame
}
// Photon properties, internally set by PhotonNetwork (PhotonNetwork builtin properties)
/// 
/// This enum makes up the set of MonoMessages sent by Photon Unity Networking.
/// Implement any of these constant names as method and it will be called
/// in the respective situation.
/// 
/// 
/// Implement:
/// public void OnLeftRoom() { //some work }
/// 
/// \ingroup publicApi

public enum PhotonNetworkingMessage
{
    /// 
 /// Called when the server is available and before client authenticates. Wait for the call to OnJoinedLobby (or OnConnectedToMaster) before the client does anything!
    /// Example: void OnConnectedToPhoton(){ ... }
    /// 
    /// This is not called for transitions from the masterserver to game servers, which is hidden for PUN users.
    OnConnectedToPhoton,
    /// 
 /// Called once the local user left a room.
    /// Example: void OnLeftRoom(){ ... }
    /// 
    OnLeftRoom,
    /// 
    /// Called -after- switching to a new MasterClient because the previous MC left the room (not when getting into a room). The last MC will already be removed at this time.
    /// Example: void OnMasterClientSwitched(PhotonPlayer newMasterClient){ ... }
    /// 
    OnMasterClientSwitched,
    /// 
    /// Called if a CreateRoom() call failed. Most likely because the room name is already in use.
    /// Example: void OnPhotonCreateRoomFailed(){ ... }
    /// 
    OnPhotonCreateRoomFailed,
    /// 
    /// Called if a JoinRoom() call failed. Most likely because the room does not exist or the room is full.
    /// Example: void OnPhotonJoinRoomFailed(){ ... }
    /// 
    OnPhotonJoinRoomFailed,
    /// 
    /// Called when CreateRoom finishes creating the room. After this, OnJoinedRoom will be called, too (no matter if creating one or joining).
    /// Example: void OnCreatedRoom(){ ... }
    /// 
    /// This implies the local client is the MasterClient.
    OnCreatedRoom,
    /// 
    /// Called on entering the Master Server's lobby. Client can create/join rooms but room list is not available until OnReceivedRoomListUpdate is called!
    /// Example: void OnJoinedLobby(){ ... }
    /// 
    /// 
    /// Note: When PhotonNetwork.autoJoinLobby is false, OnConnectedToMaster will be called instead and the room list won't be available.
    /// While in the lobby, the roomlist is automatically updated in fixed intervals (which you can't modify).
    /// 
    OnJoinedLobby,
    /// 
    /// Called after leaving the lobby.
    /// Example: void OnLeftLobby(){ ... }
    /// 
    OnLeftLobby,
    /// 
    /// Called after disconnecting from the Photon server.
    /// In some cases, other events are sent before OnDisconnectedFromPhoton is called. Examples: OnConnectionFail and OnFailedToConnectToPhoton.
    /// Example: void OnDisconnectedFromPhoton(){ ... }
    /// 
    OnDisconnectedFromPhoton,
    /// 
    /// Called when something causes the connection to fail (after it was established), followed by a call to OnDisconnectedFromPhoton.
    /// If the server could not be reached in the first place, OnFailedToConnectToPhoton is called instead.
    /// The reason for the error is provided as StatusCode.
    /// Example: void OnConnectionFail(DisconnectCause cause){ ... }
    /// 
    OnConnectionFail,
    /// 
    /// Called if a connect call to the Photon server failed before the connection was established, followed by a call to OnDisconnectedFromPhoton.
    /// If the connection was established but then fails, OnConnectionFail is called.
    /// Example: void OnFailedToConnectToPhoton(DisconnectCause cause){ ... }
    /// 
    OnFailedToConnectToPhoton,
    /// 
    /// Called for any update of the room listing (no matter if "new" list or "update for known" list). Only called in the Lobby state (on master server).
    /// Example: void OnReceivedRoomListUpdate(){ ... }
    /// 
    OnReceivedRoomListUpdate,
    /// 
    /// Called when entering a room (by creating or joining it). Called on all clients (including the Master Client).
    /// Example: void OnJoinedRoom(){ ... }
    /// 
    OnJoinedRoom,
    /// 
    /// Called after a remote player connected to the room. This PhotonPlayer is already added to the playerlist at this time.
    /// Example: void OnPhotonPlayerConnected(PhotonPlayer newPlayer){ ... }
    /// 
    OnPhotonPlayerConnected,
 /// 
    /// Called after a remote player disconnected from the room. This PhotonPlayer is already removed from the playerlist at this time.
    /// Example: void OnPhotonPlayerDisconnected(PhotonPlayer otherPlayer){ ... }
    /// 
    OnPhotonPlayerDisconnected,
 /// 
    /// Called after a JoinRandom() call failed. Most likely all rooms are full or no rooms are available.
    /// Example: void OnPhotonRandomJoinFailed(){ ... }
    /// 
    OnPhotonRandomJoinFailed,
    /// 
    /// Called after the connection to the master is established and authenticated but only when PhotonNetwork.AutoJoinLobby is false.
    /// If AutoJoinLobby is false, the list of available rooms won't become available but you could join (random or by name) and create rooms anyways.
    /// Example: void OnConnectedToMaster(){ ... }
    /// 
    OnConnectedToMaster,
    /// 
 /// Called every network 'update' on MonoBehaviours that are being observed by a PhotonView.
    /// Example: void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info){ ... }
    /// 
    OnPhotonSerializeView,
    /// 
    /// Called on all scripts on a GameObject(and it's children) that have been spawned using PhotonNetwork.Instantiate
    /// Example: void OnPhotonInstantiate(PhotonMessageInfo info){ ... }
    /// 
    OnPhotonInstantiate,
    /// 
    /// Because the concurrent user limit was (temporarily) reached, this client is rejected by the server and disconnecting.
    /// 
    /// 
    /// When this happens, the user might try again later. You can't create or join rooms in OnPhotonMaxCcuReached(), cause the client will be disconnecting.
    /// You can raise the CCU limits with a new license (when you host yourself) or extended subscription (when using the Photon Cloud).
    /// The Photon Cloud will mail you when the CCU limit was reached. This is also visible in the Dashboard (webpage).
    /// Example: void OnPhotonMaxCccuReached(){ ... }
    /// 
    OnPhotonMaxCccuReached,
 /// 
    /// Called when inside a room when its custom properties have changed. This is ALSO called for room property changes by the local players.
    /// 
    /// 
    /// Example: void OnPhotonCustomRoomPropertiesChanged(){ ... }
    /// 
 OnPhotonCustomRoomPropertiesChanged,
 /// 
    /// Called when inside a room when a players custom properties change.
    /// 
    /// 
    /// Example: void OnPhotonPlayerPropertiesChanged(PhotonPlayer player){ ... }
    /// 
 OnPhotonPlayerPropertiesChanged,
    /// 
    /// Called when the server sent the response to a FindFriends request and updated PhotonNetwork.Friends.
    /// 
    /// 
    /// Example: void OnUpdatedFriendList(){ ... }
    /// 
    OnUpdatedFriendList,
    /// 
    /// Called when the custom authentication failed (due to user-input, bad tokens/secrets or wrong configuration). Followed by disconnect!
    /// Example: void OnCustomAuthenticationFailed(string debugMessage){ ... }
    /// 
    /// 
    /// Unless you setup a custom authentication service for your app (in the Dashboard), this won't be called!
    /// If authentication is successful, this method is also not called but OnJoinedLobby, OnConnectedToMaster will be called (just as usual).
    /// 
    OnCustomAuthenticationFailed,
}
/// 
/// Summarizes the cause for a disconnect. Used in: OnConnectionFail and OnFailedToConnectToPhoton.
/// 
/// Extracted from the status codes from ExitGames.Client.Photon.StatusCode.
/// 
/// \ingroup publicApi

public enum DisconnectCause
{
    /// Connection could not be established.
    /// Possible cause: Local server not running.
    ExceptionOnConnect = StatusCode.ExceptionOnConnect,
    /// The security settings for client or server don't allow a connection (see remarks).
    /// 
    /// A common cause for this is that browser clients read a "crossdomain" file from the server.
    /// If that file is unavailable or not configured to let the client connect, this exception is thrown.
    /// Photon usually provides this crossdomain file for Unity.
    /// If it fails, read:
    /// http://doc.exitgames.com/photon-server/PolicyApp
    /// 
    SecurityExceptionOnConnect = StatusCode.SecurityExceptionOnConnect,
    /// Connection timed out.
    /// Possible cause: Remote server not running or required ports blocked (due to router or firewall).
    TimeoutDisconnect = StatusCode.TimeoutDisconnect,
    /// Exception in the receive-loop.
    /// Possible cause: Socket failure.
    InternalReceiveException = StatusCode.InternalReceiveException,
    /// Server actively disconnected this client.
    DisconnectByServer = StatusCode.DisconnectByServer,
    /// Server actively disconnected this client.
    /// Possible cause: Server's send buffer full (too much data for client).
    DisconnectByServerLogic = StatusCode.DisconnectByServerLogic,
    /// Server actively disconnected this client. 
    /// Possible cause: The server's user limit was hit and client was forced to disconnect (on connect).
    DisconnectByServerUserLimit = StatusCode.DisconnectByServerUserLimit,
    /// Some exception caused the connection to close.
    Exception = StatusCode.Exception,
    /// (32756) Authorization on the Photon Cloud failed because the app's subscription does not allow to use a particular region's server.
    InvalidRegion = ErrorCode.InvalidRegion,
    /// (32757) Authorization on the Photon Cloud failed because the concurrent users (CCU) limit of the app's subscription is reached.
    MaxCcuReached = ErrorCode.MaxCcuReached,
}


jueves, 3 de octubre de 2013

Photon Code Example For Myself

using System.Collections;
using UnityEngine;

public class GameManager : Photon.MonoBehaviour
{
    public Transform playerPrefab;

    public void Awake()
    {
        // PhotonNetwork.logLevel = NetworkLogLevel.Full;
        if (!PhotonNetwork.connected)
        {
            // We must be connected to a photon server! Back to main menu
            Application.LoadLevel(Application.loadedLevel - 1);
            return;
        }

        PhotonNetwork.isMessageQueueRunning = true;

        // Spawn our local player
        PhotonNetwork.Instantiate(this.playerPrefab.name, transform.position, Quaternion.identity, 0);
    }

    public void OnGUI()
    {
        if (GUILayout.Button("Return to Lobby"))
        {
            PhotonNetwork.LeaveRoom();
        }
    }

    public void OnLeftRoom()
    {
        Debug.Log("OnLeftRoom (local)");
       
        // back to main menu      
        Application.LoadLevel(Application.loadedLevelName);
    }

    public void OnMasterClientSwitched(PhotonPlayer player)
    {
        Debug.Log("OnMasterClientSwitched: " + player);

        if (PhotonNetwork.connected)
        {
            photonView.RPC("SendChatMessage", PhotonNetwork.masterClient, "Hi master! From:" + PhotonNetwork.player);
            photonView.RPC("SendChatMessage", PhotonTargets.All, "WE GOT A NEW MASTER: " + player + "==" + PhotonNetwork.masterClient + " From:" + PhotonNetwork.player);
        }
    }

    public void OnDisconnectedFromPhoton()
    {
        Debug.Log("OnDisconnectedFromPhoton");

        // Back to main menu      
        Application.LoadLevel(Application.loadedLevelName);
    }

    public void OnPhotonPlayerConnected(PhotonPlayer player)
    {
        Debug.Log("OnPhotonPlayerConnected: " + player);
    }

    public void OnPhotonPlayerDisconnected(PhotonPlayer player)
    {
        Debug.Log("OnPlayerDisconneced: " + player);
    }

    public void OnReceivedRoomList()
    {
        Debug.Log("OnReceivedRoomList");
    }

    public void OnReceivedRoomListUpdate()
    {
        Debug.Log("OnReceivedRoomListUpdate");
    }

    public void OnConnectedToPhoton()
    {
        Debug.Log("OnConnectedToPhoton");
    }

    public void OnFailedToConnectToPhoton()
    {
        Debug.Log("OnFailedToConnectToPhoton");
    }

    public void OnPhotonInstantiate(PhotonMessageInfo info)
    {
        Debug.Log("OnPhotonInstantiate " + info.sender);
    }
}

viernes, 27 de septiembre de 2013

Solution to Images not showing in Moodle: slash arguments

If you have this problem (not a single image showing) and also javascript seems broken you can try to disable slash arguments since your server may not support this function. To do this go to:

  Settings > Site administration > Server > HTTP.

Untick the slash arguments option.

If you can not access the settings menu since your javascript is broken aswell (like mine) just go to this url:

  http://yourmoodlesiteurl / admin/settings.php?section=http

sábado, 21 de septiembre de 2013

Guía definitiva para instalar Moodle y BigBlueButton en el mismo servidor.

El problema...

Cuando queremos hacer funcionar Moodle (o cualquier otro CMS o servidor web) y BigBlueButton en la misma máquina o compartiendo IP pública detrás del mismo router nos surge el problema de que por defecto nuestro servidor web (Apache o cualquier otro) y Nginx (necesario para el funcionamiento de BBB) querrán utilizar el puerto 80.


Posible solución:

Una posible solución sería cambiar de puerto de Nginx a otro diferente del 80. En teoría esto es posible, pero en la práctica BigBlueButton dejará de funcionar y dará mil problemas.


La solución:

Lo que vamos a hacer es cambiar el puerto de nuestro servidor web que aloja el CMS. Después creamos un nuevo host virtual en Nginx con el nombre que queramos para nuestro CMS. Este host virtual lo único que hará será redirigir las peticiones HTTP al nuevo puerto de nuestro servidor web.

Si BBB y nuestro CMS están en la misma máquina

En este caso necesitamos cambiar el puerto de escucha de nuestro servidor web. En el caso de Lampp con Apache simplemente editamos el archivo "httpd.conf" y buscamos la linea donde aparezca "Listen 80" y sustituimos 80 por nuestro nuevo puerto. Por ejemplo 9000: "Listen 9000". Para que la configuración tenga efecto reiniciamos Apache.

Ahora creamos un nuevo host virtual en nginx. Para ello creamos un nuevo archivo en el directorio: /etc/ngingx/sites-available/. Por ejemplo, para moodle:

sudo gedit /etc/ngingx/sites-available/moodle 

Dentro de este archivo escribimos:

server {
        listen 80;
        server_name www.moodle.test;     #Este es el nombre de dominio para nuestro CMS

        location / {
                proxy_pass http://127.0.0.1:9000;   #Aquí indicamos el nuevo puerto 9000
                proxy_set_header Host $host;
        }
}

Este archivo consigue que Nginx redirija las peticiones que van a "www.moodle.test" a nuestro nuevo puerto de Apache. En el caso de moodle la línea " proxy_set_header Host $host" es necesaria ya que una instalación de Moodle queda asociada a un nombre de dominio.

Ahora creamos un enlace simbólico desde el directorio "sites-enabled" al archivo que acabamos de crear para habilitar nuestro host virtual:

sudo ln -s /etc/nginx/sites-available/moodle /etc/nginx/sites-enabled/moodle

Finalmente reiniciamos Nginx:

sudo /etc/init.d/nginx restart

Si BBB y nuestro CMS están en la misma red local pero en distinta máquina

En este caso no necesitamos cambiar el puerto de escucha del servidor web. Simplemente redirigimos las peticiones para nuestro CMS a la IP local de la máquina que este alojando el servidor web:

server {
        listen 80;
        server_name www.moodle.test;     #Este es el nombre de dominio para nuestro CMS

        location / {
                proxy_pass http://192.168.1.44;   #Aquí indicamos la IP local del servidor web
                proxy_set_header Host $host;
        }
}

Como en el caso anterior, creamos el enlace simbólico:

sudo ln -s /etc/nginx/sites-available/moodle /etc/nginx/sites-enabled/moodle

Y reiniciamos Nginx:

sudo /etc/init.d/nginx restart




Si tienes cualquier duda o problema, hazlo saber en los comentarios :)

lunes, 27 de agosto de 2012

Acentos y codificación en PHP - HTML sobre Apache

Si nos queremos asegurar de no tener problemas con los acentos y caracteres especiales, lo más rápido es configurar Apache para que envíe todos los documentos como UTF-8.

Para ello abrimos httpd.conf y añadimos esta linea:
AddDefaultCharset utf-8
Como todos los cambios en httpd.conf requiere que reiniciemos Apache.

La segunda parte a tener en cuenta es en la edición y creación de los archivos. Tenemos que asegurarnos de que se guardan codificados en UTF-8 sin BOM. Si por accidente los guardamos en UTF-8 con BOM es muy probable que aparezcan espacios indeseados en nuestra página que nos llevarán al borde de la locura a la hora de intentar eliminarlos.

Para guardar como UTF-8 sin BOM, por ejemplo en Notepad++, abrimos nuestro documento y después vamos a "Codificación" y luego "Convertir a UTF-8 sin BOM". Guardamos y listo.

Resulta también muy útil establecer esta codificación para emplearla por defecto en archivos nuevos: "Configuración", "Preferencias", Pestaña "Archivo nuevo / Carpeta predeterminada" y marcamos en "Codificación" "UTF-8 sin BOM".

Por último debemos también añadir la información de codificación en la cabecera de nuestros documentos:


Espero que os sea útil a vosotros y a mí mismo en un futuro cuando, como es habitual, vuelva a tropezar en la misma piedra.