Generator PHP - Błędy SQL ?

0

Witam mam mały problem z generatorem który zakupiłem , autor zmienił dane kontaktowe i niestety nie mam możliwości uzyskania pomocy z jego strony. Z racji iż skrypt mam na własność nie chciałbym udostępniać całego kodu źródłowego.Jest to generator opisu plików popularnego serwisu.Mówię od razu iż nie łamię praw autorskich. Mianowicie :

1.Skrypt mam uruchomiony , dane do SQL mam poprawne.
2.Strona działa , skrypt również.
3.Jeśli wchodzę w admin.php dostaję info ze strony :

 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/chomikuj/public_html/admin.php:1) in /home/chomikuj/public_html/config.php on line 2

4.W momencie tworzenia nowego szablonu dostaję :

[code]Warning: Invalid argument supplied for foreach() in /home/chomikuj/public_html/files/theme2.php on line 136[/code]

A więc tak .
Zawartość admin.php :

<?php
require_once('config.php');
$adm = array(
	"login"=>"admin",
	"passw"=>"haslo"
);
?>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="shortcut icon" href="http://imageshack.us/a/img812/8812/faviconxi.jpg" />
    <link href="style/style.css" rel="stylesheet" type="text/css" />
	<script src="script/jquery.js"></script>
	<script>
		function showHide(div){
			if(document.getElementById(div).style.display = 'block'){
				document.getElementById(div).style.display = 'none';
			}else{
				document.getElementById(div).style.display = 'block'; 
			}
		}
	</script><script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-36039157-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
</head>
<body>
<div id="content">
<?php
if($_GET['msg']) { 
	$type = "error";
	if($_GET['type'] == "success") $type = "success";
	echo '
	<div id="'.$type.'">
		<a href="#" onclick="showHide(\''.$type.'\');">[X]</a>
		<ul><li>'.$_GET['msg'].'</li></ul>
	</div>
	';
}
function _class($class) {
	require_once("classess/".$class.".php");
}
if($_SESSION['admin'] == 1) $przerwij = 1;
if($_GET['action'] == "logout") { unset($_SESSION['admin']); $przerwij = 0; $admin = 0; }
if($_POST['login'] == "admin") {
	if($_POST['nick'] == $adm['login'] and $_POST['pass'] == $adm['passw']) { $_SESSION['admin'] = 1; $przerwij = 1; unset($_SESSION["krok"]); }
}
if($przerwij != 1) {
echo <<<OUT
<div id="gchtext" style='text-align: center;'>	<form action="admin.php" method='post'>
	<input type='hidden' name='login' value='admin'>
	<input placeholder="Login" type='text' name='nick'>
	<input placeholder="Hasło" type='password' name='pass'>
	<input type='submit' value='zaloguj'>
	</form> </div>
OUT;
}else echo "<input type='submit' value='Wyloguj się' onclick=\"window.location='admin.php?action=logout'\" class='greenButtonCSSwaski'>
<input type='submit' value='Przejdź do strony głównej' onclick=\"window.location='index.php'\" class='greenButtonCSSwaski'>";
if($_SESSION['admin'] == 1) $admin = 1;
if($_POST['krok']) {
	Switch($_POST['krok']) {
		Case 'krok1':
			$krok = 'theme1';
			Break;
		Case 'krok2':
			$krok = 'theme2';
			Break;
		Case 'krok3':
			$krok = 'theme3';
			Break;
	}
}elseif($_SESSION['krokadmin']) $krok = $_SESSION['krokadmin']; else $krok = 'theme1';
$_SESSION['krokadmin'] = $krok;
if($admin == 1) {
	include 'files/'.$krok.'.php';
}
?>
</div>
</body></html>
<? ob_end_flush(); ?>

Zawartość theme2.php :

