22nd August 2009

Instalar zoneminder en ubuntu

aun no lo he probado, pero me ha parecido interesante reflejarlo en el blog para todos aquellos que tengais curiosidad.

sudo apt-get install zoneminder

sudo ln -s /etc/zm/apache.conf /etc/apache2/conf.d/zoneminder.conf

sudo adduser www-data video

(I executed this first one, then lost track of this web page, spent hours trying to debug the black screen “shared memory not initialized by capture daemon” / “shared memory not valid” / “can’t get shared memory id” issues and finally found that I could fix them with “chmod 606 /dev/video0″… but turns out that your adduser fix is the more appropriate fix )

posted in General, PHP, Redes | 0 Comments

13th January 2009

Configurar zuckerreport en sugarcrm

Aqui dejo el post que me ha salvado la vida ;D

Hi all,

I struggled a bit getting sugar, zucker reports and iReport to work correctly, so after I eventually got it working I thought I’d post on here what I done. Hopefully this may help other people out there.

Ok, lets get started….

Please note this is for the windows installation. Something that I found useful is that if you pre-install mysql then you will be able to use all the administration and monitoring software for your sugar installation and you wont have to configure a thing.

Please ensure that your system has the latest java installed (I used version 6.0.70.6).
Download the file ’sugarcrm-CE-5.1.0a-windows-installer.exe’ and run the installation.

Once the installation is complete locate the php.ini file, e.g. sugarcrm-5.1.0a/php
Edit this file and:
Change post_max_size to 40M
Change upload_tmp_dir to a directory folder without spaces, e.g. C:\tmp
Change upload_max_filesize to 40M

Restart Sugar.

Download ZuckerReports (I used version 1.10).
Login to SugarCrm as administrator, head to the Admin page and select Module Loader.
Upload a new module and select the Zucker zip file. Once uploaded then install the package.
Hopefully at this point all is well.

Navigate to the folder ‘htdocs\sugarcrm\modules\ZuckerReports’
Edit the file config.php and:
Find the line that is commented out for Windows Environment and replace with the following line -
“java_cmdline” => “C:\ZuckerJava\javaw %ARGS% 2>&1″
Note: The javaw.exe has been copied to a folder that does not contain any spaces as this may cause problems.

If the installation of SugarCRM used a different SQL port, e.g. it was not the default of 3306 then the following needs to be changed.
Navigate to: ‘htdocs\sugarcrm\modules\ZuckerReportTemplate’
Change the file ReportTemplate.php, scan for 3306 and change to the appropriate port number.

The Zucker images may also be in the wrong place, check if they appear when in the ZuckerReports module whilst you are in Sugar. If no images appear then copy the files within ‘htdocs\sugarcrm\custom\themes\Awesome80s\images’ put them in ‘htdocs\sugarcrm\themes\default\images’.

We are getting there!!

Next up is to install iReport, if you don’t know what this is then it will allow you to create some cool reports and upload them into sugar. Download the latest version (I used version 3.1.1) from here and install.

Find the file ‘jasperreports-3.1.0.jar’ within the iReport installation folder and copy it to ‘htdocs\sugarcrm\modules\ZuckerReports\jasper’. I also removed any older version of the same jar file but I am not sure if it is required or not!

At this point restart Sugar and all should be working nicely.
You could start up iReport, add a database and point it to sugar - the driver will be mysql and the connection url will be something like ‘jdbc:mysql://localhost:3306/sugarcrm’. You will need to put in the user id of ‘root’ and the appropriate password. Once you see your database create yourself a basic report click preview to see if it works. If it does then save and login to sugar. Go to the ZuckerReports module and select ‘Report and Query Templates’. Select ‘New JasperReport Template’ and then browse to the report you just created.

Here is the moment of truth, click on Save and fingers crossed it will import ok. Then select run report and hey presto you should see your report!

