Location: PHPKode > projects > MyPhpMoney > myphpmoney_2.0/public_html/portfolio.php
<?php
/**
 * $Id: portfolio.php 369 2003-04-06 12:52:20Z courou $
 *
 * Author     : tobozo&#64;users.sourceforge.net
 * Modified   : courou&#64;users.sourceforge.net
 * Website    : http://www.myphpmoney.net
 *
 * Support    : http://sourceforge.net/projects/myphpmoney/
 * CVS        : http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/myphpmoney/
 *
 */

/**
 * INCLUDE FILE
 */
     require_once 'config/settings.inc.php';

/**
 * ENTER IN THE SESSION OR BUILD THE LOGIN FORM
 */
     if (SQL_VerifSession()) {

      require_once $_MPM['dir_class'].''.$_MPM['class_phpquote'];
      require_once $_MPM['dir_class'].''.$_MPM['class_portfolio'];

      $mode = isset($_POST['mode']) ? $_POST['mode']  : __BOURSE_DISPLAY__;
      $op   = isset($_POST['op'])   ? $_POST['op']   : '';

      $my_quote     = new MPM_quote;               ## INSTANCE THE QUOTE
      $my_portfolio = new MPM_portfolio;           ## INSTANCE THE PORTFOLIO

/**
 * BUILD THE HEADER
 */
     XHTML_header(1,0,0,1,1,1,1,1);

/**
 * BUILD THE MAIN INPUT
 */
     $_MPM['BoucleMixed'] = array
     (
        'OPEN_CLOSE'       => XHTML_OPEN_CLOSE(),
        'QUOTE_TITLE'      => $_VAR['QUOTE_TITLE'],
        'QUOTE_TITLE_MORE' => $_VAR['QUOTE_TITLE_MORE'],
        'QUOTE_SUBMIT'     => $_VAR['IMG_ALT'][10],
        'QUOTE_CHOICE_1'   => $_VAR['QUOTE_CHOICE_1'],
        'QUOTE_CHOICE_2'   => $_VAR['QUOTE_CHOICE_2'],
        'QUOTE_CHOICE_3'   => $_VAR['QUOTE_CHOICE_3'],
        'QUOTE_SYMBOL'     => $_VAR['QUOTE_SYMBOL'],
        'QUOTE_LAST_PRICE' => $_VAR['QUOTE_LAST_PRICE'],
        'QUOTE_CHANGE'     => $_VAR['QUOTE_CHANGE'],
        'QUOTE_PER_CHANGE' => $_VAR['QUOTE_PER_CHANGE'],
        'QUOTE_VOLUME'     => $_VAR['QUOTE_VOLUME'],
        'QUOTE_LAST_TRAD'  => $_VAR['QUOTE_LAST_TRAD'],
        'LANG_BOOK_5'      => $_VAR['LANG_BOOK_5'],
        'B_FOLIO_ID'       => $_VAR['QUOTE_SYMBOL'],
        'CAC40'            => $_MPM['cac40'],
        'SELECTED_1'       => $mode == 84 ? ' selected="selected"' : '',
        'SELECTED_2'       => $mode == 85 ? ' selected="selected"' : '',
        'SELECTED_3'       => $mode == 86 ? ' selected="selected"' : ''
     );
     XHTML_SetFile('portfolio_main.tpl',$_MPM['BoucleMixed'],2);

/**
 * DELETE OR ADD THE QUOTE
 */
switch($op) {
  case 'add':
  if(isset($_POST['id'])) {
    $id = $_POST['id'];
      $liste_id  = explode(',',$id);
      $nbr_id    = count($liste_id);

     if ($nbr_id > 1) {
       for ($y=0; $y < $nbr_id; $y++) {
         if (strlen($liste_id[$y])> 10) $liste_id[$y] = substr($liste_id[$y],0,10);
         $my_portfolio->insert(str_replace("'", "`", $liste_id[$y]));
       }
     } else {
       if (strlen($id)> 10) $id = substr($id,0,10);
       $my_portfolio->insert(str_replace("'", "`", $id));
     }

    }
  else {
    ## echo ' no id sent to add ';
    }
  break;

  case 'delete':
  $id = addslashes(urldecode($_POST['id']));
  if($my_quote->load($id)) {
    $query = " DELETE FROM ".$_MPM['table'][5]." WHERE QUOTENAME='".$id."' AND USERID='$sess_pid' ";
    $db->query($query);
    ## echo $query;
    }
  else {
    ## echo ' not in the db ';
    }
  break;

  default:
  } ## end switch $_POST['op']

/**
 * BUILD THE QUOTE
 */
   $quote_ary = $my_portfolio->get_list();
   switch($mode) {
     default : case 84: case 85: case 86:
        if ($mode == 84) $mode = 'portfolio_single.tpl';
        if ($mode == 85) $mode = 'portfolio_narrow.tpl';
        if ($mode == 86) $mode = 'portfolio_wide.tpl';
        XHTML_SetFile($mode,"",0);
        $tpl->set_block("FILE_$mode",'BOUCLE_QUOTES',"BLOCK_$mode"); ## amorce la boucle
        $i=0; $j=0;
        if (is_array($quote_ary)) while(list($n, $quote)=each($quote_ary)) {
          if ($quote !='') {

            $my_quote->get_quote($quote);
            $tpl->set_var(array(
              'ID'               => urlencode($my_quote->Symbol),
              'Symbol'           => $my_quote->Symbol,
              'LastTrade'        => $my_quote->Last,
              'Price'            => $my_quote->Price,
              'Change'           => $my_quote->Change,
              'PercentageChange' => $my_quote->PercChange,
              'Volume'           => $my_quote->Volume,
              'classbgcolor'     => ($i++%2==1) ? 'phpdoc6' : 'phpdoc3',
              'COLOR'            => ($j++%2==1) ? __COLOR_PHPDOC_6__ : __COLOR_PHPDOC_3__
            ));
            $tpl->parse("BLOCK_$mode",'BOUCLE_QUOTES',true); ## parse la boucle partielle
            }
          }
        XHTML_SetFile($mode,$_MPM['BoucleMixed'],2);
     break;
     } ## end switch $mode


  } else {
          XHTML_DisplayLogin();
     } ## end if (SQL_VerifSession())

/**
 * BUILD THE FOOTER
 */
     XHTML_footer();
Return current item: MyPhpMoney