Skip to content

Commit

Permalink
Updated to compatibility with PHP5
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronbronow committed Oct 2, 2013
1 parent 2142c50 commit 4f44227
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 26 deletions.
2 changes: 1 addition & 1 deletion demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<? endforeach; ?>
</select>

Debug:
Colors:
<input type="checkbox" name="colors" value="1" <? if (!empty($_REQUEST['colors'])) echo 'checked'; ?> />

Big blocks?:
Expand Down
18 changes: 11 additions & 7 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@
<li><a href="demo-xml.php" target="_blank">Demo XML output</a></li>
</ul>

<h3>Source</h3>

<ul>
<li><a href="http://github.com/laurynas/php-crossword/">Github</a></li>
</ul>

<h3>Features</h3>

<ul>
Expand All @@ -59,10 +53,20 @@
<li>Colored debugging</li>
</ul>

<h3>TODO</h3>

<ul>
<li>API Documentation</li>
<li>Installation instructions</li>
<li>Client Java Applet</li>
<li>More databases support...</li>
</ul>


<hr size="1" />

&copy; Laurynas Butkus (laurynas.butkus at gmail.com), 2005


</body>
</html>
</html>
2 changes: 1 addition & 1 deletion init.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
$max_tries = (int)$_REQUEST['max_tries'] ? (int)$_REQUEST['max_tries'] : 10;
$groupid = !empty($_REQUEST['groupid']) ? $_REQUEST['groupid'] : 'demo';

$pc =& new PHP_Crossword($rows, $cols);
$pc = new PHP_Crossword($rows, $cols);

$pc->setGroupID($groupid);
$pc->setMaxWords($max_words);
Expand Down
4 changes: 2 additions & 2 deletions lib/php_crossword.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function PHP_Crossword($rows = 15, $cols = 15)
$this->cols = (int)$cols;

// connect to the database
$this->db =& new MySQL;
$this->db = new MySQL;
}

/**
Expand Down Expand Up @@ -811,4 +811,4 @@ function generateFromWords($words_list)
}

}
?>
?>
2 changes: 1 addition & 1 deletion lib/php_crossword_client.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function __getXML_Direct()
require_once 'lib/mysql.class.php';
require_once 'lib/php_crossword.class.php';

$pc =& new PHP_Crossword($this->cols, $this->rows);
$pc = new PHP_Crossword($this->cols, $this->rows);

$pc->setGroupID($this->groupid);
$pc->setMaxWords($this->words);
Expand Down
20 changes: 6 additions & 14 deletions lib/php_crossword_grid.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function __initCells()
{
for ($y = 0; $y < $this->rows; $y++)
for ($x = 0; $x < $this->cols; $x++)
$this->cells[$x][$y] =& new PHP_Crossword_Cell($x, $y);
$this->cells[$x][$y] = new PHP_Crossword_Cell($x, $y);
}

/**
Expand Down Expand Up @@ -102,7 +102,7 @@ function &getRandomWord()
*/
function placeWord($word, $x, $y, $axis)
{
$w =& new PHP_Crossword_Word($word, $axis, $this->cells[$x][$y]);
$w = new PHP_Crossword_Word($word, $axis, $this->cells[$x][$y]);

++$this->inum; // sandy addition
++$this->maxinum; // sandy addition
Expand All @@ -118,13 +118,11 @@ function placeWord($word, $x, $y, $axis)
{
$s = $x;
$c =& $cx;
$t =& $cy;
}
else
{
$s = $y;
$c =& $cy;
$t =& $cx;
}

// dump( "PLACING WORD: $cx x $cy - {$w->word}" );
Expand All @@ -141,21 +139,15 @@ function placeWord($word, $x, $y, $axis)
// disable cell before first cell
$c = $s - 1;
if ($c >= 0 )
$this->cells[$cx][$cy]->setCanCross(PC_AXIS_BOTH, FALSE);
$this->cells[$cx][$cy]->setCanCross(PC_AXIS_BOTH, FALSE);

$this->cells[$cx][$cy]->number = $w->inum; // sandy addition

// disable cell after last cell
// disable cell after first cell
$c = $s + strlen($word);
if (is_object($this->cells[$cx][$cy]))
$this->cells[$cx][$cy]->setCanCross(PC_AXIS_BOTH, FALSE);
$this->cells[$cx][$cy]->setCanCross(PC_AXIS_BOTH, FALSE);

// avoid starting "corner word" - which would use the same
// number cell as this word
$c = $s - 1;
$t = $t + 1;
if ($c >= 0 && is_object($this->cells[$cx][$cy]))
$this->cells[$cx][$cy]->setCanCross(PC_AXIS_BOTH, FALSE);
}

/**
Expand Down Expand Up @@ -395,4 +387,4 @@ function getHTML($params = array())
return $html;
}
}
?>
?>

0 comments on commit 4f44227

Please sign in to comment.