Jump to content

bbunlock

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.sunbizhosting.com

Profile Information

  • Gender
    Not Telling
  • Location
    England

bbunlock's Achievements

Member

Member (2/5)

0

Reputation

  1. thanks for the help guys, love this place wayne
  2. I know this is simple but for the life of me I cannot remember how it is done and cant find it anywhere, ive even gone throught loads of my scripts to see an example but cant find it ok I want to update a $value to include more info, for exxample $value = "value1" then alter in the code I want to be able to add to this like so $value = $value + " - value2" $value = $value + " - value3" and when I do an "echo $value" it would show value1 - value2 - value3 etc can anyone tell me how this is done, I have seen it done before but cannot for the life of me find it and I have no idea what I would even search for any help is much appriciated regards wayne
  3. Just wanted to say a big thanks to AbraCadaver for the code provided above, I now have everything work great using your code as a guide thanks you very much regards wayne
  4. Hi and thanks for taking the time to read this and to help if you can I have a flex app that is sending data to a php script that will then perform tasks based on the data found inthe array, my problem is that there are over 270 items in the array and I need to alter many of them BEFORE the script performs its task, what I need is a way to alter the data in the array without having to do it one at a time which I will have to do, below is some exxamples of what I am looking to do for example the array will have data on aprox 35 colors and I need to check and these values and change them if needed, my current system is as follows $color1 = $skin['color1']; if (preg_match("/0x/i", $color1)) { $color1 = str_replace("0x", "", $color1); } else { $color1 = str_pad(dechex($color1), 6, '0', STR_PAD_LEFT); } if($color1=="" || $color1=="000000"){$color1="100000";} now currently I would have to do this individualy for $skin['color1'], $skin['color2'], $skin['color3'] etc etc so is there a way I can do it without such bloated code, for example a while or a foreach statement etc? im not great at php so I am not sure how I would go about this if its possible another thing is that the rest of the values in the array are for image values and I need to fillter through them to find out which are the default images and which are not (no tasks are performed on default images) the following are example values from the array for the arrar item $clockface = $skin['clockface'] /home/thesite/public_html/flex_app/assets/default/clockface.png /home/thesite/public_html/flex_app/gallery/clock/clockface_3.png /home/thesite/public_html/flex_app/uploads/uploaded_file.jpg now depending on the value of the array I would wat the following for the 3 values above $clockface = ""; // if its the first value $clockface = "/home/thesite/public_html/flex_app/gallery/clock/pack3/clockface.svg" // if its the second value $clockface = "/home/thesite/public_html/flex_app/uploads/uploaded_file.jpg" // if its the third value now the above is easy to do on an individual basis but I want to streamline my code and not have an if statement with str_replace etc for each and every value which means I would have to do the code over 200 times for the images now as you can see from the first set of values there are certain things that give clues as to what and where the image is ("assests/default", "gallery/clock/clockface_3.png" and "uploads/uploaded_file.jpg") and I would use these to produce the final values above but again I would have to do it on an individual basis for each array value so is there any way I can streamline the process with again a while or a foreach statement or another way of doing this? your help is very much appriciated regards wayne
  5. thanks PFMaBiSmAd you cracked it :-) I had looked at the phpinfo data hours ago to see if the changes in the local php.ini had been made and they were, I never thought to look and see if other things had changed, I added a few lines more to the local php.ini file that were different with and without the php.ini and now all works great :-) not sure if ringtones are your thing but you might like to see it in action, http://www.ringbuz.com totaly free to use so dont panic you wont need to register or anything once again PFMaBiSmAd thanks for the help on this regards wayne
  6. Hi PFMaBiSmAd thanks for the reply first I have to say there is nothing wrong with the flash app if there is no php.ini in the domain root, here is an example of what happens with large files 1, add the php.ini to the domain root with the values listed above 2, upload an mp3 (example 5M) 3, upload completes and now transfered to the flash app for editing 4, press play and nothing is heard (doesnt play the uploaded mp3) 5, now I goto the domain root and delete the php.ini file 6, go back to web page and refresh the the page loading the flash app again 7, press play and all works fine with no php.ini I did my normal thing and tried to narrow down the problem with the php.ini by removing a line at a time and see if the ap works, the strange thing is that it doesnt matter whats in the php.ini, for example I uploaded an empty php.ini (0 bytes) and it didnt play the file, so basicaly any php.ini file with content or empty prevents the flash app from playing the mp3. Now my guess would be that the php.ini may need other param in it to work correctly? as I mentioned above it only has those 5 lines in it so I dont know if php.ini needs any special open/close params for it to work correctly, as in a .htaccess file the params above would be <IfModule mod_php4.c> php_value max_execution_time 60 php_value max_input_time 120 php_value memory_limit 128M php_value post_max_size 14M php_value upload_max_filesize 10M </IfModule> which means you need the <IfModule mod_phpxxx> for it to work in htaccess, is there somthing that php.ini needs for it to work correctly? regards wayne
  7. I have a ringtone creator site where people can upload music files and select sections to make into a ringtone, I have for the last year been using a cgi upload script becuase it can handle 32M out of the box where php can only handle 2M now I have changed the cgi upload to a flash upload but have had problems with it, the flash app usues php to move the upload file to the folder I want to store the uploaded files in so im kinda back to sqaure one with the 2mb limit. I could change the php.ini/httpd.conf file(s) to change the 2M limit but this is a shared server so didnt want to go that route so decided to try and change the limit via .htaccess but that didnt work, php is a cgi module not a apache module so php_value in htaccess has no effect when in cgi mode. I have tried adding a php.ini with the following params to the doomains root and that works great for uploading the files. max_execution_time = 60 max_input_time = 120 memory_limit = 128M post_max_size = 12M upload_max_filesize = 10M however even though that allows me to upload large files upto 12M it actualy breaks the flash application that loads and plays the uploaded mp3, for example I upload test.mp3 of 5M and it uploads perfectly to the server (with the php.ini listed above) but the flash app will not play the mp3 file? if I delete the php.ini from the root and refresh the page it works great? so basicaly the php.ini allows me to upload large files but breaks the flash app, but without the php.ini it wont upload files over 2mb, well thats not true it actualy uploads the file no problem but the flash ap then calls upload.php to move it from the servers default tmp folder to the folder where the files are stored for the flash editor and then tells me in my error_log the file was over 2M and was not saved. Now I have used .htaccess lots of times for mod rewite etc but this is the first time I have used a php.ini instead of a htaccess file, so is there somthing I need to add to my php.ini file to solve this? please be aware that the code I listed above as to what is in my php.ini file is exactly whats in it, there are no other lines of code in the file just the 5 lines listed above. hope someone can shed some light on this for me regards wayne
  8. wow cant believe it but actualy got it working, well to be honest I found a code example on php.net for readdir and managd to tweek it a couple of places and now works great thanks all the same regards wayne
  9. First of thanks for taking the time to read this and help if possible. I have a script that allows me to import data into the database, it works great for the current system setup but I have just changed it and can not figure out how to alter the script to apply the new changes to the system. the current system works like this, I upload a number of theme files (example.sis) and a screenshot of each theme file (example.jpg), now the screenshot file needs to be named exactly the same as the theme file but of course different extension, example "Blue_Theme.sis" "Blue_Theme.jpg" and the script works great. However here is my problem, the new system uses 2 screenshot files for the the themes and they are named like this "Blue_Theme.sis" "Blue_Theme-1.jpg" "Blue_Theme-2.jpg" and I cant figure out what to do on the current script to make it work with the 2 screenshot files named a little differently. I will paste the original code (before I changed it 100 times trying to get it working) for you to have a look at and hopefully get it working with the new system <? require ('inc_auth.php'); include ('functions.php'); include ('lib/lib_image.php'); $link = 10; if (isset($_POST['directory']) && count($_POST) == 1){ $directory = trim($_POST['directory']); if (is_dir($directory)) { if ($dh = opendir($directory)) { while (($file = readdir($dh)) !== false) { $arr[] = $file; } closedir($dh); foreach ($arr as $v){ preg_match("~^(.+?)\.(\w{3,4})~is", $v, $m); if (!in_array($m[1], $fileArr) && $m[1] != null) $fileArr[] = $m[1]; } } } } if (isset($_POST['dir'])){ $directory = trim($_POST['dir']); if (is_dir($directory)) { if ($dh = opendir($directory)) { while (($file = readdir($dh)) !== false) { $arr[] = $file; } closedir($dh); foreach ($arr as $v){ preg_match("~^(.+?)\.(\w{3,4})~is", $v, $m); if ($m[1] != null){ if ($m[2] == "sis") $fileArr[$m[1]]["sis"] = $v; else $fileArr[$m[1]]["image"] = $v; } } $category_id = (int)$_POST['category']; $model = (int)$_POST['model']; $thm_type_id = (int)$_POST['thm_type']; $r = $sql->load_obj("SELECT id FROM mobiles WHERE thm_type={$thm_type_id} LIMIT 1"); $mobile_id = $r->id; $r = $sql->load_obj("SELECT * FROM thm_types WHERE id={$thm_type_id}"); $thm_type = $r->type; $r = $sql->load_obj("SELECT * FROM categories WHERE id={$category_id}"); $category = $r->name; $files = $_POST['f']; foreach ($files as $v=>$value){ if (isset($fileArr[$v]['image']) && isset($fileArr[$v]['sis'])){ $sql->insert("files", array( 'name' => $fileArr[$v]['sis'], 'file_type' => "theme", 'user_id' => 1, 'category_id' => $category_id, 'upl_date' => date("Y-m-d H:i:s"), 'active' => 1, 'mobile_id' => $mobile_id)); $id = $sql->last_id(); $sql->insert("ratings", array( 'id' => $id, 'total_value' => 0, 'total_votes' => 0, 'used_ips' => 0)); $sys_file_dest = "{$id}.sis"; $thumb_file = "{$id}_thumb.jpg"; $dest_file = "{$id}.jpg"; copy("{$directory}/{$fileArr[$v]['image']}", "{$themesDir}/".folderName($thm_type)."/".folderName($category)."/{$dest_file}"); $thumb = imageCreateResized("{$directory}/{$fileArr[$v]['image']}", $themeThumbWidth); imagejpeg($thumb, "{$themesDir}/".folderName($thm_type)."/".folderName($category)."/{$thumb_file}"); copy("{$directory}/{$fileArr[$v]['sis']}", "{$themesDir}/".folderName($thm_type)."/".folderName($category)."/{$sys_file_dest}"); unlink("{$directory}/{$fileArr[$v]['image']}"); unlink("{$directory}/{$fileArr[$v]['sis']}"); $savedFiles[] = "{$directory}/{$fileArr[$v]['image']} - {$directory}/{$fileArr[$v]['sis']}"; echo $sql->error(); } } $auth->redirect("import.php?count=".count($savedFiles)); } } } ?> <HTML> <HEAD> <TITLE>Import themes</TITLE> <link rel="stylesheet" href="style.css" type="text/css"> </HEAD> <BODY> <? include ('admin/left_menu.php'); ?> <DIV style="float: left"> <h3>Import themes</h3> <form method='POST' action=''> <table class='design' cellspacing="0" width=400> <? if (count($_POST) == 0 && count($_GET) == 0){ ?> <tr> <td colspan="2"> <label for='directory'>Directory</label> public_html/<input type='text' name='directory' id='directory'> </td> </tr> <tr> <td colspan="2" align="right"><input type='submit' value='Submit' class='button'></td> </tr> <? }elseif (isset($_POST['directory'])) {?> <tr> <td> <label for='category'>Category</label> <select id='category' name="category" style="width: 140px"> <? $sql->query("SELECT * FROM categories WHERE type='Theme' ORDER BY name"); while($r = $sql->obj()){ echo "<option value='{$r->id}'>{$r->name}</option>"; } ?> </select> </td> </tr> <tr> <td> <label for='thm_type'>Type</label> <select name='thm_type' id='thm_type' style="width: 140px"> <? $sql->query("SELECT * FROM thm_types ORDER BY type"); while ($r = $sql->obj()){ echo "<option value='{$r->id}'>{$r->type}</option>"; } ?> </select> </td> </tr> <? foreach ($fileArr as $k=>$v){ echo "<tr><td colspan='2'><input type='checkbox' value='1' checked name='f[".htmlspecialchars($v)."]}'>".htmlspecialchars($v)."</td></tr>"; } ?> <input type='hidden' name='dir' value='<?=$_POST['directory']?>'> <tr> <td align="right"><input type='submit' value='Submit' class='button'></td> </tr> <?} elseif(isset($_GET['count'])){?> <tr> <td> <? echo (int)$_GET['count']." themes have been saved"; ?> </td> </tr> <?}?> </table> </form> </DIV> </BODY> </HTML> thanks in advance wayne
  10. @php.ajax.coder thanks for the info, I was going to ask how to add the paramaters to that but did a little searching and found a few examples so managed to get it working great, even found out how to make it load the theme value when page is loaded. thanks for the help regards wayne
  11. I have come accross a script suplied at w3schools (http://www.w3schools.com/PHP/php_ajax_database.asp) however I would like your help in modifying it to serve my purpose, below are the modifications I would like help with. 1, I would like to use standard links instead of a drop down form, so when a link is clicked it shows the results. 2, instead of sending just one paramater to the javascript code (value="?") I would like to send 2 paramaters in the link ("uid" and "up_type") 3, I would like it to display the first link details when page loads (so dont have to click a link to activate it on loadup) so by default the first link would be loaded on page load. If this was a standard link it would be somthing like the following "usrup.php?uid=some_id&up_type=some_type" its the "uid" and "up_type" that I need sent to the javascript code, the form only allows value="?" I need 2 paramaters sent. Unfortunately I have very little to no experience with javascript and ajax so your help would be greatly appriciated on this. There is no point me pasting the code for the form itself as im not looking to use a form/dropdown box but I will paste the javascript code used at w3schools. Javascript var xmlHttp function showUser(str) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="getuser.php" url=url+"?q="+str url=url+"&sid="+Math.random() xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true) xmlHttp.send(null) } function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("txtHint").innerHTML=xmlHttp.responseText } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { //Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } could someone please help me change this so that I can click a link instead of a form and the link supplies 2 paramaters to the javascript code instead of just the 1 thank you very much for your help regards wayne
  12. I have found another script that is almost what I want but needs some additions done to it, I will post this as a new topic instead of posting to this one. regards wayne
  13. Hi and first thanks for reading Ok I have a little ajax script that allows me to display content in divs, the content is like layers that are shown/hidden depending on the link clicked. the only problem with the script is that it loads all the divs at once, what I would like is that the content for each div is loaded when the link is clicked. below is the code im curently using javascript // CSS helper functions CSS = { // Adds a class to an element. AddClass: function (e, c) { if (!e.className.match(new RegExp("\\b" + c + "\\b", "i"))) e.className += (e.className ? " " : "") + c; }, // Removes a class from an element. RemoveClass: function (e, c) { e.className = e.className.replace(new RegExp(" \\b" + c + "\\b|\\b" + c + "\\b ?", "gi"), ""); } }; // Functions for handling tabs. Tabs = { // Changes to the tab with the specified ID. GoTo: function (contentId, skipReplace) { // This variable will be true if a tab for the specified // content ID was found. var foundTab = false; // Get the TOC element. var toc = document.getElementById("toc"); if (toc) { var lis = toc.getElementsByTagName("li"); for (var j = 0; j < lis.length; j++) { var li = lis[j]; // Give the current tab link the class "current" and // remove the class from any other TOC links. var anchors = li.getElementsByTagName("a"); for (var k = 0; k < anchors.length; k++) { if (anchors[k].hash == "#" + contentId) { CSS.AddClass(li, "current"); foundTab = true; break; } else { CSS.RemoveClass(li, "current"); } } } } // Show the content with the specified ID. var divsToHide = []; var divs = document.getElementsByTagName("div"); for (var i = 0; i < divs.length; i++) { var div = divs[i]; if (div.className.match(/\bcontent\b/i)) { if (div.id == "_" + contentId) div.style.display = "block"; else divsToHide.push(div); } } // Hide the other content boxes. for (var i = 0; i < divsToHide.length; i++) divsToHide[i].style.display = "none"; // Change the address bar. if (!skipReplace) window.location.replace("#" + contentId); }, OnClickHandler: function (e) { // Stop the event (to stop it from scrolling or // making an entry in the history). if (!e) e = window.event; if (e.preventDefault) e.preventDefault(); else e.returnValue = false; // Get the name of the anchor of the link that was clicked. Tabs.GoTo(this.hash.substring(1)); }, Init: function () { if (!document.getElementsByTagName) return; // Attach an onclick event to all the anchor links on the page. var anchors = document.getElementsByTagName("a"); for (var i = 0; i < anchors.length; i++) { var a = anchors[i]; if (a.hash) a.onclick = Tabs.OnClickHandler; } var contentId; if (window.location.hash) contentId = window.location.hash.substring(1); var divs = document.getElementsByTagName("div"); for (var i = 0; i < divs.length; i++) { var div = divs[i]; if (div.className.match(/\bcontent\b/i)) { if (!contentId) contentId = div.id; div.id = "_" + div.id; } } if (contentId) Tabs.GoTo(contentId, true); } }; // Hook up the OnLoad event to the tab initialization function. window.onload = Tabs.Init; // Hide the content while waiting for the onload event to trigger. var contentId = window.location.hash || "#Introduction"; if (document.createStyleSheet) { var style = document.createStyleSheet(); style.addRule("div.content", "display: none;"); style.addRule("div" + contentId, "display: block;"); } else { var head = document.getElementsByTagName("head")[0]; if (head) { var style = document.createElement("style"); style.setAttribute("type", "text/css"); style.appendChild(document.createTextNode("div.content { display: none; }")); style.appendChild(document.createTextNode("div" + contentId + " { display: block; }")); head.appendChild(style); } } Html <!-- start of tabbed options menu --> <ol id="toc"> <li><a href="#Themes">Themes</a></li> <li><a href="#Ringtones">Ringtones</a></li> <li><a href="#Wallpapers">Wallpapers</a></li> </ol> <!-- start of Themes section --> <div class="tab-content" id="Themes"> Do mysql query for themes do the php code to display the themes found in mysql query </div> <!-- start of Ringtones section --> <div class="tab-content" id="Ringtones"> Do mysql query for ringtones do the php code to display the ringtones found in mysql query </div> <!-- start of Wallpapers section --> <div class="tab-content" id="Wallpapers"> Do mysql query for wallpapers do the php code to display the wallpapers found in mysql query </div> Could anyone help me out here please, I have no knowledge of ajax at all. regards wayne
  14. is ther any chance you can get the topic solved button to be more visible? I always go for the topic solved when my question has been solved and I have to say I always find it hard to find (no pun intended) I would highly recomend making it more visible as it is far to easy to miss, otherwise a great feature on a great forum. regards wayne
  15. thank you very much taith for that, works great now very much appriciated regards wayne
×
×
  • 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.