Just to keep things complete I will include how to setup the scheduler, there are articles out there on how to do this, but I will include it here so at least you don’t have to dig around!
Edit the file ‘_AddJobsHere.php’ within the folder ‘htdocs\sugarcrm\modules\Schedulers’ and add the following line to the “$job_strings”-array, you put this above option 9 which is for updateTrackerSessions:
8 => ‘ZuckerReportsScheduler’,

Further down you should see a load of functions, right near the bottom and above ‘Job 9′ to keep it in order add the following function:
function ZuckerReportsScheduler() {
require_once(”modules/ZuckerRunnableReport/RunnableReport.php”);
RunnableReport::scheduler_run_all();
return true;
}

Restart sugar and login as admin. Go to the admin page and then select ‘Scheduler’. Click on ‘Create Scheduler’ and fill in the details, the job will be ‘ZuckerReportsScheduler’. You can put in whatever you want for the interval.

Phew, the last bit is to create a batch job otherwise nothing will happen!
Create a batch file, e.g. ‘SugarScheduler.bat’ and add the following:
cd \sugarcrm-5.1.0a\htdocs\sugarcrm\SugarCE-Full-5.1.0a
C:\SUGARC~1.0A\php\php-cgi.exe -c C:\SUGARC~1.0A\php\php.ini -f cron.php

You will probably need to change the path to where your installation lives. Note: you will need to use the directory short names for the actual command otherwise it will not work!

Now add this batch file to the windows scheduler or at a command line type the following:
schtasks /create /sc minute /tn “Sugar Cron” /tr c:\SugarScheduler.bat

This will create the schedule job to run every minute….hurahh!!

I hope this has helped some people out as I’ve spent a while myself getting this working.

Good luck everyone.

Frizza

Debes tener correctamente configurado el scheduler de sugar e instalado el php5-cli (en mi caso por tener php5)

posted in Linux, PHP | 0 Comments

25th September 2008

Varios Flex - Red5

SCORE
Tras volverme loco buscando que narices era el score y el IScore.. Tras no saber como pasar ese tipo de valor desde Flex, encontre que las clases creadas para red5 con java tienen una propiedad que siempre se crea y que reciben como parametro el score  o ambito en el que la aplicación trabajo.

IScore appScore;
public boolean appStart(IScope app) {
   appScore=app;
}

Con eso ya lo tenemos resuelto y disponemos del Score para usarlo donde necesitemos
dentro de la clase java, supongo que los expertos dirán “vaya chorrada”, pero yo he perdido
una tarde entera con este tema. Espero a alguíen le sea util.

SERVICEUTILS
ServiceUtils.invokeOnAllConnections(this.appScope,”ListaUsuarios”,new Object[]{pila});
Esto nos va a permitir ejecutar desde Red5 (codigo java) una funcion de flex de modo que se ejecute para todos los usuarios conectados en ese momento.Â

VIDEODISPLAY
Aqui un ejemplo de como se usa este control para poder ver tu web cam con flash.

if (Camera.getCamera()){

Camara = Camera.getCamera();

this.ctrCamaraPrivada.attachCamera(Camara);

this.lblInfo.text+=”; Cámara conectada.”

}

else

{

this.lblInfo.text +=”; Cámara no disponible.”

}Â

Â

posted in PHP, Programacion | 0 Comments

24th September 2008

Como pasar parametros a Flex por URL

Cómo pasar parámetros y recuperarlos en Flex.

Podemos pasarle y recoger parámetros a nuestro SWF generado con Flex de la siguiente manera:

En la página html que genera Flex cuando compilamos nuestra Aplicación, nos encontramos con código en JavaScript y también con un objeto que embebe nuestro SWF. En nuestro ejemplo se llamarágraficas.swf

Supongamos que queremos abrir la página que contiene nuestra aplicación de gráficas creadas en Flex, y cuyos valores los recogerá de un HttpService, que envía y recoge el Usuario y la Contraseña a una página en ASP, y ésta nos devuelve el resultado en XML.

Sería algo así:

<object classid=”clsid:D27CDB6E-11cf”
id=”graficas”
width=”100%” height=”100%”
codebase=”macromedia.com/get/flashplayer/current/swfla…
param name=”movie”
value=”graficas.swf?usuario=Antonio&pass=12345” />
<param name=”quality” value=”high” />
<param name=”bgcolor” value=”#869ca7″ />
<param name=”allowScriptAccess” value=”sameDomain” />
<embed src=”graficas.swf?usuario=Antonio&pass=12345
quality=”high” bgcolor=”#869ca7″ width=”100%” height=”100%”
name=”graficas” align=”middle” play=”true” loop=”false”
quality=”high” allowScriptAccess=”sameDomain”
type=”application/x-shockwave-flash”
pluginspage=”adobe.com/go/getflashplayer%22%3E…
</embed></object>Â

Para pasarlo mediante el código en JavaScript, haríamos lo siguiente:

AC_FL_RunContent( “src”, “graficas?usuario=Antonio&pass=12345“,
“width”, “100%”, “height”, “100%”, “align”,
“middle”, “id”, “graficas”, “quality”, “high”,
“bgcolor”, “#869ca7″, “name”, “graficas”,
“flashvars”,’historyUrl=history.htm%3F&lconid=’ + lc_id + ”,
flashvars”,’usuario=Antonio&pass=12345′,
“allowScriptAccess”,”sameDomain”, “type”,
“application/x-shockwave-flash”, “pluginspage”,
);

En el código en JS podemos pasarle los parámetros concatenados al nombre del swf o bien ponerlos como un flashvars. De cualquiera de las dos maneras funciona.

y Podemos recuperarlos desde Flex de la siguiente manera:

private var Usuario:String=”";
private var Pass:String=”";

private function ini():void{
Usuario=Application.application.parameters.usuario;
Pass=Application.application.parameters.pass;Â
}

posted in JavaScript, PHP, Programacion | 0 Comments

24th September 2008

Flex y MySql

En este primer post dedicado a la publicación o uso de bases de datos Mysqlcon nuestras aplicaciones Flex, vamos a abordar la conexión a través de una pasarela creada en PHP.

Esta primera solución es la más sencilla de todas y nos permite tener por ejemplo el frontend de nuestra aplicación en HTML y el backend en Flex.

Pongamos de ejemplo una tienda online que tiene un catálogo de productos y que queremos crear un administrador de éste mediante Flex.

El primer paso que vamos a hacer es la creación de un fichero PHP que haga las consultas pertinentes a la base de datos MySQL y nos devuelva el conjunto de resultados en XML. Este XML será procesado o consumido desde la aplicación Flex y será asociado mediante Data Binding (enlace entre controles y datos) a los controles de nuestro administrador.

Un ejemplo podría ser el siguiente:

  1. <productos>
  2. <?php
  3.    if(!($link=mysql_connect(“localhost”,“[usuario]“,“[contraseña]“))){
  4.       echo “Error conectando a la base de datos.”;
  5. Â Â Â Â Â Â exit();
  6. Â Â Â }
  7. Â Â Â Â Â Â
  8.    if (!mysql_select_db(“[nombre_bd]“,$link)) {
  9.       echo “Error seleccionando la base de datos.”;
  10. Â Â Â Â Â Â exit();
  11. Â Â Â }
  12. Â
  13.    $sql = “SELECT nombre, referencia, precio “;
  14.    $sql .= “FROM productos “;
  15.    $sql .= “ORDER BY referencia”;
  16. Â
  17.    $result = mysql_query($sql,$link);
  18.    while($row = mysql_fetch_object($result)){
  19. ?>
  20. Â Â <producto>
  21.     <referencia><?php echo $row->referencia ?></referencia>
  22.     <nombre><?php echo $row->nombre ?></nombre>
  23.     <precio><?php echo $row->precio ?></precio>
  24. Â Â </producto>
  25. <?php
  26. Â Â Â }Â Â
  27. ?>
  28. </productos>

Â