<?php
_class("curl.class");
_class("str.class");
if($_GET['usunszablon']) {
	if(mysql_query("DELETE FROM `szablony` WHERE `id` = '".$_GET['usunszablon']."'")) echo "Poprawnie usunięto";
}
if(strtolower($_POST['edit']) == 'film') {
	$typ = 'film';
	
}elseif(strtolower($_POST['edit']) == 'gra') {
	$typ = 'gra';
}else {
	$code = $_SESSION['textTheme'];
	$nazwa = $_SESSION['nazwaTheme'];
	$typ = $_SESSION['typTheme'];
	$themeId = $_SESSION['idTheme'];
}
if($_POST['action'] == 'zapisz') {
	if($_POST['krok'] == 'krok2') {
		$_POST['themeText'] = str_replace(array("'", '"'),array("{{^}}", "{{^^}}"), $_POST['themeText']);
		$nazwa = $_POST['themeName'];
		if(mysql_fetch_assoc(mysql_query("SELECT * FROM `szablony` WHERE `nazwa` = '".$_POST['themeName']."'"))) {
			$query = "UPDATE `szablony` SET `szablon`='".$_POST['themeText']."' WHERE `id`='".$_SESSION['idTheme']."'";
		}else $query = "INSERT INTO `szablony` (`szablon`, `nazwa`, `typ`) VALUES ('".$_POST['themeText']."', '".$_POST['themeName']."', '".$_POST['typ']."')";
		if(mysql_query($query)) echo "<div style='font-weight: bold; color: green;'>Poprawnie zapisano szablon</div>";
		#$code = $_POST['themeText'];
		if($aa = mysql_query("SELECT * FROM `szablony` WHERE `id` = '".$_SESSION['idTheme']."'")) {
			$aa = mysql_fetch_assoc($aa);
			$idszablonu = $_SESSION['idTheme'];
			$typ = $aa['typ'];
			$code = $aa['szablon'];
			$nazwa = $aa['nazwa'];
		}
	}
}
if(is_numeric($_POST['edit']) and $aa = mysql_query("SELECT * FROM `szablony` WHERE `id` = '".$_POST['edit']."'")) {
	$aa = mysql_fetch_assoc($aa);
	$idszablonu = $_POST['edit'];
	$typ = $aa['typ'];
	$code = $aa['szablon'];
	$nazwa = $aa['nazwa'];
}
	$_SESSION['typTheme'] = $typ;
	$_SESSION['nazwaTheme'] = $nazwa;
	$_SESSION['textTheme'] = $code;
	$_SESSION['idTheme'] = $idszablonu;

$cl1 = new curl;
$cl1->init();
#$cl1->host(strtolower(adres($url)));

