1
slitzx
mxdirectory help
  • 2010/1/12 3:30

  • slitzx

  • Just popping in

  • Posts: 7

  • Since: 2010/1/12


hi i am wondering if anyone can guide in me changing the fields in mxdirectory listing so that ican edit or add in fields that can suitable for me thanks ! below is the code in submit.php.
Resized Image
include "header.php";
include_once 
XOOPS_ROOT_PATH.'/header.php';

global 
$xoopsDB$eh$xoopsConfig$xoopsModuleConfig$xoopsUser;
include 
XOOPS_ROOT_PATH."/class/xoopsformloader.php";
include_once 
XOOPS_ROOT_PATH."/class/xoopstree.php";
include_once 
XOOPS_ROOT_PATH."/class/module.errorhandler.php";
include_once 
XOOPS_ROOT_PATH."/class/xoopslists.php";
include_once 
XOOPS_ROOT_PATH."/include/xoopscodes.php";
include 
"include/securitycheck.php";
include 
'class/formtime.php';
$myts =& MyTextSanitizer::getInstance(); // MyTextSanitizer object
$mytree = new XoopsTree($xoopsDB->prefix("xdir_cat"),"cid","pid");
$mydirname basename dirname__FILE__ ) )  ;
$uploadirectory="modules/" $mydirname"/images/shots";
$eh = new ErrorHandler//ErrorHandler object

//$captcha_anon = $xoopsModuleConfig['captcha_anon'];          //check captcha for annon users?

if (empty($xoopsUser) && !$xoopsModuleConfig['anonpost']) {
    
redirect_header(XOOPS_URL."/user.php",2,_MD_MUSTREGFIRST);
    exit();
}

