• User Attivo

    Problema con edit-listing.php di esyndicat

    Ciao a tutti,
    ho un problema con il file edit-listing.php del cms per directory esyndicat 1.6. Ho pensato che questa fosse la sezione più adeguata perchè il problema non è il cms ma questo specifico file.
    In pratica il file edit-listing.php è quello deputato alla modifica delle inserzioni già esistenti. Il problema è che quando provo a modificare l'inserzione cliccando su salva, come risposta ottengo una pagina bianca e nessuna modifica viene salvata.
    Ecco di seguito il codice, secondo voi c'è qualcosa da sistemare? :ciauz:

    <?php
    /***************************************************************************
     *
     *     PROJECT: eSyndiCat Directory Software
     *     VERSION: 1.6 (Free Release)
     *     LISENSE: GNU GPL (http://www.opensource.org/licenses/gpl-license.html)
     *
     *   This program is free software; you can redistribute it and/or modify
     *   it under the terms of the GNU General Public License as published by
     *   the Free Software Foundation.
     *
     *   Link to eSyndiCat.com can not be removed from the software pages without
     *     permission of eSyndiCat respective owners. It is the only requirement
     *     for using this software.
     *
     *   Copyright 2005-2007 Intelliants LLC
     *   http://www.intelliants.com/
     *
     ***************************************************************************/
    
    if(empty($_GET['id']) || preg_match("/\D/", $_GET['id']))
    {
        header("HTTP/1.1 404 Not found");
        die("404 Not found. <br />Powered by eSyndicat.");
    }
    
    
    require_once('.'.DIRECTORY_SEPARATOR.'header.php');
    $config         = &Config::instance();
    
    require_once(ADMIN_CLASSES.'DirCategory.php');
    $Category = &new Category;
    
    require_once(ADMIN_CLASSES.'DirListing.php');
    $Listing = &new Listing;
    
    require_once(ADMIN_CLASSES."DirAccount.php");
    $Account = &new Account;
    
    if(!$Listing->exists("`id`='".$_GET['id']."'"))
    {
        goto("browse.php");
    }
    
    $Listing->adjustClicks($_GET['id']);
    
    if ($_POST['title'])
    {
        loadUTF8Core();
        loadUTF8Util('validation');
        loadUTF8Util('bad');
        loadUTF8Util('ascii');    
        loadUTF8Util('utf8_to_ascii');
    
        $temp['id']             = (int)$_GET['id'];
        $temp['recip_valid']    = (int)$_POST['recip_valid'];
        $temp['status']            = valid_status($_POST['status']) ? $_POST['status'] : '';
    
        $temp['rank']             = (int)$_POST['rank'];
    
        $temp['comment'] = $_POST['comment'];
        if(!utf8_is_valid($temp['comment']))
        {
            $temp['comment'] = utf8_bad_replace($temp['comment']);
            trigger_error("Bad UTF-8 detected (replacing with '?') in edit listing", E_USER_NOTICE);
        }
        $temp['comment']    = sql($temp['comment']);
        $temp['email']        = sql($_POST['email']);
        $temp['url']        = sql($_POST['url']);
    
        $temp['title']        = $_POST['title'];
        if(!utf8_is_valid($temp['title']))
        {
            $temp['title'] = utf8_bad_replace($temp['title']);
            trigger_error("Bad UTF-8 detected (replacing with '?') in edit listing", E_USER_NOTICE);
        }
        $temp['title'] = $temp['alias']    = sql($temp['title']);
        $temp['alias'] = utf8_to_ascii($temp['alias']);
    
        $temp['description']     = $_POST['description'];
        if(!utf8_is_valid($temp['description']))
        {
            $temp['description'] = utf8_bad_replace($temp['description']);
            trigger_error("Bad UTF-8 detected (replacing with '?') in edit listing", E_USER_NOTICE);
        }
        $temp['description']    = sql($temp['description']);
        
        $temp['reciprocal']     = sql($_POST['reciprocal']);
        $temp['header']         = (int)$_POST['header'];
    
        $temp['no_follow'] = (1 == (int)$_POST['no_follow']) ? 1 : 0;
        
        if (!$temp['description'])
        {
            $error = true;
            $msg = 'Listing description field is empty.';
        }
        
        if (!$temp['title'])
        {
            $error = true;
            $msg = 'Listing title field is empty.';
        }
    
        if (!$temp['url'] || ($temp['url'] == 'http://') || !valid_url($temp['url']))
        {
            $error = true;
            $msg = 'Please input correct listing URL.';
        }
        else
        {
            $temp['domain'] = get_domain($temp['url']);
        }
    
        $temp['id_account'] = 0;
        if(isset($_POST['account']))
        {
            $id = $Account->one("`id`", "`username` = '".sql($_POST['account'])."'");
            if($id)
            {
                $temp['id_account'] = $id;
            }
        }
    
        if (!$error)
        {
            if(!empty($_POST['send_email']))
            {
                $temp['_notify'] = true;
            }
    
            $Listing->update($temp);
            $msg = ($_POST['send_email']) ? 'Listing info changed. Email sent.' : 'Listing info changed. Email was not sent.';
        }
    }
    
    if (!empty($_POST['action']) && $_POST['action'] == 'move' && is_array($_POST['categories']) && !empty($_POST['categories']))
    {
        $category            = array();
        $category['id']    = $_POST['categories'][0];
    
        $Listing->move((int)$_GET['id'], $category['id'], true);
        $msg = $gDirLang;
    
        // new category
        $category['title'] = $Category->one("`title`","`id`='".$category['id']."'");
    }
    
    /** gets listing information **/
    $listing = $Listing->getListingById((int)$_GET['id']);
    $category = &$listing['category'];
    
    $listing['account'] = $Account->one("`username`", "`id`='".$listing['id_account']."'");
    
    $gBc[0]['title'] = $gDirLang['browse'];
    $gBc[0]['url'] = 'browse.php';
    
    $gBc[1]['title'] = $gDirLang['edit_listing'];
    $gBc[1]['url'] = '';
    
    $gTitle = $gDirLang['edit_listing'];
    
    require_once('top.php');
    
    print_box($error, $msg);
    
    
    echo '<div class="buttons">';
    echo "<a href=\"javascript:history.go(-1);\"><img src=\"img/ico-back.gif\" title=\"{$gDirLang['go_back']}\" alt=\"{$gDirLang['go_back']}\"/></a>";
    echo "<a href=\"javascript:void(0);\" onclick=\"document.listings_form.submit();\"><img src=\"img/ico-save.gif\" title=\"{$gDirLang['save_changes']}\" alt=\"{$gDirLang['save_changes']}\" /></a>";
    echo '</div>';
    ?>
    <script type="text/javascript">
    //<![CDATA[
        // contains previous tree type (move, cross, relate,subcat)
        var previousType;
        function getCategoryChildren(catid, state)
        {
            var act = $("#action").val();
            var c = "#category_"+catid;
    
            // flag
            var reloadTree = false;
            // if type changed then reload the tree
            if(previousType != act)
            {
                if(previousType == 'move')
                {
                    reloadTree = true
                }
                if(act == 'move')
                {
                    reloadTree = true
                }
            }
            previousType = act;
    
            imsrc = $('#im_' + catid).attr("src");
    
            // if the node is expanded then collapse
            if(-1!=imsrc.indexOf("minus.png"))
            {
                $('#im_' + catid).attr("src", 'img/plus.png');
                
                t = $('#imf_' + catid).attr("src");
                if(-1!=t.indexOf("folder2.gif"))
                {
                    t = "folder2.gif";
                }
                else
                {
                    t = "folder.gif";
                }
                $('#imf_' + catid).attr("src", 'img/'+t);
                $(c).hide();
    
                return;
            }
            else
            {
                var x = $(c).attr("class");
                $('#im_' + catid).attr("src", 'img/minus.png');    
                t = $('#imf_' + catid).attr("src");
                if(-1!=t.indexOf("folder2.gif"))
                {
                    t = "folder2.gif";
                }
                else
                {
                    t = "folder.gif";
                }
                $('#imf_' + catid).attr("src", 'img/open_'+t);
    
                // if class contains _tree_loaded but not marked as reloadTree then show already loaded
                // otherwise tree must be reloaded (e.g if type of the tree is changed)
                if(!reloadTree && x && x.match(/_tree_loaded/))
                {
                    $(c).show();
    
                    return;
                }
            }
    
            var pars = 'id='+catid;
    
            if(state != null && state!='')
            {
                pars+="&state="+state;
            }
            pars += '&type=moveORtree';
            if(act == 'move')
            {
                pars += '&widget=radio';
            }
            $(c).before($("#spinner"));
            $("#spinner").show();
    
            $.get("get-categories.php?"+pars,
                function(data)
                {
                    $(c).html(data).show();
                    // mark the node as loaded see above code
                    $(c).addClass("_tree_loaded");
                    $("#spinner").hide();
                });
        }
    //]]>
    </script>
    <div id="treeContainer" style="display:none;">
    <?php ob_start(); ?>
    <form action="<?php echo "edit-listing.php?id=".$_GET['id']."&amp;category=".$category['id']; ?>" method="post">
    <input id="action" type="hidden" name="action" value="" />
    <ul class="tree">
        <li>
            <a href="javascript:getCategoryChildren('0')" class="no">
            <img alt="" style="margin-bottom:3px;height:9px;width:9px" src="img/plus.png" id="im_0" />
            <img alt="" style="margin-bottom:3px;height:12px;width:16px" src="img/folder.gif" id="imf_0" /></a>
            <input type="radio" name="categories[]" value="0" id="labelcat0" />
            <label for="labelcat0">ROOT</label>
            <div id="category_0" style="display:none;"></div>
        </li>
    </ul>
    <input style="margin:15px 0px 0px 24px;" type="submit" value=" <?php echo $gDirLang['submit']?> " />
    </form>
    <?php
    
    $str = ob_get_clean();
    box('box', $gDirLang['tree'], $str, '', 'margin-bottom: 10px;');
    echo "</div>"; // end tree container
    
    ob_start();
    ?>
    
    <form action="<?php echo "edit-listing.php?id={$listing['id']}"; ?>" method="post" name="listings_form" id="listings_form">
    <table cellspacing="0" width="100%" class="striped">
    <tr>
        <td><strong><?php echo $gDirLang['category']?>:</strong></td>
        <td><strong><?php echo "<a href=\"browse.php?id={$category['id']}\">{$category['title']}</a>"; ?></strong> | <a href="javascript:void(0);" onClick="$('#treeContainer').fadeIn();$('#action').val('move');return false;"><?php echo $gDirLang['move_to']?></a></td>
    </tr>
    <tr>
        <td class="first"><?php echo $gDirLang['account']?>:</td>
        <td><input type="text" class="ac_input" id="account" name="account" value="<?php echo $listing['account']?>" autocomplete="off" /></td>
    </tr>
    <tr>
        <td><strong><?php echo $gDirLang['url']?>:</strong></td>
        <td><input type="text" name="url" size="45" maxlength="150" value="<?php echo html($listing['url']); ?>" /></td>
    </tr>
    <tr>
        <td><strong><?php echo $gDirLang['title']?>:</strong></td>
        <td><input type="text" name="title" size="45" maxlength="150" value="<?php echo html($listing['title']); ?>" /></td>
    </tr>
    <tr>
        <td class="first" colspan="2"><?php echo $gDirLang['description']?>:<br /><br />
        <?php
        if($listing['status'] == 'active'):
            require_once(CLASSES."DirFckeditor.php");
            $Editor                 = & new FCKeditor('description');
            $Editor->Value     = $listing['description'];
            $Editor->Create();
        else: ?>
        <h4><?php echo $gDirLang['editor_not_showed_listing_inactive']?></h4>
            <textarea name="description" cols="53" rows="8"><?php echo html($listing['description']); ?></textarea>
        <?php endif; ?></td>
    </tr>
    <tr>
        <td><strong><?php echo $gDirLang['email']?>:</strong></td>
        <td><input type="text" name="email" size="45" maxlength="100" value="<?php echo html($listing['email']); ?>" /></td>
    </tr>
    <tr>
        <td><strong><?php echo $gDirLang['reciprocal']?>:</strong></td>
        <td><input type="text" name="reciprocal" size="45" maxlength="150" value="<?php echo html($listing['reciprocal']); ?>" />
            <?php echo ($listing['reciprocal'] && ($listing['reciprocal'] != 'http://')) ? " | <a href=\"{$listing['reciprocal']}\" style=\"font-weight: bold;\" target=\"_blank\">visit page</a>" : '';?>
        </td>
    </tr>
    <tr>
        <td class="caption" colspan="2"><strong><?php echo $gDirLang['additional_fields']?></strong>
    </td>
    <tr>
        <td><strong><?php echo $gDirLang['reciprocal_valid']?>:</strong></td>
        <td><input type="radio" name="recip_valid" value="1" id="recip_yes"<?php echo ($listing['recip_valid'] == '1') ? ' checked="checked"' : ''; ?> /><label for="recip_yes">correct</label>
            <input type="radio" name="recip_valid" value="0" id="recip_no"<?php echo ($listing['recip_valid'] == '0') ? ' checked="checked" ' : ''; ?> /><label for="recip_no">incorrect</label>
        </td>
    </tr>
    <tr>
        <td><strong><?php echo $gDirLang['status']?>:</strong></td>
        <td>
            <select name="status">
                <option value="active"<?php echo ($listing['status'] == 'active') ? ' selected="selected" ' : ''; ?>>Active</option>
                <option value="approval"<?php echo ($listing['status'] == 'approval') ? ' selected="selected" ' : ''; ?>>Approval</option>            
                <option value="banned"<?php echo ($listing['status'] == 'banned') ? ' selected="selected" ' : ''; ?>>Banned</option>            
            </select> | 
            <strong>URL header:</strong>
                <select name="header">
                <?php
                    foreach($gHeaders as $key=>$value)
                    {
                        $selected = ($key == $listing['header']) ? ' selected="selected" ' : '';
                        echo "<option value=\"{$key}\"{$selected}>{$value}</option>";
                    }
                ?>
                </select>
        </td>
    </tr>
    <tr>
        <td class="first"><?php echo $gDirLang['no_follow']?>:</td>
        <td>
        <?php
            $noFollow = false;
            if($listing['no_follow'] || !$listing['no_follow'] && !empty($_POST['no_follow']))
            {
                $noFollow = true;
            }
        ?>
            <input type="radio" id="no_follow1" name="no_follow" value="1"<?php echo $noFollow ? ' checked="checked"' : ''; ?> />
            <label for="no_follow1"><?php echo $gDirLang['yes']?></label>
            <input type="radio" id="no_follow0" name="no_follow" value="0"<?php echo !$noFollow ? ' checked="checked"' : ''; ?> />
            <label for="no_follow0"><?php echo $gDirLang['no']?></label>
        </td>
    </tr>
    <tr>
        <td><strong><?php echo $gDirLang?>:</strong></td>
        <td>
            <select name="rank">
                <option value="0"><?php echo $gDirLang['not_rated']?></option>
            <?php
                for($i = 1; $i <= 10; $i++)
                {
                    $cause = ($listing['rank'] == $i) ? ' selected="selected" ' : '';
                    echo "<option value=\"{$i}\"{$cause}>Rank {$i}</option>";
                }
            ?>
            </select>
        </td>
    </tr>
    <tr>
        <td><strong><?php echo $gDirLang['admin_comment']?>:</strong></td>
        <td><textarea name="comment" cols="50" rows="8"><?php echo html($listing['comment']); ?></textarea></td>
    </tr>
    <tr class="all">
    <td colspan="2"><input type="checkbox" name="send_email" id="send_email"<?php echo $config->get('listing_modify') ? ' checked="checked"' : ''; ?> /><label for="send_email">Send email notification</label> | <input type="submit" name="edit_listing" value="<?php echo $gDirLang['save_changes'];?>" class="button" /></td>
    </tr>
    </table>
    <input type="hidden" id="move_listing_to" name="move_to" />
    <input type="hidden" id="id_category" name="id_category" value="<?php echo $listing['id_category']; ?>" />
    </form>
    <?php
    $s = ob_get_clean();
    box('box', $gDirLang['edit_listing'], $s);
    
    require_once('footer.php');
    
    

  • User Attivo

    Nel forum di Esyndicat un utente dice inoltre di aver risolto il problema così:

    Ho risolto in un modo non troppo corretto, ma comunque funzionante.

    In /admin/edit-listing.php ho commentato la linea 78:
    PHP Code:
    $temp['alias'] = utf8_to_ascii($temp['alias']);

    Chi mi dà una mano? Grazie. 🙂


  • User Attivo

    Ho scoperto che la tipologia di errore è questa:
    **```
    Cannot modify header information ? headers already sent

    
    Non c'è proprio nessuno che sappia spiegarmi cos'ha di sbagliato il codice? Ho capito che prima di header() non ci deve essere nessun tipo di output ma qui non vedo nulla di strano...
    :?
    
    EDIT: Risolto. Grazie lo stesso. :)