if($typ == "gra") {
	$url = 'http://www.gry-online.pl/S016.asp?ID=17731';
	$url = str_replace("gra.asp", "S016.asp", $url);
	$cl1->get($url);
	$html = iconv('Windows-1250', 'UTF-8', $cl1->exec);
	#echo $html;
	$conf['Tytuł'] = str::exh($html, '<h1 itemprop="name">', '</h1>');
	$conf['Okładka'] = "<img src=\"http://gry-online.pl/".str::exh($html, '<aside class="area-css"><img src="', '"')."\" />";
	$conf['Link okładki'] = "http://gry-online.pl/".str::exh($html, '<aside class="area-css"><img src="', '"');
	$conf['Opis'] = str::exh($html, '<p itemprop="description">', '</p>');
	$conf['Platformy'] = str::exh($html, '<nav class="mgrp">', '</nav><nav class="mgr">');
	$conf['Platformy'] = explode("</a>", $conf['Platformy']);
	$types = $conf['Platformy'];$conf['Platformy'] = NULL;$conf['Platformy'] = str::exh($types[0]."</a>", '">', '</a>');
	for($i = 1; $i<=count($types)-2; $i++) {
		$string = explode('">', $types[$i]);
		$conf['Platformy'] .= ', '.$string[1];
	}
	$conf['Kategorie'] = str::exh($html, '<p class="xmc">', '</p>');
	$conf['Kategorie'] = explode("</a>", $conf['Kategorie']);
	$types = $conf['Kategorie'];$conf['Kategorie'] = NULL;$conf['Kategorie'] = str::exh($types[0]."</a>", '">', '</a>');
	for($i = 1; $i<=count($types)-2; $i++) {
		$string = explode('">', $types[$i]);
		$conf['Kategorie'] .= ', '.$string[1];
	}
	$conf['Tryb'] = str::exh($html, '<p>Tryb gry: ', '&nbsp;');
	$conf['Ocena'] = str::exh($html, '<div class="score">', '</div>');
	$conf['Wymagania sprzętowe'] = str::exh($html, '<h3>wymagania sprzętowe:</h3> <p>', '</p></article>');
	$title= "Edycja szablonu gry";
	#print_r($conf);
}elseif($typ == "film") {
	$url = 'http://www.filmweb.pl/film/Avengers+3D-2012-371515';
	$cl1->get($url);
	#echo $cl1->exec;
	$conf['Org. tytuł'] = str::exh($cl1->exec, '<h2 class="text-large caption">', "</h2>");
	$conf['Tytuł'] = str::exh($cl1->exec, '<div id=filmTitle class=hide>', "</div><d");
	$conf['Screen'] = '<img src="'.str::exh($cl1->exec, '<div class=posterLightbox><a rel="v:image" href="', '" class=film_mini>').'" />';
	if(empty($conf['Org. tytuł'])) $conf['Org. tytuł'] = $conf['Tytuł'];
	$conf['Link screen'] = str::exh($cl1->exec, '<div class=posterLightbox><a rel="v:image" href="', '" class=film_mini>');
	$conf['Okładka'] = "<img src=\"".str::exh($cl1->exec, '" class=film_mini><img src="', '" alt="').'" />';
	$conf['Link okładka'] = str::exh($cl1->exec, '" class=film_mini><img src="', '" alt="');
	$conf['Czas filmu'] = str::exh($cl1->exec, '<div class=filmTime><i class=icon-small-clock></i>', '</div><div');
	$conf['Ocena'] = str::exh($cl1->exec, "<div class=communityRate>ocena społeczności: <strong>", "</strong></div>");
	$conf['Średnia'] = str::exh($cl1->exec, '<span class=filmRate><strong rel="v:rating" property="v:average">', "</strong>");
	$conf['Ranking światowy'] = str::exh($cl1->exec, '<span class=worldRanking>', '. ');
	$conf['Premiera w polsce'] = str::exh($cl1->exec, '<span id=filmPremierePoland style="display:none">', '</span>');
	$conf['Premiera na świecie'] = str::exh($cl1->exec, '<span id=filmPremiereWorld style="display:none">', '</span>');
	$conf['Gatunek'] = str::exh($cl1->exec, '<tr><th>gatunek:</th><td>', '</td>');
	$conf['Gatunek'] = explode(", ", $conf['Gatunek']);
	$Gatunek = $conf['Gatunek'];
	$conf['Gatunek'] = NULL;
		$string = explode('<a href="/search/film?genreIds=', $Gatunek[0]);
		$conf['Gatunek'] = str::exh($string[1], '">', '</a>');
	for($i = 1; $i<=count($Gatunek)-1; $i++) {
		$string = explode('<a href="/search/film?genreIds=', $Gatunek[$i]);
		$string = str::exh($string[1], '">', '</a>');
		$conf['Gatunek'] .= ', '.$string;
	}
	$string = explode('<a href="/search/film?countryIds=', $cl1->exec);
	$conf['Produkcja'] = str::exh($string[1], '">', '</a>');
	$conf['Reżyseria'] = str::exh($cl1->exec, '" rel="v:directedBy">', '</a>');
	$string = explode('</td></tr><tr><th>scenariusz:</th><td', $cl1->exec);
	$conf['Scenariusz'] = str::exh($string[1], '" title="', '">');
	$conf['Opis'] = str::exh($cl1->exec, '</div><p class=text property="v:summary">', '</p></div>');
	$conf['Opis'] = $conf['Opis'] ? $conf['Opis'] : str::exh($cl1->exec, '</div><p class="text longText" property="v:summary">', '</p></div>');
	$conf['Opis'] = str_replace(array('</span> <button class="link-btn toggle hide">... więcej</button>', '<span class="fullText hide">'), '', $conf['Opis']);
	$$images = str::exh($cl1->exec, 'filmPhotos">', "</div></div><script");
	$images = explode("</div>", $images);
	foreach($images as $image) {
		$imoge[] = str::exh($image, '<img src="', '"');
	}
	for($i = 1; $i<=6; $i++) {
		$conf['Zdjęcie '.$i] = "<img src='".$imoge[$i-1]."' id='imgfilm'/>";
		$conf['Link zdjęcia '.$i] = $imoge[$i-1];
	}
	$conf['Zmniejsz zdjęcia'] = "<style>#imgfilm { max-width: 106px; }</style>";
	$title= "Edycja szablonu filmu";
	#print_r($conf);
}
?><?php if($idszablonu) echo '<span class="greenButtonCSSwaski" onclick="window.location=\'?usunszablon='.$idszablonu.'\'">Usuń ten szablon</span>'; ?>
<div class="title">Krok 2 - <?= $title; ?></div>
<div id="gchmenu">
		<form method="post" action="admin.php"><br />
			<?php
				$i = 0;
				Foreach($conf as $name => $value):
					$i++;
					if($i == "11" or $i == "18" or $i == "24") echo "<br /><br />";
					echo '<span type="textareaAdd" class="greenButtonCSSwaski" value="{{'.$name.'}}" />{{'.$name.'}}</span>';
				EndForeach;
			?><br><br>
			<input type="hidden" value="krok2" id="krok" name="krok">
			<input type="hidden" value="krok2" name="krokt">
			<input type="hidden" value="zapisz" name="action">
			<input type="hidden" value="<?= $typ ?>" name="typ">
			<div id="gchform">
				<style>
					#left {
						width: 890px;
					}
					#right {
						width: 560px;
						text-align: left;
					}
					#left textarea {
						width: 100%;
						height: 300px;
					}
				</style>
				<div id="left"><input type="text" style="width: 100%;" name="themeName" title="Wpisz tu nazwę szablonu, jeśli będzie zajęta, zostanie nadpisana" placeholder="Wpisz tu nazwę szablonu, jeśli będzie zajęta, zostanie nadpisana" value="<?= $nazwa ?>" /><br>