if (!empty(
$_POST['submit'])) {
    
// Form posted - evaluate the results & put into the dB for approval
    //xoops security class before captcha eval.
        
if (!$GLOBALS['xoopsSecurity']->check()) {
        print 
_MD_SUBMITTER.''._MD_SECURITY_CODE.' '._MD_UPGRADEFAILED;
        return;
        }
    
// next check captcha security
    
if (empty($_POST['captcha_stat'] ) ) {
         
redirect_header("./",5,_MD_FAIL_SECURITY);
  }
    switch (
$_POST['captcha_stat'] ) {
        case 
false:
        case 
0:
            
redirect_header(XOOPS_URL."./",5,_MD_FAIL_GD_LOAD);
            break;
        case 
1:
        case 
2:
            if (empty(
$_POST["security"]) || empty($_POST["sec_hidden"])) {
                
$eh->show("0008");
            } else {
            
// values are set - now verify
                
$sec_post $myts->addSlashes($_POST["security"]);
                
$sec_post_hidden $myts->addSlashes($_POST["sec_hidden"]);
                
$spass mx_security_check($sec_post,$sec_post_hidden);
                if (
$spass === false){
                  
redirect_header("./",5,_MD_FAIL_SECURITY);
                 }
          }
            break;
        default:
            break;
    }
    
// end of security graphic validation check

    
$submitter = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0;

    
$notify = !empty($_POST['notify']) ? 0;
    
$cid = ( !empty($_POST['cid']) ) ? intval($_POST['cid']) : 0;
    
    
// Check if title is invalid - will only happen if someone tries to spoof the form
     
if ( !isset($_POST["title"]) || (trim($_POST["title"])=="") ) {
         
redirect_header("./",5,_MD_FIELDEMPTY);
    } elseif ( !isset(
$_POST["submitter"] ) ) {
        
//        $url = $myts->formatURL($_POST["url"]);
        //        $url = urlencode($url);
        
redirect_header("./",5,_MD_NOPERM);
    }

    
$status = ( $xoopsModuleConfig['autoapprove'] == ) ? ;

    if (!empty(
$_FILES["logoup"]["name"])){
            
$thislogo $_FILES["logoup"]["name"];
            
$logourl $myts->addSlashes($thislogo);
    }    elseif(!empty(
$POST["logourl"])) {
        
$logourl $myts->addSlashes($_POST["logourl"]);
            
$logourl = ( basename($logourl) == "0") ? "" $logourl ;
    } else {
      
$logourl '';
    }
    
$title trim($myts->addSlashes($_POST["title"]));
    
$address trim($myts->addSlashes($_POST["address"]));
    
$address2 trim($myts->addSlashes($_POST["address2"]));
    
$city trim($myts->addSlashes($_POST["city"]));
    
$state trim($myts->addSlashes($_POST["state"]));
    
$zip trim($myts->addSlashes($_POST["zip"]));
    
$country trim($myts->addSlashes($_POST["country"]));
    
$mfhrs trim($myts->addSlashes($_POST["mfhrs"]));
    
$sathrs =    trim($myts->addSlashes($_POST["sathrs"]));
    
$sunhrs =    trim($myts->addSlashes($_POST["sunhrs"]));            
    
$phone trim($myts->addSlashes($_POST["phone"]));
    
$fax trim($myts->addSlashes($_POST["fax"]));
    
$mobile trim($myts->addSlashes($_POST["mobile"]));
    
$home trim($myts->addSlashes($_POST["home"]));
    
$tollfree trim($myts->addSlashes($_POST["tollfree"]));            
    
$email trim($myts->addSlashes($_POST["email"]));
    
$url trim($myts->addSlashes($_POST["url"]));
    
$admcontname trim($myts->addSlashes($_POST["admcontname"]));
    
$admcontnumb trim($myts->addSlashes($_POST["admcontnumb"]));
    
$premium trim($myts->addSlashes($_POST["premium"]));
    
$moddesc trim($myts->addSlashes($_POST["moddesc"]));
    
$date time();
    
    
// now check for a valid image
    
$domain XOOPS_URL;
    
$path './images/shots/';   //path to targetfolder
    
$path_after_domain '/modules/' $mydirname '/images/shots/';   //path to targetfolder for use in url
    
$max_size $xoopsModuleConfig['logo_maxfilesize'];          //maximum filesize
    
$ferror false;
    if ((isset(
$_FILES['logoup'])) &&  (is_uploaded_file($_FILES['logoup']['tmp_name']))) {
        if (
$_FILES['logoup']['size']>$max_size) {
            
$ferror _MD_ELOGOSIZE// file too big
        
} else {
            if ((
$_FILES['logoup']['type']=="image/gif") || ($_FILES['logoup']['type']=="image/png") || ($_FILES['logoup']['type']=="image/jpeg")) {
                if (
file_exists($path $_FILES['logoup']['name'])) {
                    
$ferror _MD_ELOGOSAMENAME;  // file exists
                
} else {
                    if (!
copy($_FILES['logoup']['tmp_name'], $path .$_FILES['logoup']['name'])) {
                      
$ferror _MD_ELOGOTEMP;
                  }
                }
            } else {
                
$ferror _MD_ELOGOTYPE;  // wrong file type
            
}
        }
//    } elseif ((isset($_FILES['logoup'])) &&  ($_FILES['logoup']['error'] != 0)) { 
//        $ferror = sprintf(_MD_ELOGOUNK , $_FILES['logoup']['error']);
    
}

    if (
$ferror) { redirect_header("./",3,$ferror); exit(); }  // exit if error
    //
    // everything's okay so put it in the dB
    //
    
$newid $xoopsDB->genId($xoopsDB->prefix("xdir_links")."_requestid_seq");

    
$sql sprintf("INSERT INTO %s (lid, cid, title, address, address2, city, state, zip, country, mfhrs, sathrs, sunhrs, phone, fax, mobile, home, tollfree, email, url, admcontname, admcontnumb, logourl, submitter, status, date, hits, rating, votes, comments, premium) VALUES (%u, %u, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %u, %u, %u, %u, %u, %u, %u, %u)"$xoopsDB->prefix("xdir_links"), $newid$cid$title$address$address2$city$state$zip$country$mfhrs$sathrs$sunhrs$phone$fax$mobile$home$tollfree$email$url$admcontname$admcontnumb$logourl$submitter$status$date0000$premium);
    
$xoopsDB->query($sql) or $eh->show("0013");
    
$newid = ($newid == 0) ? $newid $xoopsDB->getInsertId() : $newid ;
    
$sql sprintf("INSERT INTO %s (lid, description) VALUES (%u, '%s')"$xoopsDB->prefix("xdir_text"), $newid$moddesc);
    
$xoopsDB->query($sql) or $eh->show("0013");
    
//
    // and finally set the notification
    //
    
$notification_handler =& xoops_gethandler('notification');
    
$tags = array();
    
$tags['LINK_NAME'] = $title;
    
$tags['LINK_URL'] = XOOPS_URL '/modules/'$xoopsModule->getVar('dirname') . '/singlelink.php?cid=' $cid '&lid=' $newid;
    
$sql "SELECT title FROM " $xoopsDB->prefix("xdir_cat") . " WHERE cid=" $cid;
    
$result $xoopsDB->query($sql);
    
$row $xoopsDB->fetchArray($result);
    
$tags['CATEGORY_NAME'] = $row['title'];
    
$tags['CATEGORY_URL'] = XOOPS_URL '/modules/' $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' $cid;
    if ( 
$xoopsModuleConfig['autoapprove'] == ) {
        
$notification_handler->triggerEvent('global'0'new_link'$tags);
        
$notification_handler->triggerEvent('category'$cid'new_link'$tags);
        
redirect_header("index.php",2,_MD_RECEIVED.""._MD_ISAPPROVED."");
    }else{
        
$tags['WAITINGLINKS_URL'] = XOOPS_URL '/modules/' $xoopsModule->getVar('dirname') . '/admin/index.php?op=listNewLinks';
        
$notification_handler->triggerEvent('global'0'link_submit'$tags);
        
$notification_handler->triggerEvent('category'$cid'link_submit'$tags);
        if (
$notify) {
            include_once 
XOOPS_ROOT_PATH '/include/notification_constants.php';
            
$notification_handler->subscribe('link'$newid'approve'XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE);
        }
        
redirect_header("index.php",10,_MD_RECEIVED);
    }
    exit();

} else {     
// Display submit form

    
$submitter = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : _MD_ANON;
    
$arry1 = array( =>_MD_NONE);
    
$linkimg_array XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH."/modules/".$mydirname."/images/shots/");
    