Como resultado este fichero devolverá algo como lo siguiente:

  1. <?xml version=“1.0″ encoding=“utf-8″?>
  2. <productos>
  3. Â Â Â <producto>
  4. Â Â Â Â Â Â <referencia>1</referencia>
  5. Â Â Â Â Â Â <nombre>Primer Producto</nombre>
  6. Â Â Â Â Â Â <precio>10.99</precio>
  7. Â Â Â <producto>
  8. Â
  9. Â Â Â <producto>
  10. Â Â Â Â Â Â <referencia>2</referencia>
  11. Â Â Â Â Â Â <nombre>Segundo Producto</nombre>
  12. Â Â Â Â Â Â <precio>15.45</precio>
  13. Â Â Â <producto>
  14. Â
  15. Â Â Â <producto>
  16. Â Â Â Â Â Â <referencia>3</referencia>
  17. Â Â Â Â Â Â <nombre>Tercer Producto</nombre>
  18. Â Â Â Â Â Â <precio>58.99</precio>
  19. Â Â Â <producto>
  20. </productos>

Â

Ahora pasamos a la parte Flex que se encargará de consumir este XML que nos devuelve PHP. Para ello crearemos un DataGrid que nos mostrará el resultado. Lo asociaremos mediante data binding al resultado de la llamada al php (mediante HTTPService). Usaremos el formato E4X para mayor comodidad.

  1. <?xml version=“1.0″ encoding=“utf-8″?>
  2. <mx:Application xmlns:mx=“http://www.adobe.com/2006/mxml”layout=“absolute” creationComplete=“prodRPC.send()” width=“100%”>
  3. Â Â
  4.    <mx:HTTPService id=“prodRPC”url=“http://localhost/productos.php” resultFormat=“e4x”/>
  5. Â Â
  6.        <mx:DataGrid id=“dgProductos” x=“10″ y=“10″dataProvider=“{prodRPC.lastResult..producto}” width=“561″height=“526″>
  7. Â Â Â Â Â Â Â Â Â <mx:columns>
  8.            <mx:DataGridColumn dataField=“referencia” />
  9.            <mx:DataGridColumn dataField=“nombre” />
  10.            <mx:DataGridColumn dataField=“precio” />
  11. Â Â Â Â Â Â Â Â Â </mx:columns>
  12. Â Â Â Â Â Â Â </mx:DataGrid>Â
  13. Â Â
  14. </mx:Application>

Â

El resultado sería el siguiente:

Flex DataGrid Mysql

posted in PHP, Programacion | 0 Comments

24th September 2008

Flex y PHP

Continuando con la serie de minitutoriales dedicados a la integración entre Adobe Flex y una base de datos Mysql, vamos a ilustrar un nuevo ejemplo de inserción de datos a través de nuestra pasarela PHP.

Para ello vamos a seguir trabajando sobre el primer ejemplo que teníamos y vamos a crear un nuevo estado con el nombre “insert”, donde pondremos el formulario de inserción de un nuevo producto.

Formulario de Inserción de Productos

El código fuente sería el siguiente:

  1. <mx:states>
  2.    <mx:State name=“insert”>
  3.      <mx:RemoveChild target=“{button1}”/>
  4.      <mx:RemoveChild target=“{dgProductos}”/>
  5.      <mx:AddChild position=“lastChild”>
  6.        <mx:Panel x=“10″ y=“10″ width=“319″ height=“215″layout=“absolute” title=“Nuevo Producto”>
  7.          <mx:Form x=“0″ y=“0″>
  8.            <mx:FormItem label=“Referencia”>
  9.              <mx:TextInput id=“referencia” width=“106″/>
  10. Â Â Â Â Â Â Â Â Â Â Â </mx:FormItem>
  11.            <mx:FormItem label=“Nombre”>
  12.              <mx:TextInput id=“nombre”/>
  13. Â Â Â Â Â Â Â Â Â Â Â </mx:FormItem>
  14.            <mx:FormItem label=“Precio”>
  15.              <mx:TextInput id=“precio”/>
  16. Â Â Â Â Â Â Â Â Â Â Â </mx:FormItem>
  17. Â Â Â Â Â Â Â Â Â </mx:Form>
  18.          <mx:ControlBar horizontalAlign=“right”>
  19.            <mx:Button label=“Cancelar”click=“this.currentState=””/>
  20.            <mx:Button label=“Insertar” id=“botInsertar”click=“insertaProducto()”/>
  21. Â Â Â Â Â Â Â Â Â </mx:ControlBar>
  22. Â Â Â Â Â Â Â </mx:Panel>
  23. Â Â Â Â Â </mx:AddChild>
  24. Â Â Â </mx:State>
  25. </mx:states>