<textarea id="texttheme" name="themeText">
<?= str_replace(array("{{^}}", "{{^^}}", "\n<br />"), array("'", '"', ''), $code); ?>
</TEXTAREA>
				</div>
				<center><div id="right"></div></center>
			<div id="steps">
				<input type="submit" value="Wstecz" onclick="$('#krok').attr('value', 'krok1');$('form').submit();" class="orangeButtonCSS">
				<input type="submit" value="Zapisz" onclick="$('#krok').attr('value', 'krok2');$('form').submit();" class="greenButtonCSSwaski">
			</div>
			</div>
		</form>
<script>
$(document).ready(function() {
		(function($)
        {
                $.fn.extend(
                {
                        insertAtCaret: function(openWith, closeWith, value)
                        {
                                if (!this.attr('id'))
                                {
                                        this.attr('id', 'elm1');
                                }
                                var element = document.getElementById(this.attr('id'));
 
                                if (document.selection) 
                                {
                                        element.focus();
                                        sel = document.selection.createRange();
                                        sel.text = openWith + (sel.text.length > 0 ? sel.text : value) + closeWith;
 
                                        element.focus();
                                }
                                else if (element.selectionStart || element.selectionStart == '0') 
                                {
                                        var startPos = element.selectionStart;
                                        var endPos = element.selectionEnd;
                                        var scrollTop = element.scrollTop;
 
                                        if (startPos != endPos)
                                        {
                                                var value = openWith + element.value.substring(startPos, endPos) + closeWith;
                                        }
                                        else
                                        {
                                                var value = openWith + value + closeWith;
                                        }
 
                                        element.value = element.value.substring(0, startPos) + value + element.value.substring(endPos, element.value.length);
 
                                        element.focus();
                                        element.selectionStart = startPos + value.length;
                                        element.selectionEnd = startPos + value.length;
                                        element.scrollTop = scrollTop;
                                }
                                else 
                                {
                                        element.value += (openWith + value + closeWith);
                                        element.focus();
                                }
                        }
                });
        }
        )(jQuery);
	$('span[type="textareaAdd"]').click(function(){
                $('#texttheme').insertAtCaret("", '', txtDecode($(this).attr("value")));
				$("#right").html(rec($('#texttheme').val()));
    });
    $('#texttheme').keyup(function() {

        $("#right").html(rec($('#texttheme').val()));

    }).keyup();
	function rec(text) {
		var Tablica = new Array(['\n', '<br>\n'], <?php
				Foreach($conf as $name => $value):
						echo "['{{".$name."}}', '".$value."']";
					Break;
				EndForeach;
				$i = 1;
				Foreach($conf as $name => $value):
					if($i == 1) { $i = 0; }else{
						echo ", ['{{".$name."}}', '".str_replace(array("'", '"'), array("{{^}}", "{{^^}}"), $value)."']";
					}
				EndForeach;
			?>)
		var txt = text;
		for (x=0; x<Tablica.length; x++) {
			txt = str_replace(Tablica[x][0], Tablica[x][1], txt);
		}
		return txtDecode(txt);
	}
});
function str_replace (search, replace, subject, count) {
  var i = 0,
    j = 0,
    temp = '',
    repl = '',
    sl = 0,
    fl = 0,
    f = [].concat(search),
    r = [].concat(replace),
    s = subject,
    ra = Object.prototype.toString.call(r) === '[object Array]',
    sa = Object.prototype.toString.call(s) === '[object Array]';
  s = [].concat(s);
  if (count) {
    this.window[count] = 0;
  }

  for (i = 0, sl = s.length; i < sl; i++) {
    if (s[i] === '') {
      continue;
    }
    for (j = 0, fl = f.length; j < fl; j++) {
      temp = s[i] + '';
      repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
      s[i] = (temp).split(f[j]).join(repl);
      if (count && s[i] !== temp) {
        this.window[count] += (temp.length - s[i].length) / f[j].length;
      }
    }
  }
  return sa ? s : s[0];
}
function txtDecode (encodedString) {
  var output = str_replace('{{^^}}', '"', encodedString);
  return str_replace('{{^}}', "'", output);
}
</script>
</div>