$linkimg_array array_merge($arry1 $linkimg_array);
    
$logourl '';  // clear logo
    
    
$sql "SELECT cid, title FROM ".$xoopsDB->prefix("xdir_cat");
    
$result $xoopsDB->query($sql);

    
$modlinkform = new XoopsThemeForm(_MD_ADDNEWLINK'submitform'$_SERVER['PHP_SELF'], 'POST',true);
    
$modlinkform->addElement(new XoopsFormText(_MD_SITETITLE 'title'50100''),true);
    
    
$addrtray = new XoopsFormElementTray(_MD_BUSADDRESS,'');
    
$addrtray->addElement(new XoopsFormText(_MD_BUSADDRESS1 'address'38200''));
    
$addrtray->addElement(new XoopsFormText(_MD_BUSADDRESS2 'address2'38100''));
    
$modlinkform->addElement($addrtray);
    
$modlinkform->addElement(new XoopsFormText(_MD_BUSCITY 'city'5080''));
    
$modlinkform->addElement(new XoopsFormText(_MD_BUSSTATE 'state'5080''));// EVU CODE changed size and max size
    
$modlinkform->addElement(new XoopsFormText(_MD_BUSZIP 'zip'1515''));
    
$modlinkform->addElement(new XoopsFormSelectCountry(_MD_BUSCOUNTRY 'country'''));        
    
