ianhaney Posted December 29, 2015 Share Posted December 29, 2015 Hi I am using katak support which is a ticket system script and is all installed and working perfect apart from the php captcha is not working on the new ticket page I have been looking it and saw it could be the gd library not installed or enabled, the freetype is not installed or enabled, a file permissions issue or a htaccess issue I have a phpinfo file and says gd library is enabled as well as freetype is enabled, I checked the file permissions and is ok as well as the htaccess file, I even removed the htaccess file and is still the same I don't get it, if I visit the captcha.php file itself in the browser I get a 502 Bad gateway message if it helps but not sure how to fix it I am using php version 5.5.30 I am not sure which code to post here to have a look, below is my captcha.php code <?php /********************************************************************* captcha.php Simply returns captcha image. Copyright (c) 2012-2013 Katak Support http://www.katak-support.com/ Released under the GNU General Public License WITHOUT ANY WARRANTY. Derived from osTicket by Peter Rotich. See LICENSE.TXT for details. $Id: $ **********************************************************************/ require_once('main.inc.php'); require(INCLUDE_DIR.'class.captcha.php'); $captcha = new Captcha(5,12,ROOT_DIR.'images/captcha/'); echo $captcha->getImage(); ?> Below is the code from the class.captcha.php file <?php /********************************************************************* class.captcha.php Very basic captcha class. Copyright (c) 2012-2013 Katak Support http://www.katak-support.com/ Released under the GNU General Public License WITHOUT ANY WARRANTY. Derived from osTicket by Peter Rotich. See LICENSE.TXT for details. $Id: $ **********************************************************************/ class Captcha { var $hash; var $bgimages=array('cottoncandy.png','grass.png','ripple.png','silk.png','whirlpool.png', 'bubbles.png','crackle.png','lines.png','sand.png','snakeskin.png'); var $font = 10; function Captcha($len=6,$font=7,$bg=''){ $this->hash = strtoupper(substr(md5(rand(0, 9999)),rand(0, 24),$len)); $this->font = $font; if($bg && !is_dir($bg)){ //bg file provided? $this->bgimg=$bg; }else{ //assume dir provided or defaults to local. $this->bgimg=rtrim($bg,'/').'/'.$this->bgimages[array_rand($this->bgimages, 1)]; } } function getImage(){ if(!extension_loaded('gd') || !function_exists('gd_info')) //GD ext required. return; $_SESSION['captcha'] =''; //Clear list($w,$h) = getimagesize($this->bgimg); $x = round(($w/2)-((strlen($this->hash)*imagefontwidth($this->font))/2), 1); $y = round(($h/2)-(imagefontheight($this->font)/2)); $img= imagecreatefrompng($this->bgimg); imagestring($img,$this->font, $x, $y,$this->hash,imagecolorallocate($img,0, 0, 0)); Header ("(captcha-content-type:) image/png"); imagepng($img); imagedestroy($img); $_SESSION['captcha'] = md5($this->hash); } } ?> Thank you in advance Ian Quote Link to comment Share on other sites More sharing options...
ianhaney Posted December 29, 2015 Author Share Posted December 29, 2015 Sorry I enabled php error reporting on the file include/user/open.inc.php and that returned the following errors Notice: Undefined index: name in /home/sites/it-doneright.co.uk/public_html/support-tickets/include/user/open.inc.php on line 32 Notice: Undefined index: email in /home/sites/it-doneright.co.uk/public_html/support-tickets/include/user/open.inc.php on line 44 Notice: Undefined index: phone in /home/sites/it-doneright.co.uk/public_html/support-tickets/include/user/open.inc.php on line 51 Notice: Undefined index: subject in /home/sites/it-doneright.co.uk/public_html/support-tickets/include/user/open.inc.php on line 88 Notice: Undefined index: message in /home/sites/it-doneright.co.uk/public_html/support-tickets/include/user/open.inc.php on line 97 Notice: Undefined index: captcha in /home/sites/it-doneright.co.uk/public_html/support-tickets/include/user/open.inc.php on line 142 Could they be the reason the captcha is not working? Thank you in advance Ian Below is the code from that file <?php ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); if(!defined('KTKUSERINC')) die('Adiaux amikoj!'); //Say bye to our friends. $info=($_POST && $errors)?Format::input($_POST):array(); //on error...use the post data ?> <div> <?php if($errors['err']) { ?> <p align="center" id="errormessage"><?=$errors['err']?></p> <?php }elseif($msg) { ?> <p align="center" id="infomessage"><?=$msg?></p> <?php }elseif($warn) { ?> <p id="warnmessage"><?=$warn?></p> <?php }?> </div> <div><?= _('Please fill in the form below to open a new ticket and provide as much detail as possible, so we can best assist you.')?><br /> <?= _('To update a previously submitted ticket, please go to ')?><a href="tickets.php"><?= _('Ticket Status')?></a>. </div><br /> <form action="open.php" method="POST" enctype="multipart/form-data"> <div class="input"> <span class="label"><?= _('Full Name:')?></span> <span> <?php if ($thisuser && ($name=$thisuser->getName())) { ?> <input type="hidden" name="name" value="<?=$name?>"><?=$name?> <?php }else { ?> <input type="text" name="name" size="30" maxlength="32" value="<?=$info['name']?>"> <?php } ?> <span class="error">* <?=$errors['name']?></span> </span> </div> <div class="input"> <span class="label"><?= _('Email Address:')?></span> <span> <?php if ($thisuser && ($email=$thisuser->getEmail())) { ?> <input type="hidden" name="email" size="30" value="<?=$email?>"><?=$email?> <?php }else { ?> <input type="text" name="email" size="30" maxlength="120" value="<?=$info['email']?>"> <?php } ?> <span class="error">* <?=$errors['email']?></span> </span> </div> <div class="input"> <span class="label-optional"><?= _('Telephone:')?></span> <span><input type="text" name="phone" size="30" maxlength="28" value="<?=$info['phone']?>"> <span class="error"> <?=$errors['phone']?></span> </span> </div> <div><span> </span></div> <?php // Present the topic selection menu if enabled if($cfg && $cfg->enableTopic()) {?> <div class="input"> <span class="label"><?= _('Help Topic:')?></span> <span> <select name="topicId"> <option value="" selected><?= _('Select One')?></option> <?php $services= db_query('SELECT topic_id,topic FROM '.TOPIC_TABLE.' WHERE isactive=1 ORDER BY topic'); if($services && db_num_rows($services)) { while (list($topicId,$topic) = db_fetch_row($services)){ $selected = ($info['topicId']==$topicId)?'selected':''; ?> <option value="<?=$topicId?>"<?=$selected?>><?=$topic?></option> <?php } }else{?> <option value="0" ><?= _('General Inquiry')?></option> <?php } ?> </select> <span class="error">* <?=$errors['topicId']?></span> </span> </div> <?php } else {?> <input type="hidden" name="topicId" value="0"> <?php } ?> <div class="input"> <span class="label"><?= _('Subject:')?></span> <span> <input type="text" name="subject" size="38" maxlength="64" value="<?=$info['subject']?>"> <span class="error">* <?=$errors['subject']?></span> </span> </div> <div class="input"> <span class="label"><?= _('Message:')?> <?php if($errors['message']) {?> <br /><span class="error">* <?=$errors['message']?></span><?php } ?> </span> <span> <textarea name="message" cols="40" rows="8" style="width:80%"><?=$info['message']?></textarea> </span> </div> <?php if($cfg->allowPriorityChange() ) { $sql='SELECT priority_id,priority_desc FROM '.PRIORITY_TABLE.' WHERE ispublic=1 ORDER BY priority_urgency DESC'; if(($priorities=db_query($sql)) && db_num_rows($priorities)){ ?> <div> <span class="label-optional"><?= _('Priority:')?></span> <span> <select name="pri"> <?php $info['pri']=$info['pri']?$info['pri']:$cfg->getDefaultPriorityId(); //use system's default priority. while($row=db_fetch_array($priorities)){ ?> <option value="<?=$row['priority_id']?>" <?=$info['pri']==$row['priority_id']?'selected':''?> ><?=$row['priority_desc']?></option> <?php } ?> </select> </span> </div> <?php } }?> <?php if(($cfg->allowOnlineAttachments() && !$cfg->allowAttachmentsOnlogin()) || ($cfg->allowAttachmentsOnlogin() && ($thisuser && $thisuser->isValid()))){ ?> <div class="input"> <span class="label-optional"><?= _('Attachment:')?></span> <span> <input type="file" id="multiattach" name="attachment[]" /> <span class="warning">(max <?=$cfg->getMaxFileSize()?> bytes)</span><span class="error"> <?=$errors['attachment']?></span> </span> <div id="files_list" class="files_list"></div> <?php // sorry but the script must be here, in order to be executed after the DOM is loaded ?> <script> //<!-- Create an instance of the multiSelector class, pass it the output target and the max number of files --> var multi_selector = new MultiSelector( document.getElementById( 'files_list' ), 10 ); //<!-- Pass in the file element --> multi_selector.addElement( document.getElementById( 'multiattach' ) ); </script> </div> <?php } ?> <div class="input"> <span class="label"><?= _('Captcha Text:')?></span> <span><img src="captcha.php" alt="captcha" border="0"></span> <span style="vertical-align:top"> <input type="text" name="captcha" size="7" value=""> <i><?= _('Enter the text shown on the image.')?></i> <span class="error">* <?=$errors['captcha']?></span> </span> </div> <div align="right"> <input class="button" type="submit" name="submit_x" value="<?= _('Submit Ticket')?>"> <input class="button" type="button" name="cancel" value="<?= _('Cancel')?>" onClick='window.location.href="index.php"'> </div> </form> Quote Link to comment Share on other sites More sharing options...
Solution ianhaney Posted December 29, 2015 Author Solution Share Posted December 29, 2015 Sorry got it all sussed and working perfect now Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.