Będę bardzo wdzięczny za pomoc w rozwiązaniu problemu.

0

Ot kupiłeś zapewne na allegro jakieś g.... napisane pewnie przez 13 latka ;)
Miej na uwadze, że takie narzędzia przestaną działać jak tylko chomik coś zmieni na stronie, więc kupowanie takich skryptów ma sens tylko z gwarancją aktualizacji w przypadku zmian na stronie.

I nikt raczej nie będzie przyglądać się Twojemu kilometrowej długości listingowi, bo my tu nie odwalamy roboty za kogoś (chyba, że ktoś płaci - za pracę na ogół się płaci), a pomagamy, nakierowujemy - ty chyba masz zerową wiedzę, więc zostaje dział praca.

Mogę Ci podać prosty sposób jak ukryć te błędy niedorobionego programisty, ale nie sprawi to, że ten kod zacznie działać..

0

No właśnie skrypt ten nie ingeruje w portal ponieważ pobiera tylko dane z innego serwisu i generuje gotowy opis :) A więc chomikuj tutaj nie gra znaczenia.Będę Ci bardzo wdzięczny za nakierowanie jak pozbyć się tych błędów. Hmm jeszcze jedna sprawa , tylko nie wiem jak to się nazywa. Sesja ? Chodzi mi o to iż gdy wygeneruję opis i wracam na główną to nie chcę aby mi się znów pokazywał gotowiec z poprzedniego tylko żebym miał puste pole do wpisania :)

0

poza tym ten skrypt jest dziurawy jak sito...

1 użytkowników online, w tym zalogowanych: 0, gości: 1