$hrtray = new XoopsFormElementTray(_MD_BUSHRS ,'');
    
$hrtray->addElement(new XoopsFormTime(_MD_BUSMFHRS 'mfhrs'15''));    
    
$hrtray->addElement(new XoopsFormTime(_MD_BUSSATHRS 'sathrs'15''));
    
$hrtray->addElement(new XoopsFormTime(_MD_BUSSUNHRS 'sunhrs'15''));
    
$modlinkform->addElement($hrtray);
    
$modlinkform->addElement(new XoopsFormText(_MD_BUSPHONE 'phone'1535''));
    
$modlinkform->addElement(new XoopsFormText(_MD_BUSFAX 'fax'1535''));
    
$modlinkform->addElement(new XoopsFormText(_MD_BUSMOBILE 'mobile'1535''));
    
$modlinkform->addElement(new XoopsFormText(_MD_BUSHOME 'home'1535''));
    
$modlinkform->addElement(new XoopsFormText(_MD_BUSTOLLFREE 'tollfree'1535''));
    
$modlinkform->addElement(new XoopsFormText(_MD_BUSEMAIL 'email'50100''));
    
$modlinkform->addElement(new XoopsFormText(_MD_SITEURL 'url'50250''));                                                            
    
$contray = new XoopsFormElementTray(_MD_BUSADMCONT '');
    
$contray->addElement(new XoopsFormText(_MD_BUSADMCONTNAME 'admcontname'2835''),true);       
    
$contray->addElement(new XoopsFormText(_MD_BUSADMCONTNUMB 'admcontnumb'2835''),true);    
    
$modlinkform->addElement($contray);    
    
$sel_cat = (new XoopsFormSelect(_MD_CATEGORYC 'cid'''1false));
    
$tree $mytree->getChildTreeArray(0,"title ASC");
    foreach (
$tree as $branch ) {
        
$branch['prefix'] = substr($branch['prefix'], 0, -1);
        
$branch['prefix'] = str_replace(".","--",$branch['prefix']);
        
$sel_cat -> addOption($branch['cid'],$branch['prefix'].$branch['title']);
    }
    
$modlinkform->addElement($sel_cat);
    
$modlinkform->addElement(new XoopsFormDhtmlTextArea(_MD_DESCRIPTIONC 'moddesc' null 850), false);

    
$modlinkform->addElement(new XoopsFormFile(_MD_LOGOUP 'logoup'$xoopsModuleConfig['logo_maxfilesize']));

    
$premtray = new XoopsFormElementTray(_MD_PREMIUM ,'');
    
    
$premopts getlvlselects();
    