Â

Por otra parte deberemos crear una llamada HTTPService para llamar al fichero PHP que se encarga de la inserción. Destacar que debemos poner el mismo método de petición (GET o POST) en ambos sitios:

  1. <mx:HTTPService id=“insertProd”url=“http://localhost/lsensualite/xml/insertProductos.php”method=“GET” resultFormat=“text” result=“resultHandler(event)”/>

Â

(Fichero PHP)

  1. if(!($link=mysql_connect(“localhost”,“[usuario]“,“[contraseña]“))){
  2.    echo “Error conectando a la base de datos.”;
  3. Â Â Â exit();
  4. }
  5. if (!mysql_select_db(“[nombre_bd]“,$link)) {
  6.    echo “Error seleccionando la base de datos.”;
  7. Â Â Â exit();
  8. }
  9. Â
  10. $sql = “INSERT INTO productos (referencia, nombre, precio) “;
  11. $sql .= “VALUES (’” . $_GET["referencia"] . “‘,’” . $_GET["nombre"]“‘,” . $_GET["precio"] . “) “;
  12. Â
  13. $result = mysql_query($sql,$link);

Â

Por último nos queda definir la función que se desencadenará al pulsar el botón insertar del formulario:

  1. <mx:Script>
  2. Â Â Â <![CDATA[Â Â Â Â Â Â
  3. Â Â Â Â import mx.rpc.events.ResultEvent;
  4. Â Â Â Â Â Â
  5. Â Â Â Â public function resultHandler( event: ResultEvent ):void {
  6. Â Â Â Â Â Â // Refresco el DataGrid del primer estado
  7. Â Â Â Â Â Â prodRPC.send();Â Â Â Â Â Â
  8. Â Â Â Â }Â Â
  9. Â Â Â Â
  10. Â Â Â Â public function insertaProducto():void {
  11.       // Recojo los parámetros
  12. Â Â Â Â Â Â var parametros:Object = new Object;
  13. Â Â Â Â Â Â parametros.referencia = referencia.text;
  14. Â Â Â Â Â Â parametros.nombre = nombre.text;
  15. Â Â Â Â Â Â parametros.precio = precio.text;
  16. Â Â Â Â Â Â // Llamo a PHP
  17. Â Â Â Â Â Â insertProd.send(parametros);
  18. Â Â Â Â Â Â // Vuelvo al estado inicial
  19. Â Â Â Â Â Â this.currentState = "";Â Â Â Â
  20. Â Â Â Â }
  21. Â Â ]]>
  22. </mx:Script>

posted in PHP, Programacion | 0 Comments

14th March 2007

Notas sobre Area de administracion 0.1

Cuando se elimina un fabricante cada articulo que contenga se pone a 0 (sin fabricante)
Cuando se elimina una categoria, cada articulo que contenga se pone a 0 (sin categoria), si la categoria contiene subcategorias, las elimina y pone todos los articulos a 0 (sin categoria)

Se ha modificado la clase que conecta con la base de datos. Antes de guardar los datos, hace un htmlentities() por lo que ya no es necesario hacerlo cuando se le asigna un valor a cada propiedad de cada clase

posted in PHP | 0 Comments

  • Publicidad

  • Calendar

  • March 2010
    M T W T F S S
    « Nov    
    1234567
    891011121314
    15161718192021
    22232425262728
    293031