Jump to content

simonsays

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Everything posted by simonsays

  1. I am building a small admin panel with ability to upload videos and convert them to FLV. As far as I understand FFMPEG is enough for this. However, there are additional recommended tools like FLV2TOOL or Lame MP3 Encoder. Could anyone provide me with good explanation, what is crucial for good system with converting functionality? Thanks in advance!
  2. thanks, it's better now? but why doesn't the picture stretch to the limits? it's filled with black: http://www.kashmirecarpet.com/pics/tn9FD5~1.JPG
  3. hi there! My problem is the following. I am trying to write a function that will cut out a fixed-size piece from the CENTER of an uploaded picture. However, my function seems to always cut out a piece from the bottom right corner of the image (filling the difference with black), although the image itself is rather large and the coordinates are given. Thanks in advance! Here's the code! function CreateThumb($filename) { $source = imagecreatefromjpeg($filename); $width = imagesx($source); $height = imagesy($source); $output_width = 215; $output_height = 212; $center_hor = $width/2; $center_vert = $height/2; $src_x = $center_hor - $output_width/2; $src_y = $center_vert + $output_height/2; $output = imagecreatetruecolor($output_width, $output_height); imagecopyresampled($output, $source, 0, 0, $src_x, $src_y, $output_width, $output_height, $width, $height); $new = basename($filename); imagejpeg($output, dirname($filename).'/tn'.$new, 100); imagedestroy($source); imagedestroy($output); } }
  4. Hello! I am trying to make a script that is capable of getting and displaying (using Smarty) any database table. Something like that: function getTableAll ($table) { $data = array(); $sql = pg_query("SELECT * FROM $table"); while ($row = pg_fetch_array($sql)){ array_push($data, $row); } return $data; } function getFields ($table) { $fields = array(); $sql = pg_query("SELECT * FROM $table"); $i = pg_num_fields ($sql); $j = 0; while ($j < $i) { $fields[] = pg_field_name ($sql, $j); $j++; } return $fields; } $smarty->assign('data', $data); $smarty->assign('fields', $fields); The problems come when I try to display table using Smarty, because the template engine does not have any FOR loop or something like that. {section name=a loop=$fields} <td bgcolor="#1A2F4A"><p class='main'>{$fields[a]}</p></td> {/section} {section name=b loop=$data} </tr> ????? <tr> {/section} Can anyone help?
  5. Hello! I have a smarty template, that works fine. However, when I copy-paste template code into Notepad and save it as Unicode, the PHP script gives my 'FATAL error, unrecognized tag' refering to the very first Smarty tag in the document... What might be the problem? Thanks in advance! ???
  6. The problem is following. I have a column in MySQL of TEXT type. I put some text into it and the text consists of 2 paragrahs... However, when I try to output a text with php-script the paragraphs are gone and text is output as a single paragrahp. Using html-tag <br> is not a good idea, as I use (strip_tags) function. Is there any solution? Example (I input and would like to see as an output): Sun is shining. The weather is sweet. Actually outputs: Sun is shining. The weather is sweet.
  7. that was a silly mistake. shame on me. I corrected it, but the situation seemed to be the same Then I realized that I simply never assigned new value to Smarty engine. Thanks!
  8. I seem to be a bit in trouble with changing username or password of a logged in user. Everytime the user changes it, the username/password in session don't seem to be updated and when a user tries to go to any page he gets automatically logged out and has to log in again... How can I solve the problem? Here are both complete scripts, that I use: index.php [code]<? require_once('Smarty.class.php'); $smarty = new Smarty(); function checkUser($login, $pass) { $sql = mysql_query("SELECT id FROM admin WHERE login = '$login' AND password = '$pass'") or die(mysql_error()); if (mysql_num_rows($sql) == 1) { return true; } else {return false;} } function GetName($login){$result=mysql_query("SELECT name FROM admin WHERE login='$login'") or die(mysql_error()); return $name=mysql_result($result, 0, 'name'); } include_once 'data.php'; include_once 'security.php'; session_start(); $junk = array(',' , '/' ,"\\", '`' , ';' , '[' ,  ']' , '-', '_', '*', '&', '^', '#', '!', '~', '+', '(', ')', '|', '{', '}', '<', '>', '?', ':', '"', '=', 'ь', 'х', 'д', 'ц'); if (isset($_POST['uid']) && isset($_POST['pwd'])){ $len = strlen($_POST['uid']); $_POST['uid'] = str_replace($junk, '', $_POST['uid']); $test = $_POST['uid']; if(strlen($test) != $len) { $smarty->assign('viga', 1);   } $passlen = strlen($_POST['pwd']); $_POST['pwd'] = str_replace($junk, '', $_POST['pwd']); $test2 = $_POST['pwd']; if(strlen($test2) != $passlen) { $smarty->assign('viga', 1);   }} if (isset($_POST['uid']) && isset($_POST['pwd'])) { $uid = security($_POST['uid']); $pwd = security($_POST['pwd']); if (checkUser($uid, $pwd)) { $_SESSION['auid'] = $uid; $_SESSION['apwd'] = $pwd; $smarty->assign('uid', $_SESSION['auid']); $smarty->assign('pwd', $_SESSION['apwd']); $name=GetName($_SESSION['auid']); $smarty->assign('name', $name); } else { $smarty->assign('viga', 1); }} elseif (isset($_SESSION['auid']) && isset($_SESSION['apwd'])) { $uid = $_SESSION['auid']; $pwd = $_SESSION['apwd']; $name=GetName($_SESSION['auid']); $smarty->assign('name', $name); if (checkUser($uid, $pwd)) { $smarty->assign('uid', $uid); $smarty->assign('pwd', $pwd); } else { $smarty->assign('viga', 1); } } if ((isset($_GET['logout'])) && ($_GET['logout']==1)) {         session_unset(); session_destroy(); header("Location:index.php"); } switch ($_GET['page']) { case 'change':   $smarty->assign('show', 'change');   break;   case 'addevent':   $smarty->assign('show', 'addevent');   break; default:   $smarty->assign('page', 1); } $smarty->assign('target', $_SERVER[PHP_SELF]); $smarty->display('back.tpl'); ?>[/code] change.php, that gets included into back.tpl when $_GET[page] == change [code]<? require_once('Smarty.class.php'); $smarty = new Smarty(); include_once 'security.php'; include_once 'data.php'; include_once 'checkuser2.php'; if(isset($_POST['olduid'])){ if($_POST['olduid']==NULL OR $_POST['uid1']==NULL OR $_POST['uid2']==NULL){ $smarty->assign('emptyuser', 1); } elseif($_POST['uid1']!=$_POST['uid2']){ $smarty->assign('umismatch', 1); } else{ $old=security($_POST['olduid']); if ($_SESSION['auid'] == $old){ $new=security($_POST['uid1']); if (checkUser2($new)==TRUE){ $result=mysql_query("UPDATE admin SET login='$new' WHERE login='$old'") or die(mysql_error()); $smarty->assign('uuspeh', 1); $_SESSION['auid']=$new; }else{$smarty->assign('exists', 1);} } else {$smarty->assign('wrongold', 1);} } } if(isset($_POST['oldpass'])){ if($_POST['oldpass']==NULL OR $_POST['pass1']==NULL OR $_POST['pass2']==NULL){ $smarty->assign('emptypass', 1); } elseif($_POST['pass1']!=$_POST['pass2']){ $smarty->assign('pmismatch', 1); } else{ $old=security($_POST['oldpass']); if ($_SESSION['apwd']==$old){ $new=security($_POST['pass1']); $result=mysql_query("UPDATE admin SET password='$new' WHERE password='$old' AND login='$_SESSION[auid]'") or die(mysql_error()); $smarty->assign('puspeh', 1); $_SESSION['apwd']=$new; } else {$smarty->assign('wrongoldp', 1);} } } $smarty->assign('target', $_SERVER[PHP_SELF]); $smarty->display('change.tpl'); ?>[/code]
  9. I have a little problem with logout in my script. There is a small piece of code responsible for that. [code]if ((isset($_GET['logout'])) && ($_GET['logout']==1)) {         session_unset(); session_destroy(); }[/code] And there is a link in the logged user interface with 'logout=1' in its URL.However, when I click this link, the user interface seems to stay. And it is only gone when I click it the second time. What might be the problem? Thank you in advance!
  10. well, that 's a decent solution... but isn't browser supposed not to reset these values?
  11. I am looking for some help. I realized that I do not know how to do it. I have a registration form with several fields. When user submits data, there is a script that controls data (whether username exists or not, first and second password match, etc...) If there is an error, it adds it to an array and displays the text(s) of error(s) on the same page where form is. However, all the data input into form fields is missing then and the user has to go through registration again... How do I do, so the data is saved, so the user has to repair only invalid fields and does not have to fill all the fields all over again. Is there any trick? Maybe the problem is with Smarty template engine that I am using? Thanks in advance!
  12. the code that I took for array_multisort comes directly from php.net
  13. [quote author=ignace link=topic=103171.msg410692#msg410692 date=1154875181] what does your Path() function do? And what does it do with your $row['id']? P.S.: remove the $allpaths from you array_multisort(); [/quote] Path function forms a complete category path to some lower category (e.g. Monitors>CRT, Printers> Laser > Epson, etc.) Here it is [code]function Path($child){ $cat=getParents($child); $path=getCatName($child); foreach ($cat as $element) {$path = $element['n'].' > '.$path ;} return $path;}[/code] I removed $allsorts, but it didn't seem to help much. [quote author=king arthur link=topic=103171.msg410695#msg410695 date=1154875516] Doesn't look like you need array_multisort() for this, can you not just use usort()? [/quote] array_multisort() seemed to be less complicated for me. do you think usort() is easier to use?
  14. The problem is the following. I make a new array from database results: [code]$allpaths[]=array ("id" => $row['id'], "path" => $path);[/code] It is done inside a while loop and the array is ok, except for one thing. I would like to sort the elements by 'path'... So I tried to do it like this: [code]foreach ($allpaths as $key => $row) {   $id[$key]  = $row['id'];   $path[$key] = $row['path']; } array_multisort($path, SORT_ASC, $id, SORT_ASC, $allpaths);[/code] But this does not seem to work and all the time I get [b]Warning: array_multisort(): Argument #1 is expected to be an array or a sort flag [/b] error... The complete function code is here... [code]<? function GetAllPaths($id=NULL){ $sql="SELECT id, name, upper_catalog FROM catalog"; $getcats=mysql_query($sql) or die (mysql_error()); $allpaths=array(); while ($row=mysql_fetch_array($getcats)){ if ($row['upper_catalog']!=0){ $path=Path($row['id']); $allpaths[]=array ("id" => $row['id'], "path" => $path);} else {$allpaths[]= array ("id" => $row['id'], "path" => $row['name']);} } foreach ($allpaths as $key => $row) {   $id[$key]  = $row['id'];   $path[$key] = $row['path']; } array_multisort($path, SORT_ASC, $id, SORT_ASC, $allpaths); return $allpaths; } ?>[/code] I would be very grateful if someone could really help me.
  15. actually you can capture streaming audio from any source, the absence of 'download' or 'save target as...' option is not a dead end and it is not necessarily mp3's that could give you trouble with copyright. streaming audio is prohibited as well the best possible solution IMHO is the player made in flash.
  16. [b]timmah22[/b], that page was generated using Smarty Engine. [b]AndyB[/b], thanks a lot!
  17. OK, I just started to rewrite my project using Smarty and I am new to this engine. I have come across a following problem: Here is a php file [code] <? require_once('Smarty.class.php'); $smarty = new Smarty(); $smarty->assign('self', $_SERVER['PHP_SELF']); $smarty -> assign('uid', $_SESSION['uid']); $smarty -> assign('pwd', $_SESSION['pwd']); if (isset($_POST['proceed']) && $_POST['proceed']=='yes') {$smarty -> assign('proceed', $_POST['proceed']);} $i=2001; while($i>=1920) { $years[]=$i; $i--; } $smarty->assign('years', $years); session_start(); $random = substr(md5(time()),0,6); $_SESSION['random']=$random; echo "Session is ". $_SESSION['random']; $smarty->display('reg.tpl'); ?> [/code] it does some minor routine, but the thing that interests me the most is the spot where it creates session. Echo that I use for control displays session contents perfectly. That session ($_SESSION['random']) is used later in the image.php script: [code]<?php $text = $_SESSION['random']; header("Content-type: image/png"); $im = @imagecreate(65, 27) or die("Cannot Initialize new GD image stream"); $background_color = imagecolorallocate($im, 255, 153, 0); $text_color = imagecolorallocate($im, 255, 255, 255); imagestring($im, 5, 5, 5,  $text, $text_color); imagepng($im); imagedestroy($im); ?> [/code] and there is a spot in .tpl file responsible for displaying it (<img src='image.php'>) The problem is that the image is blank (no string in it) and when I click 'submit' the registration validation script also gives error that session is empty. What's wrong? Thanks in advance!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.