$premmenu = new XoopsFormSelect(_MD_PREMIUM 'premium'''''false);
    
$premmenu->addOptionArray($premopts);
    
//$modlinkform->addElement($premmenu);
    
$premtray->addElement($premmenu);
    
$whaturl XOOPS_URL."/modules/".$mydirname."/matrix.php";
    
$premtray->addElement(new XoopsFormLabel("","$whaturl . "">" _MD_WHATTHIS .""));
    
$modlinkform->addElement($premtray);
    
//
    // zyspec - add code for security graphic
    // modified from original code from XoopsContact v1.6 by IBDeeming
    //
    // captcha_stat = 
    //                                0 or false, gd not loaded - validate captcha
    //                                1, gd loaded, - validate captcha
    //                                2, gd2 loaded - validate captcha
    //                                else, - don't validate captcha
    //
    
if ( empty($xoopsUser) && $xoopsModuleConfig['captcha_anon'] ) {
//    if (($xoopsModuleConfig['captcha_anon'])) {          //check captcha for annon users?
        
$gd = ( extension_loaded('gd') ) ? false ;
        
$gd = ( extension_loaded('gd2') ) ? $gd ;
        
$captcha_stat $gd;
        if ( 
$gd ){
            
mt_srand((double)microtime()*10000);
            
$random_num mt_rand(0100000);
            
$security "$random_num&gd=$gd' border='1' alt='"._MD_SECURITY_CODE."' title='"._MD_SECURITY_CODE."' />  "
                                    
."";
            
$captchatray = new XoopsFormElementTray('','');
            
$captchatray->addElement(new XoopsFormLabel('' $security));
            
$captchatray->addElement(new XoopsFormHidden('sec_hidden',$random_num));
            
$captchatray->addElement(new XoopsFormText('','security',15,10,''));
            
$modlinkform->addElement($captchatray);
        }
    } else {
        
$captcha_stat 99;
    }
    
$modlinkform->addElement(new XoopsFormHidden('captcha_stat'$captcha_stat));
    
//    zyspec - end of security graphic code

    
$submittray = new XoopsFormElementTray('','');
    
$regtray = new XoopsFormElementTray('','');
    
$regtray->addElement(new XoopsFormButton(''''_MD_SUBMIT'submit'));
    
$regtray->addElement(new XoopsFormHidden('submit',true));
    
$regtray->addElement(new XoopsFormButton('''cancel'_MD_CANCEL'reset'));
    
$submittray->addElement($regtray);

//    $modlinkform->addElement(new XoopsFormHidden('description', $desc));        
    
$modlinkform->addElement(new XoopsFormHidden('mfhrs'''));
    
$modlinkform->addElement(new XoopsFormHidden('sathrs'''));
    
$modlinkform->addElement(new XoopsFormHidden('sunhrs'''));
    
$modlinkform->addElement(new XoopsFormHidden('submitter'$submitter));
    
$modlinkform->addElement($submittray);

    
$modlinkform->setExtra('enctype="multipart/form-data"');
    
$modlinkform->display();
  include 
XOOPS_ROOT_PATH.'/footer.php';
}
?>

2
ghia
Re: mxdirectory help
  • 2010/1/12 9:18

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


slitzx , Welcome to the XOOPS forum!

We can't see images from your desktop here. You have to upload them somewhere on the internet (eg imageshack) and then use the URL for the image in your post. Please correct this, so we can know what your question is about.

3
slitzx
Re: mxdirectory help
  • 2010/1/12 16:23

  • slitzx

  • Just popping in

  • Posts: 7

  • Since: 2010/1/12


hi, thanks for the welcome =)
i have solved the issue of changing the fields name in my property listing form
where i change the name by language\english\main.php

Resized Image


4
slitzx
Re: mxdirectory help
  • 2010/1/14 17:28

  • slitzx

  • Just popping in

  • Posts: 7

  • Since: 2010/1/12


okay, i have successfully modified my fields and forms and can proceed with listing, however, i am stuck with the rating portion as
the rating is not working for me

include "header.php";
include_once 
XOOPS_ROOT_PATH."/class/module.errorhandler.php";
$myts =& MyTextSanitizer::getInstance(); // MyTextSanitizer object

