Source for file action.php

Documentation is available at action.php

  1. <?php
  2.  
  3.  
  4. /**
  5.  * Project:     deskweb - the dekstop manager for web <br />
  6.  * 
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  *
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20.  *
  21.  * You may contact the authors of Deskweb by emial at: <br />
  22.  * io@maxb.net <br />
  23.  *
  24.  * Or, write to: <br />
  25.  * Massimiliano Balestrieri <br />
  26.  * Via Casalis 9 <br />
  27.  * 10143 Torino <br />
  28.  * Italy <br />
  29.  *
  30.  * The latest version of deskweb can be obtained from: <br />
  31.  * http://www.deskweb.org/ <br />
  32.  *
  33.  * @link http://www.deskweb.org/
  34.  * @author Massimiliano Balestrieri <io@maxb.net>
  35.  * @version 0.1
  36.  * @copyright 2005-2006 Massimiliano Balestrieri.
  37.  * @package Core
  38.  */
  39.  
  40. /**
  41.  * classe Action
  42.  */
  43. class ActionDeskWeb {
  44.  
  45.     /**
  46.      * constructor class
  47.      */
  48.     function ActionDeskWeb({
  49.         $this->_checkCancel();
  50.         $this->_checkGetPublicActions();
  51.         $this->_checkPostPublicActions();
  52.         $this->_checkPostNoPublicActions();
  53.     }
  54.     function _checkGetPublicActions({
  55.  
  56.         global $request$session;
  57.         switch ($request->action{
  58.             case ACTION_VIEW_FULLSCREEN :
  59.                 global $session$request;
  60.                 $session->setFullscreen();
  61.                 header("Location:".MAIN."?id=".$request->id);
  62.                 exit ();
  63.                 break;
  64.             case ACTION_CLOSE_CONTENTS :
  65.                 $session->purgeActive();
  66.                 header("Location:".MAIN);
  67.                 break;
  68.             case ACTION_CLOSE_CONTENT //chiudi la finestra cliccata
  69.                 $session->removeFromActive($request->id);
  70.                 header("Location:".MAIN);
  71.                 break;
  72.             case ACTION_CLOSE_OTHER_CONTENT //chiudi le altre finestre
  73.                 $session->removeOtherActive($request->id);
  74.                 header("Location:".MAIN);
  75.                 break;
  76.  
  77.         }
  78.  
  79.     }
  80.     function _checkPostPublicActions({
  81.  
  82.         global $request;
  83.         ///////////////////////////AZIONI
  84.         //print_r($request->form);
  85.         if (isset ($request->form['action'])) {
  86.             switch ($request->form['action']{
  87.                 case ACTION_TEXT_LOGIN :
  88.                     global $session$request;
  89.                     if ($session->getAuthAttempt(3{
  90.                         $sql "select id_user,username,pass,fk_firstgroup,desktop_bg from ".PREFIX_DB."users where username='".$request->form['user_utente']."'";
  91.                         //echo $sql;
  92.                         $dati MySqlDao :: getDati($sql);
  93.                         if (is_array($dati)) {
  94.                             if ($dati[0]['pass'== md5($request->form['p_utente'])) {
  95.                                 $session->authFromForm($dati[0]);
  96.                             }
  97.                         else {
  98.                             $session->addAuthAttempt();
  99.                         }
  100.                         header("Location:".MAIN);
  101.                     }
  102.                     break;
  103.                 case ACTION_TEXT_REGISTER :
  104.                     global $session$request;
  105.                     $sql "select username,pass,fk_firstgroup,desktop_bg from ".PREFIX_DB."users where username='".$request->form['user_utente']."'";
  106.                     $dati MySqlDao :: getDati($sql);
  107.                     if (!is_array($dati[0])) {
  108.                         $sql "select id_user from ".PREFIX_DB."users order by id_user desc limit 1";
  109.                         $new_id_user MySqlDao :: getDati($sql);
  110.                         $new_id_user = ++ $new_id_user[0]['id_user'];
  111.                         if ($new_id_user 1000)
  112.                             $new_id_user 1000;
  113.                         //$sql = "select id_group from ".PREFIX_DB."groups order by id_group desc limit 1";
  114.                         //$new_id_group = MySqlDao :: getDati($sql);
  115.                         //$new_id_group = ++$new_id_group[0]['id_group'];
  116.                         //$sql = "insert into ".PREFIX_DB."groups (id_group,groupname) values('".$new_id_group."','".$request->form['user_utente']."')";
  117.                         //$id_group = MySqlDao :: insertDati($sql);
  118.  
  119.                         $new_id_group 1000;
  120.  
  121.                         $sql "insert into ".PREFIX_DB."users (id_user,username,pass,mail,fk_firstgroup,desktop_bg) values('".$new_id_user."','".$request->form['user_utente']."','".md5($request->form['p_utente'])."','".$request->form['email']."','".$new_id_group."','".$request->form['color']."')";
  122.                         $id_user MySqlDao :: insertDati($sql);
  123.  
  124.                         $sql "select id_user,username,pass,fk_firstgroup,desktop_bg from ".PREFIX_DB."users where username='".$request->form['user_utente']."'";
  125.                         //echo $sql;
  126.                         $dati MySqlDao :: getDati($sql);
  127.                         $session->authFromForm($dati[0]);
  128.                         header("Location:".MAIN."?id=".$request->id."&action=".ACTION_CLOSE_CONTENT);
  129.                     }
  130.                     break;
  131.             }
  132.         }
  133.  
  134.         // ALTRE AZIONI
  135.         if (isset ($request->form['n'])) {
  136.             switch ($request->form['n']{
  137.                 case ACTION_LEFT :
  138.                     global $session;
  139.                     $req $session->getPreviousRequest();
  140.                     header("Location:".MAIN."?id=".$req);
  141.                     break;
  142.                 case ACTION_RIGHT :
  143.                     global $session;
  144.                     $req $session->getNextRequest();
  145.                     header("Location:".MAIN."?id=".$req);
  146.                     break;
  147.                 case ACTION_CUT :
  148.                     if (!isset ($request->form['id_node']))
  149.                         return;
  150.                     global $session;
  151.                     $session->registerCut();
  152.                     break;
  153.                 case ACTION_COPY :
  154.                     if (!isset ($request->form['id_node']))
  155.                         return;
  156.                     $tree ModelDeskWeb :: getTree($request->form['id_node']$tree);
  157.                     global $session;
  158.                     $session->registerCopy($tree);
  159.                     header("Location:".MAIN);
  160.                     //echo "<pre>".print_r($tree,true)."</pre>";
  161.                     //die();
  162.                     break;
  163.                 case ACTION_PASTE :
  164.                     global $session$request;
  165.                     $copy $session->getClipboardCopy();
  166.                     if ($copy != null{
  167.                         //echo "<pre>".print_r($copy,true)."</pre><hr>";
  168.                         $destinazione_iniziale $request->id;
  169.                         $new_id null;
  170.  
  171.                         for ($x 0$x <= sizeof($copy1$x ++{
  172.                             //echo strpos($copy[$x]['clone'],"{destination}")."<hr>";
  173.                             if (strpos($copy[$x]['clone']"{destination}"0{
  174.                                 $sql str_replace("{destination}"$destinazione_iniziale$copy[$x]['clone']);
  175.                                 //echo $copy[$x]['clone']."<hr>";
  176.                             else {
  177.                                 $parent substr($copy[$x]['fk_parent']1strlen($copy[$x]['fk_parent']2);
  178.                                 $sql str_replace($copy[$x]['fk_parent']$new_id[$parent]$copy[$x]['clone']);
  179.                                 //echo $copy[$x]['clone']."<hr>";
  180.                             }
  181.                             $id MySqlDao :: insertDati($sql);
  182.                             //prova
  183.                             $new_id[$copy[$x]['id_node']] $id;
  184.                             //echo $sql."<hr>";
  185.                         }
  186.                         //echo "<pre>".print_r($new_id,true)."</pre><hr>";
  187.                         $session->purgeClipboard();
  188.                         header("Location:".MAIN);
  189.                         die();
  190.                     else {
  191.                         if ($session->getClipboardFrom(!= $request->id{
  192.                             $sql "update ".PREFIX_DB."node set fk_parent = '".$request->id."' where id_node  in(".join(","$session->getClipboardNodes()).");";
  193.                             //echo $sql;//die();
  194.                             $rows MySqlDao :: updateDati($sql);
  195.                             $session->purgeClipboard();
  196.                             header("Location:".MAIN);
  197.                         }
  198.                     }
  199.                     break;
  200.                 case ACTION_DELETE :
  201.                     if (!isset ($request->form['id_node']))
  202.                         return;
  203.                     $tree ModelDeskWeb :: getTreeId($request->form['id_node']$tree);
  204.                     //echo "<pre>".print_r($tree,true)."</pre><hr>";
  205.                     $sql "delete from ".PREFIX_DB."node where id_node in(".join(","$tree).")";
  206.                     //echo $sql;die();
  207.                     $delrows MySqlDao :: deleteDati($sql);
  208.                     header("Location:".MAIN);
  209.                     exit ();
  210.                     break;
  211.                 case ACTION_DELETE_CONTENT :
  212.                     $sql "delete from ".PREFIX_DB."node where id_node = '".$request->id."' limit 1";
  213.                     //echo $sql;
  214.                     $aff MySqlDao :: updateDati($sql);
  215.                     header("Location:".MAIN."?id=".DEFAULT_SAVE_POSITION);
  216.                     exit ();
  217.                     break;
  218.                 case ACTION_RELOAD :
  219.                     global $request;
  220.                     header("Location:".MAIN."?id=".$request->id);
  221.                     exit ();
  222.                     break;
  223.                 case ACTION_GO_PUBLIC :
  224.                     global $session;
  225.                     header("Location:".MAIN."?id=".$session->getPublic());
  226.                     exit ();
  227.                     break;
  228.                 case ACTION_GO_HOME :
  229.                     global $session;
  230.                     header("Location:".MAIN."?id=".$session->getHomeCurrentUser());
  231.                     exit ();
  232.                     break;
  233.                 case ACTION_UP :
  234.                     global $request;
  235.                     $parent ModelDeskWeb :: getParent($request->id);
  236.                     header("Location:".MAIN."?id=".$parent);
  237.                     exit ();
  238.                     break;
  239.                 case ACTION_VIEW_DETAILED :
  240.                     global $session$request;
  241.                     $session->setView(VIEW_DETAILED);
  242.                     header("Location:".MAIN."?id=".$request->id);
  243.                     exit ();
  244.                     break;
  245.                 case ACTION_VIEW_ICON :
  246.                     global $session$request;
  247.                     $session->setView(VIEW_ICON);
  248.                     header("Location:".MAIN."?id=".$request->id);
  249.                     exit ();
  250.                     break;
  251.                 case ACTION_VIEW_FULLSCREEN :
  252.                     global $session$request;
  253.                     $session->setFullscreen();
  254.                     header("Location:".MAIN."?id=".$request->id);
  255.                     exit ();
  256.                     break;
  257.  
  258.             }
  259.         }
  260.  
  261.     }
  262.     function _checkCancel({
  263.         global $request;
  264.         if (isset ($request->form['annulla']|| (isset ($request->form['action']&& $request->form['action'== ACTION_TEXT_ANNULLA))
  265.             header("Location:".MAIN);
  266.  
  267.     }
  268.     function _checkPostNoPublicActions({
  269.  
  270.         global $request$session;
  271.  
  272.         //die();
  273.         if ($session->getCurrentUser(0{
  274.             if (count($request->form&& !isset ($request->form['applicazione'])) {
  275.  
  276.                 //CREAZIONI FILE
  277.                 if (isset ($request->form['type'])) {
  278.  
  279.                     switch ($request->form['type']{
  280.                         case "dir" :
  281.                             //////////////////////////////////////////////////////////CREA DIRECTORY//////////////////////////////////////////////////////////
  282.                             //print_r($_POST);
  283.                             if (strlen($request->form['icona']== 0)
  284.                                 $request->form['icona'"cartella.png";
  285.  
  286.                             $request->form['node'$request->form['nome_file'];
  287.                             $request->form['application'"dwnautilus";
  288.                             $request->form['have_child'1;
  289.                             break;
  290.                         case "html" :
  291.  
  292.                             if (strlen($request->form['icona']== 0)
  293.                                 $request->form['icona'"html.png";
  294.  
  295.                             $request->form['node'$request->form['nome_file'];
  296.                             $request->form['application'"dweditor";
  297.                             $request->form['have_child'0;
  298.                             break;
  299.                         case "news" :
  300.                             #ver 0.3
  301.                             //crea news
  302.                             if (strlen($request->form['icona']== 0)
  303.                                 $request->form['icona''doc.png';
  304.  
  305.                             $request->form['node'$request->form['nome_file'];
  306.                             $request->form['application'"dweditor";
  307.                             $request->form['have_child'0;
  308.                             break;
  309.                         case "txt" :
  310.                             //crea txt
  311.                             if (strlen($request->form['icona']== 0)
  312.                                 $request->form['icona'"kate.png";
  313.  
  314.                             $request->form['node'$request->form['nome_file'];
  315.                             $request->form['application'"dwnano";
  316.                             $request->form['have_child'0;
  317.                             break;
  318.                         case "form" :
  319.                             //crea modulo
  320.                             if (strlen($request->form['icona']== 0)
  321.                                 $request->form['icona'"browser.png";
  322.  
  323.                             $request->form['node'$request->form['nome_file'];
  324.                             $request->form['application'"dweditor";
  325.                             $request->form['have_child'0;
  326.                             break;
  327.                         case "link" :
  328.                             #ver 0.3
  329.                             //crea link
  330.                             if (strlen($request->form['icona']== 0)
  331.                                 $request->form['icona'"web.png";
  332.                             if (!isset ($request->form['link'])) {
  333.                                 $request->form['link'substr($request->form['nome_file']strpos($request->form['nome_file']"#"1);
  334.                                 $request->form['nome_file'substr($request->form['nome_file']0strpos($request->form['nome_file']"#"));
  335.                             }
  336.                             $request->form['node'$request->form['nome_file']."#".$request->form['link'];
  337.                             $request->form['application'null;
  338.                             $request->form['have_child'0;
  339.                             break;
  340.                         case "note" :
  341.                             #ver 0.3
  342.                             //crea nota
  343.                             $request->form['node'$request->form['nome_file'];
  344.                             $request->form['application'"dwnano";
  345.                             $request->form['icona'"klipper.png";
  346.                             $request->form['have_child'0;
  347.                             break;
  348.                     }
  349.                     $permessi $request->recuperaPermessi();
  350.                     $sql "insert into ".PREFIX_DB."node(node,fk_parent,type,application,icon,last_date,permissions,have_child,fk_user,fk_group)values("."'".$request->form['node']."',"."'".$request->id."',"."'".$request->form['type']."',"."'".$request->form['application']."',"."'".$request->form['icona']."',"."'".date("Y-m-d H:i:s")."',"."'rwx---".$permessi."',"."'".$request->form['have_child']."',"."'".$session->getCurrentUser()."',"."'".$session->getCurrentGroup()."')";
  351.                     //echo $sql;//die();
  352.                     if (strlen($request->form['node']0)
  353.                         $id MySqlDao :: insertDati($sql);
  354.                     header("Location:".MAIN);
  355.                 }
  356.  
  357.             }
  358.         }
  359.     }
  360.  
  361. }
  362. ?>

Documentation generated on Sun, 18 Jun 2006 23:16:13 +0200 by phpDocumentor 1.3.0RC6