if (!empty($HTTP_POST_VARS['submit'])) {
    
$eh = new ErrorHandler//ErrorHandler object
    
if(empty($xoopsUser)){
        
$ratinguser 0;
    }else{
        
$ratinguser $xoopsUser->getVar('uid');
    }

       
//Make sure only 1 anonymous from an IP in a single day.
       
$anonwaitdays 1;
       
$ip getenv("REMOTE_ADDR");
    
$lid intval($HTTP_POST_VARS['lid']);
    
$cid intval($HTTP_POST_VARS['cid']);
    
$rating intval($HTTP_POST_VARS['rating']);

       
// Check if Rating is Null
       
if ($rating=="--") {
        
redirect_header("ratelink.php?cid=".$cid."&lid=".$lid."",4,_MD_NORATING);
        exit();
       }

       
// Check if Link POSTER is voting (UNLESS Anonymous users allowed to post)
       
if ($ratinguser != 0) {
           
$result=$xoopsDB->query("select submitter from ".$xoopsDB->prefix("xdir_links")." where lid=$lid");
           while(list(
$ratinguserDB) = $xoopsDB->fetchRow($result)) {
               if (
$ratinguserDB == $ratinguser) {
                
redirect_header("index.php",4,_MD_CANTVOTEOWN);
                exit();
              }
           }

        
// Check if REG user is trying to vote twice.
           
$result=$xoopsDB->query("select ratinguser from ".$xoopsDB->prefix("xdir_votedata")." where lid=$lid");
           while(list(
$ratinguserDB) = $xoopsDB->fetchRow($result)) {
               if (
$ratinguserDB == $ratinguser) {
                
redirect_header("index.php",4,_MD_VOTEONCE2);
                exit();
               }
          }

       } else {

           
// Check if ANONYMOUS user is trying to vote more than once per day.
        
$yesterday = (time()-(86400 $anonwaitdays));
           
$result=$xoopsDB->query("select count(*) FROM ".$xoopsDB->prefix("xdir_votedata")." WHERE lid=$lid AND ratinguser=0 AND ratinghostname = '$ip' AND ratingtimestamp > $yesterday");
           list(
$anonvotecount) = $xoopsDB->fetchRow($result);
           if (
$anonvotecount 0) {
            
redirect_header("index.php",4,_MD_VOTEONCE2);
            exit();
           }
       }
    if(
$rating 10){
        
$rating 10;
    }

    
//All is well.  Add to Line Item Rate to DB.
    
$newid $xoopsDB->genId($xoopsDB->prefix("xdir_votedata")."_ratingid_seq");
    
$datetime time();
    
$sql sprintf("INSERT INTO %s (ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp) VALUES (%u, %u, %u, %u, '%s', %u)"$xoopsDB->prefix("xdir_votedata"), $newid$lid$ratinguser$rating$ip$datetime);
    
$xoopsDB->query($sql) or $eh->show("0013");

    
//All is well.  Calculate Score & Add to Summary (for quick retrieval & sorting) to DB.
    
updaterating($lid);
    
$ratemessage _MD_VOTEAPPRE."".sprintf(_MD_THANKURATE,$xoopsConfig[sitename]);
    
redirect_header("index.php",2,$ratemessage);
    exit();

} else {

    
$xoopsOption['template_main'] = 'xdir_ratelink.html';
    include 
XOOPS_ROOT_PATH."/header.php";
    
$lid intval($_GET['lid']);
    
$cid intval($_GET['cid']);
    
$result=$xoopsDB->query("select title from ".$xoopsDB->prefix("xdir_links")." where lid=$lid");
    list(
$title) = $xoopsDB->fetchRow($result);
    
$xoopsTpl->assign('link', array('id' => $lid'cid' => $cid'title' => $myts->htmlSpecialChars($title)));
    
$xoopsTpl->assign('lang_voteonce'_MD_VOTEONCE);
    
$xoopsTpl->assign('lang_ratingscale'_MD_RATINGSCALE);
    
$xoopsTpl->assign('lang_beobjective'_MD_BEOBJECTIVE);
    
$xoopsTpl->assign('lang_donotvote'_MD_DONOTVOTE);
    
$xoopsTpl->assign('lang_rateit'_MD_RATEIT);
    
$xoopsTpl->assign('lang_cancel'_CANCEL);
    
//Smarty directory autodetect
    
$smartydir $xoopsModule->getVar('dirname');
    
$xoopsTpl->assign('smartydir'$smartydir);
    include 
XOOPS_ROOT_PATH.'/footer.php';
}
?>

may i know which code to change as the values are not added to db after i click rate!

5
trabis
Re: mxdirectory help
  • 2010/1/14 19:08

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Replace $HTTP_POST_VARS with $_POST.

Login

Who's Online

277 user(s) are online (186 user(s) are browsing Support Forums)


Members: 0


Guests: 277


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits